LCOV - code coverage report
Current view: top level - EnergyPlus - DXCoils.cc (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 6371 9631 66.2 %
Date: 2023-01-17 19:17:23 Functions: 60 63 95.2 %

          Line data    Source code
       1             : // EnergyPlus, Copyright (c) 1996-2023, The Board of Trustees of the University of Illinois,
       2             : // The Regents of the University of California, through Lawrence Berkeley National Laboratory
       3             : // (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge
       4             : // National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other
       5             : // contributors. All rights reserved.
       6             : //
       7             : // NOTICE: This Software was developed under funding from the U.S. Department of Energy and the
       8             : // U.S. Government consequently retains certain rights. As such, the U.S. Government has been
       9             : // granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable,
      10             : // worldwide license in the Software to reproduce, distribute copies to the public, prepare
      11             : // derivative works, and perform publicly and display publicly, and to permit others to do so.
      12             : //
      13             : // Redistribution and use in source and binary forms, with or without modification, are permitted
      14             : // provided that the following conditions are met:
      15             : //
      16             : // (1) Redistributions of source code must retain the above copyright notice, this list of
      17             : //     conditions and the following disclaimer.
      18             : //
      19             : // (2) Redistributions in binary form must reproduce the above copyright notice, this list of
      20             : //     conditions and the following disclaimer in the documentation and/or other materials
      21             : //     provided with the distribution.
      22             : //
      23             : // (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory,
      24             : //     the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be
      25             : //     used to endorse or promote products derived from this software without specific prior
      26             : //     written permission.
      27             : //
      28             : // (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form
      29             : //     without changes from the version obtained under this License, or (ii) Licensee makes a
      30             : //     reference solely to the software portion of its product, Licensee must refer to the
      31             : //     software as "EnergyPlus version X" software, where "X" is the version number Licensee
      32             : //     obtained under this License and may not use a different name for the software. Except as
      33             : //     specifically required in this Section (4), Licensee shall not use in a company name, a
      34             : //     product name, in advertising, publicity, or other promotional activities any name, trade
      35             : //     name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly
      36             : //     similar designation, without the U.S. Department of Energy's prior written consent.
      37             : //
      38             : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
      39             : // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
      40             : // AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
      41             : // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
      42             : // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
      43             : // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
      44             : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
      45             : // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
      46             : // POSSIBILITY OF SUCH DAMAGE.
      47             : 
      48             : // C++ Headers
      49             : #include <cmath>
      50             : #include <string>
      51             : 
      52             : // ObjexxFCL Headers
      53             : #include <ObjexxFCL/Fmath.hh>
      54             : 
      55             : // EnergyPlus Headers
      56             : #include <EnergyPlus/Autosizing/All_Simple_Sizing.hh>
      57             : #include <EnergyPlus/Autosizing/CoolingAirFlowSizing.hh>
      58             : #include <EnergyPlus/Autosizing/CoolingCapacitySizing.hh>
      59             : #include <EnergyPlus/Autosizing/CoolingSHRSizing.hh>
      60             : #include <EnergyPlus/Autosizing/HeatingAirFlowSizing.hh>
      61             : #include <EnergyPlus/Autosizing/HeatingCapacitySizing.hh>
      62             : #include <EnergyPlus/BranchNodeConnections.hh>
      63             : #include <EnergyPlus/CurveManager.hh>
      64             : #include <EnergyPlus/DXCoils.hh>
      65             : #include <EnergyPlus/Data/EnergyPlusData.hh>
      66             : #include <EnergyPlus/DataAirSystems.hh>
      67             : #include <EnergyPlus/DataBranchNodeConnections.hh>
      68             : #include <EnergyPlus/DataContaminantBalance.hh>
      69             : #include <EnergyPlus/DataEnvironment.hh>
      70             : #include <EnergyPlus/DataGlobalConstants.hh>
      71             : #include <EnergyPlus/DataHeatBalance.hh>
      72             : #include <EnergyPlus/DataLoopNode.hh>
      73             : #include <EnergyPlus/DataPrecisionGlobals.hh>
      74             : #include <EnergyPlus/DataSizing.hh>
      75             : #include <EnergyPlus/DataWater.hh>
      76             : #include <EnergyPlus/EMSManager.hh>
      77             : #include <EnergyPlus/Fans.hh>
      78             : #include <EnergyPlus/General.hh>
      79             : #include <EnergyPlus/GeneralRoutines.hh>
      80             : #include <EnergyPlus/GlobalNames.hh>
      81             : #include <EnergyPlus/HVACFan.hh>
      82             : #include <EnergyPlus/HVACVariableRefrigerantFlow.hh>
      83             : #include <EnergyPlus/HeatBalanceInternalHeatGains.hh>
      84             : #include <EnergyPlus/InputProcessing/InputProcessor.hh>
      85             : #include <EnergyPlus/NodeInputManager.hh>
      86             : #include <EnergyPlus/OutAirNodeManager.hh>
      87             : #include <EnergyPlus/OutputProcessor.hh>
      88             : #include <EnergyPlus/OutputReportPredefined.hh>
      89             : #include <EnergyPlus/Psychrometrics.hh>
      90             : #include <EnergyPlus/ScheduleManager.hh>
      91             : #include <EnergyPlus/SimAirServingZones.hh>
      92             : #include <EnergyPlus/StandardRatings.hh>
      93             : #include <EnergyPlus/UtilityRoutines.hh>
      94             : #include <EnergyPlus/WaterManager.hh>
      95             : #include <EnergyPlus/ZoneTempPredictorCorrector.hh>
      96             : 
      97             : namespace EnergyPlus::DXCoils {
      98             : 
      99             : // Module containing the DX coil simulation routines
     100             : 
     101             : // MODULE INFORMATION:
     102             : //       AUTHOR         Fred Buhl
     103             : //       DATE WRITTEN   May 2000
     104             : //       MODIFIED       Aug 2000, Don Shirey, Sept 2000, Feb/Oct 2001, Sept 2003, Jan 2004
     105             : //                      Feb 2005, M. J. Witte, GARD Analytics, Inc., Add new coil type COIL:DX:MultiMode:CoolingEmpirical: Work supported by
     106             : //                      ASHRAE research project 1254-RP Aug 2006, B Griffith, NREL, Added water system interactions for new water manager, Feb
     107             : //                      2010, B Nigusse, FSEC, Added Standard Rating for Coil:Cooling:DX:SingleSpeed Apr 2010, Chandan Sharma, FSEC, Added basin
     108             : //                      heater routines for Coil:Cooling:DX:SingleSpeed, Coil:Cooling:DX:TwoSpeed,
     109             : //                                Coil:Cooling:DX:MultiSpeed, and Coil:Cooling:DX:TwoStageWithHumidityControlMode
     110             : //                      Feb 2013, Bereket Nigusse, FSEC, Added DX Coil Model For 100% OA systems
     111             : //                      Jul 2015, RP Zhang, XF Pang, LBNL, Added new coil type for VRF-FluidTemperatureControl Model
     112             : 
     113             : // PURPOSE OF THIS MODULE:
     114             : // To encapsulate the data and algorithms required to simulate DX cooling coils in
     115             : // EnergyPlus. Module currently models air-cooled or evap-cooled direct expansion systems
     116             : // (split or packaged). Air-side performance is modeled to determine coil discharge
     117             : // air conditions. The module also determines the DX unit's electrical energy usage.
     118             : // Neither the air-side performance nor the electrical energy usage includes the effect
     119             : // of supply air fan heat/energy usage. The supply air fan is modeled by other modules.
     120             : 
     121             : // USE STATEMENTS:
     122             : // Use statements for data only modules
     123             : // Using/Aliasing
     124             : using namespace DataLoopNode;
     125             : using namespace DataHVACGlobals;
     126             : using namespace Psychrometrics;
     127             : 
     128             : // Use statements for access to subroutines in other modules
     129             : using namespace ScheduleManager;
     130             : 
     131             : // Functions
     132             : 
     133    51275364 : void SimDXCoil(EnergyPlusData &state,
     134             :                std::string_view CompName,              // name of the fan coil unit
     135             :                CompressorOperation const CompressorOp, // compressor operation; 1=on, 0=off
     136             :                bool const FirstHVACIteration,          // True when first HVAC iteration
     137             :                int &CompIndex,
     138             :                int const FanOpMode,                               // allows parent object to control fan mode
     139             :                Optional<Real64 const> PartLoadRatio,              // part load ratio (for single speed cycling unit)
     140             :                Optional<Real64 const> OnOffAFR,                   // ratio of compressor on airflow to compressor off airflow
     141             :                Optional<Real64 const> CoilCoolingHeatingPLRRatio, // used for cycling fan RH control
     142             :                Optional<Real64 const> MaxCap,                     // maximum cooling capacity of VRF terminal units
     143             :                Optional<Real64 const> CompCyclingRatio            // cycling ratio of VRF condenser connected to this TU
     144             : )
     145             : {
     146             : 
     147             :     // SUBROUTINE INFORMATION:
     148             :     //       AUTHOR         Fred Buhl
     149             :     //       DATE WRITTEN   May 2000
     150             :     //       MODIFIED       Don Shirey, Sept 2000, October 2001, June 2005
     151             : 
     152             :     // PURPOSE OF THIS SUBROUTINE:
     153             :     // Manages the simulation of a single speed on/off DX coil.
     154             : 
     155             :     // Using/Aliasing
     156             : 
     157             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     158             :     int DXCoilNum;       // index of fan coil unit being simulated
     159             :     Real64 AirFlowRatio; // ratio of compressor on airflow to compressor off airflow
     160             :     Real64 CompCycRatio; // compressor cycling ratio of VRF condenser
     161             : 
     162             :     // First time SimDXCoil is called, get the input for all the DX coils (condensing units)
     163    51275364 :     if (state.dataDXCoils->GetCoilsInputFlag) {
     164           0 :         GetDXCoils(state);
     165           0 :         state.dataDXCoils->GetCoilsInputFlag = false; // Set GetInputFlag false so you don't get coil inputs again
     166             :     }
     167             : 
     168    51275364 :     if (CompIndex == 0) {
     169          22 :         DXCoilNum = UtilityRoutines::FindItemInList(CompName, state.dataDXCoils->DXCoil);
     170          22 :         if (DXCoilNum == 0) {
     171           0 :             ShowFatalError(state, "DX Coil not found=" + std::string{CompName});
     172             :         }
     173          22 :         CompIndex = DXCoilNum;
     174             :     } else {
     175    51275342 :         DXCoilNum = CompIndex;
     176    51275342 :         if (DXCoilNum > state.dataDXCoils->NumDXCoils || DXCoilNum < 1) {
     177           0 :             ShowFatalError(state,
     178           0 :                            format("SimDXCoil: Invalid CompIndex passed={}, Number of DX Coils={}, Coil name={}",
     179             :                                   DXCoilNum,
     180           0 :                                   state.dataDXCoils->NumDXCoils,
     181           0 :                                   CompName));
     182             :         }
     183    51275342 :         if (state.dataDXCoils->CheckEquipName(DXCoilNum)) {
     184         806 :             if (!CompName.empty() && CompName != state.dataDXCoils->DXCoil(DXCoilNum).Name) {
     185           0 :                 ShowFatalError(state,
     186           0 :                                format("SimDXCoil: Invalid CompIndex passed={}, Coil name={}, stored Coil Name for that index={}",
     187             :                                       DXCoilNum,
     188             :                                       CompName,
     189           0 :                                       state.dataDXCoils->DXCoil(DXCoilNum).Name));
     190             :             }
     191         806 :             state.dataDXCoils->CheckEquipName(DXCoilNum) = false;
     192             :         }
     193             :     }
     194             : 
     195    51275364 :     if (present(OnOffAFR)) {
     196    47047064 :         AirFlowRatio = OnOffAFR;
     197             :     } else {
     198     4228300 :         AirFlowRatio = 1.0;
     199             :     }
     200             : 
     201    51275364 :     if (present(CompCyclingRatio)) {
     202     1401966 :         CompCycRatio = CompCyclingRatio;
     203             :     } else {
     204    49873398 :         CompCycRatio = 1.0;
     205             :     }
     206             : 
     207             :     // Initialize the DX coil unit
     208    51275364 :     InitDXCoil(state, DXCoilNum);
     209             : 
     210             :     // Select the correct unit type
     211    51275364 :     switch (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num) { // Autodesk:OPTIONAL PartLoadRatio, MaxCap used in this block without PRESENT check
     212    38421084 :     case CoilDX_CoolingSingleSpeed: {
     213    38421084 :         if (present(CoilCoolingHeatingPLRRatio)) {
     214    30855161 :             CalcDoe2DXCoil(state, DXCoilNum, CompressorOp, FirstHVACIteration, PartLoadRatio, FanOpMode, _, AirFlowRatio, CoilCoolingHeatingPLRRatio);
     215             :         } else {
     216     7565923 :             CalcDoe2DXCoil(state, DXCoilNum, CompressorOp, FirstHVACIteration, PartLoadRatio, FanOpMode, _, AirFlowRatio);
     217             :         }
     218    38421084 :     } break;
     219     7410534 :     case CoilDX_HeatingEmpirical: {
     220     7410534 :         CalcDXHeatingCoil(state, DXCoilNum, PartLoadRatio, FanOpMode, AirFlowRatio);
     221     7410534 :     } break;
     222     1023180 :     case CoilDX_HeatPumpWaterHeaterPumped:
     223             :     case CoilDX_HeatPumpWaterHeaterWrapped: {
     224             :         //   call the HPWHDXCoil routine to calculate water side performance set up the DX coil info for air-side calcs
     225     1023180 :         CalcHPWHDXCoil(state, DXCoilNum, PartLoadRatio);
     226             :         //    CALL CalcDoe2DXCoil(state, DXCoilNum, CompressorOp, FirstHVACIteration,PartLoadRatio), perform air-side calculations
     227     1023180 :         CalcDoe2DXCoil(state, DXCoilNum, CompressorOperation::On, FirstHVACIteration, PartLoadRatio, FanOpMode);
     228     1023180 :     } break;
     229     1553911 :     case CoilVRF_Cooling: {
     230     3107822 :         CalcVRFCoolingCoil(
     231     1553911 :             state, DXCoilNum, CompressorOperation::On, FirstHVACIteration, PartLoadRatio, FanOpMode, CompCycRatio, _, AirFlowRatio, MaxCap);
     232     1553911 :     } break;
     233     1553911 :     case CoilVRF_Heating: {
     234     1553911 :         CalcDXHeatingCoil(state, DXCoilNum, PartLoadRatio, FanOpMode, AirFlowRatio, MaxCap);
     235     1553911 :     } break;
     236      656372 :     case CoilVRF_FluidTCtrl_Cooling: {
     237      656372 :         CalcVRFCoolingCoil_FluidTCtrl(state, DXCoilNum, CompressorOperation::On, FirstHVACIteration, PartLoadRatio, FanOpMode, CompCycRatio, _, _);
     238      656372 :     } break;
     239      656372 :     case CoilVRF_FluidTCtrl_Heating: {
     240      656372 :         CalcVRFHeatingCoil_FluidTCtrl(state, CompressorOp, DXCoilNum, PartLoadRatio, FanOpMode, _, MaxCap);
     241      656372 :     } break;
     242           0 :     default: {
     243           0 :         ShowSevereError(state, "Error detected in DX Coil=" + std::string{CompName});
     244           0 :         ShowContinueError(state, "Invalid DX Coil Type=" + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType);
     245           0 :         ShowFatalError(state, "Preceding condition causes termination.");
     246           0 :     } break;
     247             :     }
     248             : 
     249             :     // Update the unit outlet nodes
     250    51275364 :     UpdateDXCoil(state, DXCoilNum);
     251             : 
     252             :     // Report the result of the simulation
     253    51275364 :     ReportDXCoil(state, DXCoilNum);
     254    51275364 : }
     255             : 
     256    13597981 : void SimDXCoilMultiSpeed(EnergyPlusData &state,
     257             :                          std::string_view CompName, // name of the fan coil unit
     258             :                          Real64 const SpeedRatio,   // = (CompressorSpeed - CompressorSpeedMin) /
     259             :                          Real64 const CycRatio,     // cycling part load ratio for variable speed
     260             :                          int &CompIndex,
     261             :                          Optional_int_const SpeedNum,      // Speed number for multispeed cooling coil onlyn
     262             :                          Optional_int_const FanOpMode,     // Fan operation mode
     263             :                          CompressorOperation CompressorOp, // Compressor on/off; 1=on, 0=off
     264             :                          Optional_int_const SingleMode     // Single mode operation Yes/No; 1=Yes, 0=No
     265             : )
     266             : {
     267             : 
     268             :     // SUBROUTINE INFORMATION:
     269             :     //       AUTHOR         Fred Buhl
     270             :     //       DATE WRITTEN   September 2002
     271             :     //       MODIFIED       Lixing Gu, Sep. 2007
     272             : 
     273             :     // PURPOSE OF THIS SUBROUTINE:
     274             :     // Manages the simulation of a multi speed DX coil.
     275             : 
     276             :     // Using/Aliasing
     277             : 
     278             :     // Locals
     279             :     // SUBROUTINE ARGUMENT DEFINITIONS:
     280             :     //   (CompressorSpeedMax - CompressorSpeedMin)
     281             :     // for variable speed or 2 speed compressors
     282             :     // or 2 speed compressors
     283             : 
     284             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     285             :     int DXCoilNum;      // index of fan coil unit being simulated
     286             :     int SingleModeOper; // SingleMode Operation
     287             : 
     288             :     // First time SimDXCoil is called, get the input for all the DX coils (condensing units)
     289    13597981 :     if (state.dataDXCoils->GetCoilsInputFlag) {
     290           0 :         GetDXCoils(state);
     291           0 :         state.dataDXCoils->GetCoilsInputFlag = false; // Set GetInputFlag false so you don't get coil inputs again
     292             :     }
     293             : 
     294             :     //  find correct DX Coil
     295             : 
     296    13597981 :     if (CompIndex == 0) {
     297           0 :         DXCoilNum = UtilityRoutines::FindItemInList(CompName, state.dataDXCoils->DXCoil);
     298           0 :         if (DXCoilNum == 0) {
     299           0 :             ShowFatalError(state, "DX Coil not found=" + std::string{CompName});
     300             :         }
     301           0 :         CompIndex = DXCoilNum;
     302             :     } else {
     303    13597981 :         DXCoilNum = CompIndex;
     304    13597981 :         if (DXCoilNum > state.dataDXCoils->NumDXCoils || DXCoilNum < 1) {
     305           0 :             ShowFatalError(state,
     306           0 :                            format("SimDXCoilMultiSpeed: Invalid CompIndex passed={}, Number of DX Coils={}, Coil name={}",
     307             :                                   DXCoilNum,
     308           0 :                                   state.dataDXCoils->NumDXCoils,
     309           0 :                                   CompName));
     310             :         }
     311    13597981 :         if (state.dataDXCoils->CheckEquipName(DXCoilNum)) {
     312         135 :             if (!CompName.empty() && CompName != state.dataDXCoils->DXCoil(DXCoilNum).Name) {
     313           0 :                 ShowFatalError(state,
     314           0 :                                format("SimDXCoilMultiSpeed: Invalid CompIndex passed={}, Coil name={}, stored Coil Name for that index={}",
     315             :                                       DXCoilNum,
     316             :                                       CompName,
     317           0 :                                       state.dataDXCoils->DXCoil(DXCoilNum).Name));
     318             :             }
     319         135 :             state.dataDXCoils->CheckEquipName(DXCoilNum) = false;
     320             :         }
     321             :     }
     322             : 
     323    13597981 :     if (present(SingleMode)) {
     324     6338979 :         SingleModeOper = SingleMode;
     325             :     } else {
     326     7259002 :         SingleModeOper = 0;
     327             :     }
     328             : 
     329             :     // Initialize the DX coil unit
     330    13597981 :     InitDXCoil(state, DXCoilNum);
     331             : 
     332             :     // Select the correct unit type
     333    13597981 :     switch (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num) {
     334     2192201 :     case CoilDX_CoolingTwoSpeed: {
     335     2192201 :         CalcMultiSpeedDXCoil(state, DXCoilNum, SpeedRatio, CycRatio);
     336     2192201 :     } break;
     337     6761046 :     case CoilDX_MultiSpeedCooling: {
     338     6761046 :         if (present(SpeedNum))
     339    13522092 :             CalcMultiSpeedDXCoilCooling(state,
     340             :                                         DXCoilNum,
     341             :                                         SpeedRatio,
     342             :                                         CycRatio,
     343             :                                         SpeedNum,
     344             :                                         FanOpMode,
     345             :                                         CompressorOp,
     346    13522092 :                                         SingleModeOper); // Autodesk:OPTIONAL FanOpMode, CompressorOp used without PRESENT check
     347             : 
     348     6761046 :     } break;
     349     4644734 :     case CoilDX_MultiSpeedHeating: {
     350     4644734 :         if (present(SpeedNum))
     351     9289468 :             CalcMultiSpeedDXCoilHeating(state,
     352             :                                         DXCoilNum,
     353             :                                         SpeedRatio,
     354             :                                         CycRatio,
     355             :                                         SpeedNum,
     356             :                                         FanOpMode,
     357     9289468 :                                         SingleModeOper); // Autodesk:OPTIONAL FanOpMode used without PRESENT check
     358             : 
     359     4644734 :     } break;
     360           0 :     default: {
     361           0 :         ShowSevereError(state, "Error detected in DX Coil=" + std::string{CompName});
     362           0 :         ShowContinueError(state, "Invalid DX Coil Type=" + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType);
     363           0 :         ShowFatalError(state, "Preceding condition causes termination.");
     364           0 :     } break;
     365             :     }
     366             : 
     367             :     // Update the unit outlet nodes
     368    13597981 :     UpdateDXCoil(state, DXCoilNum);
     369             : 
     370             :     // Report the result of the simulation
     371    13597981 :     ReportDXCoil(state, DXCoilNum);
     372    13597981 : }
     373             : 
     374      131261 : void SimDXCoilMultiMode(EnergyPlusData &state,
     375             :                         std::string_view CompName,                               // name of the fan coil unit
     376             :                         [[maybe_unused]] CompressorOperation const CompressorOp, // compressor operation; 1=on, 0=off !unused1208
     377             :                         bool const FirstHVACIteration,                           // true if first hvac iteration
     378             :                         Real64 const PartLoadRatio,                              // part load ratio
     379             :                         int const DehumidMode,                                   // dehumidification mode (0=normal, 1=enhanced)
     380             :                         int &CompIndex,
     381             :                         int const FanOpMode // allows parent object to control fan mode
     382             : )
     383             : {
     384             : 
     385             :     // SUBROUTINE INFORMATION:
     386             :     //       AUTHOR         M. J. Witte (based on SimDXCoilMultiSpeed by Fred Buhl)
     387             :     //       DATE WRITTEN   February 2005
     388             :     //       MODIFIED       April 2010, Chandan sharma, added basin heater
     389             : 
     390             :     // PURPOSE OF THIS SUBROUTINE:
     391             :     // Manages the simulation of a DX coil with multiple performance modes, such as
     392             :     // multiple stages, or sub-cool reheat for humidity control.
     393             : 
     394             :     // Using/Aliasing
     395             : 
     396             :     // SUBROUTINE PARAMETER DEFINITIONS:
     397             :     static constexpr std::string_view RoutineName("SimDXCoilMultiMode");
     398             : 
     399             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     400             :     int DXCoilNum; // index of coil being simulated
     401             :     int PerfMode;  // Performance mode for MultiMode DX coil; Always 1 for other coil types
     402             :     // 1-2=normal mode: 1=stage 1 only, 2=stage 1&2
     403             :     // 3-4=enhanced dehumidification mode: 3=stage 1 only, 4=stage 1&2
     404             :     Real64 AirMassFlow; // Dry air mass flow rate through coil [kg/s]
     405             : 
     406             :     Real64 S1OutletAirTemp;     // Stage 1   Outlet air dry bulb temp [C]
     407             :     Real64 S1OutletAirHumRat;   // Stage 1   Outlet air humidity ratio [kgWater/kgDryAir]
     408             :     Real64 S1OutletAirEnthalpy; // Stage 1   Outlet air enthalpy
     409             :     Real64 S1PLR;               // Stage 1   Ratio of actual sensible cooling load to
     410             :     //           steady-state sensible cooling capacity
     411             :     Real64 S1TotalCoolingEnergyRate; // Stage 1   Total cooling rate [W]
     412             :     Real64 S1SensCoolingEnergyRate;  // Stage 1   Sensible cooling rate [W]
     413             :     Real64 S1LatCoolingEnergyRate;   // Stage 1   Latent cooling rate [W]
     414             :     Real64 S1ElecCoolingPower;       // Stage 1   Electric power input [W]
     415      131261 :     Real64 S1RuntimeFraction(0.0);   // Stage 1   Run time fraction (overlaps with stage1&2 run time)
     416             :     Real64 S1EvapCondPumpElecPower;  // Stage 1   Evaporative condenser pump electric power input [W]
     417             :     Real64 S1EvapWaterConsumpRate;   // Stage 1   Evap condenser water consumption rate [m3/s]
     418             :     Real64 S1CrankcaseHeaterPower;   // Stage 1   Report variable for average crankcase heater power [W]
     419             :     Real64 S1FFullLoadOutAirTemp;    // Stage 1   Full load outlet temperature [C]
     420             :     Real64 S1FullLoadOutAirHumRat;   // Stage 1   Full load outlet humidity ratio [kgWater/kgDryAir]
     421             : 
     422             :     Real64 S12OutletAirTemp;     // Stage 1&2 Outlet air dry bulb temp [C]
     423             :     Real64 S12OutletAirHumRat;   // Stage 1&2 Outlet air humidity ratio [kgWater/kgDryAir]
     424             :     Real64 S12OutletAirEnthalpy; // Stage 1&2 Outlet air enthalpy
     425             :     //                                       !           steady-state sensible cooling capacity
     426             :     Real64 S12TotalCoolingEnergyRate; // Stage 1&2 Total cooling rate [W]
     427             :     Real64 S12SensCoolingEnergyRate;  // Stage 1&2 Sensible cooling rate [W]
     428             :     Real64 S12LatCoolingEnergyRate;   // Stage 1&2 Latent cooling rate [W]
     429             :     Real64 S12ElecCoolingPower;       // Stage 1&2 Electric power input [W]
     430             :     Real64 S12ElecCoolFullLoadPower;  // Stage 1&2 Electric power input at full load (PLR=1) [W]
     431      131261 :     Real64 S12RuntimeFraction(0.0);   // Stage 1&2 Run time fraction (overlaps with stage1 run time)
     432             :     Real64 S12EvapCondPumpElecPower;  // Stage 1&2 Evaporative condenser pump electric power input [W]
     433             :     Real64 S12EvapWaterConsumpRate;   // Stage 1&2 Evap condenser water consumption rate [m3/s]
     434             :     Real64 S12CrankcaseHeaterPower;   // Stage 1&2 Report variable for average crankcase heater power [W]
     435             :     Real64 S2PLR;                     // Stage 2   Ratio of actual sensible cooling load to
     436             :     //           steady-state sensible cooling capacity
     437             :     Real64 TSat;      // calculation to avoid calling psych routines twice
     438             :     Real64 NodePress; // Pressure at condenser inlet node (Pa)
     439             : 
     440             :     // First time SimDXCoil is called, get the input for all the DX coils (condensing units)
     441      131261 :     if (state.dataDXCoils->GetCoilsInputFlag) {
     442           0 :         GetDXCoils(state);
     443           0 :         state.dataDXCoils->GetCoilsInputFlag = false; // Set GetInputFlag false so you don't get coil inputs again
     444             :     }
     445             : 
     446             :     //  find correct DX Coil
     447      131261 :     if (CompIndex == 0) {
     448           2 :         DXCoilNum = UtilityRoutines::FindItemInList(CompName, state.dataDXCoils->DXCoil);
     449           2 :         if (DXCoilNum == 0) {
     450           0 :             ShowFatalError(state, "DX Coil not found=" + std::string{CompName});
     451             :         }
     452           2 :         CompIndex = DXCoilNum;
     453             :     } else {
     454      131259 :         DXCoilNum = CompIndex;
     455      131259 :         if (DXCoilNum > state.dataDXCoils->NumDXCoils || DXCoilNum < 1) {
     456           0 :             ShowFatalError(state,
     457           0 :                            format("SimDXCoilMultiMode: Invalid CompIndex passed={}, Number of DX Coils={}, Coil name={}",
     458             :                                   DXCoilNum,
     459           0 :                                   state.dataDXCoils->NumDXCoils,
     460           0 :                                   CompName));
     461             :         }
     462      131259 :         if (state.dataDXCoils->CheckEquipName(DXCoilNum)) {
     463          11 :             if ((CompName != "") && (CompName != state.dataDXCoils->DXCoil(DXCoilNum).Name)) {
     464           0 :                 ShowFatalError(state,
     465           0 :                                format("SimDXCoilMultiMode: Invalid CompIndex passed={}, Coil name={}, stored Coil Name for that index={}",
     466             :                                       DXCoilNum,
     467             :                                       CompName,
     468           0 :                                       state.dataDXCoils->DXCoil(DXCoilNum).Name));
     469             :             }
     470          11 :             state.dataDXCoils->CheckEquipName(DXCoilNum) = false;
     471             :         }
     472             :     }
     473             : 
     474             :     // Initialize the DX coil unit
     475      131261 :     InitDXCoil(state, DXCoilNum);
     476             : 
     477             :     // Select the correct unit type
     478      131261 :     if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_CoolingTwoStageWHumControl) {
     479             :         // Initialize local variables
     480      131261 :         S1RuntimeFraction = 0.0;
     481      131261 :         S1OutletAirEnthalpy = state.dataDXCoils->DXCoil(DXCoilNum).InletAirEnthalpy;
     482      131261 :         S1OutletAirHumRat = state.dataDXCoils->DXCoil(DXCoilNum).InletAirHumRat;
     483      131261 :         S1OutletAirTemp = state.dataDXCoils->DXCoil(DXCoilNum).InletAirTemp;
     484      131261 :         S1ElecCoolingPower = 0.0;
     485      131261 :         S1TotalCoolingEnergyRate = 0.0;
     486      131261 :         S1SensCoolingEnergyRate = 0.0;
     487      131261 :         S1LatCoolingEnergyRate = 0.0;
     488      131261 :         S1CrankcaseHeaterPower = 0.0;
     489      131261 :         S1EvapWaterConsumpRate = 0.0;
     490      131261 :         S1EvapCondPumpElecPower = 0.0;
     491             : 
     492      131261 :         S12RuntimeFraction = 0.0;
     493      131261 :         S12OutletAirEnthalpy = state.dataDXCoils->DXCoil(DXCoilNum).InletAirEnthalpy;
     494      131261 :         S12OutletAirHumRat = state.dataDXCoils->DXCoil(DXCoilNum).InletAirHumRat;
     495      131261 :         S12OutletAirTemp = state.dataDXCoils->DXCoil(DXCoilNum).InletAirTemp;
     496      131261 :         S12ElecCoolingPower = 0.0;
     497      131261 :         S12TotalCoolingEnergyRate = 0.0;
     498      131261 :         S12SensCoolingEnergyRate = 0.0;
     499      131261 :         S12LatCoolingEnergyRate = 0.0;
     500      131261 :         S12CrankcaseHeaterPower = 0.0;
     501      131261 :         S12EvapWaterConsumpRate = 0.0;
     502      131261 :         S12EvapCondPumpElecPower = 0.0;
     503             : 
     504      131261 :         state.dataDXCoils->DXCoil(DXCoilNum).DehumidificationMode = DehumidMode;
     505      131261 :         if (DehumidMode > state.dataDXCoils->DXCoil(DXCoilNum).NumDehumidModes) {
     506           0 :             ShowFatalError(state,
     507           0 :                            state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + " \"" + state.dataDXCoils->DXCoil(DXCoilNum).Name +
     508             :                                "\" - Requested enhanced dehumidification mode not available.");
     509             :         }
     510             : 
     511             :         // If a single-stage coil OR If part load is zero,
     512             :         // run stage 1 at zero part load to set leaving conditions
     513      131261 :         if ((state.dataDXCoils->DXCoil(DXCoilNum).NumCapacityStages == 1) || (PartLoadRatio <= 0.0)) {
     514             :             // Run stage 1 at its part load
     515       79421 :             PerfMode = DehumidMode * 2 + 1;
     516       79421 :             CalcDoe2DXCoil(state, DXCoilNum, CompressorOperation::On, FirstHVACIteration, PartLoadRatio, FanOpMode, PerfMode);
     517       79421 :             S1PLR = PartLoadRatio;
     518       79421 :             S2PLR = 0.0;
     519             :         } else {
     520             :             // If a two-stage coil
     521             :             // Run stage 1 at full load
     522       51840 :             PerfMode = DehumidMode * 2 + 1;
     523       51840 :             CalcDoe2DXCoil(state, DXCoilNum, CompressorOperation::On, FirstHVACIteration, 1.0, FanOpMode, PerfMode);
     524       51840 :             S1SensCoolingEnergyRate = state.dataDXCoils->DXCoil(DXCoilNum).SensCoolingEnergyRate;
     525       51840 :             if (S1SensCoolingEnergyRate > 0.0) {
     526       51840 :                 S1PLR = PartLoadRatio;
     527             :             } else {
     528           0 :                 S1PLR = 0.0;
     529             :             }
     530             :             // Run stage 1+2 at full load
     531       51840 :             if (state.dataDXCoils->DXCoil(DXCoilNum).NumCapacityStages >= 2) {
     532       51840 :                 PerfMode = DehumidMode * 2 + 2;
     533       51840 :                 CalcDoe2DXCoil(state, DXCoilNum, CompressorOperation::On, FirstHVACIteration, 1.0, FanOpMode, PerfMode);
     534       51840 :                 S12SensCoolingEnergyRate = state.dataDXCoils->DXCoil(DXCoilNum).SensCoolingEnergyRate;
     535       51840 :                 S12ElecCoolFullLoadPower = state.dataDXCoils->DXCoil(DXCoilNum).ElecCoolingPower;
     536             :             }
     537             : 
     538             :             // Determine run-time fractions for each stage based on sensible capacities
     539             :             //   Relationships:
     540             :             //     Stage 1   PLR1=   Load/Cap1
     541             :             //     Stage1+2  PLR12=  Load/Cap12
     542             :             //     Stage 2   PLR2=   (Load-Cap1)/(Cap2)
     543             :             //     PLR = Load/(Cap1+Cap2)
     544             :             //     Load= PLR*(Cap1+Cap2)
     545             :             //     PLR1= MIN(1,(PLR*(Cap1+Cap2)/Cap1))
     546             :             //     PLR2= MIN(1,((PLR*(Cap1+Cap2)-Cap1)/Cap2))
     547             : 
     548       51840 :             if (S1SensCoolingEnergyRate > 0.0) {
     549       51840 :                 S1PLR = PartLoadRatio * S12SensCoolingEnergyRate / S1SensCoolingEnergyRate;
     550             :             } else {
     551           0 :                 S1PLR = 0.0;
     552             :             }
     553       51840 :             S1PLR = min(1.0, S1PLR);
     554       51840 :             S1PLR = max(0.0, S1PLR);
     555       51840 :             if ((S12SensCoolingEnergyRate - S1SensCoolingEnergyRate) > 0.0) {
     556       51840 :                 S2PLR = (PartLoadRatio * S12SensCoolingEnergyRate - S1SensCoolingEnergyRate) / (S12SensCoolingEnergyRate - S1SensCoolingEnergyRate);
     557             :             } else {
     558           0 :                 S2PLR = 0.0;
     559             :             }
     560       51840 :             S2PLR = min(1.0, S2PLR);
     561       51840 :             S2PLR = max(0.0, S2PLR);
     562             : 
     563             :             // Run stage 1 at its part load
     564       51840 :             PerfMode = DehumidMode * 2 + 1;
     565       51840 :             CalcDoe2DXCoil(state, DXCoilNum, CompressorOperation::On, FirstHVACIteration, S1PLR, FanOpMode, PerfMode);
     566             :         }
     567             :         // For stage-1 only operation, all outputs are set by CalcDoe2DXCoil.
     568             :         // No further adjustments are necessary.
     569             : 
     570             :         // Run stage 2 if needed and available
     571      131261 :         if ((S2PLR > 0.0) && (state.dataDXCoils->DXCoil(DXCoilNum).NumCapacityStages >= 2)) {
     572             :             // Store stage 1 outputs
     573       46544 :             S1RuntimeFraction = state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction;
     574       46544 :             S1OutletAirEnthalpy = state.dataDXCoils->DXCoil(DXCoilNum).OutletAirEnthalpy;
     575       46544 :             S1OutletAirHumRat = state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat;
     576       46544 :             S1OutletAirTemp = state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp;
     577       46544 :             S1ElecCoolingPower = state.dataDXCoils->DXCoil(DXCoilNum).ElecCoolingPower;
     578       46544 :             S1TotalCoolingEnergyRate = state.dataDXCoils->DXCoil(DXCoilNum).TotalCoolingEnergyRate;
     579       46544 :             S1SensCoolingEnergyRate = state.dataDXCoils->DXCoil(DXCoilNum).SensCoolingEnergyRate;
     580       46544 :             S1LatCoolingEnergyRate = state.dataDXCoils->DXCoil(DXCoilNum).LatCoolingEnergyRate;
     581       46544 :             S1CrankcaseHeaterPower = state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterPower;
     582       46544 :             S1EvapWaterConsumpRate = state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterConsumpRate;
     583       46544 :             S1EvapCondPumpElecPower = state.dataDXCoils->DXCoil(DXCoilNum).EvapCondPumpElecPower;
     584             : 
     585             :             // Save first stage full load outlet conditions to pass to heat recovery
     586       46544 :             S1FFullLoadOutAirTemp = state.dataDXCoils->DXCoilFullLoadOutAirTemp(DXCoilNum);
     587       46544 :             S1FullLoadOutAirHumRat = state.dataDXCoils->DXCoilFullLoadOutAirHumRat(DXCoilNum);
     588             : 
     589             :             // Run stage 1+2 at its part load
     590       46544 :             PerfMode = DehumidMode * 2 + 2;
     591       46544 :             CalcDoe2DXCoil(state, DXCoilNum, CompressorOperation::On, FirstHVACIteration, S2PLR, FanOpMode, PerfMode);
     592       46544 :             S12RuntimeFraction = state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction;
     593       46544 :             S12OutletAirEnthalpy = state.dataDXCoils->DXCoil(DXCoilNum).OutletAirEnthalpy;
     594       46544 :             S12OutletAirHumRat = state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat;
     595       46544 :             S12OutletAirTemp = state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp;
     596       46544 :             S12ElecCoolingPower = state.dataDXCoils->DXCoil(DXCoilNum).ElecCoolingPower;
     597       46544 :             S12TotalCoolingEnergyRate = state.dataDXCoils->DXCoil(DXCoilNum).TotalCoolingEnergyRate;
     598       46544 :             S12SensCoolingEnergyRate = state.dataDXCoils->DXCoil(DXCoilNum).SensCoolingEnergyRate;
     599       46544 :             S12LatCoolingEnergyRate = state.dataDXCoils->DXCoil(DXCoilNum).LatCoolingEnergyRate;
     600       46544 :             S12CrankcaseHeaterPower = state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterPower;
     601       46544 :             S12EvapWaterConsumpRate = state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterConsumpRate;
     602       46544 :             S12EvapCondPumpElecPower = state.dataDXCoils->DXCoil(DXCoilNum).EvapCondPumpElecPower;
     603             : 
     604             :             // Determine combined performance
     605       46544 :             state.dataDXCoils->DXCoil(DXCoilNum).OutletAirEnthalpy = (1.0 - S2PLR) * S1OutletAirEnthalpy + S2PLR * S12OutletAirEnthalpy;
     606       46544 :             state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat = (1.0 - S2PLR) * S1OutletAirHumRat + S2PLR * S12OutletAirHumRat;
     607       46544 :             state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp =
     608       46544 :                 PsyTdbFnHW(state.dataDXCoils->DXCoil(DXCoilNum).OutletAirEnthalpy, state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat);
     609             :             // Check for saturation error and modify temperature at constant enthalpy
     610       46544 :             if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(PerfMode) != 0) {
     611           0 :                 NodePress = state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(PerfMode)).Press;
     612             :                 // If node is not connected to anything, pressure = default, use weather data
     613           0 :                 if (NodePress == state.dataLoopNodes->DefaultNodeValues.Press) NodePress = state.dataEnvrn->OutBaroPress;
     614           0 :                 TSat = PsyTsatFnHPb(state, state.dataDXCoils->DXCoil(DXCoilNum).OutletAirEnthalpy, NodePress, RoutineName);
     615           0 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp < TSat) {
     616           0 :                     state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp = TSat;
     617             :                 }
     618           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat = PsyWFnTdbH(
     619           0 :                     state, state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp, state.dataDXCoils->DXCoil(DXCoilNum).OutletAirEnthalpy, RoutineName);
     620             :             } else {
     621       46544 :                 TSat = PsyTsatFnHPb(state, state.dataDXCoils->DXCoil(DXCoilNum).OutletAirEnthalpy, state.dataEnvrn->OutBaroPress, RoutineName);
     622       46544 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp < TSat) {
     623           0 :                     state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp = TSat;
     624             :                 }
     625             :                 //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
     626             :                 //      IF(DXCoil(DXCoilNum)%OutletAirTemp .LT. PsyTsatFnHPb(DXCoil(DXCoilNum)%OutletAirEnthalpy, &
     627             :                 //                 Node(DXCoil(DXCoilNum)%AirInNode)%Press)) THEN
     628             :                 //        DXCoil(DXCoilNum)%OutletAirTemp = PsyTsatFnHPb(DXCoil(DXCoilNum)%OutletAirEnthalpy, &
     629             :                 //                 Node(DXCoil(DXCoilNum)%AirInNode)%Press)
     630       93088 :                 state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat = PsyWFnTdbH(
     631       93088 :                     state, state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp, state.dataDXCoils->DXCoil(DXCoilNum).OutletAirEnthalpy, RoutineName);
     632             :             }
     633             : 
     634             :             //      DXCoil(DXCoilNum)%ElecCoolingPower = (1-S12RuntimeFraction)*S1ElecCoolingPower &
     635             :             //                                             +S12RuntimeFraction*S12ElecCoolingPower
     636             :             //  S12ElecCoolingPower overstates S1 portion of power, because it is also adjust by S12PLR
     637             :             //  So, must make an adjustment for S12ElecCoolingPower/S12ElecCoolFullLoadPower
     638             :             //  when subtracting off S1ElecCoolingPower
     639       46544 :             if (S12ElecCoolFullLoadPower > 0.0) {
     640       46544 :                 state.dataDXCoils->DXCoil(DXCoilNum).ElecCoolingPower =
     641       93088 :                     S1RuntimeFraction * S1ElecCoolingPower +
     642       46544 :                     S12RuntimeFraction * (S12ElecCoolingPower - S1ElecCoolingPower * S12ElecCoolingPower / S12ElecCoolFullLoadPower);
     643             :             } else {
     644           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).ElecCoolingPower = 0.0;
     645             :             }
     646             : 
     647       46544 :             state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction = S1RuntimeFraction;
     648             : 
     649       46544 :             AirMassFlow = state.dataDXCoils->DXCoil(DXCoilNum).InletAirMassFlowRate;
     650      325808 :             CalcComponentSensibleLatentOutput(AirMassFlow,
     651       46544 :                                               state.dataDXCoils->DXCoil(DXCoilNum).InletAirTemp,
     652       46544 :                                               state.dataDXCoils->DXCoil(DXCoilNum).InletAirHumRat,
     653       46544 :                                               state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp,
     654       46544 :                                               state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat,
     655       46544 :                                               state.dataDXCoils->DXCoil(DXCoilNum).SensCoolingEnergyRate,
     656       46544 :                                               state.dataDXCoils->DXCoil(DXCoilNum).LatCoolingEnergyRate,
     657       46544 :                                               state.dataDXCoils->DXCoil(DXCoilNum).TotalCoolingEnergyRate);
     658             : 
     659       46544 :             state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterConsumpRate =
     660       46544 :                 (1.0 - S12RuntimeFraction) * S1EvapWaterConsumpRate + S12RuntimeFraction * S12EvapWaterConsumpRate;
     661       46544 :             state.dataDXCoils->DXCoil(DXCoilNum).EvapCondPumpElecPower =
     662       46544 :                 (1.0 - S12RuntimeFraction) * S1EvapCondPumpElecPower + S12RuntimeFraction * S12EvapCondPumpElecPower;
     663             : 
     664             :             // Stage 1 runtime sets the crankcase heater power
     665       46544 :             state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterPower = S1CrankcaseHeaterPower;
     666             : 
     667       46544 :             state.dataDXCoils->DXCoilOutletTemp(DXCoilNum) = state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp;
     668       46544 :             state.dataDXCoils->DXCoilOutletHumRat(DXCoilNum) = state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat;
     669             : 
     670             :             //     calculate average full load outlet conditions for second stage operation
     671       46544 :             state.dataDXCoils->DXCoilFullLoadOutAirTemp(DXCoilNum) =
     672       46544 :                 (1.0 - S2PLR) * S1FFullLoadOutAirTemp + S2PLR * state.dataDXCoils->DXCoilFullLoadOutAirTemp(DXCoilNum);
     673       46544 :             state.dataDXCoils->DXCoilFullLoadOutAirHumRat(DXCoilNum) =
     674       46544 :                 (1.0 - S2PLR) * S1FullLoadOutAirHumRat + S2PLR * state.dataDXCoils->DXCoilFullLoadOutAirHumRat(DXCoilNum);
     675             : 
     676             :         } // End if stage 2 is operating
     677             : 
     678             :         //   set the part load ratio and heat reclaim capacity for use by desuperheater heating coils
     679      131261 :         state.dataDXCoils->DXCoil(DXCoilNum).PartLoadRatio = S1PLR;
     680      131261 :         state.dataDXCoils->DXCoilPartLoadRatio(DXCoilNum) = S1PLR;
     681             : 
     682             :         //   Calculation for heat reclaim needs to be corrected to use compressor power (not including condenser fan power)
     683      131261 :         state.dataHeatBal->HeatReclaimDXCoil(DXCoilNum).AvailCapacity =
     684      131261 :             state.dataDXCoils->DXCoil(DXCoilNum).TotalCoolingEnergyRate + state.dataDXCoils->DXCoil(DXCoilNum).ElecCoolingPower;
     685             : 
     686      131261 :         state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilStg2RuntimeFrac = S12RuntimeFraction;
     687             : 
     688             :         //   Calculate basin heater power
     689      131261 :         CalcBasinHeaterPowerForMultiModeDXCoil(state, DXCoilNum, DehumidMode);
     690             :     } else {
     691           0 :         ShowSevereError(state, "Error detected in DX Coil=" + std::string{CompName});
     692           0 :         ShowContinueError(state, "Invalid DX Coil Type=" + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType);
     693           0 :         ShowFatalError(state, "Preceding condition causes termination.");
     694             :     }
     695             : 
     696             :     // Update the unit outlet nodes
     697      131261 :     UpdateDXCoil(state, DXCoilNum);
     698             : 
     699             :     // Report the result of the simulation
     700      131261 :     ReportDXCoil(state, DXCoilNum);
     701      131261 : }
     702             : 
     703         241 : void GetDXCoils(EnergyPlusData &state)
     704             : {
     705             : 
     706             :     // SUBROUTINE INFORMATION:
     707             :     //       AUTHOR         Fred Buhl
     708             :     //       DATE WRITTEN   May 2000
     709             :     //       MODIFIED       Aug 2000, Don Shirey, Sept 2000, Feb/Oct 2001, Sept 2003, Jan/July 2004
     710             :     //                      Feb 2005, M. J. Witte, GARD Analytics, Inc., Add new coil type COIL:DX:MultiMode:CoolingEmpirical:
     711             :     //                      May 2005, Rich Raustad, FSEC, Added COIL:DX:HeatPumpWaterHeater
     712             :     //                      Jun 2007, L. Gu, FSEC, Added new coil type COIL:DX:MULTISPEED:COOLING and COIL:DX:MULTISPEED:HEATING
     713             :     //                      Apr 2010, Chandan Sharma, FSEC, added basin heater inputs
     714             :     //                      Jul 2015, RP Zhang, XF Pang, LBNL, Added new coil type for VRF-FluidTemperatureControl Model
     715             : 
     716             :     // PURPOSE OF THIS SUBROUTINE:
     717             :     // Obtains input data for DX coils and stores it in DX coil data structure
     718             : 
     719             :     // METHODOLOGY EMPLOYED:
     720             :     // Uses "Get" routines to read in data.
     721             : 
     722             :     // Using/Aliasing
     723             :     using BranchNodeConnections::TestCompSet;
     724             :     using Curve::checkCurveIsNormalizedToOne;
     725             :     using Curve::CurveValue;
     726             :     using Curve::GetCurveIndex;
     727             :     using Curve::SetCurveOutputMinMaxValues;
     728             :     using DataSizing::AutoSize;
     729             :     using EMSManager::ManageEMS;
     730             : 
     731             :     using GlobalNames::VerifyUniqueCoilName;
     732             :     using NodeInputManager::GetOnlySingleNode;
     733             :     using OutAirNodeManager::CheckOutAirNodeNumber;
     734             :     using ScheduleManager::GetScheduleIndex;
     735             :     using WaterManager::SetupTankDemandComponent;
     736             :     using WaterManager::SetupTankSupplyComponent;
     737             : 
     738             :     // SUBROUTINE PARAMETER DEFINITIONS:
     739             :     static constexpr std::string_view RoutineName("GetDXCoils: "); // include trailing blank space
     740         241 :     constexpr Real64 minOATCompDXCooling = -25.0;                  // min OAT for compressor operation for DX cooling coils
     741             : 
     742             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     743             :     int DXCoilIndex;                 // loop index
     744             :     int DXCoilNum;                   // current DX coil number
     745             :     int NumAlphas;                   // Number of alphas in input
     746             :     int NumNumbers;                  // Number of numeric items in input
     747         482 :     Array1D_string Alphas2;          // Alpha input items for object
     748         482 :     Array1D<Real64> Numbers2;        // Numeric input items for object
     749         482 :     Array1D_string cAlphaFields2;    // Alpha field names
     750         482 :     Array1D_string cNumericFields2;  // Numeric field names
     751         482 :     Array1D_bool lAlphaBlanks2;      // Logical array, alpha field input BLANK = .TRUE.
     752         482 :     Array1D_bool lNumericBlanks2;    // Logical array, numeric field input BLANK = .TRUE.
     753             :     int NumAlphas2;                  // Number of alphas in input for performance object
     754             :     int NumNumbers2;                 // Number of numeric items in input for performance object
     755             :     int IOStatus;                    // Input status returned from GetObjectItem
     756         241 :     bool ErrorsFound(false);         // Set to true if errors in input, fatal at end of routine
     757             :     int DXHPWaterHeaterCoilNum;      // Loop index for 1,NumDXHeatPumpWaterHeaterCoils
     758             :     int CapacityStageNum;            // Loop index for 1,Number of capacity stages
     759             :     int DehumidModeNum;              // Loop index for 1,Number of enhanced dehumidification modes
     760             :     int PerfModeNum;                 // Performance mode index
     761             :     int PerfObjectNum;               // Item number for performance object
     762             :     int AlphaIndex;                  // Index for current alpha field
     763         482 :     std::string CurrentModuleObject; // Object type for getting and error messages
     764         482 :     std::string PerfObjectType;      // Performance object type for getting and error messages
     765         482 :     std::string PerfObjectName;      // Performance object name for getting and error messages
     766             :     Real64 InletAirTemp;             // Used to pass proper inlet air temp to HPWH DX coil performance curves
     767             :     Real64 InletWaterTemp;           // Used to pass proper inlet water temp to HPWH DX coil performance curves
     768             :     int I;                           // Index of speeds
     769             :     Real64 CurveVal;                 // Used to verify modifier curves equal 1 at rated conditions
     770         482 :     Array1D_string Alphas;           // Alpha input items for object
     771         482 :     Array1D_string cAlphaFields;     // Alpha field names
     772         482 :     Array1D_string cNumericFields;   // Numeric field names
     773         482 :     Array1D<Real64> Numbers;         // Numeric input items for object
     774         482 :     Array1D_bool lAlphaBlanks;       // Logical array, alpha field input BLANK = .TRUE.
     775         482 :     Array1D_bool lNumericBlanks;     // Logical array, numeric field input BLANK = .TRUE.
     776         241 :     int MaxNumbers(0);               // Maximum number of numeric input fields
     777         241 :     int MaxAlphas(0);                // Maximum number of alpha input fields
     778         241 :     int TotalArgs(0);                // Total number of alpha and numeric arguments (max) for a
     779             :     //   certain object in the input file
     780             :     Real64 MinCurveVal; // used for testing PLF curve output
     781             :     Real64 MinCurvePLR; // used for testing PLF curve output
     782             :     Real64 MaxCurveVal; // used for testing PLF curve output
     783             :     Real64 MaxCurvePLR; // used for testing PLF curve output
     784             :     Real64 CurveInput;  // index used for testing PLF curve output
     785             : 
     786             :     // find number of each type of DX coil and calculate the total number
     787         241 :     state.dataDXCoils->NumDoe2DXCoils = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Coil:Cooling:DX:SingleSpeed");
     788         241 :     state.dataDXCoils->NumDXHeatingCoils = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Coil:Heating:DX:SingleSpeed");
     789         241 :     state.dataDXCoils->NumDXMulSpeedCoils = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Coil:Cooling:DX:TwoSpeed");
     790         241 :     state.dataDXCoils->NumDXMulModeCoils =
     791         482 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Coil:Cooling:DX:TwoStageWithHumidityControlMode");
     792         241 :     state.dataDXCoils->NumDXHeatPumpWaterHeaterPumpedCoils =
     793         241 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cAllCoilTypes(CoilDX_HeatPumpWaterHeaterPumped));
     794         241 :     state.dataDXCoils->NumDXHeatPumpWaterHeaterWrappedCoils =
     795         241 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cAllCoilTypes(CoilDX_HeatPumpWaterHeaterWrapped));
     796         241 :     state.dataDXCoils->NumDXMulSpeedCoolCoils = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Coil:Cooling:DX:MultiSpeed");
     797         241 :     state.dataDXCoils->NumDXMulSpeedHeatCoils = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Coil:Heating:DX:MultiSpeed");
     798         241 :     state.dataDXCoils->NumVRFCoolingCoils = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cAllCoilTypes(CoilVRF_Cooling));
     799         241 :     state.dataDXCoils->NumVRFHeatingCoils = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cAllCoilTypes(CoilVRF_Heating));
     800         241 :     state.dataDXCoils->NumVRFCoolingFluidTCtrlCoils =
     801         241 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cAllCoilTypes(CoilVRF_FluidTCtrl_Cooling));
     802         241 :     state.dataDXCoils->NumVRFHeatingFluidTCtrlCoils =
     803         241 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cAllCoilTypes(CoilVRF_FluidTCtrl_Heating));
     804             : 
     805         723 :     state.dataDXCoils->NumDXCoils = state.dataDXCoils->NumDoe2DXCoils + state.dataDXCoils->NumDXHeatingCoils + state.dataDXCoils->NumDXMulSpeedCoils +
     806         723 :                                     state.dataDXCoils->NumDXMulModeCoils + state.dataDXCoils->NumDXHeatPumpWaterHeaterPumpedCoils +
     807         723 :                                     state.dataDXCoils->NumDXHeatPumpWaterHeaterWrappedCoils + state.dataDXCoils->NumDXMulSpeedCoolCoils +
     808         723 :                                     state.dataDXCoils->NumDXMulSpeedHeatCoils + state.dataDXCoils->NumVRFCoolingCoils +
     809         723 :                                     state.dataDXCoils->NumVRFHeatingCoils + state.dataDXCoils->NumVRFCoolingFluidTCtrlCoils +
     810         241 :                                     state.dataDXCoils->NumVRFHeatingFluidTCtrlCoils;
     811             : 
     812             :     // Determine max number of alpha and numeric arguments for all objects being read, in order to allocate local arrays
     813         241 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, "Coil:Cooling:DX:SingleSpeed", TotalArgs, NumAlphas, NumNumbers);
     814         241 :     MaxNumbers = NumNumbers;
     815         241 :     MaxAlphas = NumAlphas;
     816         241 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, "Coil:Heating:DX:SingleSpeed", TotalArgs, NumAlphas, NumNumbers);
     817         241 :     MaxNumbers = max(MaxNumbers, NumNumbers);
     818         241 :     MaxAlphas = max(MaxAlphas, NumAlphas);
     819         241 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, "Coil:Cooling:DX:TwoSpeed", TotalArgs, NumAlphas, NumNumbers);
     820         241 :     MaxNumbers = max(MaxNumbers, NumNumbers);
     821         241 :     MaxAlphas = max(MaxAlphas, NumAlphas);
     822         482 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     823         241 :         state, "Coil:Cooling:DX:TwoStageWithHumidityControlMode", TotalArgs, NumAlphas, NumNumbers);
     824         241 :     MaxNumbers = max(MaxNumbers, NumNumbers);
     825         241 :     MaxAlphas = max(MaxAlphas, NumAlphas);
     826         482 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     827         241 :         state, cAllCoilTypes(CoilDX_HeatPumpWaterHeaterPumped), TotalArgs, NumAlphas, NumNumbers);
     828         241 :     MaxNumbers = max(MaxNumbers, NumNumbers);
     829         241 :     MaxAlphas = max(MaxAlphas, NumAlphas);
     830         482 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     831         241 :         state, cAllCoilTypes(CoilDX_HeatPumpWaterHeaterWrapped), TotalArgs, NumAlphas, NumNumbers);
     832         241 :     MaxNumbers = max(MaxNumbers, NumNumbers);
     833         241 :     MaxAlphas = max(MaxAlphas, NumAlphas);
     834         241 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, "Coil:Cooling:DX:MultiSpeed", TotalArgs, NumAlphas, NumNumbers);
     835         241 :     MaxNumbers = max(MaxNumbers, NumNumbers);
     836         241 :     MaxAlphas = max(MaxAlphas, NumAlphas);
     837         241 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, "Coil:Heating:DX:MultiSpeed", TotalArgs, NumAlphas, NumNumbers);
     838         241 :     MaxNumbers = max(MaxNumbers, NumNumbers);
     839         241 :     MaxAlphas = max(MaxAlphas, NumAlphas);
     840         241 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, cAllCoilTypes(CoilVRF_Cooling), TotalArgs, NumAlphas, NumNumbers);
     841         241 :     MaxNumbers = max(MaxNumbers, NumNumbers);
     842         241 :     MaxAlphas = max(MaxAlphas, NumAlphas);
     843         241 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, cAllCoilTypes(CoilVRF_Heating), TotalArgs, NumAlphas, NumNumbers);
     844         241 :     MaxNumbers = max(MaxNumbers, NumNumbers);
     845         241 :     MaxAlphas = max(MaxAlphas, NumAlphas);
     846         482 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     847         241 :         state, cAllCoilTypes(CoilVRF_FluidTCtrl_Cooling), TotalArgs, NumAlphas, NumNumbers);
     848         241 :     MaxNumbers = max(MaxNumbers, NumNumbers);
     849         241 :     MaxAlphas = max(MaxAlphas, NumAlphas);
     850         482 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     851         241 :         state, cAllCoilTypes(CoilVRF_FluidTCtrl_Heating), TotalArgs, NumAlphas, NumNumbers);
     852         241 :     MaxNumbers = max(MaxNumbers, NumNumbers);
     853         241 :     MaxAlphas = max(MaxAlphas, NumAlphas);
     854         241 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, "CoilPerformance:DX:Cooling", TotalArgs, NumAlphas, NumNumbers);
     855         241 :     MaxNumbers = max(MaxNumbers, NumNumbers);
     856         241 :     MaxAlphas = max(MaxAlphas, NumAlphas);
     857             : 
     858         241 :     Alphas.allocate(MaxAlphas);
     859         241 :     cAlphaFields.allocate(MaxAlphas);
     860         241 :     cNumericFields.allocate(MaxNumbers);
     861         241 :     Numbers.dimension(MaxNumbers, 0.0);
     862         241 :     lAlphaBlanks.dimension(MaxAlphas, true);
     863         241 :     lNumericBlanks.dimension(MaxNumbers, true);
     864             : 
     865         241 :     Alphas2.allocate(MaxAlphas);
     866         241 :     cAlphaFields2.allocate(MaxAlphas);
     867         241 :     cNumericFields2.allocate(MaxNumbers);
     868         241 :     Numbers2.dimension(MaxNumbers, 0.0);
     869         241 :     lAlphaBlanks2.dimension(MaxAlphas, true);
     870         241 :     lNumericBlanks2.dimension(MaxNumbers, true);
     871             : 
     872             :     // allocate the data structure
     873             : 
     874             :     // Derived types
     875         241 :     state.dataDXCoils->DXCoil.allocate(state.dataDXCoils->NumDXCoils);
     876         241 :     state.dataDXCoils->DXCoilNumericFields.allocate(state.dataDXCoils->NumDXCoils);
     877         241 :     state.dataHeatBal->HeatReclaimDXCoil.allocate(state.dataDXCoils->NumDXCoils);
     878         241 :     state.dataDXCoils->CheckEquipName.dimension(state.dataDXCoils->NumDXCoils, true);
     879             : 
     880             :     // Module level variable arrays
     881         241 :     state.dataDXCoils->DXCoilOutletTemp.allocate(state.dataDXCoils->NumDXCoils);
     882         241 :     state.dataDXCoils->DXCoilOutletHumRat.allocate(state.dataDXCoils->NumDXCoils);
     883         241 :     state.dataDXCoils->DXCoilPartLoadRatio.allocate(state.dataDXCoils->NumDXCoils);
     884         241 :     state.dataDXCoils->DXCoilFanOpMode.allocate(state.dataDXCoils->NumDXCoils);
     885         241 :     state.dataDXCoils->DXCoilFullLoadOutAirTemp.allocate(state.dataDXCoils->NumDXCoils);
     886         241 :     state.dataDXCoils->DXCoilFullLoadOutAirHumRat.allocate(state.dataDXCoils->NumDXCoils);
     887         241 :     state.dataDXCoils->DXCoilTotalCooling.allocate(state.dataDXCoils->NumDXCoils);
     888         241 :     state.dataDXCoils->DXCoilTotalHeating.allocate(state.dataDXCoils->NumDXCoils);
     889         241 :     state.dataDXCoils->DXCoilCoolInletAirWBTemp.allocate(state.dataDXCoils->NumDXCoils);
     890         241 :     state.dataDXCoils->DXCoilHeatInletAirDBTemp.allocate(state.dataDXCoils->NumDXCoils);
     891         241 :     state.dataDXCoils->DXCoilHeatInletAirWBTemp.allocate(state.dataDXCoils->NumDXCoils);
     892             : 
     893             :     // initialize the module level arrays
     894         241 :     state.dataDXCoils->DXCoilOutletTemp = 0.0;
     895         241 :     state.dataDXCoils->DXCoilOutletHumRat = 0.0;
     896         241 :     state.dataDXCoils->DXCoilPartLoadRatio = 0.0;
     897         241 :     state.dataDXCoils->DXCoilFanOpMode = 0;
     898         241 :     state.dataDXCoils->DXCoilFullLoadOutAirTemp = 0.0;
     899         241 :     state.dataDXCoils->DXCoilFullLoadOutAirHumRat = 0.0;
     900             : 
     901             :     // initialize the coil counter
     902         241 :     DXCoilNum = 0;
     903             : 
     904             :     // Loop over the Doe2 DX Coils and get & load the data
     905         241 :     CurrentModuleObject = "Coil:Cooling:DX:SingleSpeed";
     906         846 :     for (DXCoilIndex = 1; DXCoilIndex <= state.dataDXCoils->NumDoe2DXCoils; ++DXCoilIndex) {
     907             : 
     908         605 :         state.dataInputProcessing->inputProcessor->getObjectItem(state,
     909             :                                                                  CurrentModuleObject,
     910             :                                                                  DXCoilIndex,
     911             :                                                                  Alphas,
     912             :                                                                  NumAlphas,
     913             :                                                                  Numbers,
     914             :                                                                  NumNumbers,
     915             :                                                                  IOStatus,
     916             :                                                                  lNumericBlanks,
     917             :                                                                  lAlphaBlanks,
     918             :                                                                  cAlphaFields,
     919             :                                                                  cNumericFields);
     920             : 
     921         605 :         ++DXCoilNum;
     922             :         // allocate single performance mode for numeric field strings used for sizing routine
     923         605 :         state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode.allocate(1);
     924         605 :         state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(1).FieldNames.allocate(MaxNumbers);
     925         605 :         state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(1).FieldNames = cNumericFields;
     926         605 :         UtilityRoutines::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
     927             :         // ErrorsFound will be set to True if problem was found, left untouched otherwise
     928         605 :         VerifyUniqueCoilName(state, CurrentModuleObject, Alphas(1), ErrorsFound, CurrentModuleObject + " Name");
     929             : 
     930         605 :         state.dataDXCoils->DXCoil(DXCoilNum).Name = Alphas(1);
     931             :         // Initialize DataHeatBalance heat reclaim variable name for use by heat reclaim coils
     932         605 :         state.dataHeatBal->HeatReclaimDXCoil(DXCoilNum).Name = state.dataDXCoils->DXCoil(DXCoilNum).Name;
     933         605 :         state.dataHeatBal->HeatReclaimDXCoil(DXCoilNum).SourceType = CurrentModuleObject;
     934         605 :         state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType = CurrentModuleObject;
     935         605 :         state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num = CoilDX_CoolingSingleSpeed;
     936         605 :         state.dataDXCoils->DXCoil(DXCoilNum).Schedule = Alphas(2);
     937         605 :         if (lAlphaBlanks(2)) {
     938          81 :             state.dataDXCoils->DXCoil(DXCoilNum).SchedPtr = DataGlobalConstants::ScheduleAlwaysOn;
     939             :         } else {
     940         524 :             state.dataDXCoils->DXCoil(DXCoilNum).SchedPtr = GetScheduleIndex(state, Alphas(2)); // convert schedule name to pointer
     941         524 :             if (state.dataDXCoils->DXCoil(DXCoilNum).SchedPtr == 0) {
     942           0 :                 ShowSevereError(state,
     943           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
     944           0 :                 ShowContinueError(state, "..." + cAlphaFields(2) + "=\"" + Alphas(2) + "\".");
     945           0 :                 ErrorsFound = true;
     946             :             }
     947             :         }
     948         605 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(1) = Numbers(1);
     949         605 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedSHR(1) = Numbers(2);
     950         605 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedCOP(1) = Numbers(3);
     951         605 :         if (state.dataDXCoils->DXCoil(DXCoilNum).RatedCOP(1) <= 0.0) {
     952           0 :             ShowSevereError(state,
     953           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
     954           0 :             ShowContinueError(state, format("...{} must be > 0.0, entered value=[{:.2T}].", cNumericFields(3), Numbers(3)));
     955           0 :             ErrorsFound = true;
     956             :         }
     957             : 
     958         605 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(1) = Numbers(4);
     959         605 :         state.dataDXCoils->DXCoil(DXCoilNum).FanPowerPerEvapAirFlowRate(1) = Numbers(5);
     960         605 :         state.dataDXCoils->DXCoil(DXCoilNum).FanPowerPerEvapAirFlowRate_2023(1) = Numbers(6);
     961             : 
     962         605 :         state.dataDXCoils->DXCoil(DXCoilNum).AirInNode = GetOnlySingleNode(state,
     963         605 :                                                                            Alphas(3),
     964             :                                                                            ErrorsFound,
     965             :                                                                            DataLoopNode::ConnectionObjectType::CoilCoolingDXSingleSpeed,
     966         605 :                                                                            Alphas(1),
     967             :                                                                            DataLoopNode::NodeFluidType::Air,
     968             :                                                                            DataLoopNode::ConnectionType::Inlet,
     969             :                                                                            NodeInputManager::CompFluidStream::Primary,
     970         605 :                                                                            ObjectIsNotParent);
     971             : 
     972         605 :         state.dataDXCoils->DXCoil(DXCoilNum).AirOutNode = GetOnlySingleNode(state,
     973         605 :                                                                             Alphas(4),
     974             :                                                                             ErrorsFound,
     975             :                                                                             DataLoopNode::ConnectionObjectType::CoilCoolingDXSingleSpeed,
     976         605 :                                                                             Alphas(1),
     977             :                                                                             DataLoopNode::NodeFluidType::Air,
     978             :                                                                             DataLoopNode::ConnectionType::Outlet,
     979             :                                                                             NodeInputManager::CompFluidStream::Primary,
     980         605 :                                                                             ObjectIsNotParent);
     981             : 
     982         605 :         TestCompSet(state, CurrentModuleObject, Alphas(1), Alphas(3), Alphas(4), "Air Nodes");
     983             : 
     984         605 :         state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(1) = GetCurveIndex(state, Alphas(5)); // convert curve name to number
     985         605 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(1) == 0) {
     986           0 :             if (lAlphaBlanks(5)) {
     987           0 :                 ShowSevereError(state,
     988           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", missing");
     989           0 :                 ShowContinueError(state, "...required " + cAlphaFields(5) + " is blank.");
     990             :             } else {
     991           0 :                 ShowSevereError(state,
     992           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
     993           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(5) + "=\"" + Alphas(5) + "\".");
     994             :             }
     995           0 :             ErrorsFound = true;
     996             :         } else {
     997             :             // Verify Curve Object, only legal type is BiQuadratic
     998        1815 :             ErrorsFound |= Curve::CheckCurveDims(state,
     999         605 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(1), // Curve index
    1000             :                                                  {2},                                               // Valid dimensions
    1001             :                                                  RoutineName,                                       // Routine name
    1002             :                                                  CurrentModuleObject,                               // Object Type
    1003         605 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).Name,         // Object Name
    1004         605 :                                                  cAlphaFields(5));                                  // Field Name
    1005             : 
    1006         605 :             if (!ErrorsFound) {
    1007        3025 :                 checkCurveIsNormalizedToOne(state,
    1008        1210 :                                             std::string{RoutineName} + CurrentModuleObject,
    1009         605 :                                             state.dataDXCoils->DXCoil(DXCoilNum).Name,
    1010         605 :                                             state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(1),
    1011         605 :                                             cAlphaFields(5),
    1012         605 :                                             Alphas(5),
    1013             :                                             RatedInletWetBulbTemp,
    1014             :                                             RatedOutdoorAirTemp);
    1015             :             }
    1016             :         }
    1017             : 
    1018         605 :         state.dataDXCoils->DXCoil(DXCoilNum).CCapFFlow(1) = GetCurveIndex(state, Alphas(6)); // convert curve name to number
    1019         605 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CCapFFlow(1) == 0) {
    1020           0 :             if (lAlphaBlanks(6)) {
    1021           0 :                 ShowSevereError(state,
    1022           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", missing");
    1023           0 :                 ShowContinueError(state, "...required " + cAlphaFields(6) + " is blank.");
    1024             :             } else {
    1025           0 :                 ShowSevereError(state,
    1026           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    1027           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(6) + "=\"" + Alphas(6) + "\".");
    1028             :             }
    1029           0 :             ErrorsFound = true;
    1030             :         } else {
    1031             :             // Verify Curve Object, only legal type is Quadratic
    1032        1815 :             ErrorsFound |= Curve::CheckCurveDims(state,
    1033         605 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).CCapFFlow(1), // Curve index
    1034             :                                                  {1},                                               // Valid dimensions
    1035             :                                                  RoutineName,                                       // Routine name
    1036             :                                                  CurrentModuleObject,                               // Object Type
    1037         605 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).Name,         // Object Name
    1038         605 :                                                  cAlphaFields(6));                                  // Field Name
    1039             : 
    1040         605 :             if (!ErrorsFound) {
    1041        3025 :                 checkCurveIsNormalizedToOne(state,
    1042        1210 :                                             std::string{RoutineName} + CurrentModuleObject,
    1043         605 :                                             state.dataDXCoils->DXCoil(DXCoilNum).Name,
    1044         605 :                                             state.dataDXCoils->DXCoil(DXCoilNum).CCapFFlow(1),
    1045         605 :                                             cAlphaFields(6),
    1046         605 :                                             Alphas(6),
    1047             :                                             1.0);
    1048             :             }
    1049             :         }
    1050             : 
    1051         605 :         state.dataDXCoils->DXCoil(DXCoilNum).EIRFTemp(1) = GetCurveIndex(state, Alphas(7)); // convert curve name to number
    1052         605 :         if (state.dataDXCoils->DXCoil(DXCoilNum).EIRFTemp(1) == 0) {
    1053           0 :             if (lAlphaBlanks(7)) {
    1054           0 :                 ShowSevereError(state,
    1055           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", missing");
    1056           0 :                 ShowContinueError(state, "...required " + cAlphaFields(7) + " is blank.");
    1057             :             } else {
    1058           0 :                 ShowSevereError(state,
    1059           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    1060           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(7) + "=\"" + Alphas(7) + "\".");
    1061             :             }
    1062           0 :             ErrorsFound = true;
    1063             :         } else {
    1064             :             // Verify Curve Object, only legal type is BiQuadratic
    1065        1815 :             ErrorsFound |= Curve::CheckCurveDims(state,
    1066         605 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).EIRFTemp(1), // Curve index
    1067             :                                                  {2},                                              // Valid dimensions
    1068             :                                                  RoutineName,                                      // Routine name
    1069             :                                                  CurrentModuleObject,                              // Object Type
    1070         605 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).Name,        // Object Name
    1071         605 :                                                  cAlphaFields(7));                                 // Field Name
    1072             : 
    1073         605 :             if (!ErrorsFound) {
    1074        3025 :                 checkCurveIsNormalizedToOne(state,
    1075        1210 :                                             std::string{RoutineName} + CurrentModuleObject,
    1076         605 :                                             state.dataDXCoils->DXCoil(DXCoilNum).Name,
    1077         605 :                                             state.dataDXCoils->DXCoil(DXCoilNum).EIRFTemp(1),
    1078         605 :                                             cAlphaFields(7),
    1079         605 :                                             Alphas(7),
    1080             :                                             RatedInletWetBulbTemp,
    1081             :                                             RatedOutdoorAirTemp);
    1082             :             }
    1083             :         }
    1084             : 
    1085         605 :         state.dataDXCoils->DXCoil(DXCoilNum).EIRFFlow(1) = GetCurveIndex(state, Alphas(8)); // convert curve name to number
    1086         605 :         if (state.dataDXCoils->DXCoil(DXCoilNum).EIRFFlow(1) == 0) {
    1087           0 :             if (lAlphaBlanks(8)) {
    1088           0 :                 ShowSevereError(state,
    1089           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", missing");
    1090           0 :                 ShowContinueError(state, "...required " + cAlphaFields(8) + " is blank.");
    1091             :             } else {
    1092           0 :                 ShowSevereError(state,
    1093           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    1094           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(8) + "=\"" + Alphas(8) + "\".");
    1095             :             }
    1096           0 :             ErrorsFound = true;
    1097             :         } else {
    1098             :             // Verify Curve Object, only legal type is Quadratic
    1099        1815 :             ErrorsFound |= Curve::CheckCurveDims(state,
    1100         605 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).EIRFFlow(1), // Curve index
    1101             :                                                  {1},                                              // Valid dimensions
    1102             :                                                  RoutineName,                                      // Routine name
    1103             :                                                  CurrentModuleObject,                              // Object Type
    1104         605 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).Name,        // Object Name
    1105         605 :                                                  cAlphaFields(8));                                 // Field Name
    1106             : 
    1107         605 :             if (!ErrorsFound) {
    1108        3025 :                 checkCurveIsNormalizedToOne(state,
    1109        1210 :                                             std::string{RoutineName} + CurrentModuleObject,
    1110         605 :                                             state.dataDXCoils->DXCoil(DXCoilNum).Name,
    1111         605 :                                             state.dataDXCoils->DXCoil(DXCoilNum).EIRFFlow(1),
    1112         605 :                                             cAlphaFields(8),
    1113         605 :                                             Alphas(8),
    1114             :                                             1.0);
    1115             :             }
    1116             :         }
    1117             : 
    1118         605 :         state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(1) = GetCurveIndex(state, Alphas(9)); // convert curve name to number
    1119         605 :         if (state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(1) == 0) {
    1120           0 :             if (lAlphaBlanks(9)) {
    1121           0 :                 ShowSevereError(state,
    1122           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", missing");
    1123           0 :                 ShowContinueError(state, "...required " + cAlphaFields(9) + " is blank.");
    1124             :             } else {
    1125           0 :                 ShowSevereError(state,
    1126           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    1127           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(9) + "=\"" + Alphas(9) + "\".");
    1128             :             }
    1129           0 :             ErrorsFound = true;
    1130             :         } else {
    1131             :             // Verify Curve Object, only legal types are Quadratic or Cubic
    1132        1815 :             ErrorsFound |= Curve::CheckCurveDims(state,
    1133         605 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(1), // Curve index
    1134             :                                                  {1},                                             // Valid dimensions
    1135             :                                                  RoutineName,                                     // Routine name
    1136             :                                                  CurrentModuleObject,                             // Object Type
    1137         605 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).Name,       // Object Name
    1138         605 :                                                  cAlphaFields(9));                                // Field Name
    1139             : 
    1140         605 :             if (!ErrorsFound) {
    1141             :                 //     Test PLF curve minimum and maximum. Cap if less than 0.7 or greater than 1.0.
    1142         605 :                 MinCurveVal = 999.0;
    1143         605 :                 MaxCurveVal = -999.0;
    1144         605 :                 CurveInput = 0.0;
    1145      121605 :                 while (CurveInput <= 1.0) {
    1146       60500 :                     CurveVal = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(1), CurveInput);
    1147       60500 :                     if (CurveVal < MinCurveVal) {
    1148         605 :                         MinCurveVal = CurveVal;
    1149         605 :                         MinCurvePLR = CurveInput;
    1150             :                     }
    1151       60500 :                     if (CurveVal > MaxCurveVal) {
    1152       59708 :                         MaxCurveVal = CurveVal;
    1153       59708 :                         MaxCurvePLR = CurveInput;
    1154             :                     }
    1155       60500 :                     CurveInput += 0.01;
    1156             :                 }
    1157         605 :                 if (MinCurveVal < 0.7) {
    1158           0 :                     ShowWarningError(
    1159           0 :                         state, std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    1160           0 :                     ShowContinueError(state, "..." + cAlphaFields(9) + "=\"" + Alphas(9) + "\" has out of range values.");
    1161           0 :                     ShowContinueError(state,
    1162           0 :                                       format("...Curve minimum must be >= 0.7, curve min at PLR = {:.2T} is {:.3T}", MinCurvePLR, MinCurveVal));
    1163           0 :                     ShowContinueError(state, "...Setting curve minimum to 0.7 and simulation continues.");
    1164           0 :                     SetCurveOutputMinMaxValues(state, state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(1), ErrorsFound, 0.7, _);
    1165             :                 }
    1166             : 
    1167         605 :                 if (MaxCurveVal > 1.0) {
    1168           0 :                     ShowWarningError(
    1169           0 :                         state, std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    1170           0 :                     ShowContinueError(state, "..." + cAlphaFields(9) + " = " + Alphas(9) + " has out of range value.");
    1171           0 :                     ShowContinueError(state,
    1172           0 :                                       format("...Curve maximum must be <= 1.0, curve max at PLR = {:.2T} is {:.3T}", MaxCurvePLR, MaxCurveVal));
    1173           0 :                     ShowContinueError(state, "...Setting curve maximum to 1.0 and simulation continues.");
    1174           0 :                     SetCurveOutputMinMaxValues(state, state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(1), ErrorsFound, _, 1.0);
    1175             :                 }
    1176             :             }
    1177             :         }
    1178             : 
    1179             :         // Set minimum OAT for compressor operation
    1180         605 :         state.dataDXCoils->DXCoil(DXCoilNum).MinOATCompressor = Numbers(7);
    1181         605 :         if (NumNumbers < 6)
    1182           0 :             state.dataDXCoils->DXCoil(DXCoilNum).MinOATCompressor =
    1183             :                 minOATCompDXCooling; // input field is after min fields and won't default if field not included
    1184             : 
    1185         605 :         state.dataDXCoils->DXCoil(DXCoilNum).Twet_Rated(1) = Numbers(8);
    1186         605 :         state.dataDXCoils->DXCoil(DXCoilNum).Gamma_Rated(1) = Numbers(9);
    1187         605 :         state.dataDXCoils->DXCoil(DXCoilNum).MaxONOFFCyclesperHour(1) = Numbers(10);
    1188         605 :         state.dataDXCoils->DXCoil(DXCoilNum).LatentCapacityTimeConstant(1) = Numbers(11);
    1189             : 
    1190             :         // Numbers (7) through (11) must all be greater than zero to use the latent capacity degradation model
    1191         632 :         if ((Numbers(8) > 0.0 || Numbers(9) > 0.0 || Numbers(10) > 0.0 || Numbers(11) > 0.0) &&
    1192          54 :             (Numbers(8) <= 0.0 || Numbers(9) <= 0.0 || Numbers(10) <= 0.0 || Numbers(11) <= 0.0)) {
    1193           0 :             ShowWarningError(state, std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\":");
    1194           0 :             ShowContinueError(state, "...At least one of the four input parameters for the latent capacity degradation model");
    1195           0 :             ShowContinueError(state, "...is set to zero. Therefore, the latent degradation model will not be used for this simulation.");
    1196             :         }
    1197             : 
    1198             :         // outdoor condenser node
    1199         605 :         if (lAlphaBlanks(10)) {
    1200         498 :             state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(1) = 0;
    1201             :         } else {
    1202         107 :             state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(1) =
    1203         321 :                 GetOnlySingleNode(state,
    1204         107 :                                   Alphas(10),
    1205             :                                   ErrorsFound,
    1206             :                                   DataLoopNode::ConnectionObjectType::CoilCoolingDXSingleSpeed,
    1207         107 :                                   state.dataDXCoils->DXCoil(DXCoilNum).Name,
    1208             :                                   DataLoopNode::NodeFluidType::Air,
    1209             :                                   DataLoopNode::ConnectionType::OutsideAirReference,
    1210             :                                   NodeInputManager::CompFluidStream::Primary,
    1211         107 :                                   ObjectIsNotParent);
    1212             : 
    1213         107 :             if (!CheckOutAirNodeNumber(state, state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(1))) {
    1214           0 :                 ShowWarningError(
    1215           0 :                     state, std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", may be invalid");
    1216           0 :                 ShowContinueError(
    1217           0 :                     state, cAlphaFields(10) + "=\"" + Alphas(10) + "\", node does not appear in an OutdoorAir:NodeList or as an OutdoorAir:Node.");
    1218           0 :                 ShowContinueError(
    1219             :                     state, "This node needs to be included in an air system or the coil model will not be valid, and the simulation continues");
    1220             :             }
    1221             :         }
    1222             : 
    1223         605 :         if ((UtilityRoutines::SameString(Alphas(11), "AirCooled")) || lAlphaBlanks(11)) {
    1224         604 :             state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(1) = DataHeatBalance::RefrigCondenserType::Air;
    1225           1 :         } else if (UtilityRoutines::SameString(Alphas(11), "EvaporativelyCooled")) {
    1226           1 :             state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(1) = DataHeatBalance::RefrigCondenserType::Evap;
    1227           1 :             state.dataDXCoils->DXCoil(DXCoilNum).ReportEvapCondVars = true;
    1228             :         } else {
    1229           0 :             ShowSevereError(state,
    1230           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    1231           0 :             ShowContinueError(state, "..." + cAlphaFields(11) + "=\"" + Alphas(11) + "\":");
    1232           0 :             ShowContinueError(state, "...must be AirCooled or EvaporativelyCooled.");
    1233           0 :             ErrorsFound = true;
    1234             :         }
    1235             : 
    1236         605 :         state.dataDXCoils->DXCoil(DXCoilNum).EvapCondEffect(1) = Numbers(12);
    1237         605 :         if (state.dataDXCoils->DXCoil(DXCoilNum).EvapCondEffect(1) < 0.0 || state.dataDXCoils->DXCoil(DXCoilNum).EvapCondEffect(1) > 1.0) {
    1238           0 :             ShowSevereError(state,
    1239           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    1240           0 :             ShowContinueError(state, "..." + cNumericFields(11) + " cannot be < 0.0 or > 1.0.");
    1241           0 :             ShowContinueError(state, format("...entered value=[{:.2T}].", Numbers(12)));
    1242           0 :             ErrorsFound = true;
    1243             :         }
    1244             : 
    1245         605 :         state.dataDXCoils->DXCoil(DXCoilNum).EvapCondAirFlow(1) = Numbers(13);
    1246         605 :         if (state.dataDXCoils->DXCoil(DXCoilNum).EvapCondAirFlow(1) < 0.0 && state.dataDXCoils->DXCoil(DXCoilNum).EvapCondAirFlow(1) != AutoSize) {
    1247           0 :             ShowSevereError(state,
    1248           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    1249           0 :             ShowContinueError(state, "..." + cNumericFields(12) + " cannot be < 0.0.");
    1250           0 :             ShowContinueError(state, format("...entered value=[{:.2T}].", Numbers(13)));
    1251           0 :             ErrorsFound = true;
    1252             :         }
    1253             : 
    1254         605 :         state.dataDXCoils->DXCoil(DXCoilNum).EvapCondPumpElecNomPower(1) = Numbers(14);
    1255         607 :         if (state.dataDXCoils->DXCoil(DXCoilNum).EvapCondPumpElecNomPower(1) < 0.0 &&
    1256           2 :             state.dataDXCoils->DXCoil(DXCoilNum).EvapCondPumpElecNomPower(1) != AutoSize) {
    1257           0 :             ShowSevereError(state,
    1258           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    1259           0 :             ShowContinueError(state, "..." + cNumericFields(13) + " cannot be < 0.0.");
    1260           0 :             ShowContinueError(state, format("...entered value=[{:.2T}].", Numbers(14)));
    1261           0 :             ErrorsFound = true;
    1262             :         }
    1263             : 
    1264             :         // Set crankcase heater capacity
    1265         605 :         state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterCapacity = Numbers(15);
    1266         605 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterCapacity < 0.0) {
    1267           0 :             ShowSevereError(state,
    1268           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    1269           0 :             ShowContinueError(state, "..." + cNumericFields(14) + " cannot be < 0.0.");
    1270           0 :             ShowContinueError(state, format("...entered value=[{:.2T}].", Numbers(15)));
    1271           0 :             ErrorsFound = true;
    1272             :         }
    1273             : 
    1274             :         // Set crankcase heater cutout temperature
    1275         605 :         state.dataDXCoils->DXCoil(DXCoilNum).MaxOATCrankcaseHeater = Numbers(16);
    1276             : 
    1277         605 :         if (state.dataDXCoils->DXCoil(DXCoilNum).RatedCOP(1) > 0.0) {
    1278         605 :             state.dataDXCoils->DXCoil(DXCoilNum).RatedEIR(1) = 1.0 / state.dataDXCoils->DXCoil(DXCoilNum).RatedCOP(1);
    1279             :         }
    1280             : 
    1281             :         // Get Water System tank connections
    1282             :         //  A12, \field Name of Water Storage Tank for Supply
    1283         605 :         state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterSupplyName = Alphas(12);
    1284         605 :         if (lAlphaBlanks(12)) {
    1285         605 :             state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterSupplyMode = EvapWaterSupply::FromMains;
    1286             :         } else {
    1287           0 :             state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterSupplyMode = EvapWaterSupply::FromTank;
    1288           0 :             SetupTankDemandComponent(state,
    1289           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,
    1290             :                                      CurrentModuleObject,
    1291           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterSupplyName,
    1292             :                                      ErrorsFound,
    1293           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterSupTankID,
    1294           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterTankDemandARRID);
    1295             :         }
    1296             : 
    1297             :         // A13; \field Name of Water Storage Tank for Condensate Collection
    1298         605 :         state.dataDXCoils->DXCoil(DXCoilNum).CondensateCollectName = Alphas(13);
    1299         605 :         if (lAlphaBlanks(13)) {
    1300         605 :             state.dataDXCoils->DXCoil(DXCoilNum).CondensateCollectMode = CondensateCollectAction::Discard;
    1301             :         } else {
    1302           0 :             state.dataDXCoils->DXCoil(DXCoilNum).CondensateCollectMode = CondensateCollectAction::ToTank;
    1303           0 :             SetupTankSupplyComponent(state,
    1304           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,
    1305             :                                      CurrentModuleObject,
    1306           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).CondensateCollectName,
    1307             :                                      ErrorsFound,
    1308           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).CondensateTankID,
    1309           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).CondensateTankSupplyARRID);
    1310             :         }
    1311             : 
    1312             :         //   Basin heater power as a function of temperature must be greater than or equal to 0
    1313         605 :         state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterPowerFTempDiff = Numbers(17);
    1314         605 :         if (Numbers(17) < 0.0) {
    1315           0 :             ShowSevereError(state,
    1316           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    1317           0 :             ShowContinueError(state, "..." + cNumericFields(16) + " must be >= 0.0.");
    1318           0 :             ShowContinueError(state, format("...entered value=[{:.2T}].", Numbers(17)));
    1319           0 :             ErrorsFound = true;
    1320             :         }
    1321             : 
    1322         605 :         state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterSetPointTemp = Numbers(18);
    1323         605 :         if (state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterPowerFTempDiff > 0.0) {
    1324           2 :             if (NumNumbers < 18) {
    1325           1 :                 state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterSetPointTemp = 2.0;
    1326             :             }
    1327           2 :             if (state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterSetPointTemp < 2.0) {
    1328           0 :                 ShowWarningError(state,
    1329           0 :                                  std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name +
    1330             :                                      "\", freeze possible");
    1331           0 :                 ShowContinueError(state, "..." + cNumericFields(17) + " is < 2 {C}. Freezing could occur.");
    1332           0 :                 ShowContinueError(state, format("...entered value=[{:.2T}].", Numbers(18)));
    1333             :             }
    1334             :         }
    1335             : 
    1336         605 :         if (!lAlphaBlanks(14)) {
    1337           0 :             state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterSchedulePtr = GetScheduleIndex(state, Alphas(14));
    1338           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterSchedulePtr == 0) {
    1339           0 :                 ShowWarningError(state,
    1340           0 :                                  std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    1341           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(14) + "=\"" + Alphas(14) + "\".");
    1342           0 :                 ShowContinueError(state, "Basin heater will be available to operate throughout the simulation.");
    1343             :             }
    1344             :         }
    1345             : 
    1346         605 :         if (!lAlphaBlanks(15) && NumAlphas > 14) {
    1347           0 :             state.dataDXCoils->DXCoil(DXCoilNum).SHRFTemp(1) = GetCurveIndex(state, Alphas(15)); // convert curve name to number
    1348           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).SHRFTemp(1) == 0) {
    1349           0 :                 ShowSevereError(state,
    1350           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    1351           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(15) + "=\"" + Alphas(15) + "\".");
    1352             :             } else {
    1353             :                 // Verify Curve Object, only legal type is BiQuadratic
    1354           0 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    1355           0 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).SHRFTemp(1), // Curve index
    1356             :                                                      {2},                                              // Valid dimensions
    1357             :                                                      RoutineName,                                      // Routine name
    1358             :                                                      CurrentModuleObject,                              // Object Type
    1359           0 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,        // Object Name
    1360           0 :                                                      cAlphaFields(15));                                // Field Name
    1361             :             }
    1362             :         }
    1363             : 
    1364         605 :         if (!lAlphaBlanks(16) && NumAlphas > 15) {
    1365           0 :             state.dataDXCoils->DXCoil(DXCoilNum).SHRFFlow(1) = GetCurveIndex(state, Alphas(16)); // convert curve name to number
    1366           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).SHRFTemp(1) == 0) {
    1367           0 :                 ShowSevereError(state,
    1368           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    1369           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(16) + "=\"" + Alphas(16) + "\".");
    1370             :             } else {
    1371             :                 // Verify Curve Object, only legal type is Quadratic and Cubic
    1372           0 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    1373           0 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).SHRFFlow(1), // Curve index
    1374             :                                                      {1},                                              // Valid dimensions
    1375             :                                                      RoutineName,                                      // Routine name
    1376             :                                                      CurrentModuleObject,                              // Object Type
    1377           0 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,        // Object Name
    1378           0 :                                                      cAlphaFields(16));                                // Field Name
    1379             :             }
    1380             :         }
    1381             : 
    1382         605 :         if (state.dataDXCoils->DXCoil(DXCoilNum).SHRFTemp(1) > 0 && state.dataDXCoils->DXCoil(DXCoilNum).SHRFFlow(1) > 0) {
    1383           0 :             state.dataDXCoils->DXCoil(DXCoilNum).UserSHRCurveExists = true;
    1384             :         }
    1385             :         // get User Input flag for ASHRAE Standard 127 Standard Ratings Reporting
    1386         605 :         if (lAlphaBlanks(17)) {
    1387         597 :             state.dataDXCoils->DXCoil(DXCoilNum).ASHRAE127StdRprt = false;
    1388             :         } else {
    1389           8 :             if (Alphas(17) == "YES" || Alphas(17) == "Yes") {
    1390           8 :                 state.dataDXCoils->DXCoil(DXCoilNum).ASHRAE127StdRprt = true;
    1391             :             } else {
    1392           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).ASHRAE127StdRprt = false;
    1393             :             }
    1394             :         }
    1395             :         // A18; \field Zone Name for Condenser Placement
    1396         605 :         if (!lAlphaBlanks(18) && NumAlphas > 17) {
    1397           1 :             state.dataDXCoils->DXCoil(DXCoilNum).SecZonePtr = UtilityRoutines::FindItemInList(Alphas(18), state.dataHeatBal->Zone);
    1398           1 :             if (state.dataDXCoils->DXCoil(DXCoilNum).SecZonePtr > 0) {
    1399           3 :                 SetupZoneInternalGain(state,
    1400           1 :                                       state.dataDXCoils->DXCoil(DXCoilNum).SecZonePtr,
    1401           1 :                                       state.dataDXCoils->DXCoil(DXCoilNum).Name,
    1402             :                                       DataHeatBalance::IntGainType::SecCoolingDXCoilSingleSpeed,
    1403           1 :                                       &state.dataDXCoils->DXCoil(DXCoilNum).SecCoilSensibleHeatGainRate);
    1404           1 :                 state.dataDXCoils->DXCoil(DXCoilNum).IsSecondaryDXCoilInZone = true;
    1405             :             } else {
    1406           0 :                 ShowSevereError(state,
    1407           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    1408           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(18) + "=\"" + Alphas(18) + "\".");
    1409             :             }
    1410             :         }
    1411             : 
    1412             :     } // end of the Doe2 DX coil loop
    1413             : 
    1414         241 :     if (ErrorsFound) {
    1415           0 :         ShowFatalError(state,
    1416           0 :                        std::string{RoutineName} + "Errors found in getting " + CurrentModuleObject +
    1417             :                            " input. Preceding condition(s) causes termination.");
    1418             :     }
    1419             : 
    1420             :     // Loop over the Multimode DX Coils and get & load the data
    1421         241 :     CurrentModuleObject = "Coil:Cooling:DX:TwoStageWithHumidityControlMode";
    1422         252 :     for (DXCoilIndex = 1; DXCoilIndex <= state.dataDXCoils->NumDXMulModeCoils; ++DXCoilIndex) {
    1423             : 
    1424          11 :         state.dataInputProcessing->inputProcessor->getObjectItem(state,
    1425             :                                                                  CurrentModuleObject,
    1426             :                                                                  DXCoilIndex,
    1427             :                                                                  Alphas,
    1428             :                                                                  NumAlphas,
    1429             :                                                                  Numbers,
    1430             :                                                                  NumNumbers,
    1431             :                                                                  IOStatus,
    1432             :                                                                  lNumericBlanks,
    1433             :                                                                  lAlphaBlanks,
    1434             :                                                                  cAlphaFields,
    1435             :                                                                  cNumericFields);
    1436             : 
    1437          11 :         ++DXCoilNum;
    1438          11 :         UtilityRoutines::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    1439             :         // ErrorsFound will be set to True if problem was found, left untouched otherwise
    1440          11 :         VerifyUniqueCoilName(state, CurrentModuleObject, Alphas(1), ErrorsFound, CurrentModuleObject + " Name");
    1441             : 
    1442          11 :         state.dataDXCoils->DXCoil(DXCoilNum).Name = Alphas(1);
    1443             :         // Initialize DataHeatBalance heat reclaim variable name for use by heat reclaim coils
    1444          11 :         state.dataHeatBal->HeatReclaimDXCoil(DXCoilNum).Name = state.dataDXCoils->DXCoil(DXCoilNum).Name;
    1445          11 :         state.dataHeatBal->HeatReclaimDXCoil(DXCoilNum).SourceType = CurrentModuleObject;
    1446          11 :         state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType = CurrentModuleObject;
    1447          11 :         state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num = CoilDX_CoolingTwoStageWHumControl;
    1448          11 :         state.dataDXCoils->DXCoil(DXCoilNum).Schedule = Alphas(2);
    1449          11 :         if (lAlphaBlanks(2)) {
    1450           4 :             state.dataDXCoils->DXCoil(DXCoilNum).SchedPtr = DataGlobalConstants::ScheduleAlwaysOn;
    1451             :         } else {
    1452           7 :             state.dataDXCoils->DXCoil(DXCoilNum).SchedPtr = GetScheduleIndex(state, Alphas(2)); // convert schedule name to pointer
    1453           7 :             if (state.dataDXCoils->DXCoil(DXCoilNum).SchedPtr == 0) {
    1454           0 :                 ShowSevereError(state,
    1455           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    1456           0 :                 ShowContinueError(state, "..." + cAlphaFields(2) + "=\"" + Alphas(2) + "\".");
    1457           0 :                 ErrorsFound = true;
    1458             :             }
    1459             :         }
    1460             : 
    1461          11 :         state.dataDXCoils->DXCoil(DXCoilNum).AirInNode =
    1462          22 :             GetOnlySingleNode(state,
    1463          11 :                               Alphas(3),
    1464             :                               ErrorsFound,
    1465             :                               DataLoopNode::ConnectionObjectType::CoilCoolingDXTwoStageWithHumidityControlMode,
    1466          11 :                               Alphas(1),
    1467             :                               DataLoopNode::NodeFluidType::Air,
    1468             :                               DataLoopNode::ConnectionType::Inlet,
    1469             :                               NodeInputManager::CompFluidStream::Primary,
    1470          11 :                               ObjectIsNotParent);
    1471             : 
    1472          11 :         state.dataDXCoils->DXCoil(DXCoilNum).AirOutNode =
    1473          22 :             GetOnlySingleNode(state,
    1474          11 :                               Alphas(4),
    1475             :                               ErrorsFound,
    1476             :                               DataLoopNode::ConnectionObjectType::CoilCoolingDXTwoStageWithHumidityControlMode,
    1477          11 :                               Alphas(1),
    1478             :                               DataLoopNode::NodeFluidType::Air,
    1479             :                               DataLoopNode::ConnectionType::Outlet,
    1480             :                               NodeInputManager::CompFluidStream::Primary,
    1481          11 :                               ObjectIsNotParent);
    1482             : 
    1483          11 :         TestCompSet(state, CurrentModuleObject, Alphas(1), Alphas(3), Alphas(4), "Air Nodes");
    1484             : 
    1485             :         // Set crankcase heater capacity
    1486          11 :         state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterCapacity = Numbers(1);
    1487          11 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterCapacity < 0.0) {
    1488           0 :             ShowSevereError(state,
    1489           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    1490           0 :             ShowContinueError(state, format("...{} must be >= 0.0, entered value=[{:.2T}].", cNumericFields(1), Numbers(1)));
    1491           0 :             ErrorsFound = true;
    1492             :         }
    1493             : 
    1494             :         // Set crankcase heater cutout temperature
    1495          11 :         state.dataDXCoils->DXCoil(DXCoilNum).MaxOATCrankcaseHeater = Numbers(2);
    1496             : 
    1497             :         //  Number of capacity stages
    1498          11 :         state.dataDXCoils->DXCoil(DXCoilNum).NumCapacityStages = Numbers(3);
    1499             :         //  Check if requested number of capacity stages exceeds limits
    1500          22 :         if ((state.dataDXCoils->DXCoil(DXCoilNum).NumCapacityStages > MaxCapacityStages) ||
    1501          11 :             (state.dataDXCoils->DXCoil(DXCoilNum).NumCapacityStages < 1)) {
    1502           0 :             ShowSevereError(state,
    1503           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    1504           0 :             ShowContinueError(state, format("...illegal {} = {}", cNumericFields(3), state.dataDXCoils->DXCoil(DXCoilNum).NumCapacityStages));
    1505           0 :             ShowContinueError(state, format("...Valid range is 1 to {}", MaxCapacityStages));
    1506           0 :             ErrorsFound = true;
    1507             :         }
    1508             : 
    1509             :         //  Number of enhanced dehumidification modes
    1510          11 :         state.dataDXCoils->DXCoil(DXCoilNum).NumDehumidModes = Numbers(4);
    1511             :         //  Check if requested number of enhanced dehumidification modes exceeds limits
    1512          11 :         if ((state.dataDXCoils->DXCoil(DXCoilNum).NumDehumidModes > MaxDehumidModes) || (state.dataDXCoils->DXCoil(DXCoilNum).NumDehumidModes < 0)) {
    1513           0 :             ShowSevereError(state,
    1514           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    1515           0 :             ShowContinueError(state, format("...illegal {} = {}", cNumericFields(4), state.dataDXCoils->DXCoil(DXCoilNum).NumDehumidModes));
    1516           0 :             ShowContinueError(state, format("...Valid range is 0 to {}", MaxDehumidModes));
    1517           0 :             ErrorsFound = true;
    1518             :         }
    1519             : 
    1520             :         //  Set starting alpha index for coil performance inputs
    1521          11 :         AlphaIndex = 5;
    1522             :         // allocate performance modes for numeric field strings used for sizing routine
    1523          44 :         state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumDehumidModes * 2 +
    1524          11 :                                                                             state.dataDXCoils->DXCoil(DXCoilNum).NumCapacityStages *
    1525          33 :                                                                                 2); // not sure this math is correct, ask MW
    1526             : 
    1527             :         //  Loop through capacity stages and dehumidification modes
    1528          29 :         for (DehumidModeNum = 0; DehumidModeNum <= state.dataDXCoils->DXCoil(DXCoilNum).NumDehumidModes; ++DehumidModeNum) {
    1529          53 :             for (CapacityStageNum = 1; CapacityStageNum <= state.dataDXCoils->DXCoil(DXCoilNum).NumCapacityStages; ++CapacityStageNum) {
    1530             :                 //  Check if sufficient number of fields entered
    1531          35 :                 if ((AlphaIndex + 1) > NumAlphas) {
    1532           0 :                     ShowSevereError(
    1533           0 :                         state, std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    1534           0 :                     ShowContinueError(state, "...not enough remaining fields for specified Number of Operating Modes.");
    1535           0 :                     ShowContinueError(state, "...Need additional Coil Performance Object Type and Coil Performance Object Name fields.");
    1536           0 :                     ErrorsFound = true;
    1537             :                 } else {
    1538          35 :                     PerfObjectType = Alphas(AlphaIndex);
    1539          35 :                     PerfObjectName = Alphas(AlphaIndex + 1);
    1540          35 :                     PerfModeNum = DehumidModeNum * 2 + CapacityStageNum;
    1541          35 :                     state.dataDXCoils->DXCoil(DXCoilNum).CoilPerformanceType(PerfModeNum) = PerfObjectType;
    1542          35 :                     if (UtilityRoutines::SameString(PerfObjectType, "CoilPerformance:DX:Cooling")) {
    1543          35 :                         state.dataDXCoils->DXCoil(DXCoilNum).CoilPerformanceType_Num(PerfModeNum) = CoilPerfDX_CoolBypassEmpirical;
    1544             :                     } else {
    1545           0 :                         ShowSevereError(state,
    1546           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name +
    1547             :                                             "\", invalid");
    1548           0 :                         ShowContinueError(state, "...illegal " + cAlphaFields(AlphaIndex) + "=\"" + PerfObjectType + "\".");
    1549           0 :                         ShowContinueError(state, "Must be \"CoilPerformance:DX:Cooling\".");
    1550           0 :                         ErrorsFound = true;
    1551             :                     }
    1552          35 :                     state.dataDXCoils->DXCoil(DXCoilNum).CoilPerformanceName(PerfModeNum) = PerfObjectName;
    1553             :                     // Get for CoilPerformance object
    1554          35 :                     PerfObjectNum = state.dataInputProcessing->inputProcessor->getObjectItemNum(state, PerfObjectType, PerfObjectName);
    1555          35 :                     if (PerfObjectNum > 0) {
    1556             : 
    1557          35 :                         state.dataInputProcessing->inputProcessor->getObjectItem(state,
    1558             :                                                                                  PerfObjectType,
    1559             :                                                                                  PerfObjectNum,
    1560             :                                                                                  Alphas2,
    1561             :                                                                                  NumAlphas2,
    1562             :                                                                                  Numbers2,
    1563             :                                                                                  NumNumbers2,
    1564             :                                                                                  IOStatus,
    1565             :                                                                                  lNumericBlanks2,
    1566             :                                                                                  lAlphaBlanks2,
    1567             :                                                                                  cAlphaFields2,
    1568             :                                                                                  cNumericFields2);
    1569             : 
    1570             :                         // allocate performance mode numeric field strings used for sizing routine
    1571          35 :                         state.dataDXCoils->DXCoilNumericFields(DXCoilNum)
    1572          35 :                             .PerfMode(PerfModeNum)
    1573          35 :                             .FieldNames.allocate(NumNumbers2); // use MaxNumbers here??
    1574          35 :                         state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(PerfModeNum).FieldNames = cNumericFields2;
    1575             : 
    1576          35 :                         state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(PerfModeNum) = Numbers2(1);
    1577          35 :                         state.dataDXCoils->DXCoil(DXCoilNum).RatedSHR(PerfModeNum) = Numbers2(2);
    1578          35 :                         state.dataDXCoils->DXCoil(DXCoilNum).RatedCOP(PerfModeNum) = Numbers2(3);
    1579             :                         // Rated flow is immediately adjusted for bypass fraction if not autosized
    1580          35 :                         state.dataDXCoils->DXCoil(DXCoilNum).BypassedFlowFrac(PerfModeNum) = Numbers2(5);
    1581          35 :                         state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(PerfModeNum) = Numbers2(4);
    1582          35 :                         if (state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(PerfModeNum) != AutoSize) {
    1583           7 :                             state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(PerfModeNum) *=
    1584           7 :                                 (1.0 - state.dataDXCoils->DXCoil(DXCoilNum).BypassedFlowFrac(PerfModeNum));
    1585             :                         }
    1586             : 
    1587          35 :                         state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(PerfModeNum) =
    1588          35 :                             GetCurveIndex(state, Alphas2(2)); // convert curve name to number
    1589          35 :                         if (state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(PerfModeNum) == 0) {
    1590           0 :                             if (lAlphaBlanks2(2)) {
    1591           0 :                                 ShowSevereError(state, std::string{RoutineName} + PerfObjectType + "=\"" + PerfObjectName + "\", invalid");
    1592           0 :                                 ShowContinueError(state, "...required " + cAlphaFields2(2) + " is blank.");
    1593             :                             } else {
    1594           0 :                                 ShowSevereError(state, std::string{RoutineName} + PerfObjectType + "=\"" + PerfObjectName + "\", invalid");
    1595           0 :                                 ShowContinueError(state, "...not found " + cAlphaFields2(2) + "=\"" + Alphas2(2) + "\".");
    1596             :                             }
    1597           0 :                             ErrorsFound = true;
    1598             :                         } else {
    1599             :                             // Verify Curve Object, only legal type is BiQuadratic
    1600         105 :                             ErrorsFound |= Curve::CheckCurveDims(state,
    1601          35 :                                                                  state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(PerfModeNum), // Curve index
    1602             :                                                                  {2},                                                         // Valid dimensions
    1603             :                                                                  RoutineName,                                                 // Routine name
    1604             :                                                                  CurrentModuleObject,                                         // Object Type
    1605          35 :                                                                  state.dataDXCoils->DXCoil(DXCoilNum).Name,                   // Object Name
    1606          35 :                                                                  cAlphaFields2(2));                                           // Field Name
    1607             : 
    1608          35 :                             if (!ErrorsFound) {
    1609         175 :                                 checkCurveIsNormalizedToOne(state,
    1610          70 :                                                             std::string{RoutineName} + CurrentModuleObject,
    1611          35 :                                                             state.dataDXCoils->DXCoil(DXCoilNum).Name,
    1612          35 :                                                             state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(PerfModeNum),
    1613          35 :                                                             cAlphaFields2(2),
    1614          35 :                                                             Alphas2(2),
    1615             :                                                             RatedInletWetBulbTemp,
    1616             :                                                             RatedOutdoorAirTemp);
    1617             :                             }
    1618             :                         }
    1619             : 
    1620          35 :                         state.dataDXCoils->DXCoil(DXCoilNum).CCapFFlow(PerfModeNum) =
    1621          35 :                             GetCurveIndex(state, Alphas2(3)); // convert curve name to number
    1622          35 :                         if (state.dataDXCoils->DXCoil(DXCoilNum).CCapFFlow(PerfModeNum) == 0) {
    1623           0 :                             if (lAlphaBlanks2(3)) {
    1624           0 :                                 ShowSevereError(state, std::string{RoutineName} + PerfObjectType + "=\"" + PerfObjectName + "\", invalid");
    1625           0 :                                 ShowContinueError(state, "...required " + cAlphaFields2(3) + " is blank.");
    1626             :                             } else {
    1627           0 :                                 ShowSevereError(state, std::string{RoutineName} + PerfObjectType + "=\"" + PerfObjectName + "\", invalid");
    1628           0 :                                 ShowContinueError(state, "...not found " + cAlphaFields2(3) + "=\"" + Alphas2(3) + "\".");
    1629             :                             }
    1630           0 :                             ErrorsFound = true;
    1631             :                         } else {
    1632             :                             // Verify Curve Object, only legal type is Quadratic
    1633         105 :                             ErrorsFound |= Curve::CheckCurveDims(state,
    1634          35 :                                                                  state.dataDXCoils->DXCoil(DXCoilNum).CCapFFlow(PerfModeNum), // Curve index
    1635             :                                                                  {1},                                                         // Valid dimensions
    1636             :                                                                  RoutineName,                                                 // Routine name
    1637             :                                                                  CurrentModuleObject,                                         // Object Type
    1638          35 :                                                                  state.dataDXCoils->DXCoil(DXCoilNum).Name,                   // Object Name
    1639          35 :                                                                  cAlphaFields2(3));                                           // Field Name
    1640             : 
    1641          35 :                             if (!ErrorsFound) {
    1642         175 :                                 checkCurveIsNormalizedToOne(state,
    1643          70 :                                                             std::string{RoutineName} + CurrentModuleObject,
    1644          35 :                                                             state.dataDXCoils->DXCoil(DXCoilNum).Name,
    1645          35 :                                                             state.dataDXCoils->DXCoil(DXCoilNum).CCapFFlow(PerfModeNum),
    1646          35 :                                                             cAlphaFields2(3),
    1647          35 :                                                             Alphas2(3),
    1648             :                                                             1.0);
    1649             :                             }
    1650             :                         }
    1651             : 
    1652          35 :                         state.dataDXCoils->DXCoil(DXCoilNum).EIRFTemp(PerfModeNum) = GetCurveIndex(state, Alphas2(4)); // convert curve name to number
    1653          35 :                         if (state.dataDXCoils->DXCoil(DXCoilNum).EIRFTemp(PerfModeNum) == 0) {
    1654           0 :                             if (lAlphaBlanks2(4)) {
    1655           0 :                                 ShowSevereError(state, std::string{RoutineName} + PerfObjectType + "=\"" + PerfObjectName + "\", invalid");
    1656           0 :                                 ShowContinueError(state, "...required " + cAlphaFields2(4) + " is blank.");
    1657             :                             } else {
    1658           0 :                                 ShowSevereError(state, std::string{RoutineName} + PerfObjectType + "=\"" + PerfObjectName + "\", invalid");
    1659           0 :                                 ShowContinueError(state, "...not found " + cAlphaFields2(4) + "=\"" + Alphas2(4) + "\".");
    1660             :                             }
    1661           0 :                             ErrorsFound = true;
    1662             :                         } else {
    1663             :                             // Verify Curve Object, only legal type is BiQuadratic
    1664         105 :                             ErrorsFound |= Curve::CheckCurveDims(state,
    1665          35 :                                                                  state.dataDXCoils->DXCoil(DXCoilNum).EIRFTemp(PerfModeNum), // Curve index
    1666             :                                                                  {2},                                                        // Valid dimensions
    1667             :                                                                  RoutineName,                                                // Routine name
    1668             :                                                                  CurrentModuleObject,                                        // Object Type
    1669          35 :                                                                  state.dataDXCoils->DXCoil(DXCoilNum).Name,                  // Object Name
    1670          35 :                                                                  cAlphaFields2(4));                                          // Field Name
    1671             : 
    1672          35 :                             if (!ErrorsFound) {
    1673         175 :                                 checkCurveIsNormalizedToOne(state,
    1674          70 :                                                             std::string{RoutineName} + CurrentModuleObject,
    1675          35 :                                                             state.dataDXCoils->DXCoil(DXCoilNum).Name,
    1676          35 :                                                             state.dataDXCoils->DXCoil(DXCoilNum).EIRFTemp(PerfModeNum),
    1677          35 :                                                             cAlphaFields2(4),
    1678          35 :                                                             Alphas2(4),
    1679             :                                                             RatedInletWetBulbTemp,
    1680             :                                                             RatedOutdoorAirTemp);
    1681             :                             }
    1682             :                         }
    1683             : 
    1684          35 :                         state.dataDXCoils->DXCoil(DXCoilNum).EIRFFlow(PerfModeNum) = GetCurveIndex(state, Alphas2(5)); // convert curve name to number
    1685          35 :                         if (state.dataDXCoils->DXCoil(DXCoilNum).EIRFFlow(PerfModeNum) == 0) {
    1686           0 :                             if (lAlphaBlanks2(5)) {
    1687           0 :                                 ShowSevereError(state, std::string{RoutineName} + PerfObjectType + "=\"" + PerfObjectName + "\", invalid");
    1688           0 :                                 ShowContinueError(state, "...required " + cAlphaFields2(5) + " is blank.");
    1689             :                             } else {
    1690           0 :                                 ShowSevereError(state, std::string{RoutineName} + PerfObjectType + "=\"" + PerfObjectName + "\", invalid");
    1691           0 :                                 ShowContinueError(state, "...not found " + cAlphaFields2(5) + "=\"" + Alphas2(5) + "\".");
    1692             :                             }
    1693           0 :                             ErrorsFound = true;
    1694             :                         } else {
    1695             :                             // Verify Curve Object, only legal type is Quadratic
    1696         105 :                             ErrorsFound |= Curve::CheckCurveDims(state,
    1697          35 :                                                                  state.dataDXCoils->DXCoil(DXCoilNum).EIRFFlow(PerfModeNum), // Curve index
    1698             :                                                                  {1},                                                        // Valid dimensions
    1699             :                                                                  RoutineName,                                                // Routine name
    1700             :                                                                  CurrentModuleObject,                                        // Object Type
    1701          35 :                                                                  state.dataDXCoils->DXCoil(DXCoilNum).Name,                  // Object Name
    1702          35 :                                                                  cAlphaFields2(5));                                          // Field Name
    1703             : 
    1704          35 :                             if (!ErrorsFound) {
    1705         175 :                                 checkCurveIsNormalizedToOne(state,
    1706          70 :                                                             std::string{RoutineName} + CurrentModuleObject,
    1707          35 :                                                             state.dataDXCoils->DXCoil(DXCoilNum).Name,
    1708          35 :                                                             state.dataDXCoils->DXCoil(DXCoilNum).EIRFFlow(PerfModeNum),
    1709          35 :                                                             cAlphaFields2(5),
    1710          35 :                                                             Alphas2(5),
    1711             :                                                             1.0);
    1712             :                             }
    1713             :                         }
    1714             : 
    1715          35 :                         state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(PerfModeNum) = GetCurveIndex(state, Alphas2(6)); // convert curve name to number
    1716          35 :                         if (state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(PerfModeNum) == 0) {
    1717           0 :                             if (lAlphaBlanks2(6)) {
    1718           0 :                                 ShowSevereError(state, std::string{RoutineName} + PerfObjectType + "=\"" + PerfObjectName + "\", invalid");
    1719           0 :                                 ShowContinueError(state, "...required " + cAlphaFields2(6) + " is blank.");
    1720             :                             } else {
    1721           0 :                                 ShowSevereError(state, std::string{RoutineName} + PerfObjectType + "=\"" + PerfObjectName + "\", invalid");
    1722           0 :                                 ShowContinueError(state, "...not found " + cAlphaFields2(6) + "=\"" + Alphas2(6) + "\".");
    1723             :                             }
    1724           0 :                             ErrorsFound = true;
    1725             :                         } else {
    1726             :                             // Verify Curve Object, only legal types are Quadratic or Cubic
    1727         105 :                             ErrorsFound |= Curve::CheckCurveDims(state,
    1728          35 :                                                                  state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(PerfModeNum), // Curve index
    1729             :                                                                  {1},                                                       // Valid dimensions
    1730             :                                                                  RoutineName,                                               // Routine name
    1731             :                                                                  CurrentModuleObject,                                       // Object Type
    1732          35 :                                                                  state.dataDXCoils->DXCoil(DXCoilNum).Name,                 // Object Name
    1733          35 :                                                                  cAlphaFields2(6));                                         // Field Name
    1734             : 
    1735          35 :                             if (!ErrorsFound) {
    1736             :                                 //             Test PLF curve minimum and maximum. Cap if less than 0.7 or greater than 1.0.
    1737          35 :                                 MinCurveVal = 999.0;
    1738          35 :                                 MaxCurveVal = -999.0;
    1739          35 :                                 CurveInput = 0.0;
    1740        7035 :                                 while (CurveInput <= 1.0) {
    1741        3500 :                                     CurveVal = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(PerfModeNum), CurveInput);
    1742        3500 :                                     if (CurveVal < MinCurveVal) {
    1743          35 :                                         MinCurveVal = CurveVal;
    1744          35 :                                         MinCurvePLR = CurveInput;
    1745             :                                     }
    1746        3500 :                                     if (CurveVal > MaxCurveVal) {
    1747        3500 :                                         MaxCurveVal = CurveVal;
    1748        3500 :                                         MaxCurvePLR = CurveInput;
    1749             :                                     }
    1750        3500 :                                     CurveInput += 0.01;
    1751             :                                 }
    1752          35 :                                 if (MinCurveVal < 0.7) {
    1753           0 :                                     ShowWarningError(state, std::string{RoutineName} + PerfObjectType + "=\"" + PerfObjectName + "\", invalid");
    1754           0 :                                     ShowContinueError(state, "..." + cAlphaFields2(6) + " = " + Alphas2(6) + " has out of range value.");
    1755           0 :                                     ShowContinueError(
    1756             :                                         state,
    1757           0 :                                         format("...Curve minimum must be >= 0.7, curve min at PLR = {:.2T} is {:.3T}", MinCurvePLR, MinCurveVal));
    1758           0 :                                     ShowContinueError(state, "...Setting curve minimum to 0.7 and simulation continues.");
    1759           0 :                                     SetCurveOutputMinMaxValues(state, state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(PerfModeNum), ErrorsFound, 0.7, _);
    1760             :                                 }
    1761             : 
    1762          35 :                                 if (MaxCurveVal > 1.0) {
    1763           0 :                                     ShowWarningError(state, std::string{RoutineName} + PerfObjectType + "=\"" + PerfObjectName + "\", invalid");
    1764           0 :                                     ShowContinueError(state, "..." + cAlphaFields2(6) + " = " + Alphas2(6) + " has out of range value.");
    1765           0 :                                     ShowContinueError(
    1766             :                                         state,
    1767           0 :                                         format("...Curve maximum must be <= 1.0, curve max at PLR = {:.2T} is {:.3T}", MaxCurvePLR, MaxCurveVal));
    1768           0 :                                     ShowContinueError(state, "...Setting curve maximum to 1.0 and simulation continues.");
    1769           0 :                                     SetCurveOutputMinMaxValues(state, state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(PerfModeNum), ErrorsFound, _, 1.0);
    1770             :                                 }
    1771             :                             }
    1772             :                         }
    1773             : 
    1774          35 :                         state.dataDXCoils->DXCoil(DXCoilNum).Twet_Rated(PerfModeNum) = Numbers2(6);
    1775          35 :                         state.dataDXCoils->DXCoil(DXCoilNum).Gamma_Rated(PerfModeNum) = Numbers2(7);
    1776          35 :                         state.dataDXCoils->DXCoil(DXCoilNum).MaxONOFFCyclesperHour(PerfModeNum) = Numbers2(8);
    1777          35 :                         state.dataDXCoils->DXCoil(DXCoilNum).LatentCapacityTimeConstant(PerfModeNum) = Numbers2(9);
    1778             :                         // Numbers2 (6) through (9) must all be greater than zero to use the latent capacity degradation model
    1779          35 :                         if ((Numbers2(6) > 0.0 || Numbers2(7) > 0.0 || Numbers2(8) > 0.0 || Numbers2(9) > 0.0) &&
    1780           0 :                             (Numbers2(6) <= 0.0 || Numbers2(7) <= 0.0 || Numbers2(8) <= 0.0 || Numbers2(9) <= 0.0)) {
    1781           0 :                             ShowWarningError(state, std::string{RoutineName} + PerfObjectType + "=\"" + PerfObjectName + "\":");
    1782           0 :                             ShowContinueError(state, "...At least one of the four input parameters for the latent capacity degradation model");
    1783           0 :                             ShowContinueError(state,
    1784             :                                               "...is set to zero. Therefore, the latent degradation model will not be used for this simulation.");
    1785             :                         }
    1786             : 
    1787             :                         // outdoor condenser node
    1788          35 :                         if (lAlphaBlanks2(7)) {
    1789          35 :                             state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(PerfModeNum) = 0;
    1790             :                         } else {
    1791           0 :                             state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(PerfModeNum) = GetOnlySingleNode(
    1792             :                                 state,
    1793           0 :                                 Alphas2(7),
    1794             :                                 ErrorsFound,
    1795           0 :                                 (DataLoopNode::ConnectionObjectType)getEnumerationValue(BranchNodeConnections::ConnectionObjectTypeNamesUC,
    1796           0 :                                                                                         UtilityRoutines::MakeUPPERCase(PerfObjectType)),
    1797             :                                 PerfObjectName,
    1798             :                                 DataLoopNode::NodeFluidType::Air,
    1799             :                                 DataLoopNode::ConnectionType::OutsideAirReference,
    1800             :                                 NodeInputManager::CompFluidStream::Primary,
    1801           0 :                                 ObjectIsNotParent);
    1802           0 :                             if (!CheckOutAirNodeNumber(state, state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(PerfModeNum))) {
    1803           0 :                                 ShowWarningError(state, std::string{RoutineName} + PerfObjectType + "=\"" + PerfObjectName + "\":");
    1804           0 :                                 ShowContinueError(state, "may not be valid " + cAlphaFields2(7) + "=\"" + Alphas2(7) + "\".");
    1805           0 :                                 ShowContinueError(state, "node does not appear in an OutdoorAir:NodeList or as an OutdoorAir:Node.");
    1806           0 :                                 ShowContinueError(state,
    1807             :                                                   "This node needs to be included in an air system or the coil model will not be valid, and the "
    1808             :                                                   "simulation continues");
    1809             :                             }
    1810             :                         }
    1811          35 :                         if ((UtilityRoutines::SameString(Alphas2(8), "AirCooled")) || lAlphaBlanks2(8)) {
    1812          35 :                             state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(PerfModeNum) = DataHeatBalance::RefrigCondenserType::Air;
    1813           0 :                         } else if (UtilityRoutines::SameString(Alphas2(8), "EvaporativelyCooled")) {
    1814           0 :                             state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(PerfModeNum) = DataHeatBalance::RefrigCondenserType::Evap;
    1815           0 :                             state.dataDXCoils->DXCoil(DXCoilNum).ReportEvapCondVars = true;
    1816             :                         } else {
    1817           0 :                             ShowSevereError(state, std::string{RoutineName} + PerfObjectType + "=\"" + PerfObjectName + "\", invalid");
    1818           0 :                             ShowContinueError(state, "..." + cAlphaFields2(8) + "=\"" + Alphas2(8) + "\":");
    1819           0 :                             ShowContinueError(state, "...must be AirCooled or EvaporativelyCooled.");
    1820           0 :                             ErrorsFound = true;
    1821             :                         }
    1822             : 
    1823          35 :                         state.dataDXCoils->DXCoil(DXCoilNum).EvapCondEffect(PerfModeNum) = Numbers2(10);
    1824          70 :                         if (state.dataDXCoils->DXCoil(DXCoilNum).EvapCondEffect(PerfModeNum) < 0.0 ||
    1825          35 :                             state.dataDXCoils->DXCoil(DXCoilNum).EvapCondEffect(PerfModeNum) > 1.0) {
    1826           0 :                             ShowSevereError(state, std::string{RoutineName} + PerfObjectType + "=\"" + PerfObjectName + "\", invalid");
    1827           0 :                             ShowContinueError(state, "..." + cNumericFields2(10) + " cannot be < 0.0 or > 1.0.");
    1828           0 :                             ShowContinueError(state, format("...entered value=[{:.2T}].", Numbers2(10)));
    1829           0 :                             ErrorsFound = true;
    1830             :                         }
    1831             : 
    1832          35 :                         state.dataDXCoils->DXCoil(DXCoilNum).EvapCondAirFlow(PerfModeNum) = Numbers2(11);
    1833          35 :                         if (state.dataDXCoils->DXCoil(DXCoilNum).EvapCondAirFlow(PerfModeNum) < 0.0 &&
    1834           0 :                             state.dataDXCoils->DXCoil(DXCoilNum).EvapCondAirFlow(PerfModeNum) != AutoSize) {
    1835           0 :                             ShowSevereError(state, std::string{RoutineName} + PerfObjectType + "=\"" + PerfObjectName + "\", invalid");
    1836           0 :                             ShowContinueError(state, "..." + cNumericFields2(11) + " cannot be < 0.0.");
    1837           0 :                             ShowContinueError(state, format("...entered value=[{:.2T}].", Numbers2(11)));
    1838           0 :                             ErrorsFound = true;
    1839             :                         }
    1840             : 
    1841          35 :                         state.dataDXCoils->DXCoil(DXCoilNum).EvapCondPumpElecNomPower(PerfModeNum) = Numbers2(12);
    1842          35 :                         if (state.dataDXCoils->DXCoil(DXCoilNum).EvapCondPumpElecNomPower(PerfModeNum) < 0.0 &&
    1843           0 :                             state.dataDXCoils->DXCoil(DXCoilNum).EvapCondAirFlow(PerfModeNum) != AutoSize) {
    1844           0 :                             ShowSevereError(state, std::string{RoutineName} + PerfObjectType + "=\"" + PerfObjectName + "\", invalid");
    1845           0 :                             ShowContinueError(state, "..." + cNumericFields2(12) + " cannot be less than zero.");
    1846           0 :                             ShowContinueError(state, format("...entered value=[{:.2T}].", Numbers2(12)));
    1847           0 :                             ErrorsFound = true;
    1848             :                         }
    1849             : 
    1850          35 :                         state.dataDXCoils->DXCoil(DXCoilNum).RatedEIR(PerfModeNum) = 1.0 / state.dataDXCoils->DXCoil(DXCoilNum).RatedCOP(PerfModeNum);
    1851             : 
    1852             :                         // read in user specified SHR modifer curves
    1853          35 :                         if (!lAlphaBlanks2(9) && NumAlphas2 > 8) {
    1854           0 :                             state.dataDXCoils->DXCoil(DXCoilNum).SHRFTemp(PerfModeNum) =
    1855           0 :                                 GetCurveIndex(state, Alphas2(9)); // convert curve name to number
    1856           0 :                             if (state.dataDXCoils->DXCoil(DXCoilNum).SHRFTemp(PerfModeNum) == 0) {
    1857           0 :                                 ShowSevereError(state,
    1858           0 :                                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name +
    1859             :                                                     "\", invalid");
    1860           0 :                                 ShowContinueError(state, "...not found " + cAlphaFields2(9) + "=\"" + Alphas2(9) + "\".");
    1861             :                             } else {
    1862             :                                 // Verify Curve Object, only legal type is BiQuadratic
    1863           0 :                                 ErrorsFound |= Curve::CheckCurveDims(state,
    1864           0 :                                                                      state.dataDXCoils->DXCoil(DXCoilNum).SHRFTemp(PerfModeNum), // Curve index
    1865             :                                                                      {2},                                                        // Valid dimensions
    1866             :                                                                      RoutineName,                                                // Routine name
    1867             :                                                                      CurrentModuleObject,                                        // Object Type
    1868           0 :                                                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,                  // Object Name
    1869           0 :                                                                      cAlphaFields2(9));                                          // Field Name
    1870             :                             }
    1871             :                         }
    1872             : 
    1873          35 :                         if (!lAlphaBlanks2(10) && NumAlphas2 > 9) {
    1874           0 :                             state.dataDXCoils->DXCoil(DXCoilNum).SHRFFlow(PerfModeNum) =
    1875           0 :                                 GetCurveIndex(state, Alphas2(10)); // convert curve name to number
    1876           0 :                             if (state.dataDXCoils->DXCoil(DXCoilNum).SHRFTemp(PerfModeNum) == 0) {
    1877           0 :                                 ShowSevereError(state,
    1878           0 :                                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name +
    1879             :                                                     "\", invalid");
    1880           0 :                                 ShowContinueError(state, "...not found " + cAlphaFields2(10) + "=\"" + Alphas2(10) + "\".");
    1881             :                             } else {
    1882             :                                 // Verify Curve Object, only legal type is BiQuadratic
    1883           0 :                                 ErrorsFound |= Curve::CheckCurveDims(state,
    1884           0 :                                                                      state.dataDXCoils->DXCoil(DXCoilNum).SHRFFlow(PerfModeNum), // Curve index
    1885             :                                                                      {1},                                                        // Valid dimensions
    1886             :                                                                      RoutineName,                                                // Routine name
    1887             :                                                                      CurrentModuleObject,                                        // Object Type
    1888           0 :                                                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,                  // Object Name
    1889           0 :                                                                      cAlphaFields2(10));                                         // Field Name
    1890             :                             }
    1891             :                         }
    1892          35 :                         if (state.dataDXCoils->DXCoil(DXCoilNum).SHRFTemp(PerfModeNum) > 0 &&
    1893           0 :                             state.dataDXCoils->DXCoil(DXCoilNum).SHRFFlow(PerfModeNum) > 0) {
    1894           0 :                             state.dataDXCoils->DXCoil(DXCoilNum).UserSHRCurveExists = true;
    1895             :                         } else {
    1896          35 :                             state.dataDXCoils->DXCoil(DXCoilNum).UserSHRCurveExists = false;
    1897             :                         }
    1898             : 
    1899             :                     } else { // invalid performance object
    1900           0 :                         ShowSevereError(state,
    1901           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name +
    1902             :                                             "\", invalid");
    1903           0 :                         ShowContinueError(state, "... not found " + PerfObjectType + "=\"" + PerfObjectName + "\".");
    1904           0 :                         ErrorsFound = true;
    1905             :                     } // end of valid performance object check
    1906          35 :                     AlphaIndex += 2;
    1907             :                 } // end of sufficient number of fields entered check
    1908             :             }     // End of multimode DX capacity stages loop
    1909             :             // Warn if inputs entered for unused capacity stages
    1910          19 :             for (CapacityStageNum = (state.dataDXCoils->DXCoil(DXCoilNum).NumCapacityStages + 1); CapacityStageNum <= MaxCapacityStages;
    1911             :                  ++CapacityStageNum) {
    1912           1 :                 if ((AlphaIndex <= NumAlphas) && ((!Alphas(AlphaIndex).empty()) || (!Alphas(AlphaIndex + 1).empty()))) {
    1913           0 :                     ShowWarningError(state,
    1914           0 :                                      std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\":");
    1915           0 :                     ShowContinueError(state, format("...Capacity Stage {} not active. Therefore,{}", CapacityStageNum, cAlphaFields(AlphaIndex)));
    1916           0 :                     ShowContinueError(state, "... and " + cAlphaFields(AlphaIndex + 1) + " fields will be ignored.");
    1917             :                 }
    1918           1 :                 AlphaIndex += 2;
    1919             :             } // End of unused capacity stages loop
    1920             :         }     // End of multimode DX dehumidification modes loo
    1921             : 
    1922             :         // Get Water System tank connections
    1923             :         //  A13, \field Name of Water Storage Tank for Supply
    1924          11 :         state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterSupplyName = Alphas(13);
    1925          11 :         if (lAlphaBlanks(13)) {
    1926          11 :             state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterSupplyMode = EvapWaterSupply::FromMains;
    1927             :         } else {
    1928           0 :             state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterSupplyMode = EvapWaterSupply::FromTank;
    1929           0 :             SetupTankDemandComponent(state,
    1930           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,
    1931             :                                      CurrentModuleObject,
    1932           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterSupplyName,
    1933             :                                      ErrorsFound,
    1934           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterSupTankID,
    1935           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterTankDemandARRID);
    1936             :         }
    1937             : 
    1938             :         // A14; \field Name of Water Storage Tank for Condensate Collection
    1939          11 :         state.dataDXCoils->DXCoil(DXCoilNum).CondensateCollectName = Alphas(14);
    1940          11 :         if (lAlphaBlanks(14)) {
    1941          11 :             state.dataDXCoils->DXCoil(DXCoilNum).CondensateCollectMode = CondensateCollectAction::Discard;
    1942             :         } else {
    1943           0 :             state.dataDXCoils->DXCoil(DXCoilNum).CondensateCollectMode = CondensateCollectAction::ToTank;
    1944           0 :             SetupTankSupplyComponent(state,
    1945           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,
    1946             :                                      CurrentModuleObject,
    1947           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).CondensateCollectName,
    1948             :                                      ErrorsFound,
    1949           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).CondensateTankID,
    1950           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).CondensateTankSupplyARRID);
    1951             :         }
    1952             : 
    1953             :         // Set minimum OAT for compressor operation
    1954          11 :         state.dataDXCoils->DXCoil(DXCoilNum).MinOATCompressor = Numbers(5);
    1955          11 :         if (NumNumbers < 5)
    1956           8 :             state.dataDXCoils->DXCoil(DXCoilNum).MinOATCompressor =
    1957             :                 minOATCompDXCooling; // input field is after min fields and won't default if field not included
    1958             : 
    1959             :         // Basin heater power as a function of temperature must be greater than or equal to 0
    1960          11 :         state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterPowerFTempDiff = Numbers(6);
    1961          11 :         if (Numbers(6) < 0.0) {
    1962           0 :             ShowSevereError(state,
    1963           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    1964           0 :             ShowContinueError(state, "..." + cNumericFields(6) + " must be >= 0.");
    1965           0 :             ShowContinueError(state, format("...entered value=[{:.2T}].", Numbers(6)));
    1966           0 :             ErrorsFound = true;
    1967             :         }
    1968             : 
    1969          11 :         state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterSetPointTemp = Numbers(7);
    1970          11 :         if (state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterPowerFTempDiff > 0.0) {
    1971           0 :             if (NumNumbers < 7) {
    1972           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterSetPointTemp = 2.0;
    1973             :             }
    1974           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterSetPointTemp < 2.0) {
    1975           0 :                 ShowWarningError(state,
    1976           0 :                                  std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name +
    1977             :                                      "\", freeze possible");
    1978           0 :                 ShowContinueError(state, "..." + cNumericFields(7) + " is < 2 {C}. Freezing could occur.");
    1979           0 :                 ShowContinueError(state, format("...entered value=[{:.2T}].", Numbers(7)));
    1980             :             }
    1981             :         }
    1982             : 
    1983          11 :         if (!lAlphaBlanks(15)) {
    1984           0 :             state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterSchedulePtr = GetScheduleIndex(state, Alphas(15));
    1985           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterSchedulePtr == 0) {
    1986           0 :                 ShowWarningError(state,
    1987           0 :                                  std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    1988           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(15) + "=\"" + Alphas(15) + "\".");
    1989           0 :                 ShowContinueError(state, "Basin heater will be available to operate throughout the simulation.");
    1990             :             }
    1991             :         }
    1992             : 
    1993             :     } // end of the Multimode DX coil loop
    1994             : 
    1995         241 :     if (ErrorsFound) {
    1996           0 :         ShowFatalError(state,
    1997           0 :                        std::string{RoutineName} + "Errors found in getting " + CurrentModuleObject +
    1998             :                            " input.  Preceding condition(s) causes termination.");
    1999             :     }
    2000             : 
    2001             :     //************* Read Heat Pump (DX Heating Coil) Input **********
    2002         241 :     CurrentModuleObject = "Coil:Heating:DX:SingleSpeed";
    2003         314 :     for (DXCoilIndex = 1; DXCoilIndex <= state.dataDXCoils->NumDXHeatingCoils; ++DXCoilIndex) {
    2004             : 
    2005          73 :         ++DXCoilNum;
    2006             : 
    2007          73 :         state.dataInputProcessing->inputProcessor->getObjectItem(state,
    2008             :                                                                  CurrentModuleObject,
    2009             :                                                                  DXCoilIndex,
    2010             :                                                                  Alphas,
    2011             :                                                                  NumAlphas,
    2012             :                                                                  Numbers,
    2013             :                                                                  NumNumbers,
    2014             :                                                                  IOStatus,
    2015             :                                                                  lNumericBlanks,
    2016             :                                                                  lAlphaBlanks,
    2017             :                                                                  cAlphaFields,
    2018             :                                                                  cNumericFields);
    2019             : 
    2020             :         // allocate single performance mode for numeric field strings used for sizing routine
    2021          73 :         state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode.allocate(1);
    2022          73 :         state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(1).FieldNames.allocate(MaxNumbers);
    2023          73 :         state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(1).FieldNames = cNumericFields;
    2024          73 :         UtilityRoutines::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    2025             :         // ErrorsFound will be set to True if problem was found, left untouched otherwise
    2026          73 :         VerifyUniqueCoilName(state, CurrentModuleObject, Alphas(1), ErrorsFound, CurrentModuleObject + " Name");
    2027          73 :         state.dataDXCoils->DXCoil(DXCoilNum).Name = Alphas(1);
    2028          73 :         state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType = CurrentModuleObject;
    2029          73 :         state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num = CoilDX_HeatingEmpirical;
    2030          73 :         state.dataDXCoils->DXCoil(DXCoilNum).Schedule = Alphas(2);
    2031          73 :         if (lAlphaBlanks(2)) {
    2032          22 :             state.dataDXCoils->DXCoil(DXCoilNum).SchedPtr = DataGlobalConstants::ScheduleAlwaysOn;
    2033             :         } else {
    2034          51 :             state.dataDXCoils->DXCoil(DXCoilNum).SchedPtr = GetScheduleIndex(state, Alphas(2)); // convert schedule name to pointer
    2035          51 :             if (state.dataDXCoils->DXCoil(DXCoilNum).SchedPtr == 0) {
    2036           0 :                 ShowSevereError(state,
    2037           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    2038           0 :                 ShowContinueError(state, "..." + cAlphaFields(2) + "=\"" + Alphas(2) + "\".");
    2039           0 :                 ErrorsFound = true;
    2040             :             }
    2041             :         }
    2042             : 
    2043          73 :         state.dataDXCoils->DXCoil(DXCoilNum).AirInNode = GetOnlySingleNode(state,
    2044          73 :                                                                            Alphas(3),
    2045             :                                                                            ErrorsFound,
    2046             :                                                                            DataLoopNode::ConnectionObjectType::CoilHeatingDXSingleSpeed,
    2047          73 :                                                                            Alphas(1),
    2048             :                                                                            DataLoopNode::NodeFluidType::Air,
    2049             :                                                                            DataLoopNode::ConnectionType::Inlet,
    2050             :                                                                            NodeInputManager::CompFluidStream::Primary,
    2051          73 :                                                                            ObjectIsNotParent);
    2052             : 
    2053          73 :         state.dataDXCoils->DXCoil(DXCoilNum).AirOutNode = GetOnlySingleNode(state,
    2054          73 :                                                                             Alphas(4),
    2055             :                                                                             ErrorsFound,
    2056             :                                                                             DataLoopNode::ConnectionObjectType::CoilHeatingDXSingleSpeed,
    2057          73 :                                                                             Alphas(1),
    2058             :                                                                             DataLoopNode::NodeFluidType::Air,
    2059             :                                                                             DataLoopNode::ConnectionType::Outlet,
    2060             :                                                                             NodeInputManager::CompFluidStream::Primary,
    2061          73 :                                                                             ObjectIsNotParent);
    2062             : 
    2063          73 :         TestCompSet(state, CurrentModuleObject, Alphas(1), Alphas(3), Alphas(4), "Air Nodes");
    2064             : 
    2065          73 :         state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(1) = GetCurveIndex(state, Alphas(5)); // convert curve name to number
    2066          73 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(1) == 0) {
    2067           0 :             if (lAlphaBlanks(5)) {
    2068           0 :                 ShowSevereError(state,
    2069           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", missing");
    2070           0 :                 ShowContinueError(state, "...required " + cAlphaFields(5) + " is blank.");
    2071             :             } else {
    2072           0 :                 ShowSevereError(state,
    2073           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    2074           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(5) + "=\"" + Alphas(5) + "\".");
    2075             :             }
    2076           0 :             ErrorsFound = true;
    2077             :         } else {
    2078             :             // only legal types are Quadratic, BiQuadratic and Cubic
    2079         219 :             ErrorsFound |= Curve::CheckCurveDims(state,
    2080          73 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(1), // Curve index
    2081             :                                                  {1, 2},                                            // Valid dimensions
    2082             :                                                  RoutineName,                                       // Routine name
    2083             :                                                  CurrentModuleObject,                               // Object Type
    2084          73 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).Name,         // Object Name
    2085          73 :                                                  cAlphaFields(5));                                  // Field Name
    2086             : 
    2087          73 :             if (!ErrorsFound) {
    2088          73 :                 if (state.dataCurveManager->PerfCurve(state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(1)).numDims == 1) {
    2089         360 :                     checkCurveIsNormalizedToOne(state,
    2090         144 :                                                 std::string{RoutineName} + CurrentModuleObject,
    2091          72 :                                                 state.dataDXCoils->DXCoil(DXCoilNum).Name,
    2092          72 :                                                 state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(1),
    2093          72 :                                                 cAlphaFields(5),
    2094          72 :                                                 Alphas(5),
    2095             :                                                 RatedOutdoorAirTempHeat);
    2096             :                 } else {
    2097           5 :                     checkCurveIsNormalizedToOne(state,
    2098           2 :                                                 std::string{RoutineName} + CurrentModuleObject,
    2099           1 :                                                 state.dataDXCoils->DXCoil(DXCoilNum).Name,
    2100           1 :                                                 state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(1),
    2101           1 :                                                 cAlphaFields(5),
    2102           1 :                                                 Alphas(5),
    2103             :                                                 RatedInletAirTempHeat,
    2104             :                                                 RatedOutdoorAirTempHeat);
    2105             :                 }
    2106             :             }
    2107             :         }
    2108             : 
    2109          73 :         state.dataDXCoils->DXCoil(DXCoilNum).CCapFFlow(1) = GetCurveIndex(state, Alphas(6)); // convert curve name to number
    2110          73 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CCapFFlow(1) == 0) {
    2111           0 :             if (lAlphaBlanks(6)) {
    2112           0 :                 ShowSevereError(state,
    2113           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", missing");
    2114           0 :                 ShowContinueError(state, "...required " + cAlphaFields(6) + " is blank.");
    2115             :             } else {
    2116           0 :                 ShowSevereError(state,
    2117           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    2118           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(6) + "=\"" + Alphas(6) + "\".");
    2119             :             }
    2120           0 :             ErrorsFound = true;
    2121             :         } else {
    2122             :             // Verify Curve Object, only legal type is Quadratic
    2123         219 :             ErrorsFound |= Curve::CheckCurveDims(state,
    2124          73 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).CCapFFlow(1), // Curve index
    2125             :                                                  {1},                                               // Valid dimensions
    2126             :                                                  RoutineName,                                       // Routine name
    2127             :                                                  CurrentModuleObject,                               // Object Type
    2128          73 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).Name,         // Object Name
    2129          73 :                                                  cAlphaFields(6));                                  // Field Name
    2130             : 
    2131          73 :             if (!ErrorsFound) {
    2132         365 :                 checkCurveIsNormalizedToOne(state,
    2133         146 :                                             std::string{RoutineName} + CurrentModuleObject,
    2134          73 :                                             state.dataDXCoils->DXCoil(DXCoilNum).Name,
    2135          73 :                                             state.dataDXCoils->DXCoil(DXCoilNum).CCapFFlow(1),
    2136          73 :                                             cAlphaFields(6),
    2137          73 :                                             Alphas(6),
    2138             :                                             1.0);
    2139             :             }
    2140             :         }
    2141             : 
    2142          73 :         state.dataDXCoils->DXCoil(DXCoilNum).EIRFTemp(1) = GetCurveIndex(state, Alphas(7)); // convert curve name to number
    2143          73 :         if (state.dataDXCoils->DXCoil(DXCoilNum).EIRFTemp(1) == 0) {
    2144           0 :             if (lAlphaBlanks(7)) {
    2145           0 :                 ShowSevereError(state,
    2146           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", missing");
    2147           0 :                 ShowContinueError(state, "...required " + cAlphaFields(7) + " is blank.");
    2148             :             } else {
    2149           0 :                 ShowSevereError(state,
    2150           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    2151           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(7) + "=\"" + Alphas(7) + "\".");
    2152             :             }
    2153           0 :             ErrorsFound = true;
    2154             :         } else {
    2155             :             // only legal types are Quadratic, BiQuadratic and Cubic
    2156         219 :             ErrorsFound |= Curve::CheckCurveDims(state,
    2157          73 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).EIRFTemp(1), // Curve index
    2158             :                                                  {1, 2},                                           // Valid dimensions
    2159             :                                                  RoutineName,                                      // Routine name
    2160             :                                                  CurrentModuleObject,                              // Object Type
    2161          73 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).Name,        // Object Name
    2162          73 :                                                  cAlphaFields(7));                                 // Field Name
    2163             : 
    2164          73 :             if (!ErrorsFound) {
    2165          73 :                 if (state.dataCurveManager->PerfCurve(state.dataDXCoils->DXCoil(DXCoilNum).EIRFTemp(1)).numDims == 1) {
    2166         360 :                     checkCurveIsNormalizedToOne(state,
    2167         144 :                                                 std::string{RoutineName} + CurrentModuleObject,
    2168          72 :                                                 state.dataDXCoils->DXCoil(DXCoilNum).Name,
    2169          72 :                                                 state.dataDXCoils->DXCoil(DXCoilNum).EIRFTemp(1),
    2170          72 :                                                 cAlphaFields(7),
    2171          72 :                                                 Alphas(7),
    2172             :                                                 RatedOutdoorAirTempHeat);
    2173             :                 } else {
    2174           5 :                     checkCurveIsNormalizedToOne(state,
    2175           2 :                                                 std::string{RoutineName} + CurrentModuleObject,
    2176           1 :                                                 state.dataDXCoils->DXCoil(DXCoilNum).Name,
    2177           1 :                                                 state.dataDXCoils->DXCoil(DXCoilNum).EIRFTemp(1),
    2178           1 :                                                 cAlphaFields(7),
    2179           1 :                                                 Alphas(7),
    2180             :                                                 RatedInletAirTempHeat,
    2181             :                                                 RatedOutdoorAirTempHeat);
    2182             :                 }
    2183             :             }
    2184             :         }
    2185             : 
    2186          73 :         state.dataDXCoils->DXCoil(DXCoilNum).EIRFFlow(1) = GetCurveIndex(state, Alphas(8)); // convert curve name to number
    2187          73 :         if (state.dataDXCoils->DXCoil(DXCoilNum).EIRFFlow(1) == 0) {
    2188           0 :             if (lAlphaBlanks(8)) {
    2189           0 :                 ShowSevereError(state,
    2190           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", missing");
    2191           0 :                 ShowContinueError(state, "...required " + cAlphaFields(8) + " is blank.");
    2192             :             } else {
    2193           0 :                 ShowSevereError(state,
    2194           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    2195           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(8) + "=\"" + Alphas(8) + "\".");
    2196             :             }
    2197           0 :             ErrorsFound = true;
    2198             :         } else {
    2199             :             // Verify Curve Object, only legal type is Quadratic or Cubic
    2200         219 :             ErrorsFound |= Curve::CheckCurveDims(state,
    2201          73 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).EIRFFlow(1), // Curve index
    2202             :                                                  {1},                                              // Valid dimensions
    2203             :                                                  RoutineName,                                      // Routine name
    2204             :                                                  CurrentModuleObject,                              // Object Type
    2205          73 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).Name,        // Object Name
    2206          73 :                                                  cAlphaFields(8));                                 // Field Name
    2207             : 
    2208          73 :             if (!ErrorsFound) {
    2209         365 :                 checkCurveIsNormalizedToOne(state,
    2210         146 :                                             std::string{RoutineName} + CurrentModuleObject,
    2211          73 :                                             state.dataDXCoils->DXCoil(DXCoilNum).Name,
    2212          73 :                                             state.dataDXCoils->DXCoil(DXCoilNum).EIRFFlow(1),
    2213          73 :                                             cAlphaFields(8),
    2214          73 :                                             Alphas(8),
    2215             :                                             1.0);
    2216             :             }
    2217             :         }
    2218             : 
    2219          73 :         state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(1) = GetCurveIndex(state, Alphas(9)); // convert curve name to number
    2220          73 :         if (state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(1) == 0) {
    2221           0 :             if (lAlphaBlanks(9)) {
    2222           0 :                 ShowSevereError(state,
    2223           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", missing");
    2224           0 :                 ShowContinueError(state, "...required " + cAlphaFields(9) + " is blank.");
    2225             :             } else {
    2226           0 :                 ShowSevereError(state,
    2227           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    2228           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(9) + "=\"" + Alphas(9) + "\".");
    2229             :             }
    2230           0 :             ErrorsFound = true;
    2231             :         } else {
    2232             :             // Verify Curve Object, only legal types are Quadratic or Cubic
    2233         219 :             ErrorsFound |= Curve::CheckCurveDims(state,
    2234          73 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(1), // Curve index
    2235             :                                                  {1},                                             // Valid dimensions
    2236             :                                                  RoutineName,                                     // Routine name
    2237             :                                                  CurrentModuleObject,                             // Object Type
    2238          73 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).Name,       // Object Name
    2239          73 :                                                  cAlphaFields(9));                                // Field Name
    2240             : 
    2241          73 :             if (!ErrorsFound) {
    2242             :                 //     Test PLF curve minimum and maximum. Cap if less than 0.7 or greater than 1.0.
    2243          73 :                 MinCurveVal = 999.0;
    2244          73 :                 MaxCurveVal = -999.0;
    2245          73 :                 CurveInput = 0.0;
    2246       14673 :                 while (CurveInput <= 1.0) {
    2247        7300 :                     CurveVal = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(1), CurveInput);
    2248        7300 :                     if (CurveVal < MinCurveVal) {
    2249          73 :                         MinCurveVal = CurveVal;
    2250          73 :                         MinCurvePLR = CurveInput;
    2251             :                     }
    2252        7300 :                     if (CurveVal > MaxCurveVal) {
    2253        7300 :                         MaxCurveVal = CurveVal;
    2254        7300 :                         MaxCurvePLR = CurveInput;
    2255             :                     }
    2256        7300 :                     CurveInput += 0.01;
    2257             :                 }
    2258          73 :                 if (MinCurveVal < 0.7) {
    2259           0 :                     ShowWarningError(
    2260           0 :                         state, std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    2261           0 :                     ShowContinueError(state, "..." + cAlphaFields(9) + " = " + Alphas(9) + " has out of range value.");
    2262           0 :                     ShowContinueError(state,
    2263           0 :                                       format("...Curve minimum must be >= 0.7, curve min at PLR = {:.2T} is {:.3T}", MinCurvePLR, MinCurveVal));
    2264           0 :                     ShowContinueError(state, "...Setting curve minimum to 0.7 and simulation continues.");
    2265           0 :                     SetCurveOutputMinMaxValues(state, state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(1), ErrorsFound, 0.7, _);
    2266             :                 }
    2267             : 
    2268          73 :                 if (MaxCurveVal > 1.0) {
    2269           0 :                     ShowWarningError(
    2270           0 :                         state, std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    2271           0 :                     ShowContinueError(state, "..." + cAlphaFields(9) + " = " + Alphas(9) + " has out of range value.");
    2272           0 :                     ShowContinueError(state,
    2273           0 :                                       format("...Curve maximum must be <= 1.0, curve max at PLR = {:.2T} is {:.3T}", MaxCurvePLR, MaxCurveVal));
    2274           0 :                     ShowContinueError(state, "...Setting curve maximum to 1.0 and simulation continues.");
    2275           0 :                     SetCurveOutputMinMaxValues(state, state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(1), ErrorsFound, _, 1.0);
    2276             :                 }
    2277             :             }
    2278             :         }
    2279             : 
    2280             :         // Only required for reverse cycle heat pumps
    2281          73 :         state.dataDXCoils->DXCoil(DXCoilNum).DefrostEIRFT = GetCurveIndex(state, Alphas(10)); // convert curve name to number
    2282          73 :         if (UtilityRoutines::SameString(Alphas(11), "ReverseCycle")) {
    2283          27 :             if (state.dataDXCoils->DXCoil(DXCoilNum).DefrostEIRFT == 0) {
    2284           0 :                 if (lAlphaBlanks(10)) {
    2285           0 :                     ShowSevereError(
    2286           0 :                         state, std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", missing");
    2287           0 :                     ShowContinueError(state, "...required " + cAlphaFields(10) + " is blank.");
    2288           0 :                     ShowContinueError(state, "...field is required because " + cAlphaFields(11) + " is \"ReverseCycle\".");
    2289             :                 } else {
    2290           0 :                     ShowSevereError(
    2291           0 :                         state, std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    2292           0 :                     ShowContinueError(state, "...not found " + cAlphaFields(10) + "=\"" + Alphas(10) + "\".");
    2293             :                 }
    2294           0 :                 ErrorsFound = true;
    2295             :             } else {
    2296             :                 // Verify Curve Object, only legal type is BiQuadratic
    2297          81 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    2298          27 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).DefrostEIRFT, // Curve index
    2299             :                                                      {2},                                               // Valid dimensions
    2300             :                                                      RoutineName,                                       // Routine name
    2301             :                                                      CurrentModuleObject,                               // Object Type
    2302          27 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,         // Object Name
    2303          27 :                                                      cAlphaFields(10));                                 // Field Name
    2304             : 
    2305          27 :                 if (!ErrorsFound) {
    2306         135 :                     checkCurveIsNormalizedToOne(state,
    2307          54 :                                                 std::string{RoutineName} + CurrentModuleObject,
    2308          27 :                                                 state.dataDXCoils->DXCoil(DXCoilNum).Name,
    2309          27 :                                                 state.dataDXCoils->DXCoil(DXCoilNum).DefrostEIRFT,
    2310          27 :                                                 cAlphaFields(10),
    2311          27 :                                                 Alphas(10),
    2312             :                                                 RatedInletAirTempHeat,
    2313             :                                                 RatedOutdoorAirTempHeat);
    2314             :                 }
    2315             :             }
    2316             :         }
    2317             : 
    2318          73 :         if (UtilityRoutines::SameString(Alphas(11), "ReverseCycle"))
    2319          27 :             state.dataDXCoils->DXCoil(DXCoilNum).DefrostStrategy = StandardRatings::DefrostStrat::ReverseCycle;
    2320          73 :         if (UtilityRoutines::SameString(Alphas(11), "Resistive"))
    2321          46 :             state.dataDXCoils->DXCoil(DXCoilNum).DefrostStrategy = StandardRatings::DefrostStrat::Resistive;
    2322          73 :         if (state.dataDXCoils->DXCoil(DXCoilNum).DefrostStrategy == StandardRatings::DefrostStrat::Invalid) {
    2323           0 :             ShowSevereError(state,
    2324           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    2325           0 :             ShowContinueError(state, "...illegal " + cAlphaFields(11) + "=\"" + Alphas(11) + "\".");
    2326           0 :             ShowContinueError(state, "...valid values for this field are ReverseCycle or Resistive.");
    2327           0 :             ErrorsFound = true;
    2328             :         }
    2329             : 
    2330          73 :         if (UtilityRoutines::SameString(Alphas(12), "Timed"))
    2331          64 :             state.dataDXCoils->DXCoil(DXCoilNum).DefrostControl = StandardRatings::HPdefrostControl::Timed;
    2332          73 :         if (UtilityRoutines::SameString(Alphas(12), "OnDemand"))
    2333           9 :             state.dataDXCoils->DXCoil(DXCoilNum).DefrostControl = StandardRatings::HPdefrostControl::OnDemand;
    2334          73 :         if (state.dataDXCoils->DXCoil(DXCoilNum).DefrostControl == StandardRatings::HPdefrostControl::Invalid) {
    2335           0 :             ShowSevereError(state,
    2336           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    2337           0 :             ShowContinueError(state, "...illegal " + cAlphaFields(12) + "=\"" + Alphas(12) + "\".");
    2338           0 :             ShowContinueError(state, "...valid values for this field are Timed or OnDemand.");
    2339           0 :             ErrorsFound = true;
    2340             :         }
    2341             : 
    2342          73 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedSHR(1) = 1.0;
    2343          73 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(1) = Numbers(1);
    2344          73 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedCOP(1) = Numbers(2);
    2345          73 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(1) = Numbers(3);
    2346          73 :         state.dataDXCoils->DXCoil(DXCoilNum).FanPowerPerEvapAirFlowRate(1) = Numbers(4);
    2347          73 :         state.dataDXCoils->DXCoil(DXCoilNum).FanPowerPerEvapAirFlowRate_2023(1) = Numbers(5);
    2348             : 
    2349             :         // Set minimum OAT for heat pump compressor operation
    2350          73 :         state.dataDXCoils->DXCoil(DXCoilNum).MinOATCompressor = Numbers(6);
    2351             : 
    2352          73 :         state.dataDXCoils->DXCoil(DXCoilNum).OATempCompressorOn = Numbers(7);
    2353             : 
    2354          73 :         if (lNumericBlanks(7) || lNumericBlanks(6)) { //??TBD:BPS 6 or 5 | 7 or 6
    2355          72 :             state.dataDXCoils->DXCoil(DXCoilNum).OATempCompressorOnOffBlank = true;
    2356             :         } else {
    2357           1 :             state.dataDXCoils->DXCoil(DXCoilNum).OATempCompressorOnOffBlank = false;
    2358             :         }
    2359             : 
    2360          73 :         if (state.dataDXCoils->DXCoil(DXCoilNum).OATempCompressorOn < state.dataDXCoils->DXCoil(DXCoilNum).MinOATCompressor)
    2361          15 :             state.dataDXCoils->DXCoil(DXCoilNum).OATempCompressorOn = state.dataDXCoils->DXCoil(DXCoilNum).MinOATCompressor;
    2362             : 
    2363             :         // Set maximum outdoor temp for defrost to occur
    2364          73 :         state.dataDXCoils->DXCoil(DXCoilNum).MaxOATDefrost = Numbers(8);
    2365             : 
    2366             :         // Set crankcase heater capacity
    2367          73 :         state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterCapacity = Numbers(9);
    2368          73 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterCapacity < 0.0) {
    2369           0 :             ShowSevereError(state,
    2370           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    2371           0 :             ShowContinueError(state, "..." + cNumericFields(8) + " cannot be < 0.0.");
    2372           0 :             ShowContinueError(state, format("...entered value=[{:.2T}].", Numbers(9)));
    2373           0 :             ErrorsFound = true;
    2374             :         }
    2375             : 
    2376             :         // Set crankcase heater cutout temperature
    2377          73 :         state.dataDXCoils->DXCoil(DXCoilNum).MaxOATCrankcaseHeater = Numbers(10);
    2378             : 
    2379             :         // Set defrost time period
    2380          73 :         state.dataDXCoils->DXCoil(DXCoilNum).DefrostTime = Numbers(11);
    2381          73 :         if (state.dataDXCoils->DXCoil(DXCoilNum).DefrostTime == 0.0 &&
    2382           0 :             state.dataDXCoils->DXCoil(DXCoilNum).DefrostControl == StandardRatings::HPdefrostControl::Timed) {
    2383           0 :             ShowWarningError(state, std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", ");
    2384           0 :             ShowContinueError(state, "..." + cNumericFields(11) + " = 0.0 for defrost control = TIMED.");
    2385             :         }
    2386             : 
    2387             :         // Set defrost capacity (for resistive defrost)
    2388          73 :         state.dataDXCoils->DXCoil(DXCoilNum).DefrostCapacity = Numbers(12);
    2389          75 :         if (state.dataDXCoils->DXCoil(DXCoilNum).DefrostCapacity == 0.0 &&
    2390           2 :             state.dataDXCoils->DXCoil(DXCoilNum).DefrostStrategy == StandardRatings::DefrostStrat::Resistive) {
    2391           0 :             ShowWarningError(state, std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", ");
    2392           0 :             ShowContinueError(state, "..." + cNumericFields(12) + " = 0.0 for defrost strategy = RESISTIVE.");
    2393             :         }
    2394             : 
    2395             :         // Set Region number for calculating HSPF
    2396          73 :         state.dataDXCoils->DXCoil(DXCoilNum).RegionNum = Numbers(13);
    2397             : 
    2398          73 :         if (lNumericBlanks(13)) {
    2399          72 :             state.dataDXCoils->DXCoil(DXCoilNum).RegionNum = 4;
    2400             :         }
    2401             : 
    2402          73 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedEIR(1) = 1.0 / state.dataDXCoils->DXCoil(DXCoilNum).RatedCOP(1);
    2403             : 
    2404             :         // A13 is optional evaporator node name
    2405          73 :         if (lAlphaBlanks(13)) {
    2406          70 :             state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(1) = 0;
    2407             :         } else {
    2408           3 :             state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(1) =
    2409           9 :                 GetOnlySingleNode(state,
    2410           3 :                                   Alphas(13),
    2411             :                                   ErrorsFound,
    2412             :                                   DataLoopNode::ConnectionObjectType::CoilHeatingDXSingleSpeed,
    2413           3 :                                   state.dataDXCoils->DXCoil(DXCoilNum).Name,
    2414             :                                   DataLoopNode::NodeFluidType::Air,
    2415             :                                   DataLoopNode::ConnectionType::OutsideAirReference,
    2416             :                                   NodeInputManager::CompFluidStream::Primary,
    2417           3 :                                   ObjectIsNotParent);
    2418             :             // warn if not an outdoor node, but allow
    2419           3 :             if (!CheckOutAirNodeNumber(state, state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(1))) {
    2420           0 :                 ShowWarningError(
    2421           0 :                     state, std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", may be invalid");
    2422           0 :                 ShowContinueError(
    2423           0 :                     state, cAlphaFields(13) + "=\"" + Alphas(13) + "\", node does not appear in an OutdoorAir:NodeList or as an OutdoorAir:Node.");
    2424           0 :                 ShowContinueError(
    2425             :                     state, "This node needs to be included in an air system or the coil model will not be valid, and the simulation continues");
    2426             :             }
    2427             :         }
    2428             : 
    2429             :         // A14, \field Zone Name for Evaporator Placement
    2430          73 :         if (!lAlphaBlanks(14) && NumAlphas > 13) {
    2431           1 :             state.dataDXCoils->DXCoil(DXCoilNum).SecZonePtr = UtilityRoutines::FindItemInList(Alphas(14), state.dataHeatBal->Zone);
    2432           1 :             if (state.dataDXCoils->DXCoil(DXCoilNum).SecZonePtr > 0) {
    2433           4 :                 SetupZoneInternalGain(state,
    2434           1 :                                       state.dataDXCoils->DXCoil(DXCoilNum).SecZonePtr,
    2435           1 :                                       state.dataDXCoils->DXCoil(DXCoilNum).Name,
    2436             :                                       DataHeatBalance::IntGainType::SecHeatingDXCoilSingleSpeed,
    2437           1 :                                       &state.dataDXCoils->DXCoil(DXCoilNum).SecCoilSensibleHeatRemovalRate,
    2438             :                                       nullptr,
    2439             :                                       nullptr,
    2440           1 :                                       &state.dataDXCoils->DXCoil(DXCoilNum).SecCoilLatentHeatRemovalRate);
    2441           1 :                 state.dataDXCoils->DXCoil(DXCoilNum).IsSecondaryDXCoilInZone = true;
    2442             :             } else {
    2443           0 :                 ShowSevereError(state,
    2444           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    2445           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(14) + "=\"" + Alphas(14) + "\".");
    2446             :             }
    2447             :         }
    2448          73 :         if (state.dataDXCoils->DXCoil(DXCoilNum).SecZonePtr > 0) {
    2449             :             // N14, \field Secondary Coil Air Flow Rate
    2450           1 :             if (!lNumericBlanks(13)) {
    2451           1 :                 state.dataDXCoils->DXCoil(DXCoilNum).SecCoilAirFlow = Numbers(14);
    2452             :             }
    2453             :             // N15, \field Secondary Coil Fan Flow Scaling Factor
    2454           1 :             if (!lNumericBlanks(15)) {
    2455           1 :                 state.dataDXCoils->DXCoil(DXCoilNum).SecCoilAirFlowScalingFactor = Numbers(15);
    2456             :             }
    2457             :             // N16, \field Nominal Sensible Heat Ratio of Secondary Coil
    2458           1 :             if (!lNumericBlanks(16)) {
    2459           1 :                 state.dataDXCoils->DXCoil(DXCoilNum).SecCoilRatedSHR = Numbers(16);
    2460             :             } else {
    2461           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).SecCoilRatedSHR = 1.0;
    2462             :             }
    2463             :             // A15, \field Sensible Heat Ratio Modifier Function of Temperature Curve Name
    2464           1 :             if (!lAlphaBlanks(15)) {
    2465           1 :                 state.dataDXCoils->DXCoil(DXCoilNum).SecCoilSHRFT = GetCurveIndex(state, Alphas(15));
    2466           1 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).SecCoilSHRFT == 0) {
    2467           0 :                     ShowSevereError(
    2468           0 :                         state, std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    2469           0 :                     ShowContinueError(state, "...not found " + cAlphaFields(15) + "=\"" + Alphas(15) + "\".");
    2470             :                 }
    2471             :             }
    2472             :             // A16; \field Sensible Heat Ratio Function of Flow Fraction Curve Name
    2473           1 :             if (!lAlphaBlanks(16)) {
    2474           1 :                 state.dataDXCoils->DXCoil(DXCoilNum).SecCoilSHRFF = GetCurveIndex(state, Alphas(16));
    2475           1 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).SecCoilSHRFF == 0) {
    2476           0 :                     ShowSevereError(
    2477           0 :                         state, std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    2478           0 :                     ShowContinueError(state, "...not found " + cAlphaFields(16) + "=\"" + Alphas(16) + "\".");
    2479             :                 }
    2480             :             }
    2481             :         }
    2482             : 
    2483             :     } // end of the DX heating coil loop
    2484             : 
    2485         241 :     if (ErrorsFound) {
    2486           0 :         ShowFatalError(state,
    2487           0 :                        std::string{RoutineName} + "Errors found in getting " + CurrentModuleObject +
    2488             :                            " input. Preceding condition(s) causes termination.");
    2489             :     }
    2490             : 
    2491         241 :     CurrentModuleObject = "Coil:Cooling:DX:TwoSpeed";
    2492         308 :     for (DXCoilIndex = 1; DXCoilIndex <= state.dataDXCoils->NumDXMulSpeedCoils; ++DXCoilIndex) {
    2493             : 
    2494          67 :         ++DXCoilNum;
    2495             : 
    2496          67 :         state.dataInputProcessing->inputProcessor->getObjectItem(state,
    2497             :                                                                  CurrentModuleObject,
    2498             :                                                                  DXCoilIndex,
    2499             :                                                                  Alphas,
    2500             :                                                                  NumAlphas,
    2501             :                                                                  Numbers,
    2502             :                                                                  NumNumbers,
    2503             :                                                                  IOStatus,
    2504             :                                                                  lNumericBlanks,
    2505             :                                                                  lAlphaBlanks,
    2506             :                                                                  cAlphaFields,
    2507             :                                                                  cNumericFields);
    2508             : 
    2509             :         // allocate single performance mode for numeric field strings used for sizing routine
    2510          67 :         state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode.allocate(1);
    2511          67 :         state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(1).FieldNames.allocate(MaxNumbers);
    2512          67 :         state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(1).FieldNames = cNumericFields;
    2513          67 :         UtilityRoutines::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    2514             :         // ErrorsFound will be set to True if problem was found, left untouched otherwise
    2515          67 :         VerifyUniqueCoilName(state, CurrentModuleObject, Alphas(1), ErrorsFound, CurrentModuleObject + " Name");
    2516             : 
    2517          67 :         state.dataDXCoils->DXCoil(DXCoilNum).Name = Alphas(1);
    2518             :         // Initialize DataHeatBalance heat reclaim variable name for use by heat reclaim coils
    2519          67 :         state.dataHeatBal->HeatReclaimDXCoil(DXCoilNum).Name = state.dataDXCoils->DXCoil(DXCoilNum).Name;
    2520          67 :         state.dataHeatBal->HeatReclaimDXCoil(DXCoilNum).SourceType = CurrentModuleObject;
    2521          67 :         state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType = CurrentModuleObject;
    2522          67 :         state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num = CoilDX_CoolingTwoSpeed;
    2523          67 :         state.dataDXCoils->DXCoil(DXCoilNum).Schedule = Alphas(2);
    2524          67 :         if (lAlphaBlanks(2)) {
    2525           2 :             state.dataDXCoils->DXCoil(DXCoilNum).SchedPtr = DataGlobalConstants::ScheduleAlwaysOn;
    2526             :         } else {
    2527          65 :             state.dataDXCoils->DXCoil(DXCoilNum).SchedPtr = GetScheduleIndex(state, Alphas(2)); // convert schedule name to pointer
    2528          65 :             if (state.dataDXCoils->DXCoil(DXCoilNum).SchedPtr == 0) {
    2529           0 :                 ShowSevereError(state,
    2530           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    2531           0 :                 ShowContinueError(state, "..." + cAlphaFields(2) + "=\"" + Alphas(2) + "\".");
    2532           0 :                 ErrorsFound = true;
    2533             :             }
    2534             :         }
    2535          67 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(1) = Numbers(1);
    2536          67 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedSHR(1) = Numbers(2);
    2537          67 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedCOP(1) = Numbers(3);
    2538          67 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(1) = Numbers(4);
    2539          67 :         if (!lNumericBlanks(5)) {
    2540          32 :             state.dataDXCoils->DXCoil(DXCoilNum).InternalStaticPressureDrop = Numbers(5);
    2541          32 :             state.dataDXCoils->DXCoil(DXCoilNum).RateWithInternalStaticAndFanObject = true;
    2542             :         } else {
    2543          35 :             state.dataDXCoils->DXCoil(DXCoilNum).InternalStaticPressureDrop = -999.0;
    2544          35 :             state.dataDXCoils->DXCoil(DXCoilNum).RateWithInternalStaticAndFanObject = false;
    2545             :         }
    2546             : 
    2547          67 :         state.dataDXCoils->DXCoil(DXCoilNum).AirInNode = GetOnlySingleNode(state,
    2548          67 :                                                                            Alphas(3),
    2549             :                                                                            ErrorsFound,
    2550             :                                                                            DataLoopNode::ConnectionObjectType::CoilCoolingDXTwoSpeed,
    2551          67 :                                                                            Alphas(1),
    2552             :                                                                            DataLoopNode::NodeFluidType::Air,
    2553             :                                                                            DataLoopNode::ConnectionType::Inlet,
    2554             :                                                                            NodeInputManager::CompFluidStream::Primary,
    2555          67 :                                                                            ObjectIsNotParent);
    2556             : 
    2557          67 :         state.dataDXCoils->DXCoil(DXCoilNum).AirOutNode = GetOnlySingleNode(state,
    2558          67 :                                                                             Alphas(4),
    2559             :                                                                             ErrorsFound,
    2560             :                                                                             DataLoopNode::ConnectionObjectType::CoilCoolingDXTwoSpeed,
    2561          67 :                                                                             Alphas(1),
    2562             :                                                                             DataLoopNode::NodeFluidType::Air,
    2563             :                                                                             DataLoopNode::ConnectionType::Outlet,
    2564             :                                                                             NodeInputManager::CompFluidStream::Primary,
    2565          67 :                                                                             ObjectIsNotParent);
    2566             : 
    2567          67 :         TestCompSet(state, CurrentModuleObject, Alphas(1), Alphas(3), Alphas(4), "Air Nodes");
    2568             : 
    2569          67 :         state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(1) = GetCurveIndex(state, Alphas(5)); // convert curve name to number
    2570          67 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(1) == 0) {
    2571           0 :             if (lAlphaBlanks(5)) {
    2572           0 :                 ShowSevereError(state,
    2573           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", missing");
    2574           0 :                 ShowContinueError(state, "...required " + cAlphaFields(5) + " is blank.");
    2575             :             } else {
    2576           0 :                 ShowSevereError(state,
    2577           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    2578           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(5) + "=\"" + Alphas(5) + "\".");
    2579             :             }
    2580           0 :             ErrorsFound = true;
    2581             :         } else {
    2582             :             // Verify Curve Object, only legal type is BiQuadratic
    2583         201 :             ErrorsFound |= Curve::CheckCurveDims(state,
    2584          67 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(1), // Curve index
    2585             :                                                  {2},                                               // Valid dimensions
    2586             :                                                  RoutineName,                                       // Routine name
    2587             :                                                  CurrentModuleObject,                               // Object Type
    2588          67 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).Name,         // Object Name
    2589          67 :                                                  cAlphaFields(5));                                  // Field Name
    2590             : 
    2591          67 :             if (!ErrorsFound) {
    2592         335 :                 checkCurveIsNormalizedToOne(state,
    2593         134 :                                             std::string{RoutineName} + CurrentModuleObject,
    2594          67 :                                             state.dataDXCoils->DXCoil(DXCoilNum).Name,
    2595          67 :                                             state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(1),
    2596          67 :                                             cAlphaFields(5),
    2597          67 :                                             Alphas(5),
    2598             :                                             RatedInletWetBulbTemp,
    2599             :                                             RatedOutdoorAirTemp);
    2600             :             }
    2601             :         }
    2602             : 
    2603          67 :         state.dataDXCoils->DXCoil(DXCoilNum).CCapFFlow(1) = GetCurveIndex(state, Alphas(6)); // convert curve name to number
    2604          67 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CCapFFlow(1) == 0) {
    2605           0 :             if (lAlphaBlanks(6)) {
    2606           0 :                 ShowSevereError(state,
    2607           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", missing");
    2608           0 :                 ShowContinueError(state, "...required " + cAlphaFields(6) + " is blank.");
    2609             :             } else {
    2610           0 :                 ShowSevereError(state,
    2611           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    2612           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(6) + "=\"" + Alphas(6) + "\".");
    2613             :             }
    2614           0 :             ErrorsFound = true;
    2615             :         } else {
    2616             :             // Verify Curve Object, only legal type is Quadratic
    2617         201 :             ErrorsFound |= Curve::CheckCurveDims(state,
    2618          67 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).CCapFFlow(1), // Curve index
    2619             :                                                  {1},                                               // Valid dimensions
    2620             :                                                  RoutineName,                                       // Routine name
    2621             :                                                  CurrentModuleObject,                               // Object Type
    2622          67 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).Name,         // Object Name
    2623          67 :                                                  cAlphaFields(6));                                  // Field Name
    2624             : 
    2625          67 :             if (!ErrorsFound) {
    2626         335 :                 checkCurveIsNormalizedToOne(state,
    2627         134 :                                             std::string{RoutineName} + CurrentModuleObject,
    2628          67 :                                             state.dataDXCoils->DXCoil(DXCoilNum).Name,
    2629          67 :                                             state.dataDXCoils->DXCoil(DXCoilNum).CCapFFlow(1),
    2630          67 :                                             cAlphaFields(6),
    2631          67 :                                             Alphas(6),
    2632             :                                             1.0);
    2633             :             }
    2634             :         }
    2635             : 
    2636          67 :         state.dataDXCoils->DXCoil(DXCoilNum).EIRFTemp(1) = GetCurveIndex(state, Alphas(7)); // convert curve name to number
    2637          67 :         if (state.dataDXCoils->DXCoil(DXCoilNum).EIRFTemp(1) == 0) {
    2638           0 :             if (lAlphaBlanks(7)) {
    2639           0 :                 ShowSevereError(state,
    2640           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", missing");
    2641           0 :                 ShowContinueError(state, "...required " + cAlphaFields(7) + " is blank.");
    2642             :             } else {
    2643           0 :                 ShowSevereError(state,
    2644           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    2645           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(7) + "=\"" + Alphas(7) + "\".");
    2646             :             }
    2647           0 :             ErrorsFound = true;
    2648             :         } else {
    2649             :             // Verify Curve Object, only legal type is BiQuadratic
    2650         201 :             ErrorsFound |= Curve::CheckCurveDims(state,
    2651          67 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).EIRFTemp(1), // Curve index
    2652             :                                                  {2},                                              // Valid dimensions
    2653             :                                                  RoutineName,                                      // Routine name
    2654             :                                                  CurrentModuleObject,                              // Object Type
    2655          67 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).Name,        // Object Name
    2656          67 :                                                  cAlphaFields(7));                                 // Field Name
    2657             : 
    2658          67 :             if (!ErrorsFound) {
    2659         335 :                 checkCurveIsNormalizedToOne(state,
    2660         134 :                                             std::string{RoutineName} + CurrentModuleObject,
    2661          67 :                                             state.dataDXCoils->DXCoil(DXCoilNum).Name,
    2662          67 :                                             state.dataDXCoils->DXCoil(DXCoilNum).EIRFTemp(1),
    2663          67 :                                             cAlphaFields(7),
    2664          67 :                                             Alphas(7),
    2665             :                                             RatedInletWetBulbTemp,
    2666             :                                             RatedOutdoorAirTemp);
    2667             :             }
    2668             :         }
    2669             : 
    2670          67 :         state.dataDXCoils->DXCoil(DXCoilNum).EIRFFlow(1) = GetCurveIndex(state, Alphas(8)); // convert curve name to number
    2671          67 :         if (state.dataDXCoils->DXCoil(DXCoilNum).EIRFFlow(1) == 0) {
    2672           0 :             if (lAlphaBlanks(8)) {
    2673           0 :                 ShowSevereError(state,
    2674           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", missing");
    2675           0 :                 ShowContinueError(state, "...required " + cAlphaFields(8) + " is blank.");
    2676             :             } else {
    2677           0 :                 ShowSevereError(state,
    2678           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    2679           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(8) + "=\"" + Alphas(8) + "\".");
    2680             :             }
    2681           0 :             ErrorsFound = true;
    2682             :         } else {
    2683             :             // Verify Curve Object, only legal type is Quadratic
    2684         201 :             ErrorsFound |= Curve::CheckCurveDims(state,
    2685          67 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).EIRFFlow(1), // Curve index
    2686             :                                                  {1},                                              // Valid dimensions
    2687             :                                                  RoutineName,                                      // Routine name
    2688             :                                                  CurrentModuleObject,                              // Object Type
    2689          67 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).Name,        // Object Name
    2690          67 :                                                  cAlphaFields(8));                                 // Field Name
    2691             : 
    2692          67 :             if (!ErrorsFound) {
    2693         335 :                 checkCurveIsNormalizedToOne(state,
    2694         134 :                                             std::string{RoutineName} + CurrentModuleObject,
    2695          67 :                                             state.dataDXCoils->DXCoil(DXCoilNum).Name,
    2696          67 :                                             state.dataDXCoils->DXCoil(DXCoilNum).EIRFFlow(1),
    2697          67 :                                             cAlphaFields(8),
    2698          67 :                                             Alphas(8),
    2699             :                                             1.0);
    2700             :             }
    2701             :         }
    2702             : 
    2703          67 :         state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(1) = GetCurveIndex(state, Alphas(9)); // convert curve name to number
    2704          67 :         if (state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(1) == 0) {
    2705           0 :             if (lAlphaBlanks(9)) {
    2706           0 :                 ShowSevereError(state,
    2707           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", missing");
    2708           0 :                 ShowContinueError(state, "...required " + cAlphaFields(9) + " is blank.");
    2709             :             } else {
    2710           0 :                 ShowSevereError(state,
    2711           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    2712           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(9) + "=\"" + Alphas(9) + "\".");
    2713             :             }
    2714           0 :             ErrorsFound = true;
    2715             :         } else {
    2716             :             // Verify Curve Object, only legal types are Quadratic or Cubic
    2717         201 :             ErrorsFound |= Curve::CheckCurveDims(state,
    2718          67 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(1), // Curve index
    2719             :                                                  {1},                                             // Valid dimensions
    2720             :                                                  RoutineName,                                     // Routine name
    2721             :                                                  CurrentModuleObject,                             // Object Type
    2722          67 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).Name,       // Object Name
    2723          67 :                                                  cAlphaFields(9));                                // Field Name
    2724             : 
    2725          67 :             if (!ErrorsFound) {
    2726             :                 //     Test PLF curve minimum and maximum. Cap if less than 0.7 or greater than 1.0.
    2727          67 :                 MinCurveVal = 999.0;
    2728          67 :                 MaxCurveVal = -999.0;
    2729          67 :                 CurveInput = 0.0;
    2730       13467 :                 while (CurveInput <= 1.0) {
    2731        6700 :                     CurveVal = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(1), CurveInput);
    2732        6700 :                     if (CurveVal < MinCurveVal) {
    2733          67 :                         MinCurveVal = CurveVal;
    2734          67 :                         MinCurvePLR = CurveInput;
    2735             :                     }
    2736        6700 :                     if (CurveVal > MaxCurveVal) {
    2737        2542 :                         MaxCurveVal = CurveVal;
    2738        2542 :                         MaxCurvePLR = CurveInput;
    2739             :                     }
    2740        6700 :                     CurveInput += 0.01;
    2741             :                 }
    2742          67 :                 if (MinCurveVal < 0.7) {
    2743           0 :                     ShowWarningError(
    2744           0 :                         state, std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    2745           0 :                     ShowContinueError(state, "..." + cAlphaFields(9) + " = " + Alphas(9) + " has out of range value.");
    2746           0 :                     ShowContinueError(state,
    2747           0 :                                       format("...Curve minimum must be >= 0.7, curve min at PLR = {:.2T} is {:.3T}", MinCurvePLR, MinCurveVal));
    2748           0 :                     ShowContinueError(state, "...Setting curve minimum to 0.7 and simulation continues.");
    2749           0 :                     SetCurveOutputMinMaxValues(state, state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(1), ErrorsFound, 0.7, _);
    2750             :                 }
    2751             : 
    2752          67 :                 if (MaxCurveVal > 1.0) {
    2753           0 :                     ShowWarningError(
    2754           0 :                         state, std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    2755           0 :                     ShowContinueError(state, "..." + cAlphaFields(9) + " = " + Alphas(9) + " has out of range value.");
    2756           0 :                     ShowContinueError(state,
    2757           0 :                                       format("...Curve maximum must be <= 1.0, curve max at PLR = {:.2T} is {:.3T}", MaxCurvePLR, MaxCurveVal));
    2758           0 :                     ShowContinueError(state, "...Setting curve maximum to 1.0 and simulation continues.");
    2759           0 :                     SetCurveOutputMinMaxValues(state, state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(1), ErrorsFound, _, 1.0);
    2760             :                 }
    2761             :             }
    2762             :         }
    2763             : 
    2764          67 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedEIR(1) = 1.0 / state.dataDXCoils->DXCoil(DXCoilNum).RatedCOP(1);
    2765             : 
    2766          67 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap2 = Numbers(6);
    2767          67 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedSHR2 = Numbers(7);
    2768          67 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedCOP2 = Numbers(8);
    2769          67 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate2 = Numbers(9);
    2770          67 :         if (lNumericBlanks(10)) {
    2771          67 :             state.dataDXCoils->DXCoil(DXCoilNum).MinOATCompressor = -25.0;
    2772             :         } else {
    2773           0 :             state.dataDXCoils->DXCoil(DXCoilNum).MinOATCompressor = Numbers(10);
    2774             :         }
    2775             : 
    2776          67 :         state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp2 = GetCurveIndex(state, Alphas(10)); // convert curve name to number
    2777          67 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp2 == 0) {
    2778           0 :             if (lAlphaBlanks(10)) {
    2779           0 :                 ShowSevereError(state,
    2780           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", missing");
    2781           0 :                 ShowContinueError(state, "...required " + cAlphaFields(10) + " is blank.");
    2782             :             } else {
    2783           0 :                 ShowSevereError(state,
    2784           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    2785           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(10) + "=\"" + Alphas(10) + "\".");
    2786             :             }
    2787           0 :             ErrorsFound = true;
    2788             :         } else {
    2789             :             // Verify Curve Object, only legal type is BiQuadratic
    2790         201 :             ErrorsFound |= Curve::CheckCurveDims(state,
    2791          67 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp2, // Curve index
    2792             :                                                  {2},                                             // Valid dimensions
    2793             :                                                  RoutineName,                                     // Routine name
    2794             :                                                  CurrentModuleObject,                             // Object Type
    2795          67 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).Name,       // Object Name
    2796          67 :                                                  cAlphaFields(10));                               // Field Name
    2797             : 
    2798          67 :             if (!ErrorsFound) {
    2799         335 :                 checkCurveIsNormalizedToOne(state,
    2800         134 :                                             std::string{RoutineName} + CurrentModuleObject,
    2801          67 :                                             state.dataDXCoils->DXCoil(DXCoilNum).Name,
    2802          67 :                                             state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp2,
    2803          67 :                                             cAlphaFields(10),
    2804          67 :                                             Alphas(10),
    2805             :                                             RatedInletWetBulbTemp,
    2806             :                                             RatedOutdoorAirTemp);
    2807             :             }
    2808             :         }
    2809             : 
    2810          67 :         state.dataDXCoils->DXCoil(DXCoilNum).EIRFTemp2 = GetCurveIndex(state, Alphas(11)); // convert curve name to number
    2811          67 :         if (state.dataDXCoils->DXCoil(DXCoilNum).EIRFTemp2 == 0) {
    2812           0 :             if (lAlphaBlanks(11)) {
    2813           0 :                 ShowSevereError(state,
    2814           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", missing");
    2815           0 :                 ShowContinueError(state, "...required " + cAlphaFields(11) + " is blank.");
    2816             :             } else {
    2817           0 :                 ShowSevereError(state,
    2818           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    2819           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(11) + "=\"" + Alphas(11) + "\".");
    2820             :             }
    2821           0 :             ErrorsFound = true;
    2822             :         } else {
    2823             :             // Verify Curve Object, only legal type is BiQuadratic
    2824         201 :             ErrorsFound |= Curve::CheckCurveDims(state,
    2825          67 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).EIRFTemp2, // Curve index
    2826             :                                                  {2},                                            // Valid dimensions
    2827             :                                                  RoutineName,                                    // Routine name
    2828             :                                                  CurrentModuleObject,                            // Object Type
    2829          67 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).Name,      // Object Name
    2830          67 :                                                  cAlphaFields(11));                              // Field Name
    2831             : 
    2832          67 :             if (!ErrorsFound) {
    2833         335 :                 checkCurveIsNormalizedToOne(state,
    2834         134 :                                             std::string{RoutineName} + CurrentModuleObject,
    2835          67 :                                             state.dataDXCoils->DXCoil(DXCoilNum).Name,
    2836          67 :                                             state.dataDXCoils->DXCoil(DXCoilNum).EIRFTemp2,
    2837          67 :                                             cAlphaFields(11),
    2838          67 :                                             Alphas(11),
    2839             :                                             RatedInletWetBulbTemp,
    2840             :                                             RatedOutdoorAirTemp);
    2841             :             }
    2842             :         }
    2843             : 
    2844             :         // outdoor condenser node
    2845          67 :         if (lAlphaBlanks(12)) {
    2846          58 :             state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(1) = 0;
    2847             :         } else {
    2848           9 :             state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(1) =
    2849          27 :                 GetOnlySingleNode(state,
    2850           9 :                                   Alphas(12),
    2851             :                                   ErrorsFound,
    2852             :                                   DataLoopNode::ConnectionObjectType::CoilCoolingDXTwoSpeed,
    2853           9 :                                   state.dataDXCoils->DXCoil(DXCoilNum).Name,
    2854             :                                   DataLoopNode::NodeFluidType::Air,
    2855             :                                   DataLoopNode::ConnectionType::OutsideAirReference,
    2856             :                                   NodeInputManager::CompFluidStream::Primary,
    2857           9 :                                   ObjectIsNotParent);
    2858           9 :             if (!CheckOutAirNodeNumber(state, state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(1))) {
    2859           0 :                 ShowWarningError(
    2860           0 :                     state, std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", may be invalid");
    2861           0 :                 ShowContinueError(
    2862           0 :                     state, cAlphaFields(12) + "=\"" + Alphas(12) + "\", node does not appear in an OutdoorAir:NodeList or as an OutdoorAir:Node.");
    2863           0 :                 ShowContinueError(
    2864             :                     state, "This node needs to be included in an air system or the coil model will not be valid, and the simulation continues");
    2865             :             }
    2866             :         }
    2867             : 
    2868          67 :         if ((UtilityRoutines::SameString(Alphas(13), "AirCooled")) || lAlphaBlanks(13)) {
    2869          66 :             state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(1) = DataHeatBalance::RefrigCondenserType::Air;
    2870           1 :         } else if (UtilityRoutines::SameString(Alphas(13), "EvaporativelyCooled")) {
    2871           1 :             state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(1) = DataHeatBalance::RefrigCondenserType::Evap;
    2872           1 :             state.dataDXCoils->DXCoil(DXCoilNum).ReportEvapCondVars = true;
    2873             :         } else {
    2874           0 :             ShowSevereError(state,
    2875           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    2876           0 :             ShowContinueError(state, "..." + cAlphaFields(13) + "=\"" + Alphas(13) + "\":");
    2877           0 :             ShowContinueError(state, "...must be AirCooled or EvaporativelyCooled.");
    2878           0 :             ErrorsFound = true;
    2879             :         }
    2880             : 
    2881          67 :         state.dataDXCoils->DXCoil(DXCoilNum).EvapCondEffect(1) = Numbers(11);
    2882          67 :         if (state.dataDXCoils->DXCoil(DXCoilNum).EvapCondEffect(1) < 0.0 || state.dataDXCoils->DXCoil(DXCoilNum).EvapCondEffect(1) > 1.0) {
    2883           0 :             ShowSevereError(state,
    2884           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    2885           0 :             ShowContinueError(state, "..." + cNumericFields(11) + " cannot be < 0.0 or > 1.0.");
    2886           0 :             ShowContinueError(state, format("...entered value=[{:.2T}].", Numbers(11)));
    2887           0 :             ErrorsFound = true;
    2888             :         }
    2889             : 
    2890          67 :         state.dataDXCoils->DXCoil(DXCoilNum).EvapCondAirFlow(1) = Numbers(12);
    2891          67 :         if (state.dataDXCoils->DXCoil(DXCoilNum).EvapCondAirFlow(1) < 0.0 && state.dataDXCoils->DXCoil(DXCoilNum).EvapCondAirFlow(1) != AutoSize) {
    2892           0 :             ShowSevereError(state,
    2893           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    2894           0 :             ShowContinueError(state, "..." + cNumericFields(12) + " cannot be < 0.0.");
    2895           0 :             ShowContinueError(state, format("...entered value=[{:.2T}].", Numbers(12)));
    2896           0 :             ErrorsFound = true;
    2897             :         }
    2898             : 
    2899          67 :         state.dataDXCoils->DXCoil(DXCoilNum).EvapCondPumpElecNomPower(1) = Numbers(13);
    2900          67 :         if (state.dataDXCoils->DXCoil(DXCoilNum).EvapCondPumpElecNomPower(1) < 0.0 &&
    2901           0 :             state.dataDXCoils->DXCoil(DXCoilNum).EvapCondPumpElecNomPower(1) != AutoSize) {
    2902           0 :             ShowSevereError(state,
    2903           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    2904           0 :             ShowContinueError(state, "..." + cNumericFields(13) + " cannot be < 0.0.");
    2905           0 :             ShowContinueError(state, format("...entered value=[{:.2T}].", Numbers(13)));
    2906           0 :             ErrorsFound = true;
    2907             :         }
    2908             : 
    2909          67 :         state.dataDXCoils->DXCoil(DXCoilNum).EvapCondEffect2 = Numbers(14);
    2910          67 :         if (state.dataDXCoils->DXCoil(DXCoilNum).EvapCondEffect2 < 0.0 || state.dataDXCoils->DXCoil(DXCoilNum).EvapCondEffect2 > 1.0) {
    2911           0 :             ShowSevereError(state,
    2912           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    2913           0 :             ShowContinueError(state, "..." + cNumericFields(14) + " cannot be cannot be < 0.0 or > 1.0.");
    2914           0 :             ShowContinueError(state, format("...entered value=[{:.2T}].", Numbers(14)));
    2915           0 :             ErrorsFound = true;
    2916             :         }
    2917             : 
    2918          67 :         state.dataDXCoils->DXCoil(DXCoilNum).EvapCondAirFlow2 = Numbers(15);
    2919          67 :         if (state.dataDXCoils->DXCoil(DXCoilNum).EvapCondAirFlow2 < 0.0 && state.dataDXCoils->DXCoil(DXCoilNum).EvapCondAirFlow2 != AutoSize) {
    2920           0 :             ShowSevereError(state,
    2921           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    2922           0 :             ShowContinueError(state, "..." + cNumericFields(15) + " cannot be < 0.0.");
    2923           0 :             ShowContinueError(state, format("...entered value=[{:.2T}].", Numbers(15)));
    2924           0 :             ErrorsFound = true;
    2925             :         }
    2926             : 
    2927          67 :         state.dataDXCoils->DXCoil(DXCoilNum).EvapCondPumpElecNomPower2 = Numbers(16);
    2928          67 :         if (state.dataDXCoils->DXCoil(DXCoilNum).EvapCondPumpElecNomPower2 < 0.0 &&
    2929           0 :             state.dataDXCoils->DXCoil(DXCoilNum).EvapCondPumpElecNomPower2 != AutoSize) {
    2930           0 :             ShowSevereError(state,
    2931           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    2932           0 :             ShowContinueError(state, "..." + cNumericFields(16) + " cannot be < 0.0.");
    2933           0 :             ShowContinueError(state, format("...entered value=[{:.2T}].", Numbers(16)));
    2934           0 :             ErrorsFound = true;
    2935             :         }
    2936             : 
    2937          67 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedEIR2 = 1.0 / state.dataDXCoils->DXCoil(DXCoilNum).RatedCOP2;
    2938             : 
    2939             :         // Get Water System tank connections
    2940             :         //  A14, \field Name of Water Storage Tank for Supply
    2941          67 :         state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterSupplyName = Alphas(14);
    2942          67 :         if (lAlphaBlanks(14)) {
    2943          67 :             state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterSupplyMode = EvapWaterSupply::FromMains;
    2944             :         } else {
    2945           0 :             state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterSupplyMode = EvapWaterSupply::FromTank;
    2946           0 :             SetupTankDemandComponent(state,
    2947           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,
    2948             :                                      CurrentModuleObject,
    2949           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterSupplyName,
    2950             :                                      ErrorsFound,
    2951           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterSupTankID,
    2952           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterTankDemandARRID);
    2953             :         }
    2954             : 
    2955             :         // A15; \field Name of Water Storage Tank for Condensate Collection
    2956          67 :         state.dataDXCoils->DXCoil(DXCoilNum).CondensateCollectName = Alphas(15);
    2957          67 :         if (lAlphaBlanks(15)) {
    2958          67 :             state.dataDXCoils->DXCoil(DXCoilNum).CondensateCollectMode = CondensateCollectAction::Discard;
    2959             :         } else {
    2960           0 :             state.dataDXCoils->DXCoil(DXCoilNum).CondensateCollectMode = CondensateCollectAction::ToTank;
    2961           0 :             SetupTankSupplyComponent(state,
    2962           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,
    2963             :                                      CurrentModuleObject,
    2964           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).CondensateCollectName,
    2965             :                                      ErrorsFound,
    2966           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).CondensateTankID,
    2967           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).CondensateTankSupplyARRID);
    2968             :         }
    2969             : 
    2970             :         // Basin heater power as a function of temperature must be greater than or equal to 0
    2971          67 :         state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterPowerFTempDiff = Numbers(17);
    2972          67 :         if (Numbers(17) < 0.0) {
    2973           0 :             ShowSevereError(state,
    2974           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    2975           0 :             ShowContinueError(state, "..." + cNumericFields(17) + " must be >= 0.0.");
    2976           0 :             ShowContinueError(state, format("...entered value=[{:.2T}].", Numbers(17)));
    2977           0 :             ErrorsFound = true;
    2978             :         }
    2979             : 
    2980          67 :         state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterSetPointTemp = Numbers(18);
    2981          67 :         if (state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterPowerFTempDiff > 0.0) {
    2982           1 :             if (NumNumbers < 18) {
    2983           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterSetPointTemp = 2.0;
    2984             :             }
    2985           1 :             if (state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterSetPointTemp < 2.0) {
    2986           0 :                 ShowWarningError(state,
    2987           0 :                                  std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name +
    2988             :                                      "\", freeze possible");
    2989           0 :                 ShowContinueError(state, "..." + cNumericFields(18) + " is < 2 {C}. Freezing could occur.");
    2990           0 :                 ShowContinueError(state, format("...entered value=[{:.2T}].", Numbers(18)));
    2991             :             }
    2992             :         }
    2993             : 
    2994          67 :         if (!lAlphaBlanks(16)) {
    2995           1 :             state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterSchedulePtr = GetScheduleIndex(state, Alphas(16));
    2996           1 :             if (state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterSchedulePtr == 0) {
    2997           0 :                 ShowWarningError(state,
    2998           0 :                                  std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    2999           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(16) + "=\"" + Alphas(16) + "\".");
    3000           0 :                 ShowContinueError(state, "Basin heater will be available to operate throughout the simulation.");
    3001             :             }
    3002             :         }
    3003             : 
    3004          67 :         if (!lAlphaBlanks(17) && NumAlphas > 16) {
    3005           1 :             state.dataDXCoils->DXCoil(DXCoilNum).SHRFTemp(1) = GetCurveIndex(state, Alphas(17)); // convert curve name to number
    3006             :             // DXCoil(DXCoilNum)%SHRFTemp2 = DXCoil(DXCoilNum)%SHRFTemp(1)
    3007           1 :             if (state.dataDXCoils->DXCoil(DXCoilNum).SHRFTemp(1) == 0) {
    3008           0 :                 ShowSevereError(state,
    3009           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3010           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(17) + "=\"" + Alphas(17) + "\".");
    3011             :             } else {
    3012             :                 // Verify Curve Object, only legal type is BiQuadratic
    3013           3 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    3014           1 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).SHRFTemp(1), // Curve index
    3015             :                                                      {2},                                              // Valid dimensions
    3016             :                                                      RoutineName,                                      // Routine name
    3017             :                                                      CurrentModuleObject,                              // Object Type
    3018           1 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,        // Object Name
    3019           1 :                                                      cAlphaFields(17));                                // Field Name
    3020             :             }
    3021             :         }
    3022             : 
    3023          67 :         if (!lAlphaBlanks(18) && NumAlphas > 17) {
    3024           1 :             state.dataDXCoils->DXCoil(DXCoilNum).SHRFFlow(1) = GetCurveIndex(state, Alphas(18)); // convert curve name to number
    3025             :             // DXCoil(DXCoilNum)%SHRFFlow2 = DXCoil(DXCoilNum)%SHRFFlow(1)
    3026           1 :             if (state.dataDXCoils->DXCoil(DXCoilNum).SHRFFlow(1) == 0) {
    3027           0 :                 ShowSevereError(state,
    3028           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3029           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(18) + "=\"" + Alphas(18) + "\".");
    3030             :             } else {
    3031             :                 // Verify Curve Object, only legal type is BiQuadratic
    3032           3 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    3033           1 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).SHRFFlow(1), // Curve index
    3034             :                                                      {1},                                              // Valid dimensions
    3035             :                                                      RoutineName,                                      // Routine name
    3036             :                                                      CurrentModuleObject,                              // Object Type
    3037           1 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,        // Object Name
    3038           1 :                                                      cAlphaFields(18));                                // Field Name
    3039             :             }
    3040             :         }
    3041             : 
    3042          67 :         if (!lAlphaBlanks(19) && NumAlphas > 18) {
    3043           1 :             state.dataDXCoils->DXCoil(DXCoilNum).SHRFTemp2 = GetCurveIndex(state, Alphas(19)); // convert curve name to number
    3044           1 :             if (state.dataDXCoils->DXCoil(DXCoilNum).SHRFTemp2 == 0) {
    3045           0 :                 ShowSevereError(state,
    3046           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3047           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(19) + "=\"" + Alphas(19) + "\".");
    3048             :             } else {
    3049             :                 // Verify Curve Object, only legal type is BiQuadratic
    3050           3 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    3051           1 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).SHRFTemp2, // Curve index
    3052             :                                                      {2},                                            // Valid dimensions
    3053             :                                                      RoutineName,                                    // Routine name
    3054             :                                                      CurrentModuleObject,                            // Object Type
    3055           1 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,      // Object Name
    3056           1 :                                                      cAlphaFields(19));                              // Field Name
    3057             :             }
    3058             :         }
    3059             : 
    3060          67 :         if (!lAlphaBlanks(20) && NumAlphas > 19) {
    3061           1 :             state.dataDXCoils->DXCoil(DXCoilNum).SHRFFlow2 = GetCurveIndex(state, Alphas(20)); // convert curve name to number
    3062           1 :             if (state.dataDXCoils->DXCoil(DXCoilNum).SHRFTemp2 == 0) {
    3063           0 :                 ShowSevereError(state,
    3064           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3065           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(20) + "=\"" + Alphas(20) + "\".");
    3066             :             } else {
    3067             :                 // Verify Curve Object, only legal type is BiQuadratic
    3068           3 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    3069           1 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).SHRFFlow2, // Curve index
    3070             :                                                      {1},                                            // Valid dimensions
    3071             :                                                      RoutineName,                                    // Routine name
    3072             :                                                      CurrentModuleObject,                            // Object Type
    3073           1 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,      // Object Name
    3074           1 :                                                      cAlphaFields(20));                              // Field Name
    3075             :             }
    3076             :         }
    3077         136 :         if (state.dataDXCoils->DXCoil(DXCoilNum).SHRFTemp(1) > 0 && state.dataDXCoils->DXCoil(DXCoilNum).SHRFFlow(1) > 0 &&
    3078          69 :             state.dataDXCoils->DXCoil(DXCoilNum).SHRFTemp2 > 0 && state.dataDXCoils->DXCoil(DXCoilNum).SHRFFlow2 > 0) {
    3079           1 :             state.dataDXCoils->DXCoil(DXCoilNum).UserSHRCurveExists = true;
    3080             :         } else {
    3081          66 :             state.dataDXCoils->DXCoil(DXCoilNum).UserSHRCurveExists = false;
    3082             :         }
    3083             :         // A21; \field Zone Name for Condenser Placement
    3084          67 :         if (!lAlphaBlanks(21) && NumAlphas > 20) {
    3085           0 :             state.dataDXCoils->DXCoil(DXCoilNum).SecZonePtr = UtilityRoutines::FindItemInList(Alphas(21), state.dataHeatBal->Zone);
    3086           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).SecZonePtr > 0) {
    3087           0 :                 SetupZoneInternalGain(state,
    3088           0 :                                       state.dataDXCoils->DXCoil(DXCoilNum).SecZonePtr,
    3089           0 :                                       state.dataDXCoils->DXCoil(DXCoilNum).Name,
    3090             :                                       DataHeatBalance::IntGainType::SecCoolingDXCoilTwoSpeed,
    3091           0 :                                       &state.dataDXCoils->DXCoil(DXCoilNum).SecCoilSensibleHeatGainRate);
    3092           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).IsSecondaryDXCoilInZone = true;
    3093             :             } else {
    3094           0 :                 ShowSevereError(state,
    3095           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3096           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(21) + "=\"" + Alphas(21) + "\".");
    3097             :             }
    3098             :         }
    3099             :     }
    3100             : 
    3101         241 :     if (ErrorsFound) {
    3102           0 :         ShowFatalError(state,
    3103           0 :                        std::string{RoutineName} + "Errors found in getting " + CurrentModuleObject +
    3104             :                            " input.  Preceding condition(s) causes termination.");
    3105             :     }
    3106             : 
    3107             :     // Loop over the Pumped DX Water Heater Coils and get & load the data
    3108         241 :     CurrentModuleObject = cAllCoilTypes(CoilDX_HeatPumpWaterHeaterPumped);
    3109         254 :     for (DXHPWaterHeaterCoilNum = 1; DXHPWaterHeaterCoilNum <= state.dataDXCoils->NumDXHeatPumpWaterHeaterPumpedCoils; ++DXHPWaterHeaterCoilNum) {
    3110             : 
    3111          13 :         state.dataInputProcessing->inputProcessor->getObjectItem(state,
    3112             :                                                                  CurrentModuleObject,
    3113             :                                                                  DXHPWaterHeaterCoilNum,
    3114             :                                                                  Alphas,
    3115             :                                                                  NumAlphas,
    3116             :                                                                  Numbers,
    3117             :                                                                  NumNumbers,
    3118             :                                                                  IOStatus,
    3119             :                                                                  lNumericBlanks,
    3120             :                                                                  lAlphaBlanks,
    3121             :                                                                  cAlphaFields,
    3122             :                                                                  cNumericFields);
    3123             : 
    3124          13 :         ++DXCoilNum;
    3125             : 
    3126             :         // allocate single performance mode for numeric field strings used for sizing routine
    3127          13 :         state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode.allocate(1);
    3128          13 :         state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(1).FieldNames.allocate(MaxNumbers);
    3129          13 :         state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(1).FieldNames = cNumericFields;
    3130          13 :         UtilityRoutines::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    3131             :         // ErrorsFound will be set to True if problem was found, left untouched otherwise
    3132          13 :         VerifyUniqueCoilName(state, CurrentModuleObject, Alphas(1), ErrorsFound, CurrentModuleObject + " Name");
    3133             : 
    3134          13 :         state.dataDXCoils->DXCoil(DXCoilNum).Name = Alphas(1);
    3135          13 :         state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType = CurrentModuleObject;
    3136          13 :         state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num = CoilDX_HeatPumpWaterHeaterPumped;
    3137          13 :         state.dataDXCoils->DXCoil(DXCoilNum).SchedPtr = 0; // heat pump water heater DX coil has no schedule
    3138             : 
    3139             :         // Store the HPWH DX coil heating capacity in RatedTotCap2. After backing off pump and fan heat,
    3140             :         // move to RatedTotCap() for use by DX coil
    3141          13 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap2 = Numbers(1);
    3142          13 :         if (state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap2 <= 0.0) {
    3143           0 :             ShowSevereError(state,
    3144           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3145           0 :             ShowContinueError(state, format("...{} must be > 0.0, entered value=[{:.2T}].", cNumericFields(1), Numbers(1)));
    3146           0 :             ErrorsFound = true;
    3147             :         }
    3148             : 
    3149          13 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedCOP(1) = Numbers(2);
    3150          13 :         if (state.dataDXCoils->DXCoil(DXCoilNum).RatedCOP(1) <= 0.0) {
    3151           0 :             ShowSevereError(state,
    3152           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3153           0 :             ShowContinueError(state, format("...{} must be > 0.0, entered value=[{:.2T}].", cNumericFields(2), Numbers(2)));
    3154           0 :             ErrorsFound = true;
    3155             :         }
    3156             : 
    3157          13 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedSHR(1) = Numbers(3);
    3158          13 :         if (state.dataDXCoils->DXCoil(DXCoilNum).RatedSHR(1) <= 0.0 || state.dataDXCoils->DXCoil(DXCoilNum).RatedSHR(1) > 1.0) {
    3159           0 :             ShowSevereError(state,
    3160           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3161           0 :             ShowContinueError(state, format("...{} must be > 0 and <= 1.  entered value=[{:.3T}].", cNumericFields(3), Numbers(3)));
    3162             : 
    3163           0 :             ErrorsFound = true;
    3164             :         }
    3165             : 
    3166          13 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedInletDBTemp = Numbers(4);
    3167          13 :         if (state.dataDXCoils->DXCoil(DXCoilNum).RatedInletDBTemp <= 5.0) {
    3168           0 :             ShowSevereError(state,
    3169           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3170           0 :             ShowContinueError(state, format("...{} must be > 5 {{C}}.  entered value=[{:.1T}].", cNumericFields(4), Numbers(4)));
    3171           0 :             ErrorsFound = true;
    3172             :         }
    3173             : 
    3174          13 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedInletWBTemp = Numbers(5);
    3175          13 :         if (state.dataDXCoils->DXCoil(DXCoilNum).RatedInletWBTemp <= 5.0) {
    3176           0 :             ShowSevereError(state,
    3177           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3178           0 :             ShowContinueError(state, format("...{} must be > 5 {{C}}.  entered value=[{:.1T}].", cNumericFields(5), Numbers(5)));
    3179           0 :             ErrorsFound = true;
    3180             :         }
    3181             : 
    3182          13 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedInletWaterTemp = Numbers(6);
    3183          13 :         if (state.dataDXCoils->DXCoil(DXCoilNum).RatedInletWaterTemp <= 25.0) {
    3184           0 :             ShowSevereError(state,
    3185           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3186           0 :             ShowContinueError(state, format("...{} must be > 25 {{C}}.  entered value=[{:.1T}].", cNumericFields(6), Numbers(6)));
    3187           0 :             ErrorsFound = true;
    3188             :         }
    3189             : 
    3190          13 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(1) = Numbers(7);
    3191          13 :         if (state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(1) != DataGlobalConstants::AutoCalculate) {
    3192           7 :             if (state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(1) <= 0.0) {
    3193           0 :                 ShowSevereError(state,
    3194           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3195           0 :                 ShowContinueError(state, format("...{} must be > 0.0.  entered value=[{:.3T}].", cNumericFields(7), Numbers(7)));
    3196           0 :                 ErrorsFound = true;
    3197             :             }
    3198             :         }
    3199             : 
    3200          13 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedHPWHCondWaterFlow = Numbers(8);
    3201             :         // move to init
    3202          13 :         if (state.dataDXCoils->DXCoil(DXCoilNum).RatedHPWHCondWaterFlow != DataGlobalConstants::AutoCalculate) {
    3203           7 :             if (state.dataDXCoils->DXCoil(DXCoilNum).RatedHPWHCondWaterFlow <= 0.0) {
    3204           0 :                 ShowSevereError(state,
    3205           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3206           0 :                 ShowContinueError(state, format("...{} must be > 0.0  entered value=[{:.3T}].", cNumericFields(8), Numbers(8)));
    3207           0 :                 ErrorsFound = true;
    3208             :             }
    3209             :             //   check the range of flow rate to be >= 1 gpm/ton and <= 5 gpm/ton
    3210          14 :             if (state.dataDXCoils->DXCoil(DXCoilNum).RatedHPWHCondWaterFlow / state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap2 < 1.79405e-8 ||
    3211           7 :                 state.dataDXCoils->DXCoil(DXCoilNum).RatedHPWHCondWaterFlow / state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap2 > 8.97024e-8) {
    3212           0 :                 ShowWarningError(
    3213           0 :                     state, std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", outside range");
    3214           0 :                 ShowContinueError(
    3215             :                     state,
    3216           0 :                     "..." + cNumericFields(8) + " per watt of " + cNumericFields(1) +
    3217             :                         " is outside the recommended range of >= 1.79405E-8 m3/s/W (0.083 gpm/MBH) and <= 8.97024E-8 m3/s/W (0.417 gpm/MBH).");
    3218           0 :                 ShowContinueError(
    3219             :                     state,
    3220           0 :                     format("...Entered Flow rate per watt = [{:.10T}].",
    3221           0 :                            (state.dataDXCoils->DXCoil(DXCoilNum).RatedHPWHCondWaterFlow / state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap2)));
    3222             :             }
    3223             :         }
    3224             : 
    3225          13 :         if (UtilityRoutines::SameString(Alphas(2), "Yes") || UtilityRoutines::SameString(Alphas(2), "No")) {
    3226             :             //  initialized to TRUE on allocate
    3227          13 :             if (UtilityRoutines::SameString(Alphas(2), "No")) state.dataDXCoils->DXCoil(DXCoilNum).FanPowerIncludedInCOP = false;
    3228             :         } else {
    3229           0 :             ShowSevereError(state,
    3230           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3231           0 :             ShowContinueError(state, ",,,invalid choice for " + cAlphaFields(2) + ".  Entered choice = " + Alphas(2));
    3232           0 :             ShowContinueError(state, "Valid choices are Yes or No.");
    3233           0 :             ErrorsFound = true;
    3234             :         }
    3235             : 
    3236          13 :         if (UtilityRoutines::SameString(Alphas(3), "Yes") || UtilityRoutines::SameString(Alphas(3), "No")) {
    3237             :             //  initialized to FALSE on allocate
    3238          13 :             if (UtilityRoutines::SameString(Alphas(3), "Yes")) state.dataDXCoils->DXCoil(DXCoilNum).CondPumpPowerInCOP = true;
    3239             :         } else {
    3240           0 :             ShowSevereError(state,
    3241           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3242           0 :             ShowContinueError(state, ",,,invalid choice for " + cAlphaFields(3) + ".  Entered choice = " + Alphas(3));
    3243           0 :             ShowContinueError(state, "Valid choices are Yes or No.");
    3244           0 :             ErrorsFound = true;
    3245             :         }
    3246             : 
    3247          13 :         if (UtilityRoutines::SameString(Alphas(4), "Yes") || UtilityRoutines::SameString(Alphas(4), "No")) {
    3248             :             //  initialized to FALSE on allocate
    3249          13 :             if (UtilityRoutines::SameString(Alphas(4), "Yes")) state.dataDXCoils->DXCoil(DXCoilNum).CondPumpHeatInCapacity = true;
    3250             :         } else {
    3251           0 :             ShowSevereError(state,
    3252           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3253           0 :             ShowContinueError(state, ",,,invalid choice for " + cAlphaFields(4) + ".  Entered choice = " + Alphas(4));
    3254           0 :             ShowContinueError(state, "Valid choices are Yes or No.");
    3255           0 :             ErrorsFound = true;
    3256             :         }
    3257             : 
    3258          13 :         state.dataDXCoils->DXCoil(DXCoilNum).HPWHCondPumpElecNomPower = Numbers(9);
    3259          13 :         if (state.dataDXCoils->DXCoil(DXCoilNum).HPWHCondPumpElecNomPower < 0.0) {
    3260           0 :             ShowSevereError(state,
    3261           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3262           0 :             ShowContinueError(state, format("...{} must be >= 0.0  entered value=[{:.3T}].", cNumericFields(9), Numbers(9)));
    3263           0 :             ErrorsFound = true;
    3264             :         }
    3265             : 
    3266          13 :         state.dataDXCoils->DXCoil(DXCoilNum).HPWHCondPumpFracToWater = Numbers(10);
    3267          26 :         if (state.dataDXCoils->DXCoil(DXCoilNum).HPWHCondPumpFracToWater <= 0.0 ||
    3268          13 :             state.dataDXCoils->DXCoil(DXCoilNum).HPWHCondPumpFracToWater > 1.0) {
    3269           0 :             ShowSevereError(state,
    3270           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3271           0 :             ShowContinueError(state, format("...{} must be >= 0 and <= 1.  entered value=[{:.3T}].", cNumericFields(10), Numbers(10)));
    3272           0 :             ErrorsFound = true;
    3273             :         }
    3274             : 
    3275             :         // Air nodes
    3276          13 :         state.dataDXCoils->DXCoil(DXCoilNum).AirInNode =
    3277          26 :             GetOnlySingleNode(state,
    3278          13 :                               Alphas(5),
    3279             :                               ErrorsFound,
    3280             :                               DataLoopNode::ConnectionObjectType::CoilWaterHeatingAirToWaterHeatPumpPumped,
    3281          13 :                               Alphas(1),
    3282             :                               DataLoopNode::NodeFluidType::Air,
    3283             :                               DataLoopNode::ConnectionType::Inlet,
    3284             :                               NodeInputManager::CompFluidStream::Primary,
    3285          13 :                               ObjectIsNotParent);
    3286             : 
    3287          13 :         state.dataDXCoils->DXCoil(DXCoilNum).AirOutNode =
    3288          26 :             GetOnlySingleNode(state,
    3289          13 :                               Alphas(6),
    3290             :                               ErrorsFound,
    3291             :                               DataLoopNode::ConnectionObjectType::CoilWaterHeatingAirToWaterHeatPumpPumped,
    3292          13 :                               Alphas(1),
    3293             :                               DataLoopNode::NodeFluidType::Air,
    3294             :                               DataLoopNode::ConnectionType::Outlet,
    3295             :                               NodeInputManager::CompFluidStream::Primary,
    3296          13 :                               ObjectIsNotParent);
    3297             : 
    3298          13 :         TestCompSet(state, CurrentModuleObject, Alphas(1), Alphas(5), Alphas(6), "Air Nodes");
    3299             : 
    3300             :         // Check if the air inlet node is OA node, to justify whether the coil is placed in zone or not
    3301          13 :         state.dataDXCoils->DXCoil(DXCoilNum).IsDXCoilInZone = !CheckOutAirNodeNumber(state, state.dataDXCoils->DXCoil(DXCoilNum).AirInNode);
    3302             : 
    3303             :         // Water nodes
    3304          13 :         state.dataDXCoils->DXCoil(DXCoilNum).WaterInNode =
    3305          26 :             GetOnlySingleNode(state,
    3306          13 :                               Alphas(7),
    3307             :                               ErrorsFound,
    3308             :                               DataLoopNode::ConnectionObjectType::CoilWaterHeatingAirToWaterHeatPumpPumped,
    3309          13 :                               Alphas(1),
    3310             :                               DataLoopNode::NodeFluidType::Water,
    3311             :                               DataLoopNode::ConnectionType::Inlet,
    3312             :                               NodeInputManager::CompFluidStream::Secondary,
    3313          13 :                               ObjectIsNotParent);
    3314             : 
    3315          13 :         state.dataDXCoils->DXCoil(DXCoilNum).WaterOutNode =
    3316          26 :             GetOnlySingleNode(state,
    3317          13 :                               Alphas(8),
    3318             :                               ErrorsFound,
    3319             :                               DataLoopNode::ConnectionObjectType::CoilWaterHeatingAirToWaterHeatPumpPumped,
    3320          13 :                               Alphas(1),
    3321             :                               DataLoopNode::NodeFluidType::Water,
    3322             :                               DataLoopNode::ConnectionType::Outlet,
    3323             :                               NodeInputManager::CompFluidStream::Secondary,
    3324          13 :                               ObjectIsNotParent);
    3325             : 
    3326          13 :         TestCompSet(state, CurrentModuleObject, Alphas(1), Alphas(7), Alphas(8), "Water Nodes");
    3327             : 
    3328          13 :         state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterCapacity = Numbers(11);
    3329          13 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterCapacity < 0.0) {
    3330           0 :             ShowSevereError(state,
    3331           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3332           0 :             ShowContinueError(state, format("...{} must be >= 0.0  entered value=[{:.1T}].", cNumericFields(11), Numbers(11)));
    3333           0 :             ErrorsFound = true;
    3334             :         }
    3335             : 
    3336          13 :         state.dataDXCoils->DXCoil(DXCoilNum).MaxOATCrankcaseHeater = Numbers(12);
    3337          13 :         if (state.dataDXCoils->DXCoil(DXCoilNum).MaxOATCrankcaseHeater < 0.0) {
    3338           0 :             ShowSevereError(state,
    3339           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3340           0 :             ShowContinueError(state, format("...{} must be >= 0 {{C}}.  entered value=[{:.1T}].", cNumericFields(12), Numbers(12)));
    3341           0 :             ErrorsFound = true;
    3342             :         }
    3343             : 
    3344          13 :         if (UtilityRoutines::SameString(Alphas(9), "DryBulbTemperature")) {
    3345           0 :             state.dataDXCoils->DXCoil(DXCoilNum).InletAirTemperatureType = DryBulbIndicator;
    3346          13 :         } else if (UtilityRoutines::SameString(Alphas(9), "WetBulbTemperature")) {
    3347          13 :             state.dataDXCoils->DXCoil(DXCoilNum).InletAirTemperatureType = WetBulbIndicator;
    3348             :         } else {
    3349             :             //   wrong temperature type selection
    3350           0 :             ShowSevereError(state,
    3351           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3352           0 :             ShowContinueError(state, "..." + cAlphaFields(9) + " must be DryBulbTemperature or WetBulbTemperature.");
    3353           0 :             ShowContinueError(state, "...entered value=\"" + Alphas(9) + "\".");
    3354           0 :             ErrorsFound = true;
    3355             :         }
    3356             : 
    3357             :         // set rated inlet air temperature for curve object verification
    3358          13 :         if (state.dataDXCoils->DXCoil(DXCoilNum).InletAirTemperatureType == WetBulbIndicator) {
    3359          13 :             InletAirTemp = state.dataDXCoils->DXCoil(DXCoilNum).RatedInletWBTemp;
    3360             :         } else {
    3361           0 :             InletAirTemp = state.dataDXCoils->DXCoil(DXCoilNum).RatedInletDBTemp;
    3362             :         }
    3363             :         // set rated water temperature for curve object verification
    3364          13 :         InletWaterTemp = state.dataDXCoils->DXCoil(DXCoilNum).RatedInletWaterTemp;
    3365             : 
    3366          13 :         if (!lAlphaBlanks(10)) {
    3367          13 :             state.dataDXCoils->DXCoil(DXCoilNum).HCapFTemp = GetCurveIndex(state, Alphas(10));
    3368          13 :             if (state.dataDXCoils->DXCoil(DXCoilNum).HCapFTemp == 0) {
    3369           0 :                 ShowSevereError(state,
    3370           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3371           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(10) + "=\"" + Alphas(10) + "\".");
    3372           0 :                 ErrorsFound = true;
    3373             :             } else {
    3374             :                 // Verify Curve Object, only legal types are BiQuadratic or Cubic
    3375          39 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    3376          13 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).HCapFTemp, // Curve index
    3377             :                                                      {1, 2},                                         // Valid dimensions
    3378             :                                                      RoutineName,                                    // Routine name
    3379             :                                                      CurrentModuleObject,                            // Object Type
    3380          13 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,      // Object Name
    3381          13 :                                                      cAlphaFields(10));                              // Field Name
    3382             : 
    3383          13 :                 if (!ErrorsFound) {
    3384          13 :                     if (state.dataCurveManager->PerfCurve(state.dataDXCoils->DXCoil(DXCoilNum).HCapFTemp).numDims == 1) {
    3385           0 :                         checkCurveIsNormalizedToOne(state,
    3386           0 :                                                     std::string{RoutineName} + CurrentModuleObject,
    3387           0 :                                                     state.dataDXCoils->DXCoil(DXCoilNum).Name,
    3388           0 :                                                     state.dataDXCoils->DXCoil(DXCoilNum).HCapFTemp,
    3389           0 :                                                     cAlphaFields(10),
    3390           0 :                                                     Alphas(10),
    3391             :                                                     InletAirTemp);
    3392             :                     } else {
    3393          65 :                         checkCurveIsNormalizedToOne(state,
    3394          26 :                                                     std::string{RoutineName} + CurrentModuleObject,
    3395          13 :                                                     state.dataDXCoils->DXCoil(DXCoilNum).Name,
    3396          13 :                                                     state.dataDXCoils->DXCoil(DXCoilNum).HCapFTemp,
    3397          13 :                                                     cAlphaFields(10),
    3398          13 :                                                     Alphas(10),
    3399             :                                                     InletAirTemp,
    3400             :                                                     InletWaterTemp);
    3401             :                     }
    3402             :                 }
    3403             :             }
    3404             :         }
    3405             : 
    3406          13 :         if (!lAlphaBlanks(11)) {
    3407           0 :             state.dataDXCoils->DXCoil(DXCoilNum).HCapFAirFlow = GetCurveIndex(state, Alphas(11));
    3408           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).HCapFAirFlow == 0) {
    3409           0 :                 ShowSevereError(state,
    3410           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3411           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(11) + "=\"" + Alphas(11) + "\".");
    3412           0 :                 ErrorsFound = true;
    3413             :             } else {
    3414             :                 // Verify Curve Object, only legal types are Cubic or Quadratic
    3415           0 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    3416           0 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).HCapFAirFlow, // Curve index
    3417             :                                                      {1},                                               // Valid dimensions
    3418             :                                                      RoutineName,                                       // Routine name
    3419             :                                                      CurrentModuleObject,                               // Object Type
    3420           0 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,         // Object Name
    3421           0 :                                                      cAlphaFields(11));                                 // Field Name
    3422             : 
    3423           0 :                 if (!ErrorsFound) {
    3424           0 :                     checkCurveIsNormalizedToOne(state,
    3425           0 :                                                 std::string{RoutineName} + CurrentModuleObject,
    3426           0 :                                                 state.dataDXCoils->DXCoil(DXCoilNum).Name,
    3427           0 :                                                 state.dataDXCoils->DXCoil(DXCoilNum).HCapFAirFlow,
    3428           0 :                                                 cAlphaFields(11),
    3429           0 :                                                 Alphas(11),
    3430             :                                                 1.0);
    3431             :                 }
    3432             :             }
    3433             :         }
    3434             : 
    3435          13 :         if (!lAlphaBlanks(12)) {
    3436           0 :             state.dataDXCoils->DXCoil(DXCoilNum).HCapFWaterFlow = GetCurveIndex(state, Alphas(12));
    3437           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).HCapFWaterFlow == 0) {
    3438           0 :                 ShowSevereError(state,
    3439           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3440           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(12) + "=\"" + Alphas(12) + "\".");
    3441           0 :                 ErrorsFound = true;
    3442             :             } else {
    3443             :                 // Verify Curve Object, only legal types are Cubic or Quadratic
    3444           0 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    3445           0 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).HCapFWaterFlow, // Curve index
    3446             :                                                      {1},                                                 // Valid dimensions
    3447             :                                                      RoutineName,                                         // Routine name
    3448             :                                                      CurrentModuleObject,                                 // Object Type
    3449           0 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,           // Object Name
    3450           0 :                                                      cAlphaFields(12));                                   // Field Name
    3451             : 
    3452           0 :                 if (!ErrorsFound) {
    3453           0 :                     checkCurveIsNormalizedToOne(state,
    3454           0 :                                                 std::string{RoutineName} + CurrentModuleObject,
    3455           0 :                                                 state.dataDXCoils->DXCoil(DXCoilNum).Name,
    3456           0 :                                                 state.dataDXCoils->DXCoil(DXCoilNum).HCapFWaterFlow,
    3457           0 :                                                 cAlphaFields(12),
    3458           0 :                                                 Alphas(12),
    3459             :                                                 1.0);
    3460             :                 }
    3461             :             }
    3462             :         }
    3463             : 
    3464          13 :         if (!lAlphaBlanks(13)) {
    3465          13 :             state.dataDXCoils->DXCoil(DXCoilNum).HCOPFTemp = GetCurveIndex(state, Alphas(13));
    3466          13 :             if (state.dataDXCoils->DXCoil(DXCoilNum).HCOPFTemp == 0) {
    3467           0 :                 ShowSevereError(state,
    3468           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3469           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(13) + "=\"" + Alphas(13) + "\".");
    3470           0 :                 ErrorsFound = true;
    3471             :             } else {
    3472             :                 // Verify Curve Object, only legal types are BiQuadratic or Cubic
    3473          39 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    3474          13 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).HCOPFTemp, // Curve index
    3475             :                                                      {1, 2},                                         // Valid dimensions
    3476             :                                                      RoutineName,                                    // Routine name
    3477             :                                                      CurrentModuleObject,                            // Object Type
    3478          13 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,      // Object Name
    3479          13 :                                                      cAlphaFields(13));                              // Field Name
    3480             : 
    3481          13 :                 if (!ErrorsFound) {
    3482          13 :                     if (state.dataCurveManager->PerfCurve(state.dataDXCoils->DXCoil(DXCoilNum).HCOPFTemp).numDims == 1) {
    3483           0 :                         checkCurveIsNormalizedToOne(state,
    3484           0 :                                                     std::string{RoutineName} + CurrentModuleObject,
    3485           0 :                                                     state.dataDXCoils->DXCoil(DXCoilNum).Name,
    3486           0 :                                                     state.dataDXCoils->DXCoil(DXCoilNum).HCOPFTemp,
    3487           0 :                                                     cAlphaFields(13),
    3488           0 :                                                     Alphas(13),
    3489             :                                                     InletAirTemp);
    3490             :                     } else {
    3491          65 :                         checkCurveIsNormalizedToOne(state,
    3492          26 :                                                     std::string{RoutineName} + CurrentModuleObject,
    3493          13 :                                                     state.dataDXCoils->DXCoil(DXCoilNum).Name,
    3494          13 :                                                     state.dataDXCoils->DXCoil(DXCoilNum).HCOPFTemp,
    3495          13 :                                                     cAlphaFields(13),
    3496          13 :                                                     Alphas(13),
    3497             :                                                     InletAirTemp,
    3498             :                                                     InletWaterTemp);
    3499             :                     }
    3500             :                 }
    3501             :             }
    3502             :         }
    3503             : 
    3504          13 :         if (!lAlphaBlanks(14)) {
    3505           0 :             state.dataDXCoils->DXCoil(DXCoilNum).HCOPFAirFlow = GetCurveIndex(state, Alphas(14));
    3506           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).HCOPFAirFlow == 0) {
    3507           0 :                 ShowSevereError(state,
    3508           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3509           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(14) + "=\"" + Alphas(14) + "\".");
    3510           0 :                 ErrorsFound = true;
    3511             :             } else {
    3512             :                 // Verify Curve Object, only legal types are Cubic or Quadratic
    3513           0 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    3514           0 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).HCOPFAirFlow, // Curve index
    3515             :                                                      {1},                                               // Valid dimensions
    3516             :                                                      RoutineName,                                       // Routine name
    3517             :                                                      CurrentModuleObject,                               // Object Type
    3518           0 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,         // Object Name
    3519           0 :                                                      cAlphaFields(14));                                 // Field Name
    3520             : 
    3521           0 :                 if (!ErrorsFound) {
    3522           0 :                     checkCurveIsNormalizedToOne(state,
    3523           0 :                                                 std::string{RoutineName} + CurrentModuleObject,
    3524           0 :                                                 state.dataDXCoils->DXCoil(DXCoilNum).Name,
    3525           0 :                                                 state.dataDXCoils->DXCoil(DXCoilNum).HCOPFAirFlow,
    3526           0 :                                                 cAlphaFields(14),
    3527           0 :                                                 Alphas(14),
    3528             :                                                 1.0);
    3529             :                 }
    3530             :             }
    3531             :         }
    3532             : 
    3533          13 :         if (!lAlphaBlanks(15)) {
    3534           0 :             state.dataDXCoils->DXCoil(DXCoilNum).HCOPFWaterFlow = GetCurveIndex(state, Alphas(15));
    3535           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).HCOPFWaterFlow == 0) {
    3536           0 :                 ShowSevereError(state,
    3537           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3538           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(15) + "=\"" + Alphas(15) + "\".");
    3539           0 :                 ErrorsFound = true;
    3540             :             } else {
    3541             :                 // Verify Curve Object, only legal types are Cubic or Quadratic
    3542           0 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    3543           0 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).HCOPFWaterFlow, // Curve index
    3544             :                                                      {1},                                                 // Valid dimensions
    3545             :                                                      RoutineName,                                         // Routine name
    3546             :                                                      CurrentModuleObject,                                 // Object Type
    3547           0 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,           // Object Name
    3548           0 :                                                      cAlphaFields(15));                                   // Field Name
    3549             : 
    3550           0 :                 if (!ErrorsFound) {
    3551           0 :                     checkCurveIsNormalizedToOne(state,
    3552           0 :                                                 std::string{RoutineName} + CurrentModuleObject,
    3553           0 :                                                 state.dataDXCoils->DXCoil(DXCoilNum).Name,
    3554           0 :                                                 state.dataDXCoils->DXCoil(DXCoilNum).HCOPFWaterFlow,
    3555           0 :                                                 cAlphaFields(15),
    3556           0 :                                                 Alphas(15),
    3557             :                                                 1.0);
    3558             :                 }
    3559             :             }
    3560             :         }
    3561             : 
    3562          13 :         if (!lAlphaBlanks(16)) {
    3563          13 :             state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(1) = GetCurveIndex(state, Alphas(16));
    3564          13 :             if (state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(1) == 0) {
    3565           0 :                 ShowSevereError(state,
    3566           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3567           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(16) + "=\"" + Alphas(16) + "\".");
    3568           0 :                 ErrorsFound = true;
    3569             :             } else {
    3570             :                 // Verify Curve Object, only legal types are Cubic or Quadratic
    3571          39 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    3572          13 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(1), // Curve index
    3573             :                                                      {1},                                             // Valid dimensions
    3574             :                                                      RoutineName,                                     // Routine name
    3575             :                                                      CurrentModuleObject,                             // Object Type
    3576          13 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,       // Object Name
    3577          13 :                                                      cAlphaFields(16));                               // Field Name
    3578             : 
    3579          13 :                 if (!ErrorsFound) {
    3580             :                     //       Test PLF curve minimum and maximum. Cap if less than 0.7 or greater than 1.0.
    3581          13 :                     MinCurveVal = 999.0;
    3582          13 :                     MaxCurveVal = -999.0;
    3583          13 :                     CurveInput = 0.0;
    3584        2613 :                     while (CurveInput <= 1.0) {
    3585        1300 :                         CurveVal = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(1), CurveInput);
    3586        1300 :                         if (CurveVal < MinCurveVal) {
    3587          13 :                             MinCurveVal = CurveVal;
    3588          13 :                             MinCurvePLR = CurveInput;
    3589             :                         }
    3590        1300 :                         if (CurveVal > MaxCurveVal) {
    3591        1300 :                             MaxCurveVal = CurveVal;
    3592        1300 :                             MaxCurvePLR = CurveInput;
    3593             :                         }
    3594        1300 :                         CurveInput += 0.01;
    3595             :                     }
    3596          13 :                     if (MinCurveVal < 0.7) {
    3597           0 :                         ShowWarningError(state,
    3598           0 :                                          std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name +
    3599             :                                              "\", invalid");
    3600           0 :                         ShowContinueError(state, "..." + cAlphaFields(16) + " = " + Alphas(16) + " has out of range value.");
    3601           0 :                         ShowContinueError(state,
    3602           0 :                                           format("...Curve minimum must be >= 0.7, curve min at PLR = {:.2T} is {:.3T}", MinCurvePLR, MinCurveVal));
    3603           0 :                         ShowContinueError(state, "...Setting curve minimum to 0.7 and simulation continues.");
    3604           0 :                         SetCurveOutputMinMaxValues(state, state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(1), ErrorsFound, 0.7, _);
    3605             :                     }
    3606             : 
    3607          13 :                     if (MaxCurveVal > 1.0) {
    3608           0 :                         ShowWarningError(state,
    3609           0 :                                          std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name +
    3610             :                                              "\", invalid");
    3611           0 :                         ShowContinueError(state, "..." + cAlphaFields(16) + " = " + Alphas(16) + " has out of range value.");
    3612           0 :                         ShowContinueError(state,
    3613           0 :                                           format("...Curve maximum must be <= 1.0, curve max at PLR = {:.2T} is {:.3T}", MaxCurvePLR, MaxCurveVal));
    3614           0 :                         ShowContinueError(state, "...Setting curve maximum to 1.0 and simulation continues.");
    3615           0 :                         SetCurveOutputMinMaxValues(state, state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(1), ErrorsFound, _, 1.0);
    3616             :                     }
    3617             :                 }
    3618             :             }
    3619             :         }
    3620             : 
    3621             :         // assume compressor resides at the inlet to the DX Coil
    3622          13 :         state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(1) = state.dataDXCoils->DXCoil(DXCoilNum).AirInNode;
    3623             : 
    3624             :         // set condenser type as HPWH
    3625          13 :         state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(1) = DataHeatBalance::RefrigCondenserType::WaterHeater;
    3626             : 
    3627             :     } // end of the DX water heater coil loop
    3628             : 
    3629         241 :     if (ErrorsFound) {
    3630           0 :         ShowFatalError(state,
    3631           0 :                        std::string{RoutineName} + "Errors found in getting " + CurrentModuleObject +
    3632             :                            " input. Preceding condition(s) causes termination.");
    3633             :     }
    3634             :     // Loop over the Wrapped DX Water Heater Coils and get & load the data
    3635         241 :     CurrentModuleObject = cAllCoilTypes(CoilDX_HeatPumpWaterHeaterWrapped);
    3636         244 :     for (DXHPWaterHeaterCoilNum = 1; DXHPWaterHeaterCoilNum <= state.dataDXCoils->NumDXHeatPumpWaterHeaterWrappedCoils; ++DXHPWaterHeaterCoilNum) {
    3637             : 
    3638           3 :         state.dataInputProcessing->inputProcessor->getObjectItem(state,
    3639             :                                                                  CurrentModuleObject,
    3640             :                                                                  DXHPWaterHeaterCoilNum,
    3641             :                                                                  Alphas,
    3642             :                                                                  NumAlphas,
    3643             :                                                                  Numbers,
    3644             :                                                                  NumNumbers,
    3645             :                                                                  IOStatus,
    3646             :                                                                  lNumericBlanks,
    3647             :                                                                  lAlphaBlanks,
    3648             :                                                                  cAlphaFields,
    3649             :                                                                  cNumericFields);
    3650             : 
    3651           3 :         ++DXCoilNum;
    3652             : 
    3653             :         // allocate single performance mode for numeric field strings used for sizing routine
    3654           3 :         state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode.allocate(1);
    3655           3 :         state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(1).FieldNames.allocate(MaxNumbers);
    3656           3 :         state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(1).FieldNames = cNumericFields;
    3657           3 :         UtilityRoutines::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    3658             :         // ErrorsFound will be set to True if problem was found, left untouched otherwise
    3659           3 :         VerifyUniqueCoilName(state, CurrentModuleObject, Alphas(1), ErrorsFound, CurrentModuleObject + " Name");
    3660             : 
    3661           3 :         state.dataDXCoils->DXCoil(DXCoilNum).Name = Alphas(1);
    3662           3 :         state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType = CurrentModuleObject;
    3663           3 :         state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num = CoilDX_HeatPumpWaterHeaterWrapped;
    3664           3 :         state.dataDXCoils->DXCoil(DXCoilNum).SchedPtr = 0; // heat pump water heater DX coil has no schedule
    3665             : 
    3666             :         // Store the HPWH DX coil heating capacity in RatedTotCap2. After backing off pump and fan heat,
    3667             :         // move to RatedTotCap() for use by DX coil
    3668           3 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap2 = Numbers(1);
    3669           3 :         if (state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap2 <= 0.0) {
    3670           0 :             ShowSevereError(state,
    3671           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3672           0 :             ShowContinueError(state, format("...{} must be > 0.0, entered value=[{:.2T}].", cNumericFields(1), Numbers(1)));
    3673           0 :             ErrorsFound = true;
    3674             :         }
    3675             : 
    3676           3 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedCOP(1) = Numbers(2);
    3677           3 :         if (state.dataDXCoils->DXCoil(DXCoilNum).RatedCOP(1) <= 0.0) {
    3678           0 :             ShowSevereError(state,
    3679           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3680           0 :             ShowContinueError(state, format("...{} must be > 0.0, entered value=[{:.2T}].", cNumericFields(2), Numbers(2)));
    3681           0 :             ErrorsFound = true;
    3682             :         }
    3683             : 
    3684           3 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedSHR(1) = Numbers(3);
    3685           3 :         if (state.dataDXCoils->DXCoil(DXCoilNum).RatedSHR(1) <= 0.0 || state.dataDXCoils->DXCoil(DXCoilNum).RatedSHR(1) > 1.0) {
    3686           0 :             ShowSevereError(state,
    3687           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3688           0 :             ShowContinueError(state, format("...{} must be > 0 and <= 1.  entered value=[{:.3T}].", cNumericFields(3), Numbers(3)));
    3689             : 
    3690           0 :             ErrorsFound = true;
    3691             :         }
    3692             : 
    3693           3 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedInletDBTemp = Numbers(4);
    3694           3 :         if (state.dataDXCoils->DXCoil(DXCoilNum).RatedInletDBTemp <= 5.0) {
    3695           0 :             ShowSevereError(state,
    3696           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3697           0 :             ShowContinueError(state, format("...{} must be > 5 {{C}}.  entered value=[{:.1T}].", cNumericFields(4), Numbers(4)));
    3698           0 :             ErrorsFound = true;
    3699             :         }
    3700             : 
    3701           3 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedInletWBTemp = Numbers(5);
    3702           3 :         if (state.dataDXCoils->DXCoil(DXCoilNum).RatedInletWBTemp <= 5.0) {
    3703           0 :             ShowSevereError(state,
    3704           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3705           0 :             ShowContinueError(state, format("...{} must be > 5 {{C}}.  entered value=[{:.1T}].", cNumericFields(5), Numbers(5)));
    3706           0 :             ErrorsFound = true;
    3707             :         }
    3708             : 
    3709           3 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedInletWaterTemp = Numbers(6);
    3710           3 :         if (state.dataDXCoils->DXCoil(DXCoilNum).RatedInletWaterTemp <= 25.0) {
    3711           0 :             ShowSevereError(state,
    3712           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3713           0 :             ShowContinueError(state, format("...{} must be > 25 {{C}}.  entered value=[{:.1T}].", cNumericFields(6), Numbers(6)));
    3714           0 :             ErrorsFound = true;
    3715             :         }
    3716             : 
    3717           3 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(1) = Numbers(7);
    3718           3 :         if (state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(1) != DataGlobalConstants::AutoCalculate) {
    3719           3 :             if (state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(1) <= 0.0) {
    3720           0 :                 ShowSevereError(state,
    3721           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3722           0 :                 ShowContinueError(state, format("...{} must be > 0.0.  entered value=[{:.3T}].", cNumericFields(7), Numbers(7)));
    3723           0 :                 ErrorsFound = true;
    3724             :             }
    3725             :         }
    3726             : 
    3727           3 :         if (UtilityRoutines::SameString(Alphas(2), "Yes") || UtilityRoutines::SameString(Alphas(2), "No")) {
    3728             :             //  initialized to TRUE on allocate
    3729           3 :             if (UtilityRoutines::SameString(Alphas(2), "No")) state.dataDXCoils->DXCoil(DXCoilNum).FanPowerIncludedInCOP = false;
    3730             :         } else {
    3731           0 :             ShowSevereError(state,
    3732           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3733           0 :             ShowContinueError(state, ",,,invalid choice for " + cAlphaFields(2) + ".  Entered choice = " + Alphas(2));
    3734           0 :             ShowContinueError(state, "Valid choices are Yes or No.");
    3735           0 :             ErrorsFound = true;
    3736             :         }
    3737             : 
    3738             :         // Air nodes
    3739           3 :         state.dataDXCoils->DXCoil(DXCoilNum).AirInNode =
    3740           6 :             GetOnlySingleNode(state,
    3741           3 :                               Alphas(3),
    3742             :                               ErrorsFound,
    3743             :                               DataLoopNode::ConnectionObjectType::CoilWaterHeatingAirToWaterHeatPumpWrapped,
    3744           3 :                               Alphas(1),
    3745             :                               DataLoopNode::NodeFluidType::Air,
    3746             :                               DataLoopNode::ConnectionType::Inlet,
    3747             :                               NodeInputManager::CompFluidStream::Primary,
    3748           3 :                               ObjectIsNotParent);
    3749             : 
    3750           3 :         state.dataDXCoils->DXCoil(DXCoilNum).AirOutNode =
    3751           6 :             GetOnlySingleNode(state,
    3752           3 :                               Alphas(4),
    3753             :                               ErrorsFound,
    3754             :                               DataLoopNode::ConnectionObjectType::CoilWaterHeatingAirToWaterHeatPumpWrapped,
    3755           3 :                               Alphas(1),
    3756             :                               DataLoopNode::NodeFluidType::Air,
    3757             :                               DataLoopNode::ConnectionType::Outlet,
    3758             :                               NodeInputManager::CompFluidStream::Primary,
    3759           3 :                               ObjectIsNotParent);
    3760             : 
    3761           3 :         TestCompSet(state, CurrentModuleObject, Alphas(1), Alphas(3), Alphas(4), "Air Nodes");
    3762             : 
    3763             :         // Check if the air inlet node is OA node, to justify whether the coil is placed in zone or not
    3764           3 :         state.dataDXCoils->DXCoil(DXCoilNum).IsDXCoilInZone = !CheckOutAirNodeNumber(state, state.dataDXCoils->DXCoil(DXCoilNum).AirInNode);
    3765             : 
    3766           6 :         std::string const DummyCondenserInletName("DUMMY CONDENSER INLET " + state.dataDXCoils->DXCoil(DXCoilNum).Name);
    3767           6 :         std::string const DummyCondenserOutletName("DUMMY CONDENSER OUTLET " + state.dataDXCoils->DXCoil(DXCoilNum).Name);
    3768           3 :         state.dataDXCoils->DXCoil(DXCoilNum).WaterInNode =
    3769           6 :             GetOnlySingleNode(state,
    3770             :                               DummyCondenserInletName,
    3771             :                               ErrorsFound,
    3772             :                               DataLoopNode::ConnectionObjectType::CoilWaterHeatingAirToWaterHeatPumpWrapped,
    3773           3 :                               Alphas(1),
    3774             :                               DataLoopNode::NodeFluidType::Water,
    3775             :                               DataLoopNode::ConnectionType::Inlet,
    3776             :                               NodeInputManager::CompFluidStream::Secondary,
    3777           3 :                               ObjectIsNotParent);
    3778             : 
    3779           3 :         state.dataDXCoils->DXCoil(DXCoilNum).WaterOutNode =
    3780           6 :             GetOnlySingleNode(state,
    3781             :                               DummyCondenserOutletName,
    3782             :                               ErrorsFound,
    3783             :                               DataLoopNode::ConnectionObjectType::CoilWaterHeatingAirToWaterHeatPumpWrapped,
    3784           3 :                               Alphas(1),
    3785             :                               DataLoopNode::NodeFluidType::Water,
    3786             :                               DataLoopNode::ConnectionType::Outlet,
    3787             :                               NodeInputManager::CompFluidStream::Secondary,
    3788           3 :                               ObjectIsNotParent);
    3789             : 
    3790           3 :         TestCompSet(state, CurrentModuleObject, Alphas(1), DummyCondenserInletName, DummyCondenserOutletName, "Water Nodes");
    3791             : 
    3792           3 :         state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterCapacity = Numbers(8);
    3793           3 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterCapacity < 0.0) {
    3794           0 :             ShowSevereError(state,
    3795           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3796           0 :             ShowContinueError(state, format("...{} must be >= 0.0  entered value=[{:.1T}].", cNumericFields(8), Numbers(8)));
    3797           0 :             ErrorsFound = true;
    3798             :         }
    3799             : 
    3800           3 :         state.dataDXCoils->DXCoil(DXCoilNum).MaxOATCrankcaseHeater = Numbers(9);
    3801           3 :         if (state.dataDXCoils->DXCoil(DXCoilNum).MaxOATCrankcaseHeater < 0.0) {
    3802           0 :             ShowSevereError(state,
    3803           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3804           0 :             ShowContinueError(state, format("...{} must be >= 0 {{C}}.  entered value=[{:.1T}].", cNumericFields(9), Numbers(9)));
    3805           0 :             ErrorsFound = true;
    3806             :         }
    3807             : 
    3808           3 :         if (UtilityRoutines::SameString(Alphas(5), "DryBulbTemperature")) {
    3809           0 :             state.dataDXCoils->DXCoil(DXCoilNum).InletAirTemperatureType = DryBulbIndicator;
    3810           3 :         } else if (UtilityRoutines::SameString(Alphas(5), "WetBulbTemperature")) {
    3811           3 :             state.dataDXCoils->DXCoil(DXCoilNum).InletAirTemperatureType = WetBulbIndicator;
    3812             :         } else {
    3813             :             //   wrong temperature type selection
    3814           0 :             ShowSevereError(state,
    3815           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3816           0 :             ShowContinueError(state, "..." + cAlphaFields(5) + " must be DryBulbTemperature or WetBulbTemperature.");
    3817           0 :             ShowContinueError(state, "...entered value=\"" + Alphas(5) + "\".");
    3818           0 :             ErrorsFound = true;
    3819             :         }
    3820             : 
    3821             :         // set rated inlet air temperature for curve object verification
    3822           3 :         if (state.dataDXCoils->DXCoil(DXCoilNum).InletAirTemperatureType == WetBulbIndicator) {
    3823           3 :             InletAirTemp = state.dataDXCoils->DXCoil(DXCoilNum).RatedInletWBTemp;
    3824             :         } else {
    3825           0 :             InletAirTemp = state.dataDXCoils->DXCoil(DXCoilNum).RatedInletDBTemp;
    3826             :         }
    3827             :         // set rated water temperature for curve object verification
    3828           3 :         InletWaterTemp = state.dataDXCoils->DXCoil(DXCoilNum).RatedInletWaterTemp;
    3829             : 
    3830           3 :         if (!lAlphaBlanks(6)) {
    3831           3 :             state.dataDXCoils->DXCoil(DXCoilNum).HCapFTemp = GetCurveIndex(state, Alphas(6));
    3832           3 :             if (state.dataDXCoils->DXCoil(DXCoilNum).HCapFTemp == 0) {
    3833           0 :                 ShowSevereError(state,
    3834           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3835           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(6) + "=\"" + Alphas(6) + "\".");
    3836           0 :                 ErrorsFound = true;
    3837             :             } else {
    3838             :                 // Verify Curve Object, only legal types are BiQuadratic or Cubic
    3839           9 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    3840           3 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).HCapFTemp, // Curve index
    3841             :                                                      {1, 2},                                         // Valid dimensions
    3842             :                                                      RoutineName,                                    // Routine name
    3843             :                                                      CurrentModuleObject,                            // Object Type
    3844           3 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,      // Object Name
    3845           3 :                                                      cAlphaFields(6));                               // Field Name
    3846             : 
    3847           3 :                 if (!ErrorsFound) {
    3848           3 :                     if (state.dataCurveManager->PerfCurve(state.dataDXCoils->DXCoil(DXCoilNum).HCapFTemp).numDims == 1) {
    3849           0 :                         checkCurveIsNormalizedToOne(state,
    3850           0 :                                                     std::string{RoutineName} + CurrentModuleObject,
    3851           0 :                                                     state.dataDXCoils->DXCoil(DXCoilNum).Name,
    3852           0 :                                                     state.dataDXCoils->DXCoil(DXCoilNum).HCapFTemp,
    3853           0 :                                                     cAlphaFields(6),
    3854           0 :                                                     Alphas(6),
    3855             :                                                     InletAirTemp);
    3856             :                     } else {
    3857          15 :                         checkCurveIsNormalizedToOne(state,
    3858           6 :                                                     std::string{RoutineName} + CurrentModuleObject,
    3859           3 :                                                     state.dataDXCoils->DXCoil(DXCoilNum).Name,
    3860           3 :                                                     state.dataDXCoils->DXCoil(DXCoilNum).HCapFTemp,
    3861           3 :                                                     cAlphaFields(6),
    3862           3 :                                                     Alphas(6),
    3863             :                                                     InletAirTemp,
    3864             :                                                     InletWaterTemp);
    3865             :                     }
    3866             :                 }
    3867             :             }
    3868             :         }
    3869             : 
    3870           3 :         if (!lAlphaBlanks(7)) {
    3871           0 :             state.dataDXCoils->DXCoil(DXCoilNum).HCapFAirFlow = GetCurveIndex(state, Alphas(7));
    3872           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).HCapFAirFlow == 0) {
    3873           0 :                 ShowSevereError(state,
    3874           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3875           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(7) + "=\"" + Alphas(7) + "\".");
    3876           0 :                 ErrorsFound = true;
    3877             :             } else {
    3878             :                 // Verify Curve Object, only legal types are Cubic or Quadratic
    3879           0 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    3880           0 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).HCapFAirFlow, // Curve index
    3881             :                                                      {1},                                               // Valid dimensions
    3882             :                                                      RoutineName,                                       // Routine name
    3883             :                                                      CurrentModuleObject,                               // Object Type
    3884           0 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,         // Object Name
    3885           0 :                                                      cAlphaFields(7));                                  // Field Name
    3886             : 
    3887           0 :                 if (!ErrorsFound) {
    3888           0 :                     checkCurveIsNormalizedToOne(state,
    3889           0 :                                                 std::string{RoutineName} + CurrentModuleObject,
    3890           0 :                                                 state.dataDXCoils->DXCoil(DXCoilNum).Name,
    3891           0 :                                                 state.dataDXCoils->DXCoil(DXCoilNum).HCapFAirFlow,
    3892           0 :                                                 cAlphaFields(7),
    3893           0 :                                                 Alphas(7),
    3894             :                                                 1.0);
    3895             :                 }
    3896             :             }
    3897             :         }
    3898             : 
    3899           3 :         if (!lAlphaBlanks(8)) {
    3900           3 :             state.dataDXCoils->DXCoil(DXCoilNum).HCOPFTemp = GetCurveIndex(state, Alphas(8));
    3901           3 :             if (state.dataDXCoils->DXCoil(DXCoilNum).HCOPFTemp == 0) {
    3902           0 :                 ShowSevereError(state,
    3903           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3904           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(8) + "=\"" + Alphas(8) + "\".");
    3905           0 :                 ErrorsFound = true;
    3906             :             } else {
    3907             :                 // Verify Curve Object, only legal types are BiQuadratic or Cubic
    3908           9 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    3909           3 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).HCOPFTemp, // Curve index
    3910             :                                                      {1, 2},                                         // Valid dimensions
    3911             :                                                      RoutineName,                                    // Routine name
    3912             :                                                      CurrentModuleObject,                            // Object Type
    3913           3 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,      // Object Name
    3914           3 :                                                      cAlphaFields(8));                               // Field Name
    3915             : 
    3916           3 :                 if (!ErrorsFound) {
    3917           3 :                     if (state.dataCurveManager->PerfCurve(state.dataDXCoils->DXCoil(DXCoilNum).HCOPFTemp).numDims == 1) {
    3918           0 :                         checkCurveIsNormalizedToOne(state,
    3919           0 :                                                     std::string{RoutineName} + CurrentModuleObject,
    3920           0 :                                                     state.dataDXCoils->DXCoil(DXCoilNum).Name,
    3921           0 :                                                     state.dataDXCoils->DXCoil(DXCoilNum).HCOPFTemp,
    3922           0 :                                                     cAlphaFields(8),
    3923           0 :                                                     Alphas(8),
    3924             :                                                     InletAirTemp);
    3925             :                     } else {
    3926          15 :                         checkCurveIsNormalizedToOne(state,
    3927           6 :                                                     std::string{RoutineName} + CurrentModuleObject,
    3928           3 :                                                     state.dataDXCoils->DXCoil(DXCoilNum).Name,
    3929           3 :                                                     state.dataDXCoils->DXCoil(DXCoilNum).HCOPFTemp,
    3930           3 :                                                     cAlphaFields(8),
    3931           3 :                                                     Alphas(8),
    3932             :                                                     InletAirTemp,
    3933             :                                                     InletWaterTemp);
    3934             :                     }
    3935             :                 }
    3936             :             }
    3937             :         }
    3938             : 
    3939           3 :         if (!lAlphaBlanks(9)) {
    3940           0 :             state.dataDXCoils->DXCoil(DXCoilNum).HCOPFAirFlow = GetCurveIndex(state, Alphas(9));
    3941           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).HCOPFAirFlow == 0) {
    3942           0 :                 ShowSevereError(state,
    3943           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3944           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(9) + "=\"" + Alphas(9) + "\".");
    3945           0 :                 ErrorsFound = true;
    3946             :             } else {
    3947             :                 // Verify Curve Object, only legal types are Cubic or Quadratic
    3948           0 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    3949           0 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).HCOPFAirFlow, // Curve index
    3950             :                                                      {1},                                               // Valid dimensions
    3951             :                                                      RoutineName,                                       // Routine name
    3952             :                                                      CurrentModuleObject,                               // Object Type
    3953           0 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,         // Object Name
    3954           0 :                                                      cAlphaFields(9));                                  // Field Name
    3955             : 
    3956           0 :                 if (!ErrorsFound) {
    3957           0 :                     checkCurveIsNormalizedToOne(state,
    3958           0 :                                                 std::string{RoutineName} + CurrentModuleObject,
    3959           0 :                                                 state.dataDXCoils->DXCoil(DXCoilNum).Name,
    3960           0 :                                                 state.dataDXCoils->DXCoil(DXCoilNum).HCOPFAirFlow,
    3961           0 :                                                 cAlphaFields(9),
    3962           0 :                                                 Alphas(9),
    3963             :                                                 1.0);
    3964             :                 }
    3965             :             }
    3966             :         }
    3967             : 
    3968           3 :         if (!lAlphaBlanks(10)) {
    3969           3 :             state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(1) = GetCurveIndex(state, Alphas(10));
    3970           3 :             if (state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(1) == 0) {
    3971           0 :                 ShowSevereError(state,
    3972           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    3973           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(10) + "=\"" + Alphas(10) + "\".");
    3974           0 :                 ErrorsFound = true;
    3975             :             } else {
    3976             :                 // Verify Curve Object, only legal types are Cubic or Quadratic
    3977           9 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    3978           3 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(1), // Curve index
    3979             :                                                      {1},                                             // Valid dimensions
    3980             :                                                      RoutineName,                                     // Routine name
    3981             :                                                      CurrentModuleObject,                             // Object Type
    3982           3 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,       // Object Name
    3983           3 :                                                      cAlphaFields(10));                               // Field Name
    3984             : 
    3985           3 :                 if (!ErrorsFound) {
    3986             :                     //       Test PLF curve minimum and maximum. Cap if less than 0.7 or greater than 1.0.
    3987           3 :                     MinCurveVal = 999.0;
    3988           3 :                     MaxCurveVal = -999.0;
    3989           3 :                     CurveInput = 0.0;
    3990         603 :                     while (CurveInput <= 1.0) {
    3991         300 :                         CurveVal = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(1), CurveInput);
    3992         300 :                         if (CurveVal < MinCurveVal) {
    3993           3 :                             MinCurveVal = CurveVal;
    3994           3 :                             MinCurvePLR = CurveInput;
    3995             :                         }
    3996         300 :                         if (CurveVal > MaxCurveVal) {
    3997           3 :                             MaxCurveVal = CurveVal;
    3998           3 :                             MaxCurvePLR = CurveInput;
    3999             :                         }
    4000         300 :                         CurveInput += 0.01;
    4001             :                     }
    4002           3 :                     if (MinCurveVal < 0.7) {
    4003           0 :                         ShowWarningError(state,
    4004           0 :                                          std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name +
    4005             :                                              "\", invalid");
    4006           0 :                         ShowContinueError(state, "..." + cAlphaFields(10) + " = " + Alphas(10) + " has out of range value.");
    4007           0 :                         ShowContinueError(state,
    4008           0 :                                           format("...Curve minimum must be >= 0.7, curve min at PLR = {:.2T} is {:.3T}", MinCurvePLR, MinCurveVal));
    4009           0 :                         ShowContinueError(state, "...Setting curve minimum to 0.7 and simulation continues.");
    4010           0 :                         SetCurveOutputMinMaxValues(state, state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(1), ErrorsFound, 0.7, _);
    4011             :                     }
    4012             : 
    4013           3 :                     if (MaxCurveVal > 1.0) {
    4014           0 :                         ShowWarningError(state,
    4015           0 :                                          std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name +
    4016             :                                              "\", invalid");
    4017           0 :                         ShowContinueError(state, "..." + cAlphaFields(10) + " = " + Alphas(10) + " has out of range value.");
    4018           0 :                         ShowContinueError(state,
    4019           0 :                                           format("...Curve maximum must be <= 1.0, curve max at PLR = {:.2T} is {:.3T}", MaxCurvePLR, MaxCurveVal));
    4020           0 :                         ShowContinueError(state, "...Setting curve maximum to 1.0 and simulation continues.");
    4021           0 :                         SetCurveOutputMinMaxValues(state, state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(1), ErrorsFound, _, 1.0);
    4022             :                     }
    4023             :                 }
    4024             :             }
    4025             :         }
    4026             : 
    4027             :         // assume compressor resides at the inlet to the DX Coil
    4028           3 :         state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(1) = state.dataDXCoils->DXCoil(DXCoilNum).AirInNode;
    4029             : 
    4030             :         // set condenser type as HPWH
    4031           3 :         state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(1) = DataHeatBalance::RefrigCondenserType::WaterHeater;
    4032             : 
    4033             :     } // end of the DX water heater wrapped coil loop
    4034             : 
    4035         241 :     if (ErrorsFound) {
    4036           0 :         ShowFatalError(state,
    4037           0 :                        std::string{RoutineName} + "Errors found in getting " + CurrentModuleObject +
    4038             :                            " input. Preceding condition(s) causes termination.");
    4039             :     }
    4040             : 
    4041             :     // DX Multispeed cooling coil
    4042         241 :     CurrentModuleObject = "Coil:Cooling:DX:MultiSpeed";
    4043         289 :     for (DXCoilIndex = 1; DXCoilIndex <= state.dataDXCoils->NumDXMulSpeedCoolCoils; ++DXCoilIndex) {
    4044             : 
    4045          48 :         ++DXCoilNum;
    4046             : 
    4047          48 :         state.dataInputProcessing->inputProcessor->getObjectItem(state,
    4048             :                                                                  CurrentModuleObject,
    4049             :                                                                  DXCoilIndex,
    4050             :                                                                  Alphas,
    4051             :                                                                  NumAlphas,
    4052             :                                                                  Numbers,
    4053             :                                                                  NumNumbers,
    4054             :                                                                  IOStatus,
    4055             :                                                                  lNumericBlanks,
    4056             :                                                                  lAlphaBlanks,
    4057             :                                                                  cAlphaFields,
    4058             :                                                                  cNumericFields);
    4059             : 
    4060             :         // allocate single performance mode for numeric field strings used for sizing routine (all fields are in this object)
    4061          48 :         state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode.allocate(1);
    4062          48 :         state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(1).FieldNames.allocate(MaxNumbers);
    4063          48 :         state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(1).FieldNames = cNumericFields;
    4064          48 :         UtilityRoutines::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    4065             :         // ErrorsFound will be set to True if problem was found, left untouched otherwise
    4066          48 :         VerifyUniqueCoilName(state, CurrentModuleObject, Alphas(1), ErrorsFound, CurrentModuleObject + " Name");
    4067          48 :         state.dataDXCoils->DXCoil(DXCoilNum).Name = Alphas(1);
    4068             :         // Initialize DataHeatBalance heat reclaim variable name for use by heat reclaim coils
    4069          48 :         state.dataHeatBal->HeatReclaimDXCoil(DXCoilNum).Name = state.dataDXCoils->DXCoil(DXCoilNum).Name;
    4070          48 :         state.dataHeatBal->HeatReclaimDXCoil(DXCoilNum).SourceType = CurrentModuleObject;
    4071          48 :         state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType = CurrentModuleObject;
    4072          48 :         state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num = CoilDX_MultiSpeedCooling;
    4073          48 :         state.dataDXCoils->DXCoil(DXCoilNum).Schedule = Alphas(2);
    4074          48 :         if (lAlphaBlanks(2)) {
    4075           1 :             state.dataDXCoils->DXCoil(DXCoilNum).SchedPtr = DataGlobalConstants::ScheduleAlwaysOn;
    4076             :         } else {
    4077          47 :             state.dataDXCoils->DXCoil(DXCoilNum).SchedPtr = GetScheduleIndex(state, Alphas(2)); // convert schedule name to pointer
    4078          47 :             if (state.dataDXCoils->DXCoil(DXCoilNum).SchedPtr == 0) {
    4079           0 :                 ShowSevereError(state,
    4080           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    4081           0 :                 ShowContinueError(state, "..." + cAlphaFields(2) + "=\"" + Alphas(2) + "\".");
    4082           0 :                 ErrorsFound = true;
    4083             :             }
    4084             :         }
    4085             : 
    4086          48 :         state.dataDXCoils->DXCoil(DXCoilNum).AirInNode = GetOnlySingleNode(state,
    4087          48 :                                                                            Alphas(3),
    4088             :                                                                            ErrorsFound,
    4089             :                                                                            DataLoopNode::ConnectionObjectType::CoilCoolingDXMultiSpeed,
    4090          48 :                                                                            Alphas(1),
    4091             :                                                                            DataLoopNode::NodeFluidType::Air,
    4092             :                                                                            DataLoopNode::ConnectionType::Inlet,
    4093             :                                                                            NodeInputManager::CompFluidStream::Primary,
    4094          48 :                                                                            ObjectIsNotParent);
    4095             : 
    4096          48 :         state.dataDXCoils->DXCoil(DXCoilNum).AirOutNode = GetOnlySingleNode(state,
    4097          48 :                                                                             Alphas(4),
    4098             :                                                                             ErrorsFound,
    4099             :                                                                             DataLoopNode::ConnectionObjectType::CoilCoolingDXMultiSpeed,
    4100          48 :                                                                             Alphas(1),
    4101             :                                                                             DataLoopNode::NodeFluidType::Air,
    4102             :                                                                             DataLoopNode::ConnectionType::Outlet,
    4103             :                                                                             NodeInputManager::CompFluidStream::Primary,
    4104          48 :                                                                             ObjectIsNotParent);
    4105             : 
    4106          48 :         TestCompSet(state, CurrentModuleObject, Alphas(1), Alphas(3), Alphas(4), "Air Nodes");
    4107             : 
    4108             :         // outdoor condenser node
    4109          48 :         if (lAlphaBlanks(5)) {
    4110          32 :             state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(1) = 0;
    4111             :         } else {
    4112          16 :             state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(1) =
    4113          48 :                 GetOnlySingleNode(state,
    4114          16 :                                   Alphas(5),
    4115             :                                   ErrorsFound,
    4116             :                                   DataLoopNode::ConnectionObjectType::CoilCoolingDXMultiSpeed,
    4117          16 :                                   state.dataDXCoils->DXCoil(DXCoilNum).Name,
    4118             :                                   DataLoopNode::NodeFluidType::Air,
    4119             :                                   DataLoopNode::ConnectionType::OutsideAirReference,
    4120             :                                   NodeInputManager::CompFluidStream::Primary,
    4121          16 :                                   ObjectIsNotParent);
    4122          16 :             if (!CheckOutAirNodeNumber(state, state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(1))) {
    4123           0 :                 ShowWarningError(
    4124           0 :                     state, std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", may be invalid");
    4125           0 :                 ShowContinueError(
    4126           0 :                     state, cAlphaFields(5) + "=\"" + Alphas(5) + "\", node does not appear in an OutdoorAir:NodeList or as an OutdoorAir:Node.");
    4127           0 :                 ShowContinueError(
    4128             :                     state, "This node needs to be included in an air system or the coil model will not be valid, and the simulation continues");
    4129             :             }
    4130             :         }
    4131             : 
    4132          48 :         if ((UtilityRoutines::SameString(Alphas(6), "AirCooled")) || lAlphaBlanks(6)) {
    4133          48 :             state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(1) = DataHeatBalance::RefrigCondenserType::Air;
    4134           0 :         } else if (UtilityRoutines::SameString(Alphas(6), "EvaporativelyCooled")) {
    4135           0 :             state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(1) = DataHeatBalance::RefrigCondenserType::Evap;
    4136           0 :             state.dataDXCoils->DXCoil(DXCoilNum).ReportEvapCondVars = true;
    4137             :         } else {
    4138           0 :             ShowSevereError(state,
    4139           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    4140           0 :             ShowContinueError(state, "..." + cAlphaFields(6) + "=\"" + Alphas(6) + "\":");
    4141           0 :             ShowContinueError(state, "...must be AirCooled or EvaporativelyCooled.");
    4142           0 :             ErrorsFound = true;
    4143             :         }
    4144             : 
    4145             :         // Get Water System tank connections
    4146             :         //  A8, \field Name of Water Storage Tank for Supply
    4147          48 :         state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterSupplyName = Alphas(7);
    4148          48 :         if (lAlphaBlanks(7)) {
    4149          48 :             state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterSupplyMode = EvapWaterSupply::FromMains;
    4150             :         } else {
    4151           0 :             state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterSupplyMode = EvapWaterSupply::FromTank;
    4152           0 :             SetupTankDemandComponent(state,
    4153           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,
    4154             :                                      CurrentModuleObject,
    4155           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterSupplyName,
    4156             :                                      ErrorsFound,
    4157           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterSupTankID,
    4158           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterTankDemandARRID);
    4159             :         }
    4160             : 
    4161             :         // A9; \field Name of Water Storage Tank for Condensate Collection
    4162          48 :         state.dataDXCoils->DXCoil(DXCoilNum).CondensateCollectName = Alphas(8);
    4163          48 :         if (lAlphaBlanks(8)) {
    4164          48 :             state.dataDXCoils->DXCoil(DXCoilNum).CondensateCollectMode = CondensateCollectAction::Discard;
    4165             :         } else {
    4166           0 :             state.dataDXCoils->DXCoil(DXCoilNum).CondensateCollectMode = CondensateCollectAction::ToTank;
    4167           0 :             SetupTankSupplyComponent(state,
    4168           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,
    4169             :                                      CurrentModuleObject,
    4170           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).CondensateCollectName,
    4171             :                                      ErrorsFound,
    4172           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).CondensateTankID,
    4173           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).CondensateTankSupplyARRID);
    4174             :         }
    4175             : 
    4176             :         // Set minimum OAT for compressor operation
    4177          48 :         state.dataDXCoils->DXCoil(DXCoilNum).MinOATCompressor = Numbers(1);
    4178             : 
    4179             :         // Set crankcase heater capacity
    4180          48 :         state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterCapacity = Numbers(2);
    4181          48 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterCapacity < 0.0) {
    4182           0 :             ShowSevereError(state,
    4183           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    4184           0 :             ShowContinueError(state, "..." + cNumericFields(2) + " cannot be < 0.0.");
    4185           0 :             ShowContinueError(state, format("...entered value=[{:.2T}].", Numbers(2)));
    4186           0 :             ErrorsFound = true;
    4187             :         }
    4188             : 
    4189             :         // Set crankcase heater cutout temperature
    4190          48 :         state.dataDXCoils->DXCoil(DXCoilNum).MaxOATCrankcaseHeater = Numbers(3);
    4191             : 
    4192          48 :         if (UtilityRoutines::SameString(Alphas(9), "Yes")) {
    4193           0 :             state.dataDXCoils->DXCoil(DXCoilNum).PLRImpact = true;
    4194          48 :         } else if (UtilityRoutines::SameString(Alphas(9), "No")) {
    4195          48 :             state.dataDXCoils->DXCoil(DXCoilNum).PLRImpact = false;
    4196             :         } else {
    4197           0 :             ShowSevereError(state,
    4198           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    4199           0 :             ShowContinueError(state, ",,,invalid choice for " + cAlphaFields(9) + ".  Entered choice = " + Alphas(9));
    4200           0 :             ShowContinueError(state, "The allowed choices are Yes or No.");
    4201           0 :             ErrorsFound = true;
    4202             :         }
    4203             : 
    4204          48 :         if (UtilityRoutines::SameString(Alphas(10), "Yes")) {
    4205           0 :             state.dataDXCoils->DXCoil(DXCoilNum).LatentImpact = true;
    4206          48 :         } else if (UtilityRoutines::SameString(Alphas(10), "No")) {
    4207          48 :             state.dataDXCoils->DXCoil(DXCoilNum).LatentImpact = false;
    4208             :         } else {
    4209           0 :             ShowSevereError(state,
    4210           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    4211           0 :             ShowContinueError(state, ",,,invalid choice for " + cAlphaFields(10) + ".  Entered choice = " + Alphas(10));
    4212           0 :             ShowContinueError(state, "The allowed choices are Yes or No.");
    4213           0 :             ErrorsFound = true;
    4214             :         }
    4215             : 
    4216             :         //   Basin heater power as a function of temperature must be greater than or equal to 0
    4217          48 :         state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterPowerFTempDiff = Numbers(4);
    4218          48 :         if (Numbers(4) < 0.0) {
    4219           0 :             ShowSevereError(state,
    4220           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    4221           0 :             ShowContinueError(state, format("...{} must be >= 0.0, entered value=[{:.3T}].", cNumericFields(4), Numbers(4)));
    4222           0 :             ErrorsFound = true;
    4223             :         }
    4224             : 
    4225          48 :         state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterSetPointTemp = Numbers(5);
    4226          48 :         if (state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterPowerFTempDiff > 0.0) {
    4227           0 :             if (NumNumbers < 5) {
    4228           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterSetPointTemp = 2.0;
    4229             :             }
    4230           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterSetPointTemp < 2.0) {
    4231           0 :                 ShowWarningError(state,
    4232           0 :                                  std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name +
    4233             :                                      "\", freeze possible");
    4234           0 :                 ShowContinueError(state, "..." + cNumericFields(5) + " is less than 2 {C}. Freezing could occur.");
    4235           0 :                 ShowContinueError(state, format("...entered value=[{:.2T}].", Numbers(5)));
    4236             :             }
    4237             :         }
    4238             : 
    4239          48 :         if (!lAlphaBlanks(11)) {
    4240           0 :             state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterSchedulePtr = GetScheduleIndex(state, Alphas(11));
    4241           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterSchedulePtr == 0) {
    4242           0 :                 ShowWarningError(state,
    4243           0 :                                  std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    4244           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(11) + "=\"" + Alphas(11) + "\".");
    4245           0 :                 ShowContinueError(state, "Basin heater will be available to operate throughout the simulation.");
    4246             :             }
    4247             :         }
    4248             : 
    4249             :         // A12; \field Fuel type, Validate fuel type input
    4250          48 :         bool FuelTypeError(false);
    4251         144 :         UtilityRoutines::ValidateFuelTypeWithAssignResourceTypeNum(
    4252         144 :             Alphas(12), state.dataDXCoils->DXCoil(DXCoilNum).FuelType, state.dataDXCoils->DXCoil(DXCoilNum).FuelTypeNum, FuelTypeError);
    4253          48 :         if (FuelTypeError) {
    4254           0 :             ShowSevereError(state,
    4255           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    4256           0 :             ShowContinueError(state, ",,,invalid choice for " + cAlphaFields(12) + ".  Entered choice = " + Alphas(12));
    4257           0 :             ShowContinueError(
    4258             :                 state, "Valid choices are Electricity, NaturalGas, PropaneGas, Diesel, Gasoline, FuelOilNo1, FuelOilNo2, OtherFuel1 or OtherFuel2");
    4259           0 :             ErrorsFound = true;
    4260           0 :             FuelTypeError = false;
    4261             :         }
    4262             : 
    4263          48 :         state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds = Numbers(6); // Number of speeds
    4264          48 :         if (state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds < 2) {
    4265           0 :             ShowSevereError(state,
    4266           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    4267           0 :             ShowContinueError(state, format("...{} must be >= 2. entered number is {:.0T}", cNumericFields(6), Numbers(6)));
    4268           0 :             ErrorsFound = true;
    4269             :         }
    4270             : 
    4271             :         // Allocate arrays based on the number of speeds
    4272          48 :         state.dataDXCoils->DXCoil(DXCoilNum).MSErrIndex.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4273          48 :         state.dataDXCoils->DXCoil(DXCoilNum).MSErrIndex = 0;
    4274          48 :         state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4275          48 :         state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCapDes.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4276          48 :         state.dataDXCoils->DXCoil(DXCoilNum).MSRatedSHR.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4277          48 :         state.dataDXCoils->DXCoil(DXCoilNum).MSRatedCOP.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4278          48 :         state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirVolFlowRate.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4279          48 :         state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirMassFlowRate.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4280          48 :         state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFTemp.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4281          48 :         state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFFlow.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4282          48 :         state.dataDXCoils->DXCoil(DXCoilNum).MSEIRFTemp.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4283          48 :         state.dataDXCoils->DXCoil(DXCoilNum).MSEIRFFlow.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4284          48 :         state.dataDXCoils->DXCoil(DXCoilNum).MSWasteHeat.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4285          48 :         state.dataDXCoils->DXCoil(DXCoilNum).MSEvapCondEffect.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4286          48 :         state.dataDXCoils->DXCoil(DXCoilNum).MSEvapCondAirFlow.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4287          48 :         state.dataDXCoils->DXCoil(DXCoilNum).MSEvapCondPumpElecNomPower.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4288          48 :         state.dataDXCoils->DXCoil(DXCoilNum).MSRatedCBF.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4289          48 :         state.dataDXCoils->DXCoil(DXCoilNum).MSWasteHeatFrac.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4290          48 :         state.dataDXCoils->DXCoil(DXCoilNum).MSPLFFPLR.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4291          48 :         state.dataDXCoils->DXCoil(DXCoilNum).MSTwet_Rated.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4292          48 :         state.dataDXCoils->DXCoil(DXCoilNum).MSGamma_Rated.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4293          48 :         state.dataDXCoils->DXCoil(DXCoilNum).MSMaxONOFFCyclesperHour.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4294          48 :         state.dataDXCoils->DXCoil(DXCoilNum).MSLatentCapacityTimeConstant.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4295          48 :         state.dataDXCoils->DXCoil(DXCoilNum).MSFanPowerPerEvapAirFlowRate.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4296          48 :         state.dataDXCoils->DXCoil(DXCoilNum).MSFanPowerPerEvapAirFlowRate_2023.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4297             : 
    4298         157 :         for (I = 1; I <= state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds; ++I) {
    4299         109 :             state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(I) = Numbers(7 + (I - 1) * 14);
    4300         109 :             state.dataDXCoils->DXCoil(DXCoilNum).MSRatedSHR(I) = Numbers(8 + (I - 1) * 14);
    4301         109 :             state.dataDXCoils->DXCoil(DXCoilNum).MSRatedCOP(I) = Numbers(9 + (I - 1) * 14);
    4302         109 :             state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirVolFlowRate(I) = Numbers(10 + (I - 1) * 14);
    4303         109 :             state.dataDXCoils->DXCoil(DXCoilNum).MSFanPowerPerEvapAirFlowRate(I) = Numbers(11 + (I - 1) * 14);
    4304         109 :             state.dataDXCoils->DXCoil(DXCoilNum).MSFanPowerPerEvapAirFlowRate_2023(I) = Numbers(12 + (I - 1) * 14);
    4305             : 
    4306         109 :             state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFTemp(I) = GetCurveIndex(state, Alphas(13 + (I - 1) * 6)); // convert curve name to number
    4307         109 :             if (state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFTemp(I) == 0) {
    4308           0 :                 if (lAlphaBlanks(13 + (I - 1) * 6)) {
    4309           0 :                     ShowSevereError(
    4310           0 :                         state, std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", missing");
    4311           0 :                     ShowContinueError(state, "...required " + cAlphaFields(13 + (I - 1) * 6) + " is blank.");
    4312             :                 } else {
    4313           0 :                     ShowSevereError(
    4314           0 :                         state, std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    4315           0 :                     ShowContinueError(state, "...not found " + cAlphaFields(13 + (I - 1) * 6) + "=\"" + Alphas(13 + (I - 1) * 6) + "\".");
    4316             :                 }
    4317           0 :                 ErrorsFound = true;
    4318             :             } else {
    4319             :                 // Verify Curve Object, only legal type is BiQuadratic
    4320         327 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    4321         109 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFTemp(I), // Curve index
    4322             :                                                      {2},                                                 // Valid dimensions
    4323             :                                                      RoutineName,                                         // Routine name
    4324             :                                                      CurrentModuleObject,                                 // Object Type
    4325         109 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,           // Object Name
    4326         109 :                                                      cAlphaFields(13 + (I - 1) * 6));                     // Field Name
    4327             : 
    4328         109 :                 if (!ErrorsFound) {
    4329         545 :                     checkCurveIsNormalizedToOne(state,
    4330         218 :                                                 std::string{RoutineName} + CurrentModuleObject,
    4331         109 :                                                 state.dataDXCoils->DXCoil(DXCoilNum).Name,
    4332         109 :                                                 state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFTemp(I),
    4333         109 :                                                 cAlphaFields(13 + (I - 1) * 6),
    4334         109 :                                                 Alphas(13 + (I - 1) * 6),
    4335             :                                                 RatedInletWetBulbTemp,
    4336             :                                                 RatedOutdoorAirTemp);
    4337             :                 }
    4338             :             }
    4339             : 
    4340         109 :             state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFFlow(I) = GetCurveIndex(state, Alphas(14 + (I - 1) * 6)); // convert curve name to number
    4341         109 :             if (state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFFlow(I) == 0) {
    4342           0 :                 if (lAlphaBlanks(14 + (I - 1) * 6)) {
    4343           0 :                     ShowSevereError(
    4344           0 :                         state, std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", missing");
    4345           0 :                     ShowContinueError(state, "...required " + cAlphaFields(14 + (I - 1) * 6) + " is blank.");
    4346             :                 } else {
    4347           0 :                     ShowSevereError(
    4348           0 :                         state, std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    4349           0 :                     ShowContinueError(state, "...not found " + cAlphaFields(14 + (I - 1) * 6) + "=\"" + Alphas(14 + (I - 1) * 6) + "\".");
    4350             :                 }
    4351           0 :                 ErrorsFound = true;
    4352             :             } else {
    4353             :                 // Verify Curve Object, only legal type is Quadratic
    4354         327 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    4355         109 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFFlow(I), // Curve index
    4356             :                                                      {1},                                                 // Valid dimensions
    4357             :                                                      RoutineName,                                         // Routine name
    4358             :                                                      CurrentModuleObject,                                 // Object Type
    4359         109 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,           // Object Name
    4360         109 :                                                      cAlphaFields(14 + (I - 1) * 6));                     // Field Name
    4361             : 
    4362         109 :                 if (!ErrorsFound) {
    4363         545 :                     checkCurveIsNormalizedToOne(state,
    4364         218 :                                                 std::string{RoutineName} + CurrentModuleObject,
    4365         109 :                                                 state.dataDXCoils->DXCoil(DXCoilNum).Name,
    4366         109 :                                                 state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFFlow(I),
    4367         109 :                                                 cAlphaFields(14 + (I - 1) * 6),
    4368         109 :                                                 Alphas(14 + (I - 1) * 6),
    4369             :                                                 1.0);
    4370             :                 }
    4371             :             }
    4372             : 
    4373         109 :             state.dataDXCoils->DXCoil(DXCoilNum).MSEIRFTemp(I) = GetCurveIndex(state, Alphas(15 + (I - 1) * 6)); // convert curve name to number
    4374         109 :             if (state.dataDXCoils->DXCoil(DXCoilNum).MSEIRFTemp(I) == 0) {
    4375           0 :                 if (lAlphaBlanks(15 + (I - 1) * 6)) {
    4376           0 :                     ShowSevereError(
    4377           0 :                         state, std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", missing");
    4378           0 :                     ShowContinueError(state, "...required " + cAlphaFields(15 + (I - 1) * 6) + " is blank.");
    4379             :                 } else {
    4380           0 :                     ShowSevereError(
    4381           0 :                         state, std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    4382           0 :                     ShowContinueError(state, "...not found " + cAlphaFields(15 + (I - 1) * 6) + "=\"" + Alphas(15 + (I - 1) * 6) + "\".");
    4383             :                 }
    4384           0 :                 ErrorsFound = true;
    4385             :             } else {
    4386             :                 // Verify Curve Object, only legal type is BiQuadratic
    4387         327 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    4388         109 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).MSEIRFTemp(I), // Curve index
    4389             :                                                      {2},                                                // Valid dimensions
    4390             :                                                      RoutineName,                                        // Routine name
    4391             :                                                      CurrentModuleObject,                                // Object Type
    4392         109 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,          // Object Name
    4393         109 :                                                      cAlphaFields(15 + (I - 1) * 6));                    // Field Name
    4394             : 
    4395         109 :                 if (!ErrorsFound) {
    4396         545 :                     checkCurveIsNormalizedToOne(state,
    4397         218 :                                                 std::string{RoutineName} + CurrentModuleObject,
    4398         109 :                                                 state.dataDXCoils->DXCoil(DXCoilNum).Name,
    4399         109 :                                                 state.dataDXCoils->DXCoil(DXCoilNum).MSEIRFTemp(I),
    4400         109 :                                                 cAlphaFields(15 + (I - 1) * 6),
    4401         109 :                                                 Alphas(15 + (I - 1) * 6),
    4402             :                                                 RatedInletWetBulbTemp,
    4403             :                                                 RatedOutdoorAirTemp);
    4404             :                 }
    4405             :             }
    4406             : 
    4407         109 :             state.dataDXCoils->DXCoil(DXCoilNum).MSEIRFFlow(I) = GetCurveIndex(state, Alphas(16 + (I - 1) * 6)); // convert curve name to number
    4408         109 :             if (state.dataDXCoils->DXCoil(DXCoilNum).MSEIRFFlow(I) == 0) {
    4409           0 :                 if (lAlphaBlanks(16 + (I - 1) * 6)) {
    4410           0 :                     ShowSevereError(
    4411           0 :                         state, std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", missing");
    4412           0 :                     ShowContinueError(state, "...required " + cAlphaFields(16 + (I - 1) * 6) + " is blank.");
    4413             :                 } else {
    4414           0 :                     ShowSevereError(
    4415           0 :                         state, std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    4416           0 :                     ShowContinueError(state, "...not found " + cAlphaFields(16 + (I - 1) * 6) + "=\"" + Alphas(16 + (I - 1) * 6) + "\".");
    4417             :                 }
    4418           0 :                 ErrorsFound = true;
    4419             :             } else {
    4420             :                 // Verify Curve Object, only legal type is Quadratic
    4421         327 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    4422         109 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).MSEIRFFlow(I), // Curve index
    4423             :                                                      {1},                                                // Valid dimensions
    4424             :                                                      RoutineName,                                        // Routine name
    4425             :                                                      CurrentModuleObject,                                // Object Type
    4426         109 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,          // Object Name
    4427         109 :                                                      cAlphaFields(16 + (I - 1) * 6));                    // Field Name
    4428             : 
    4429         109 :                 if (!ErrorsFound) {
    4430         545 :                     checkCurveIsNormalizedToOne(state,
    4431         218 :                                                 std::string{RoutineName} + CurrentModuleObject,
    4432         109 :                                                 state.dataDXCoils->DXCoil(DXCoilNum).Name,
    4433         109 :                                                 state.dataDXCoils->DXCoil(DXCoilNum).MSEIRFFlow(I),
    4434         109 :                                                 cAlphaFields(16 + (I - 1) * 6),
    4435         109 :                                                 Alphas(16 + (I - 1) * 6),
    4436             :                                                 1.0);
    4437             :                 }
    4438             :             }
    4439             : 
    4440         109 :             state.dataDXCoils->DXCoil(DXCoilNum).MSPLFFPLR(I) = GetCurveIndex(state, Alphas(17 + (I - 1) * 6)); // convert curve name to number
    4441         109 :             if (state.dataDXCoils->DXCoil(DXCoilNum).MSPLFFPLR(I) == 0) {
    4442           0 :                 if (lAlphaBlanks(17 + (I - 1) * 6)) {
    4443           0 :                     ShowSevereError(
    4444           0 :                         state, std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", missing");
    4445           0 :                     ShowContinueError(state, "...required " + cAlphaFields(17 + (I - 1) * 6) + " is blank.");
    4446             :                 } else {
    4447           0 :                     ShowSevereError(
    4448           0 :                         state, std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    4449           0 :                     ShowContinueError(state, "...not found " + cAlphaFields(17 + (I - 1) * 6) + "=\"" + Alphas(16 + (I - 1) * 6) + "\".");
    4450             :                 }
    4451           0 :                 ErrorsFound = true;
    4452             :             } else {
    4453             :                 // Verify Curve Object, only legal types are Quadratic or Cubic
    4454         327 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    4455         109 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).MSPLFFPLR(I), // Curve index
    4456             :                                                      {1},                                               // Valid dimensions
    4457             :                                                      RoutineName,                                       // Routine name
    4458             :                                                      CurrentModuleObject,                               // Object Type
    4459         109 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,         // Object Name
    4460         109 :                                                      cAlphaFields(17 + (I - 1) * 6));                   // Field Name
    4461             : 
    4462         109 :                 if (!ErrorsFound) {
    4463             :                     //       Test PLF curve minimum and maximum. Cap if less than 0.7 or greater than 1.0.
    4464         109 :                     MinCurveVal = 999.0;
    4465         109 :                     MaxCurveVal = -999.0;
    4466         109 :                     CurveInput = 0.0;
    4467       21909 :                     while (CurveInput <= 1.0) {
    4468       10900 :                         CurveVal = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).MSPLFFPLR(I), CurveInput);
    4469       10900 :                         if (CurveVal < MinCurveVal) {
    4470         109 :                             MinCurveVal = CurveVal;
    4471         109 :                             MinCurvePLR = CurveInput;
    4472             :                         }
    4473       10900 :                         if (CurveVal > MaxCurveVal) {
    4474       10900 :                             MaxCurveVal = CurveVal;
    4475       10900 :                             MaxCurvePLR = CurveInput;
    4476             :                         }
    4477       10900 :                         CurveInput += 0.01;
    4478             :                     }
    4479         109 :                     if (MinCurveVal < 0.7) {
    4480           0 :                         ShowWarningError(state,
    4481           0 :                                          std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name +
    4482             :                                              "\", invalid");
    4483           0 :                         ShowContinueError(state,
    4484           0 :                                           "..." + cAlphaFields2(17 + (I - 1) * 6) + " = " + Alphas2(17 + (I - 1) * 6) + " has out of range value.");
    4485           0 :                         ShowContinueError(state,
    4486           0 :                                           format("...Curve minimum must be >= 0.7, curve min at PLR = {:.2T} is {:.3T}", MinCurvePLR, MinCurveVal));
    4487           0 :                         ShowContinueError(state, "...Setting curve minimum to 0.7 and simulation continues.");
    4488           0 :                         SetCurveOutputMinMaxValues(state, state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(PerfModeNum), ErrorsFound, 0.7, _);
    4489             :                     }
    4490             : 
    4491         109 :                     if (MaxCurveVal > 1.0) {
    4492           0 :                         ShowWarningError(state,
    4493           0 :                                          std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name +
    4494             :                                              "\", invalid");
    4495           0 :                         ShowContinueError(state,
    4496           0 :                                           "..." + cAlphaFields2(17 + (I - 1) * 6) + " = " + Alphas2(17 + (I - 1) * 6) + " has out of range value.");
    4497           0 :                         ShowContinueError(state,
    4498           0 :                                           format("...Curve maximum must be <= 1.0, curve max at PLR = {:.2T} is {:.3T}", MaxCurvePLR, MaxCurveVal));
    4499           0 :                         ShowContinueError(state, "...Setting curve maximum to 1.0 and simulation continues.");
    4500           0 :                         SetCurveOutputMinMaxValues(state, state.dataDXCoils->DXCoil(DXCoilNum).MSPLFFPLR(I), ErrorsFound, _, 1.0);
    4501             :                     }
    4502             :                 }
    4503             :             }
    4504             : 
    4505             :             // read data for latent degradation
    4506         109 :             state.dataDXCoils->DXCoil(DXCoilNum).MSTwet_Rated(I) = Numbers(13 + (I - 1) * 14);
    4507         109 :             if (state.dataDXCoils->DXCoil(DXCoilNum).MSTwet_Rated(I) < 0.0) {
    4508           0 :                 ShowSevereError(state,
    4509           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    4510           0 :                 ShowContinueError(state,
    4511           0 :                                   format("...{} cannot be < 0.0, entered value=[{:.4T}].",
    4512           0 :                                          cNumericFields(13 + (I - 1) * 14),
    4513           0 :                                          state.dataDXCoils->DXCoil(DXCoilNum).MSTwet_Rated(I)));
    4514           0 :                 ErrorsFound = true;
    4515             :             }
    4516         109 :             state.dataDXCoils->DXCoil(DXCoilNum).MSGamma_Rated(I) = Numbers(14 + (I - 1) * 14);
    4517         109 :             if (state.dataDXCoils->DXCoil(DXCoilNum).MSGamma_Rated(I) < 0.0) {
    4518           0 :                 ShowSevereError(state,
    4519           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    4520           0 :                 ShowContinueError(state,
    4521           0 :                                   format("...{} cannot be < 0.0, entered value=[{:.4T}].",
    4522             :                                          cNumericFields(14 + (I - 1) * 14),
    4523           0 :                                          state.dataDXCoils->DXCoil(DXCoilNum).MSGamma_Rated(I)));
    4524           0 :                 ErrorsFound = true;
    4525             :             }
    4526         109 :             state.dataDXCoils->DXCoil(DXCoilNum).MSMaxONOFFCyclesperHour(I) = Numbers(15 + (I - 1) * 14);
    4527         109 :             if (state.dataDXCoils->DXCoil(DXCoilNum).Gamma_Rated(I) < 0.0) {
    4528           0 :                 ShowSevereError(state,
    4529           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    4530           0 :                 ShowContinueError(state,
    4531           0 :                                   format("...{} cannot be < 0.0, entered value=[{:.2T}].",
    4532           0 :                                          cNumericFields(15 + (I - 1) * 14),
    4533           0 :                                          state.dataDXCoils->DXCoil(DXCoilNum).MSMaxONOFFCyclesperHour(I)));
    4534           0 :                 ErrorsFound = true;
    4535             :             }
    4536         109 :             state.dataDXCoils->DXCoil(DXCoilNum).MSLatentCapacityTimeConstant(I) = Numbers(16 + (I - 1) * 14);
    4537         109 :             if (state.dataDXCoils->DXCoil(DXCoilNum).Gamma_Rated(I) < 0.0) {
    4538           0 :                 ShowSevereError(state,
    4539           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    4540           0 :                 ShowContinueError(state,
    4541           0 :                                   format("...{} cannot be < 0.0, entered value=[{:.2T}].",
    4542           0 :                                          cNumericFields(16 + (I - 1) * 14),
    4543           0 :                                          state.dataDXCoils->DXCoil(DXCoilNum).MSLatentCapacityTimeConstant(I)));
    4544           0 :                 ErrorsFound = true;
    4545             :             }
    4546             : 
    4547         109 :             state.dataDXCoils->DXCoil(DXCoilNum).MSWasteHeatFrac(I) = Numbers(17 + (I - 1) * 14);
    4548             : 
    4549             :             // Read waste heat modifier curve name
    4550         109 :             state.dataDXCoils->DXCoil(DXCoilNum).MSWasteHeat(I) = GetCurveIndex(state, Alphas(18 + (I - 1) * 6)); // convert curve name to number
    4551         109 :             if (state.dataDXCoils->DXCoil(DXCoilNum).FuelTypeNum != DataGlobalConstants::ResourceType::Electricity) {
    4552          24 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).MSWasteHeat(I) > 0) {
    4553             :                     // Verify Curve Object, only legal types are BiQuadratic
    4554          72 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    4555          24 :                                                          state.dataDXCoils->DXCoil(DXCoilNum).MSWasteHeat(I), // Curve index
    4556             :                                                          {2},                                                 // Valid dimensions
    4557             :                                                          RoutineName,                                         // Routine name
    4558             :                                                          CurrentModuleObject,                                 // Object Type
    4559          24 :                                                          state.dataDXCoils->DXCoil(DXCoilNum).Name,           // Object Name
    4560          24 :                                                          cAlphaFields(18 + (I - 1) * 6));                     // Field Name
    4561             : 
    4562          24 :                     if (!ErrorsFound) {
    4563          24 :                         CurveVal = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).MSWasteHeat(I), RatedOutdoorAirTemp, RatedInletAirTemp);
    4564          24 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
    4565           0 :                             ShowWarningError(state,
    4566           0 :                                              std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name +
    4567             :                                                  "\", curve values");
    4568           0 :                             ShowContinueError(state, cAlphaFields(18 + (I - 1) * 6) + " = " + Alphas(18 + (I - 1) * 6));
    4569           0 :                             ShowContinueError(
    4570           0 :                                 state, "..." + cAlphaFields(18 + (I - 1) * 6) + " output is not equal to 1.0 (+ or - 10%) at rated conditions.");
    4571           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    4572             :                         }
    4573             :                     }
    4574             :                 }
    4575             :             }
    4576             : 
    4577         109 :             state.dataDXCoils->DXCoil(DXCoilNum).MSEvapCondEffect(I) = Numbers(18 + (I - 1) * 14);
    4578         109 :             if (state.dataDXCoils->DXCoil(DXCoilNum).MSEvapCondEffect(I) < 0.0 || state.dataDXCoils->DXCoil(DXCoilNum).MSEvapCondEffect(I) > 1.0) {
    4579           0 :                 ShowSevereError(state,
    4580           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    4581           0 :                 ShowContinueError(
    4582             :                     state,
    4583           0 :                     format("...{} cannot be < 0.0 or > 1.0, entered value=[{:.3T}].", cNumericFields(18 + (I - 1) * 14), Numbers(18 + (I - 1) * 14)));
    4584           0 :                 ErrorsFound = true;
    4585             :             }
    4586             : 
    4587         109 :             state.dataDXCoils->DXCoil(DXCoilNum).MSEvapCondAirFlow(I) = Numbers(19 + (I - 1) * 14);
    4588         109 :             if (state.dataDXCoils->DXCoil(DXCoilNum).MSEvapCondAirFlow(I) < 0.0 &&
    4589           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).MSEvapCondAirFlow(I) != AutoSize) {
    4590           0 :                 ShowSevereError(state,
    4591           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    4592           0 :                 ShowContinueError(
    4593           0 :                     state, format("...{} cannot be < 0.0, entered value=[{:.3T}].", cNumericFields(19 + (I - 1) * 14), Numbers(19 + (I - 1) * 14)));
    4594           0 :                 ErrorsFound = true;
    4595             :             }
    4596             : 
    4597         109 :             state.dataDXCoils->DXCoil(DXCoilNum).MSEvapCondPumpElecNomPower(I) = Numbers(20 + (I - 1) * 14);
    4598         109 :             if (state.dataDXCoils->DXCoil(DXCoilNum).MSEvapCondPumpElecNomPower(I) < 0.0 &&
    4599           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).MSEvapCondPumpElecNomPower(I) != AutoSize) {
    4600           0 :                 ShowSevereError(state,
    4601           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    4602           0 :                 ShowContinueError(
    4603           0 :                     state, format("...{} cannot be < 0.0, entered value=[{:.3T}].", cNumericFields(20 + (I - 1) * 14), Numbers(20 + (I - 1) * 14)));
    4604           0 :                 ErrorsFound = true;
    4605             :             }
    4606             :         }
    4607             :         // A37; \field Zone Name for Condenser Placement
    4608          48 :         if (!lAlphaBlanks(37) && NumAlphas > 36) {
    4609           0 :             state.dataDXCoils->DXCoil(DXCoilNum).SecZonePtr = UtilityRoutines::FindItemInList(Alphas(37), state.dataHeatBal->Zone);
    4610           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).SecZonePtr > 0) {
    4611           0 :                 SetupZoneInternalGain(state,
    4612           0 :                                       state.dataDXCoils->DXCoil(DXCoilNum).SecZonePtr,
    4613           0 :                                       state.dataDXCoils->DXCoil(DXCoilNum).Name,
    4614             :                                       DataHeatBalance::IntGainType::SecCoolingDXCoilMultiSpeed,
    4615           0 :                                       &state.dataDXCoils->DXCoil(DXCoilNum).SecCoilSensibleHeatGainRate);
    4616           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).IsSecondaryDXCoilInZone = true;
    4617             :             } else {
    4618           0 :                 ShowSevereError(state,
    4619           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    4620           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(37) + "=\"" + Alphas(37) + "\".");
    4621             :             }
    4622             :         }
    4623             :     }
    4624             : 
    4625         241 :     if (ErrorsFound) {
    4626           0 :         ShowFatalError(state,
    4627           0 :                        std::string{RoutineName} + "Errors found in getting " + CurrentModuleObject +
    4628             :                            " input. Preceding condition(s) causes termination.");
    4629             :     }
    4630             : 
    4631             :     // DX multispeed heating coil
    4632         241 :     CurrentModuleObject = "Coil:Heating:DX:MultiSpeed";
    4633         261 :     for (DXCoilIndex = 1; DXCoilIndex <= state.dataDXCoils->NumDXMulSpeedHeatCoils; ++DXCoilIndex) {
    4634             : 
    4635          20 :         ++DXCoilNum;
    4636             : 
    4637          20 :         state.dataInputProcessing->inputProcessor->getObjectItem(state,
    4638             :                                                                  CurrentModuleObject,
    4639             :                                                                  DXCoilIndex,
    4640             :                                                                  Alphas,
    4641             :                                                                  NumAlphas,
    4642             :                                                                  Numbers,
    4643             :                                                                  NumNumbers,
    4644             :                                                                  IOStatus,
    4645             :                                                                  lNumericBlanks,
    4646             :                                                                  lAlphaBlanks,
    4647             :                                                                  cAlphaFields,
    4648             :                                                                  cNumericFields);
    4649             : 
    4650             :         // *** will have to circle back to this one to fix since the multispeed coil has all fields in this coil object ***
    4651             :         // allocate single performance mode for numeric field strings used for sizing routine
    4652          20 :         state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode.allocate(1);
    4653          20 :         state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(1).FieldNames.allocate(MaxNumbers);
    4654          20 :         state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(1).FieldNames = cNumericFields;
    4655          20 :         UtilityRoutines::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    4656             :         // ErrorsFound will be set to True if problem was found, left untouched otherwise
    4657          20 :         VerifyUniqueCoilName(state, CurrentModuleObject, Alphas(1), ErrorsFound, CurrentModuleObject + " Name");
    4658             : 
    4659          20 :         state.dataDXCoils->DXCoil(DXCoilNum).Name = Alphas(1);
    4660             :         // Initialize DataHeatBalance heat reclaim variable name for use by heat reclaim coils
    4661          20 :         state.dataHeatBal->HeatReclaimDXCoil(DXCoilNum).Name = state.dataDXCoils->DXCoil(DXCoilNum).Name;
    4662          20 :         state.dataHeatBal->HeatReclaimDXCoil(DXCoilNum).SourceType = CurrentModuleObject;
    4663          20 :         state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType = CurrentModuleObject;
    4664          20 :         state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num = CoilDX_MultiSpeedHeating;
    4665          20 :         state.dataDXCoils->DXCoil(DXCoilNum).Schedule = Alphas(2);
    4666          20 :         if (lAlphaBlanks(2)) {
    4667           6 :             state.dataDXCoils->DXCoil(DXCoilNum).SchedPtr = DataGlobalConstants::ScheduleAlwaysOn;
    4668             :         } else {
    4669          14 :             state.dataDXCoils->DXCoil(DXCoilNum).SchedPtr = GetScheduleIndex(state, Alphas(2)); // convert schedule name to pointer
    4670          14 :             if (state.dataDXCoils->DXCoil(DXCoilNum).SchedPtr == 0) {
    4671           0 :                 ShowSevereError(state,
    4672           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    4673           0 :                 ShowContinueError(state, "..." + cAlphaFields(2) + "=\"" + Alphas(2) + "\".");
    4674           0 :                 ErrorsFound = true;
    4675             :             }
    4676             :         }
    4677             : 
    4678          20 :         state.dataDXCoils->DXCoil(DXCoilNum).AirInNode = GetOnlySingleNode(state,
    4679          20 :                                                                            Alphas(3),
    4680             :                                                                            ErrorsFound,
    4681             :                                                                            DataLoopNode::ConnectionObjectType::CoilHeatingDXMultiSpeed,
    4682          20 :                                                                            Alphas(1),
    4683             :                                                                            DataLoopNode::NodeFluidType::Air,
    4684             :                                                                            DataLoopNode::ConnectionType::Inlet,
    4685             :                                                                            NodeInputManager::CompFluidStream::Primary,
    4686          20 :                                                                            ObjectIsNotParent);
    4687             : 
    4688          20 :         state.dataDXCoils->DXCoil(DXCoilNum).AirOutNode = GetOnlySingleNode(state,
    4689          20 :                                                                             Alphas(4),
    4690             :                                                                             ErrorsFound,
    4691             :                                                                             DataLoopNode::ConnectionObjectType::CoilHeatingDXMultiSpeed,
    4692          20 :                                                                             Alphas(1),
    4693             :                                                                             DataLoopNode::NodeFluidType::Air,
    4694             :                                                                             DataLoopNode::ConnectionType::Outlet,
    4695             :                                                                             NodeInputManager::CompFluidStream::Primary,
    4696          20 :                                                                             ObjectIsNotParent);
    4697             : 
    4698          20 :         TestCompSet(state, CurrentModuleObject, Alphas(1), Alphas(3), Alphas(4), "Air Nodes");
    4699             : 
    4700             :         // Set minimum OAT for heat pump compressor operation
    4701          20 :         state.dataDXCoils->DXCoil(DXCoilNum).MinOATCompressor = Numbers(1);
    4702             : 
    4703             :         // set Minimum Outdoor Dry-Bulb Temperature for Compressor Operation
    4704          20 :         state.dataDXCoils->DXCoil(DXCoilNum).OATempCompressorOn = Numbers(2);
    4705             :         // Set crankcase heater capacity
    4706          20 :         state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterCapacity = Numbers(3);
    4707          20 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterCapacity < 0.0) {
    4708           0 :             ShowSevereError(state,
    4709           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    4710           0 :             ShowContinueError(state, format("...{} cannot be < 0.0, entered value=[{:.2T}].", cNumericFields(3), Numbers(3)));
    4711           0 :             ErrorsFound = true;
    4712             :         }
    4713             : 
    4714             :         // Set crankcase heater cutout temperature
    4715          20 :         state.dataDXCoils->DXCoil(DXCoilNum).MaxOATCrankcaseHeater = Numbers(4);
    4716             : 
    4717             :         // Only required for reverse cycle heat pumps
    4718          20 :         state.dataDXCoils->DXCoil(DXCoilNum).DefrostEIRFT = GetCurveIndex(state, Alphas(5)); // convert curve name to number
    4719          20 :         if (UtilityRoutines::SameString(Alphas(6), "ReverseCycle")) {
    4720          20 :             if (state.dataDXCoils->DXCoil(DXCoilNum).DefrostEIRFT == 0) {
    4721           0 :                 if (lAlphaBlanks(5)) {
    4722           0 :                     ShowSevereError(
    4723           0 :                         state, std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", missing");
    4724           0 :                     ShowContinueError(state, "...required " + cAlphaFields(5) + " is blank.");
    4725             :                 } else {
    4726           0 :                     ShowSevereError(
    4727           0 :                         state, std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    4728           0 :                     ShowContinueError(state, "...not found " + cAlphaFields(5) + "=\"" + Alphas(5) + "\".");
    4729             :                 }
    4730           0 :                 ErrorsFound = true;
    4731             :             } else {
    4732             :                 // Verify Curve Object, only legal type is BiQuadratic
    4733          60 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    4734          20 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).DefrostEIRFT, // Curve index
    4735             :                                                      {2},                                               // Valid dimensions
    4736             :                                                      RoutineName,                                       // Routine name
    4737             :                                                      CurrentModuleObject,                               // Object Type
    4738          20 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,         // Object Name
    4739          20 :                                                      cAlphaFields(5));                                  // Field Name
    4740             : 
    4741          20 :                 if (!ErrorsFound) {
    4742         100 :                     checkCurveIsNormalizedToOne(state,
    4743          40 :                                                 std::string{RoutineName} + CurrentModuleObject,
    4744          20 :                                                 state.dataDXCoils->DXCoil(DXCoilNum).Name,
    4745          20 :                                                 state.dataDXCoils->DXCoil(DXCoilNum).DefrostEIRFT,
    4746          20 :                                                 cAlphaFields(5),
    4747          20 :                                                 Alphas(5),
    4748             :                                                 RatedInletWetBulbTempHeat,
    4749             :                                                 RatedOutdoorAirTempHeat);
    4750             :                 }
    4751             :             }
    4752             :         }
    4753             : 
    4754          20 :         if (UtilityRoutines::SameString(Alphas(6), "ReverseCycle"))
    4755          20 :             state.dataDXCoils->DXCoil(DXCoilNum).DefrostStrategy = StandardRatings::DefrostStrat::ReverseCycle;
    4756          20 :         if (UtilityRoutines::SameString(Alphas(6), "Resistive"))
    4757           0 :             state.dataDXCoils->DXCoil(DXCoilNum).DefrostStrategy = StandardRatings::DefrostStrat::Resistive;
    4758          20 :         if (state.dataDXCoils->DXCoil(DXCoilNum).DefrostStrategy == StandardRatings::DefrostStrat::Invalid) {
    4759           0 :             ShowSevereError(state,
    4760           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    4761           0 :             ShowContinueError(state, "...illegal " + cAlphaFields(6) + "=\"" + Alphas(6) + "\".");
    4762           0 :             ShowContinueError(state, "...valid values for this field are ReverseCycle or Resistive.");
    4763           0 :             ErrorsFound = true;
    4764             :         }
    4765             : 
    4766          20 :         if (UtilityRoutines::SameString(Alphas(7), "Timed"))
    4767          20 :             state.dataDXCoils->DXCoil(DXCoilNum).DefrostControl = StandardRatings::HPdefrostControl::Timed;
    4768          20 :         if (UtilityRoutines::SameString(Alphas(7), "OnDemand"))
    4769           0 :             state.dataDXCoils->DXCoil(DXCoilNum).DefrostControl = StandardRatings::HPdefrostControl::OnDemand;
    4770          20 :         if (state.dataDXCoils->DXCoil(DXCoilNum).DefrostControl == StandardRatings::HPdefrostControl::Invalid) {
    4771           0 :             ShowSevereError(state,
    4772           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    4773           0 :             ShowContinueError(state, "...illegal " + cAlphaFields(7) + "=\"" + Alphas(7) + "\".");
    4774           0 :             ShowContinueError(state, "...valid values for this field are Timed or OnDemand.");
    4775           0 :             ErrorsFound = true;
    4776             :         }
    4777             : 
    4778             :         // Set maximum outdoor temp for defrost to occur
    4779          20 :         state.dataDXCoils->DXCoil(DXCoilNum).MaxOATDefrost = Numbers(5);
    4780             : 
    4781             :         // Set defrost time period
    4782          20 :         state.dataDXCoils->DXCoil(DXCoilNum).DefrostTime = Numbers(6);
    4783          20 :         if (state.dataDXCoils->DXCoil(DXCoilNum).DefrostTime == 0.0 &&
    4784           0 :             state.dataDXCoils->DXCoil(DXCoilNum).DefrostControl == StandardRatings::HPdefrostControl::Timed) {
    4785           0 :             ShowWarningError(state, std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", ");
    4786           0 :             ShowContinueError(state, "..." + cNumericFields(5) + " = 0.0 for defrost control = TIMED.");
    4787             :         }
    4788             : 
    4789             :         // Set defrost capacity (for resistive defrost)
    4790          20 :         state.dataDXCoils->DXCoil(DXCoilNum).DefrostCapacity = Numbers(7);
    4791          20 :         if (state.dataDXCoils->DXCoil(DXCoilNum).DefrostCapacity == 0.0 &&
    4792           0 :             state.dataDXCoils->DXCoil(DXCoilNum).DefrostStrategy == StandardRatings::DefrostStrat::Resistive) {
    4793           0 :             ShowWarningError(state, std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", ");
    4794           0 :             ShowContinueError(state, "..." + cNumericFields(7) + " = 0.0 for defrost strategy = RESISTIVE.");
    4795             :         }
    4796             : 
    4797          20 :         if (UtilityRoutines::SameString(Alphas(8), "Yes")) {
    4798           0 :             state.dataDXCoils->DXCoil(DXCoilNum).PLRImpact = true;
    4799          20 :         } else if (UtilityRoutines::SameString(Alphas(8), "No")) {
    4800          20 :             state.dataDXCoils->DXCoil(DXCoilNum).PLRImpact = false;
    4801             :         } else {
    4802           0 :             ShowSevereError(state,
    4803           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    4804           0 :             ShowContinueError(state, ",,,invalid choice for " + cAlphaFields(8) + ".  Entered choice = " + Alphas(8));
    4805           0 :             ShowContinueError(state, "The allowed choices are Yes or No.");
    4806           0 :             ErrorsFound = true;
    4807             :         }
    4808             : 
    4809             :         // A9; \field Fuel type, Validate fuel type input
    4810          20 :         bool FuelTypeError(false);
    4811          60 :         UtilityRoutines::ValidateFuelTypeWithAssignResourceTypeNum(
    4812          60 :             Alphas(9), state.dataDXCoils->DXCoil(DXCoilNum).FuelType, state.dataDXCoils->DXCoil(DXCoilNum).FuelTypeNum, FuelTypeError);
    4813          20 :         if (FuelTypeError) {
    4814           0 :             ShowSevereError(state,
    4815           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    4816           0 :             ShowContinueError(state, ",,,invalid choice for " + cAlphaFields(9) + ".  Entered choice = " + Alphas(9));
    4817           0 :             ShowContinueError(
    4818             :                 state, "Valid choices are Electricity, NaturalGas, PropaneGas, Diesel, Gasoline, FuelOilNo1, FuelOilNo2, OtherFuel1 or OtherFuel2");
    4819           0 :             ErrorsFound = true;
    4820           0 :             FuelTypeError = false;
    4821             :         }
    4822             : 
    4823          20 :         state.dataDXCoils->DXCoil(DXCoilNum).RegionNum = Numbers(8);   // Region Number for HSPF Calc
    4824          20 :         state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds = Numbers(9); // Number of speeds
    4825          20 :         if (state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds < 2) {
    4826           0 :             ShowSevereError(state,
    4827           0 :                             std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    4828           0 :             ShowContinueError(state, format("...{} must be >= 2. entered number is {:.0T}", cNumericFields(9), Numbers(9)));
    4829           0 :             ErrorsFound = true;
    4830             :         }
    4831             : 
    4832             :         // Allocate arrays based on the number of speeds
    4833          20 :         state.dataDXCoils->DXCoil(DXCoilNum).MSErrIndex.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4834          20 :         state.dataDXCoils->DXCoil(DXCoilNum).MSErrIndex = 0;
    4835          20 :         state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4836          20 :         state.dataDXCoils->DXCoil(DXCoilNum).MSRatedCOP.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4837          20 :         state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirVolFlowRate.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4838          20 :         state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirMassFlowRate.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4839          20 :         state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFTemp.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4840          20 :         state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFFlow.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4841          20 :         state.dataDXCoils->DXCoil(DXCoilNum).MSEIRFTemp.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4842          20 :         state.dataDXCoils->DXCoil(DXCoilNum).MSEIRFFlow.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4843          20 :         state.dataDXCoils->DXCoil(DXCoilNum).MSWasteHeat.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4844          20 :         state.dataDXCoils->DXCoil(DXCoilNum).MSPLFFPLR.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4845          20 :         state.dataDXCoils->DXCoil(DXCoilNum).MSRatedCBF.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4846          20 :         state.dataDXCoils->DXCoil(DXCoilNum).MSWasteHeatFrac.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4847          20 :         state.dataDXCoils->DXCoil(DXCoilNum).MSFanPowerPerEvapAirFlowRate.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4848          20 :         state.dataDXCoils->DXCoil(DXCoilNum).MSFanPowerPerEvapAirFlowRate_2023.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4849          20 :         state.dataDXCoils->DXCoil(DXCoilNum).MSSecCoilSHRFT.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4850          20 :         state.dataDXCoils->DXCoil(DXCoilNum).MSSecCoilSHRFF.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4851          20 :         state.dataDXCoils->DXCoil(DXCoilNum).MSSecCoilAirFlow.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4852          20 :         state.dataDXCoils->DXCoil(DXCoilNum).MSSecCoilAirFlowScalingFactor.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4853          20 :         state.dataDXCoils->DXCoil(DXCoilNum).MSSecCoilRatedSHR.allocate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    4854             : 
    4855          20 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedSHR(1) = 1.0;
    4856             : 
    4857          82 :         for (I = 1; I <= state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds; ++I) {
    4858          62 :             state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(I) = Numbers(10 + (I - 1) * 6);
    4859          62 :             state.dataDXCoils->DXCoil(DXCoilNum).MSRatedCOP(I) = Numbers(11 + (I - 1) * 6);
    4860          62 :             state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirVolFlowRate(I) = Numbers(12 + (I - 1) * 6);
    4861          62 :             state.dataDXCoils->DXCoil(DXCoilNum).MSFanPowerPerEvapAirFlowRate(I) = Numbers(13 + (I - 1) * 6);
    4862          62 :             state.dataDXCoils->DXCoil(DXCoilNum).MSFanPowerPerEvapAirFlowRate_2023(I) = Numbers(14 + (I - 1) * 6);
    4863          62 :             state.dataDXCoils->DXCoil(DXCoilNum).MSWasteHeatFrac(I) = Numbers(15 + (I - 1) * 6);
    4864             : 
    4865          62 :             state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFTemp(I) = GetCurveIndex(state, Alphas(10 + (I - 1) * 6)); // convert curve name to number
    4866          62 :             if (state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFTemp(I) == 0) {
    4867           0 :                 ShowSevereError(state,
    4868           0 :                                 CurrentModuleObject + ", \"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\" " + cAlphaFields(10 + (I - 1) * 6) +
    4869           0 :                                     " not found:" + Alphas(10 + (I - 1) * 6));
    4870           0 :                 ErrorsFound = true;
    4871             :             } else {
    4872             :                 // only legal types are Quadratic, BiQuadratic and Cubic
    4873         186 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    4874          62 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFTemp(I), // Curve index
    4875             :                                                      {1, 2},                                              // Valid dimensions
    4876             :                                                      RoutineName,                                         // Routine name
    4877             :                                                      CurrentModuleObject,                                 // Object Type
    4878          62 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,           // Object Name
    4879          62 :                                                      cAlphaFields(10 + (I - 1) * 6));                     // Field Name
    4880             : 
    4881          62 :                 if (!ErrorsFound) {
    4882          62 :                     if (state.dataCurveManager->PerfCurve(state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFTemp(I)).numDims == 1) {
    4883         220 :                         checkCurveIsNormalizedToOne(state,
    4884          88 :                                                     std::string{RoutineName} + CurrentModuleObject,
    4885          44 :                                                     state.dataDXCoils->DXCoil(DXCoilNum).Name,
    4886          44 :                                                     state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFTemp(I),
    4887          44 :                                                     cAlphaFields(10 + (I - 1) * 6),
    4888          44 :                                                     Alphas(10 + (I - 1) * 6),
    4889             :                                                     RatedOutdoorAirTempHeat);
    4890             :                     } else {
    4891          90 :                         checkCurveIsNormalizedToOne(state,
    4892          36 :                                                     std::string{RoutineName} + CurrentModuleObject,
    4893          18 :                                                     state.dataDXCoils->DXCoil(DXCoilNum).Name,
    4894          18 :                                                     state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFTemp(I),
    4895          18 :                                                     cAlphaFields(10 + (I - 1) * 6),
    4896          18 :                                                     Alphas(10 + (I - 1) * 6),
    4897             :                                                     RatedInletAirTempHeat,
    4898             :                                                     RatedOutdoorAirTempHeat);
    4899             :                     }
    4900             :                 }
    4901             :             }
    4902             : 
    4903          62 :             state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFFlow(I) = GetCurveIndex(state, Alphas(11 + (I - 1) * 6)); // convert curve name to number
    4904          62 :             if (state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFFlow(I) == 0) {
    4905           0 :                 if (lAlphaBlanks(11 + (I - 1) * 6)) {
    4906           0 :                     ShowSevereError(
    4907           0 :                         state, std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", missing");
    4908           0 :                     ShowContinueError(state, "...required " + cAlphaFields(11 + (I - 1) * 6) + " is blank.");
    4909             :                 } else {
    4910           0 :                     ShowSevereError(
    4911           0 :                         state, std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    4912           0 :                     ShowContinueError(state, "...not found " + cAlphaFields(11 + (I - 1) * 6) + "=\"" + Alphas(11 + (I - 1) * 6) + "\".");
    4913             :                 }
    4914           0 :                 ErrorsFound = true;
    4915             :             } else {
    4916             :                 // Verify Curve Object, only legal type is Quadratic
    4917         186 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    4918          62 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFFlow(I), // Curve index
    4919             :                                                      {1},                                                 // Valid dimensions
    4920             :                                                      RoutineName,                                         // Routine name
    4921             :                                                      CurrentModuleObject,                                 // Object Type
    4922          62 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,           // Object Name
    4923          62 :                                                      cAlphaFields(11 + (I - 1) * 6));                     // Field Name
    4924             : 
    4925          62 :                 if (!ErrorsFound) {
    4926         310 :                     checkCurveIsNormalizedToOne(state,
    4927         124 :                                                 std::string{RoutineName} + CurrentModuleObject,
    4928          62 :                                                 state.dataDXCoils->DXCoil(DXCoilNum).Name,
    4929          62 :                                                 state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFFlow(I),
    4930          62 :                                                 cAlphaFields(11 + (I - 1) * 6),
    4931          62 :                                                 Alphas(11 + (I - 1) * 6),
    4932             :                                                 1.0);
    4933             :                 }
    4934             :             }
    4935             : 
    4936          62 :             state.dataDXCoils->DXCoil(DXCoilNum).MSEIRFTemp(I) = GetCurveIndex(state, Alphas(12 + (I - 1) * 6)); // convert curve name to number
    4937          62 :             if (state.dataDXCoils->DXCoil(DXCoilNum).MSEIRFTemp(I) == 0) {
    4938           0 :                 if (lAlphaBlanks(12 + (I - 1) * 6)) {
    4939           0 :                     ShowSevereError(
    4940           0 :                         state, std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", missing");
    4941           0 :                     ShowContinueError(state, "...required " + cAlphaFields(12 + (I - 1) * 6) + " is blank.");
    4942             :                 } else {
    4943           0 :                     ShowSevereError(
    4944           0 :                         state, std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    4945           0 :                     ShowContinueError(state, "...not found " + cAlphaFields(12 + (I - 1) * 6) + "=\"" + Alphas(15 + (I - 1) * 6) + "\".");
    4946             :                 }
    4947           0 :                 ErrorsFound = true;
    4948             :             } else {
    4949             :                 // only legal types are Quadratic, BiQuadratic and Cubic
    4950         186 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    4951          62 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).MSEIRFTemp(I), // Curve index
    4952             :                                                      {1, 2},                                             // Valid dimensions
    4953             :                                                      RoutineName,                                        // Routine name
    4954             :                                                      CurrentModuleObject,                                // Object Type
    4955          62 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,          // Object Name
    4956          62 :                                                      cAlphaFields(12 + (I - 1) * 6));                    // Field Name
    4957             : 
    4958          62 :                 if (!ErrorsFound) {
    4959          62 :                     if (state.dataCurveManager->PerfCurve(state.dataDXCoils->DXCoil(DXCoilNum).MSEIRFTemp(I)).numDims == 1) {
    4960         220 :                         checkCurveIsNormalizedToOne(state,
    4961          88 :                                                     std::string{RoutineName} + CurrentModuleObject,
    4962          44 :                                                     state.dataDXCoils->DXCoil(DXCoilNum).Name,
    4963          44 :                                                     state.dataDXCoils->DXCoil(DXCoilNum).MSEIRFTemp(I),
    4964          44 :                                                     cAlphaFields(12 + (I - 1) * 6),
    4965          44 :                                                     Alphas(12 + (I - 1) * 6),
    4966             :                                                     RatedOutdoorAirTempHeat);
    4967             :                     } else {
    4968          90 :                         checkCurveIsNormalizedToOne(state,
    4969          36 :                                                     std::string{RoutineName} + CurrentModuleObject,
    4970          18 :                                                     state.dataDXCoils->DXCoil(DXCoilNum).Name,
    4971          18 :                                                     state.dataDXCoils->DXCoil(DXCoilNum).MSEIRFTemp(I),
    4972          18 :                                                     cAlphaFields(12 + (I - 1) * 6),
    4973          18 :                                                     Alphas(12 + (I - 1) * 6),
    4974             :                                                     RatedInletAirTempHeat,
    4975             :                                                     RatedOutdoorAirTempHeat);
    4976             :                     }
    4977             :                 }
    4978             :             }
    4979             : 
    4980          62 :             state.dataDXCoils->DXCoil(DXCoilNum).MSEIRFFlow(I) = GetCurveIndex(state, Alphas(13 + (I - 1) * 6)); // convert curve name to number
    4981          62 :             if (state.dataDXCoils->DXCoil(DXCoilNum).MSEIRFFlow(I) == 0) {
    4982           0 :                 if (lAlphaBlanks(13 + (I - 1) * 6)) {
    4983           0 :                     ShowSevereError(
    4984           0 :                         state, std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", missing");
    4985           0 :                     ShowContinueError(state, "...required " + cAlphaFields(13 + (I - 1) * 6) + " is blank.");
    4986             :                 } else {
    4987           0 :                     ShowSevereError(
    4988           0 :                         state, std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    4989           0 :                     ShowContinueError(state, "...not found " + cAlphaFields(13 + (I - 1) * 6) + "=\"" + Alphas(13 + (I - 1) * 6) + "\".");
    4990             :                 }
    4991           0 :                 ErrorsFound = true;
    4992             :             } else {
    4993             :                 // Verify Curve Object, only legal type is Quadratic
    4994         186 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    4995          62 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).MSEIRFFlow(I), // Curve index
    4996             :                                                      {1},                                                // Valid dimensions
    4997             :                                                      RoutineName,                                        // Routine name
    4998             :                                                      CurrentModuleObject,                                // Object Type
    4999          62 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,          // Object Name
    5000          62 :                                                      cAlphaFields(13 + (I - 1) * 6));                    // Field Name
    5001             : 
    5002          62 :                 if (!ErrorsFound) {
    5003         310 :                     checkCurveIsNormalizedToOne(state,
    5004         124 :                                                 std::string{RoutineName} + CurrentModuleObject,
    5005          62 :                                                 state.dataDXCoils->DXCoil(DXCoilNum).Name,
    5006          62 :                                                 state.dataDXCoils->DXCoil(DXCoilNum).MSEIRFFlow(I),
    5007          62 :                                                 cAlphaFields(13 + (I - 1) * 6),
    5008          62 :                                                 Alphas(13 + (I - 1) * 6),
    5009             :                                                 1.0);
    5010             :                 }
    5011             :             }
    5012             : 
    5013          62 :             state.dataDXCoils->DXCoil(DXCoilNum).MSPLFFPLR(I) = GetCurveIndex(state, Alphas(14 + (I - 1) * 6)); // convert curve name to number
    5014          62 :             if (state.dataDXCoils->DXCoil(DXCoilNum).MSPLFFPLR(I) == 0) {
    5015           0 :                 if (lAlphaBlanks(14 + (I - 1) * 6)) {
    5016           0 :                     ShowSevereError(
    5017           0 :                         state, std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", missing");
    5018           0 :                     ShowContinueError(state, "...required " + cAlphaFields(14 + (I - 1) * 6) + " is blank.");
    5019             :                 } else {
    5020           0 :                     ShowSevereError(
    5021           0 :                         state, std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    5022           0 :                     ShowContinueError(state, "...not found " + cAlphaFields(14 + (I - 1) * 6) + "=\"" + Alphas(14 + (I - 1) * 6) + "\".");
    5023             :                 }
    5024           0 :                 ErrorsFound = true;
    5025             :             } else {
    5026             :                 // Verify Curve Object, only legal types are Quadratic or Cubic
    5027         186 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    5028          62 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).MSPLFFPLR(I), // Curve index
    5029             :                                                      {1},                                               // Valid dimensions
    5030             :                                                      RoutineName,                                       // Routine name
    5031             :                                                      CurrentModuleObject,                               // Object Type
    5032          62 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,         // Object Name
    5033          62 :                                                      cAlphaFields(14 + (I - 1) * 6));                   // Field Name
    5034             : 
    5035          62 :                 if (!ErrorsFound) {
    5036             :                     //       Test PLF curve minimum and maximum. Cap if less than 0.7 or greater than 1.0.
    5037          62 :                     MinCurveVal = 999.0;
    5038          62 :                     MaxCurveVal = -999.0;
    5039          62 :                     CurveInput = 0.0;
    5040       12462 :                     while (CurveInput <= 1.0) {
    5041        6200 :                         CurveVal = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).MSPLFFPLR(I), CurveInput);
    5042        6200 :                         if (CurveVal < MinCurveVal) {
    5043          62 :                             MinCurveVal = CurveVal;
    5044          62 :                             MinCurvePLR = CurveInput;
    5045             :                         }
    5046        6200 :                         if (CurveVal > MaxCurveVal) {
    5047        6200 :                             MaxCurveVal = CurveVal;
    5048        6200 :                             MaxCurvePLR = CurveInput;
    5049             :                         }
    5050        6200 :                         CurveInput += 0.01;
    5051             :                     }
    5052          62 :                     if (MinCurveVal < 0.7) {
    5053           0 :                         ShowWarningError(state,
    5054           0 :                                          std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name +
    5055             :                                              "\", invalid");
    5056           0 :                         ShowContinueError(state,
    5057           0 :                                           "..." + cAlphaFields(14 + (I - 1) * 6) + " = " + Alphas(14 + (I - 1) * 6) + " has out of range value.");
    5058           0 :                         ShowContinueError(state,
    5059           0 :                                           format("...Curve minimum must be >= 0.7, curve min at PLR = {:.2T} is {:.3T}", MinCurvePLR, MinCurveVal));
    5060           0 :                         ShowContinueError(state, "...Setting curve minimum to 0.7 and simulation continues.");
    5061           0 :                         SetCurveOutputMinMaxValues(state, state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(1), ErrorsFound, 0.7, _);
    5062           0 :                         SetCurveOutputMinMaxValues(state, state.dataDXCoils->DXCoil(DXCoilNum).MSPLFFPLR(I), ErrorsFound, 0.7, _);
    5063             :                     }
    5064             : 
    5065          62 :                     if (MaxCurveVal > 1.0) {
    5066           0 :                         ShowWarningError(state,
    5067           0 :                                          std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name +
    5068             :                                              "\", invalid");
    5069           0 :                         ShowContinueError(state,
    5070           0 :                                           "..." + cAlphaFields(14 + (I - 1) * 6) + " = " + Alphas(14 + (I - 1) * 6) + " has out of range value.");
    5071           0 :                         ShowContinueError(state,
    5072           0 :                                           format("...Curve maximum must be <= 1.0, curve max at PLR = {:.2T} is {:.3T}", MaxCurvePLR, MaxCurveVal));
    5073           0 :                         ShowContinueError(state, "...Setting curve maximum to 1.0 and simulation continues.");
    5074           0 :                         SetCurveOutputMinMaxValues(state, state.dataDXCoils->DXCoil(DXCoilNum).MSPLFFPLR(I), ErrorsFound, _, 1.0);
    5075             :                     }
    5076             :                 }
    5077             :             }
    5078             : 
    5079             :             // Read waste heat modifier curve name
    5080          62 :             state.dataDXCoils->DXCoil(DXCoilNum).MSWasteHeat(I) = GetCurveIndex(state, Alphas(15 + (I - 1) * 6)); // convert curve name to number
    5081          62 :             if (state.dataDXCoils->DXCoil(DXCoilNum).FuelTypeNum != DataGlobalConstants::ResourceType::Electricity) {
    5082          16 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).MSWasteHeat(I) > 0) {
    5083             :                     // Verify Curve Object, only legal types are BiQuadratic
    5084          48 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    5085          16 :                                                          state.dataDXCoils->DXCoil(DXCoilNum).MSWasteHeat(I), // Curve index
    5086             :                                                          {2},                                                 // Valid dimensions
    5087             :                                                          RoutineName,                                         // Routine name
    5088             :                                                          CurrentModuleObject,                                 // Object Type
    5089          16 :                                                          state.dataDXCoils->DXCoil(DXCoilNum).Name,           // Object Name
    5090          16 :                                                          cAlphaFields(15 + (I - 1) * 6));                     // Field Name
    5091             : 
    5092          16 :                     if (!ErrorsFound) {
    5093          80 :                         checkCurveIsNormalizedToOne(state,
    5094          32 :                                                     std::string{RoutineName} + CurrentModuleObject,
    5095          16 :                                                     state.dataDXCoils->DXCoil(DXCoilNum).Name,
    5096          16 :                                                     state.dataDXCoils->DXCoil(DXCoilNum).MSWasteHeat(I),
    5097          16 :                                                     cAlphaFields(15 + (I - 1) * 6),
    5098          16 :                                                     Alphas(15 + (I - 1) * 6),
    5099             :                                                     RatedOutdoorAirTempHeat,
    5100             :                                                     RatedInletAirTempHeat);
    5101             :                     }
    5102             :                 }
    5103             :             }
    5104             :         }
    5105             :         // A34; \field Zone Name for Condenser Placement
    5106          20 :         if (!lAlphaBlanks(34) && NumAlphas > 33) {
    5107           0 :             state.dataDXCoils->DXCoil(DXCoilNum).SecZonePtr = UtilityRoutines::FindItemInList(Alphas(34), state.dataHeatBal->Zone);
    5108           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).SecZonePtr > 0) {
    5109           0 :                 SetupZoneInternalGain(state,
    5110           0 :                                       state.dataDXCoils->DXCoil(DXCoilNum).SecZonePtr,
    5111           0 :                                       state.dataDXCoils->DXCoil(DXCoilNum).Name,
    5112             :                                       DataHeatBalance::IntGainType::SecHeatingDXCoilMultiSpeed,
    5113           0 :                                       &state.dataDXCoils->DXCoil(DXCoilNum).SecCoilSensibleHeatRemovalRate,
    5114             :                                       nullptr,
    5115             :                                       nullptr,
    5116           0 :                                       &state.dataDXCoils->DXCoil(DXCoilNum).SecCoilLatentHeatRemovalRate);
    5117           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).IsSecondaryDXCoilInZone = true;
    5118             :             } else {
    5119           0 :                 ShowSevereError(state,
    5120           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    5121           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(34) + "=\"" + Alphas(34) + "\".");
    5122             :             }
    5123             :         }
    5124          20 :         if (state.dataDXCoils->DXCoil(DXCoilNum).SecZonePtr > 0) {
    5125           0 :             for (I = 1; I <= state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds; ++I) {
    5126           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).MSSecCoilAirFlow(I) = Numbers(34 + (I - 1) * 3);
    5127           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).MSSecCoilAirFlowScalingFactor(I) = Numbers(35 + (I - 1) * 3);
    5128           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).MSSecCoilRatedSHR(I) = Numbers(36 + (I - 1) * 3);
    5129             :                 // Read SHR modifier curve function of temperature
    5130           0 :                 if (!lAlphaBlanks(35 + (I - 1) * 2)) {
    5131           0 :                     state.dataDXCoils->DXCoil(DXCoilNum).MSSecCoilSHRFT(I) =
    5132           0 :                         GetCurveIndex(state, Alphas(35 + (I - 1) * 2)); // convert curve name to number
    5133           0 :                     if (state.dataDXCoils->DXCoil(DXCoilNum).MSSecCoilSHRFT(I) == 0) {
    5134           0 :                         ShowSevereError(state,
    5135           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name +
    5136             :                                             "\", invalid");
    5137           0 :                         ShowContinueError(state, "...not found " + cAlphaFields(35 + (I - 1) * 2) + "=\"" + Alphas(35 + (I - 1) * 2) + "\".");
    5138             :                     }
    5139             :                 }
    5140             :                 // Read SHR modifier curve function of flow fraction
    5141           0 :                 if (!lAlphaBlanks(36 + (I - 1) * 2)) {
    5142           0 :                     state.dataDXCoils->DXCoil(DXCoilNum).MSSecCoilSHRFF(I) =
    5143           0 :                         GetCurveIndex(state, Alphas(36 + (I - 1) * 2)); // convert curve name to number
    5144           0 :                     if (state.dataDXCoils->DXCoil(DXCoilNum).MSSecCoilSHRFF(I) == 0) {
    5145           0 :                         ShowSevereError(state,
    5146           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name +
    5147             :                                             "\", invalid");
    5148           0 :                         ShowContinueError(state, "...not found " + cAlphaFields(36 + (I - 1) * 2) + "=\"" + Alphas(36 + (I - 1) * 2) + "\".");
    5149             :                     }
    5150             :                 }
    5151             :             }
    5152             :         }
    5153             :     }
    5154             : 
    5155             :     // Loop over the VRF Cooling Coils and get & load the data
    5156         241 :     CurrentModuleObject = cAllCoilTypes(CoilVRF_Cooling);
    5157         282 :     for (DXCoilIndex = 1; DXCoilIndex <= state.dataDXCoils->NumVRFCoolingCoils; ++DXCoilIndex) {
    5158             : 
    5159          41 :         state.dataInputProcessing->inputProcessor->getObjectItem(state,
    5160             :                                                                  CurrentModuleObject,
    5161             :                                                                  DXCoilIndex,
    5162             :                                                                  Alphas,
    5163             :                                                                  NumAlphas,
    5164             :                                                                  Numbers,
    5165             :                                                                  NumNumbers,
    5166             :                                                                  IOStatus,
    5167             :                                                                  lNumericBlanks,
    5168             :                                                                  lAlphaBlanks,
    5169             :                                                                  cAlphaFields,
    5170             :                                                                  cNumericFields);
    5171             : 
    5172          41 :         ++DXCoilNum;
    5173             : 
    5174             :         // allocate single performance mode for numeric field strings used for sizing routine
    5175          41 :         state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode.allocate(1);
    5176          41 :         state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(1).FieldNames.allocate(MaxNumbers);
    5177          41 :         state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(1).FieldNames = cNumericFields;
    5178          41 :         UtilityRoutines::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    5179             :         // ErrorsFound will be set to True if problem was found, left untouched otherwise
    5180          41 :         VerifyUniqueCoilName(state, CurrentModuleObject, Alphas(1), ErrorsFound, CurrentModuleObject + " Name");
    5181             : 
    5182          41 :         state.dataDXCoils->DXCoil(DXCoilNum).Name = Alphas(1);
    5183          41 :         state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType = CurrentModuleObject;
    5184          41 :         state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num = CoilVRF_Cooling;
    5185          41 :         state.dataDXCoils->DXCoil(DXCoilNum).Schedule = Alphas(2);
    5186          41 :         if (lAlphaBlanks(2)) {
    5187           5 :             state.dataDXCoils->DXCoil(DXCoilNum).SchedPtr = DataGlobalConstants::ScheduleAlwaysOn;
    5188             :         } else {
    5189          36 :             state.dataDXCoils->DXCoil(DXCoilNum).SchedPtr = GetScheduleIndex(state, Alphas(2)); // convert schedule name to pointer
    5190          36 :             if (state.dataDXCoils->DXCoil(DXCoilNum).SchedPtr == 0) {
    5191           0 :                 ShowSevereError(state,
    5192           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    5193           0 :                 ShowContinueError(state, "..." + cAlphaFields(2) + "=\"" + Alphas(2) + "\".");
    5194           0 :                 ErrorsFound = true;
    5195             :             }
    5196             :         }
    5197          41 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(1) = Numbers(1);
    5198          41 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedSHR(1) = Numbers(2);
    5199          41 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(1) = Numbers(3);
    5200             : 
    5201          41 :         state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(1) = GetCurveIndex(state, Alphas(3));
    5202             :         // Verify Curve Object, only legal type is Linear, Quadratic, Cubic, or BiQuadratic
    5203         123 :         ErrorsFound |= Curve::CheckCurveDims(state,
    5204          41 :                                              state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(1), // Curve index
    5205             :                                              {1, 2},                                            // Valid dimensions
    5206             :                                              RoutineName,                                       // Routine name
    5207             :                                              CurrentModuleObject,                               // Object Type
    5208          41 :                                              state.dataDXCoils->DXCoil(DXCoilNum).Name,         // Object Name
    5209          41 :                                              cAlphaFields(3));                                  // Field Name
    5210             : 
    5211          41 :         if (!ErrorsFound) {
    5212          41 :             if (state.dataCurveManager->PerfCurve(state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(1)).numDims == 1) {
    5213         130 :                 checkCurveIsNormalizedToOne(state,
    5214          52 :                                             std::string{RoutineName} + CurrentModuleObject,
    5215          26 :                                             state.dataDXCoils->DXCoil(DXCoilNum).Name,
    5216          26 :                                             state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(1),
    5217          26 :                                             cAlphaFields(3),
    5218          26 :                                             Alphas(3),
    5219             :                                             RatedInletWetBulbTemp);
    5220             :             } else {
    5221          75 :                 checkCurveIsNormalizedToOne(state,
    5222          30 :                                             std::string{RoutineName} + CurrentModuleObject,
    5223          15 :                                             state.dataDXCoils->DXCoil(DXCoilNum).Name,
    5224          15 :                                             state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(1),
    5225          15 :                                             cAlphaFields(3),
    5226          15 :                                             Alphas(3),
    5227             :                                             RatedInletWetBulbTemp,
    5228             :                                             RatedOutdoorAirTemp);
    5229             :             }
    5230             :         }
    5231             : 
    5232          41 :         state.dataDXCoils->DXCoil(DXCoilNum).CCapFFlow(1) = GetCurveIndex(state, Alphas(4)); // convert curve name to number
    5233          41 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CCapFFlow(1) == 0) {
    5234           0 :             if (lAlphaBlanks(4)) {
    5235           0 :                 ShowSevereError(state,
    5236           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", missing");
    5237           0 :                 ShowContinueError(state, "...required " + cAlphaFields(4) + " is blank.");
    5238             :             } else {
    5239           0 :                 ShowSevereError(state,
    5240           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    5241           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(4) + "=\"" + Alphas(4) + "\".");
    5242             :             }
    5243           0 :             ErrorsFound = true;
    5244             :         } else {
    5245             :             // Verify Curve Object, only legal type is Linear, Quadratic or Cubic
    5246         123 :             ErrorsFound |= Curve::CheckCurveDims(state,
    5247          41 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).CCapFFlow(1), // Curve index
    5248             :                                                  {1},                                               // Valid dimensions
    5249             :                                                  RoutineName,                                       // Routine name
    5250             :                                                  CurrentModuleObject,                               // Object Type
    5251          41 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).Name,         // Object Name
    5252          41 :                                                  cAlphaFields(4));                                  // Field Name
    5253             : 
    5254          41 :             if (!ErrorsFound) {
    5255         205 :                 checkCurveIsNormalizedToOne(state,
    5256          82 :                                             std::string{RoutineName} + CurrentModuleObject,
    5257          41 :                                             state.dataDXCoils->DXCoil(DXCoilNum).Name,
    5258          41 :                                             state.dataDXCoils->DXCoil(DXCoilNum).CCapFFlow(1),
    5259          41 :                                             cAlphaFields(4),
    5260          41 :                                             Alphas(4),
    5261             :                                             1.0);
    5262             :             }
    5263             :         }
    5264             : 
    5265          41 :         state.dataDXCoils->DXCoil(DXCoilNum).AirInNode = GetOnlySingleNode(state,
    5266          41 :                                                                            Alphas(5),
    5267             :                                                                            ErrorsFound,
    5268             :                                                                            DataLoopNode::ConnectionObjectType::CoilCoolingDXVariableRefrigerantFlow,
    5269          41 :                                                                            Alphas(1),
    5270             :                                                                            DataLoopNode::NodeFluidType::Air,
    5271             :                                                                            DataLoopNode::ConnectionType::Inlet,
    5272             :                                                                            NodeInputManager::CompFluidStream::Primary,
    5273          41 :                                                                            ObjectIsNotParent);
    5274             : 
    5275          41 :         state.dataDXCoils->DXCoil(DXCoilNum).AirOutNode = GetOnlySingleNode(state,
    5276          41 :                                                                             Alphas(6),
    5277             :                                                                             ErrorsFound,
    5278             :                                                                             DataLoopNode::ConnectionObjectType::CoilCoolingDXVariableRefrigerantFlow,
    5279          41 :                                                                             Alphas(1),
    5280             :                                                                             DataLoopNode::NodeFluidType::Air,
    5281             :                                                                             DataLoopNode::ConnectionType::Outlet,
    5282             :                                                                             NodeInputManager::CompFluidStream::Primary,
    5283          41 :                                                                             ObjectIsNotParent);
    5284             : 
    5285          41 :         TestCompSet(state, CurrentModuleObject, Alphas(1), Alphas(5), Alphas(6), "Air Nodes");
    5286             : 
    5287          41 :         state.dataDXCoils->DXCoil(DXCoilNum).CondensateCollectName = Alphas(7);
    5288          41 :         if (lAlphaBlanks(7)) {
    5289          41 :             state.dataDXCoils->DXCoil(DXCoilNum).CondensateCollectMode = CondensateCollectAction::Discard;
    5290             :         } else {
    5291           0 :             state.dataDXCoils->DXCoil(DXCoilNum).CondensateCollectMode = CondensateCollectAction::ToTank;
    5292           0 :             SetupTankSupplyComponent(state,
    5293           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,
    5294             :                                      CurrentModuleObject,
    5295           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).CondensateCollectName,
    5296             :                                      ErrorsFound,
    5297           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).CondensateTankID,
    5298           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).CondensateTankSupplyARRID);
    5299             :         }
    5300             :     }
    5301             : 
    5302         241 :     if (ErrorsFound) {
    5303           0 :         ShowFatalError(state,
    5304           0 :                        std::string{RoutineName} + "Errors found in getting " + CurrentModuleObject +
    5305             :                            " input. Preceding condition(s) causes termination.");
    5306             :     }
    5307             : 
    5308             :     // Loop over the VRF Heating Coils and get & load the data
    5309         241 :     CurrentModuleObject = cAllCoilTypes(CoilVRF_Heating);
    5310         282 :     for (DXCoilIndex = 1; DXCoilIndex <= state.dataDXCoils->NumVRFHeatingCoils; ++DXCoilIndex) {
    5311             : 
    5312          41 :         state.dataInputProcessing->inputProcessor->getObjectItem(state,
    5313             :                                                                  CurrentModuleObject,
    5314             :                                                                  DXCoilIndex,
    5315             :                                                                  Alphas,
    5316             :                                                                  NumAlphas,
    5317             :                                                                  Numbers,
    5318             :                                                                  NumNumbers,
    5319             :                                                                  IOStatus,
    5320             :                                                                  lNumericBlanks,
    5321             :                                                                  lAlphaBlanks,
    5322             :                                                                  cAlphaFields,
    5323             :                                                                  cNumericFields);
    5324             : 
    5325          41 :         ++DXCoilNum;
    5326             : 
    5327             :         // allocate single performance mode for numeric field strings used for sizing routine
    5328          41 :         state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode.allocate(1);
    5329          41 :         state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(1).FieldNames.allocate(MaxNumbers);
    5330          41 :         state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(1).FieldNames = cNumericFields;
    5331          41 :         UtilityRoutines::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    5332             :         // ErrorsFound will be set to True if problem was found, left untouched otherwise
    5333          41 :         VerifyUniqueCoilName(state, CurrentModuleObject, Alphas(1), ErrorsFound, CurrentModuleObject + " Name");
    5334             : 
    5335          41 :         state.dataDXCoils->DXCoil(DXCoilNum).Name = Alphas(1);
    5336          41 :         state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType = CurrentModuleObject;
    5337          41 :         state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num = CoilVRF_Heating;
    5338          41 :         state.dataDXCoils->DXCoil(DXCoilNum).Schedule = Alphas(2);
    5339          41 :         if (lAlphaBlanks(2)) {
    5340           5 :             state.dataDXCoils->DXCoil(DXCoilNum).SchedPtr = DataGlobalConstants::ScheduleAlwaysOn;
    5341             :         } else {
    5342          36 :             state.dataDXCoils->DXCoil(DXCoilNum).SchedPtr = GetScheduleIndex(state, Alphas(2)); // convert schedule name to pointer
    5343          36 :             if (state.dataDXCoils->DXCoil(DXCoilNum).SchedPtr == 0) {
    5344           0 :                 ShowSevereError(state,
    5345           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    5346           0 :                 ShowContinueError(state, "..." + cAlphaFields(2) + "=\"" + Alphas(2) + "\".");
    5347           0 :                 ErrorsFound = true;
    5348             :             }
    5349             :         }
    5350          41 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(1) = Numbers(1);
    5351          41 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(1) = Numbers(2);
    5352             : 
    5353          41 :         state.dataDXCoils->DXCoil(DXCoilNum).AirInNode = GetOnlySingleNode(state,
    5354          41 :                                                                            Alphas(3),
    5355             :                                                                            ErrorsFound,
    5356             :                                                                            DataLoopNode::ConnectionObjectType::CoilHeatingDXVariableRefrigerantFlow,
    5357          41 :                                                                            Alphas(1),
    5358             :                                                                            DataLoopNode::NodeFluidType::Air,
    5359             :                                                                            DataLoopNode::ConnectionType::Inlet,
    5360             :                                                                            NodeInputManager::CompFluidStream::Primary,
    5361          41 :                                                                            ObjectIsNotParent);
    5362             : 
    5363          41 :         state.dataDXCoils->DXCoil(DXCoilNum).AirOutNode = GetOnlySingleNode(state,
    5364          41 :                                                                             Alphas(4),
    5365             :                                                                             ErrorsFound,
    5366             :                                                                             DataLoopNode::ConnectionObjectType::CoilHeatingDXVariableRefrigerantFlow,
    5367          41 :                                                                             Alphas(1),
    5368             :                                                                             DataLoopNode::NodeFluidType::Air,
    5369             :                                                                             DataLoopNode::ConnectionType::Outlet,
    5370             :                                                                             NodeInputManager::CompFluidStream::Primary,
    5371          41 :                                                                             ObjectIsNotParent);
    5372             : 
    5373          41 :         TestCompSet(state, CurrentModuleObject, Alphas(1), Alphas(3), Alphas(4), "Air Nodes");
    5374             : 
    5375          41 :         state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp = GetCurveIndex(state, Alphas(5));
    5376          41 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(1) == 0) {
    5377           0 :             if (lAlphaBlanks(5)) {
    5378           0 :                 ShowSevereError(state,
    5379           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", missing");
    5380           0 :                 ShowContinueError(state, "...required " + cAlphaFields(5) + " is blank.");
    5381             :             } else {
    5382           0 :                 ShowSevereError(state,
    5383           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    5384           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(5) + "=\"" + Alphas(5) + "\".");
    5385             :             }
    5386           0 :             ErrorsFound = true;
    5387             :         } else {
    5388         123 :             ErrorsFound |= Curve::CheckCurveDims(state,
    5389          41 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(1), // Curve index
    5390             :                                                  {1, 2},                                            // Valid dimensions
    5391             :                                                  RoutineName,                                       // Routine name
    5392             :                                                  CurrentModuleObject,                               // Object Type
    5393          41 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).Name,         // Object Name
    5394          41 :                                                  cAlphaFields(5));                                  // Field Name
    5395             : 
    5396          41 :             if (!ErrorsFound) {
    5397          41 :                 if (state.dataCurveManager->PerfCurve(state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(1)).numDims == 1) {
    5398         130 :                     checkCurveIsNormalizedToOne(state,
    5399          52 :                                                 std::string{RoutineName} + CurrentModuleObject,
    5400          26 :                                                 state.dataDXCoils->DXCoil(DXCoilNum).Name,
    5401          26 :                                                 state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(1),
    5402          26 :                                                 cAlphaFields(5),
    5403          26 :                                                 Alphas(5),
    5404             :                                                 RatedInletAirTempHeat);
    5405             :                 } else {
    5406             :                     // Can't check this here, don't know if using outdoor dry-bulb or outdoor wet-bulb temp as input. Make this check in VRF TU
    5407             :                     // GetInput.
    5408             :                 }
    5409             :             }
    5410             :         }
    5411             : 
    5412          41 :         state.dataDXCoils->DXCoil(DXCoilNum).CCapFFlow(1) = GetCurveIndex(state, Alphas(6)); // convert curve name to number
    5413          41 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CCapFFlow(1) == 0) {
    5414           0 :             if (lAlphaBlanks(6)) {
    5415           0 :                 ShowSevereError(state,
    5416           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", missing");
    5417           0 :                 ShowContinueError(state, "...required " + cAlphaFields(6) + " is blank.");
    5418             :             } else {
    5419           0 :                 ShowSevereError(state,
    5420           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    5421           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(6) + "=\"" + Alphas(6) + "\".");
    5422             :             }
    5423           0 :             ErrorsFound = true;
    5424             :         } else {
    5425             :             // Verify Curve Object, only legal type is Quadratic
    5426         123 :             ErrorsFound |= Curve::CheckCurveDims(state,
    5427          41 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).CCapFFlow(1), // Curve index
    5428             :                                                  {1},                                               // Valid dimensions
    5429             :                                                  RoutineName,                                       // Routine name
    5430             :                                                  CurrentModuleObject,                               // Object Type
    5431          41 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).Name,         // Object Name
    5432          41 :                                                  cAlphaFields(6));                                  // Field Name
    5433             : 
    5434          41 :             if (!ErrorsFound) {
    5435         205 :                 checkCurveIsNormalizedToOne(state,
    5436          82 :                                             std::string{RoutineName} + CurrentModuleObject,
    5437          41 :                                             state.dataDXCoils->DXCoil(DXCoilNum).Name,
    5438          41 :                                             state.dataDXCoils->DXCoil(DXCoilNum).CCapFFlow(1),
    5439          41 :                                             cAlphaFields(6),
    5440          41 :                                             Alphas(6),
    5441             :                                             1.0);
    5442             :             }
    5443             :         }
    5444             :     }
    5445             : 
    5446         241 :     if (ErrorsFound) {
    5447           0 :         ShowFatalError(state,
    5448           0 :                        std::string{RoutineName} + "Errors found in getting " + CurrentModuleObject +
    5449             :                            " input. Preceding condition(s) causes termination.");
    5450             :     }
    5451             : 
    5452             :     // Loop over the VRF Cooling Coils for VRF FluidTCtrl Model_zrp 2015
    5453         241 :     CurrentModuleObject = cAllCoilTypes(CoilVRF_FluidTCtrl_Cooling);
    5454         256 :     for (DXCoilIndex = 1; DXCoilIndex <= state.dataDXCoils->NumVRFCoolingFluidTCtrlCoils; ++DXCoilIndex) {
    5455             : 
    5456          15 :         state.dataInputProcessing->inputProcessor->getObjectItem(state,
    5457             :                                                                  CurrentModuleObject,
    5458             :                                                                  DXCoilIndex,
    5459             :                                                                  Alphas,
    5460             :                                                                  NumAlphas,
    5461             :                                                                  Numbers,
    5462             :                                                                  NumNumbers,
    5463             :                                                                  IOStatus,
    5464             :                                                                  lNumericBlanks,
    5465             :                                                                  lAlphaBlanks,
    5466             :                                                                  cAlphaFields,
    5467             :                                                                  cNumericFields);
    5468             : 
    5469          15 :         ++DXCoilNum;
    5470             : 
    5471             :         // allocate single performance mode for numeric field strings used for sizing routine
    5472          15 :         state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode.allocate(1);
    5473          15 :         state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(1).FieldNames.allocate(MaxNumbers);
    5474          15 :         state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(1).FieldNames = cNumericFields;
    5475          15 :         UtilityRoutines::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    5476             :         // ErrorsFound will be set to True if problem was found, left untouched otherwise
    5477          15 :         VerifyUniqueCoilName(state, CurrentModuleObject, Alphas(1), ErrorsFound, CurrentModuleObject + " Name");
    5478             : 
    5479          15 :         state.dataDXCoils->DXCoil(DXCoilNum).Name = Alphas(1);
    5480          15 :         state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType = CurrentModuleObject;
    5481          15 :         state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num = CoilVRF_FluidTCtrl_Cooling;
    5482          15 :         state.dataDXCoils->DXCoil(DXCoilNum).Schedule = Alphas(2);
    5483          15 :         if (lAlphaBlanks(2)) {
    5484           0 :             state.dataDXCoils->DXCoil(DXCoilNum).SchedPtr = DataGlobalConstants::ScheduleAlwaysOn;
    5485             :         } else {
    5486          15 :             state.dataDXCoils->DXCoil(DXCoilNum).SchedPtr = GetScheduleIndex(state, Alphas(2)); // convert schedule name to pointer
    5487          15 :             if (state.dataDXCoils->DXCoil(DXCoilNum).SchedPtr == 0) {
    5488           0 :                 ShowSevereError(state,
    5489           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    5490           0 :                 ShowContinueError(state, "..." + cAlphaFields(2) + "=\"" + Alphas(2) + "\".");
    5491           0 :                 ErrorsFound = true;
    5492             :             }
    5493             :         }
    5494             : 
    5495          15 :         state.dataDXCoils->DXCoil(DXCoilNum).AirInNode =
    5496          30 :             GetOnlySingleNode(state,
    5497          15 :                               Alphas(3),
    5498             :                               ErrorsFound,
    5499             :                               DataLoopNode::ConnectionObjectType::CoilCoolingDXVariableRefrigerantFlowFluidTemperatureControl,
    5500          15 :                               Alphas(1),
    5501             :                               DataLoopNode::NodeFluidType::Air,
    5502             :                               DataLoopNode::ConnectionType::Inlet,
    5503             :                               NodeInputManager::CompFluidStream::Primary,
    5504          15 :                               ObjectIsNotParent);
    5505          15 :         state.dataDXCoils->DXCoil(DXCoilNum).AirOutNode =
    5506          30 :             GetOnlySingleNode(state,
    5507          15 :                               Alphas(4),
    5508             :                               ErrorsFound,
    5509             :                               DataLoopNode::ConnectionObjectType::CoilCoolingDXVariableRefrigerantFlowFluidTemperatureControl,
    5510          15 :                               Alphas(1),
    5511             :                               DataLoopNode::NodeFluidType::Air,
    5512             :                               DataLoopNode::ConnectionType::Outlet,
    5513             :                               NodeInputManager::CompFluidStream::Primary,
    5514          15 :                               ObjectIsNotParent);
    5515          15 :         TestCompSet(state, CurrentModuleObject, Alphas(1), Alphas(3), Alphas(4), "Air Nodes");
    5516             : 
    5517          15 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(1) = Numbers(1);
    5518          15 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedSHR(1) = Numbers(2);
    5519          15 :         state.dataDXCoils->DXCoil(DXCoilNum).SH = Numbers(3);
    5520             :         // @@ DXCoil( DXCoilNum ).RateBFVRFIUEvap = 0.0592; there will be a new field for this, which will be handled in a separate issue to
    5521             :         // update VRF-HP idd. It is not hanlded here to avoide tranistion issues for VRF-HP.
    5522             : 
    5523          15 :         int indexSHCurve = GetCurveIndex(state, Alphas(5)); // convert curve name to index number
    5524             :         // Verify curve name and type
    5525          15 :         if (indexSHCurve == 0) {
    5526           0 :             if (lAlphaBlanks(5)) {
    5527           0 :                 ShowSevereError(state,
    5528           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", missing");
    5529           0 :                 ShowContinueError(state, "...required " + cAlphaFields(5) + " is blank.");
    5530             :             } else {
    5531           0 :                 ShowSevereError(state,
    5532           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    5533           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(5) + "=\"" + Alphas(5) + "\".");
    5534             :             }
    5535           0 :             ErrorsFound = true;
    5536             :         } else {
    5537             :             {
    5538          15 :                 if (state.dataCurveManager->PerfCurve(indexSHCurve).curveType == Curve::CurveType::Quadratic) {
    5539          15 :                     state.dataDXCoils->DXCoil(DXCoilNum).C1Te = state.dataCurveManager->PerfCurve(indexSHCurve).coeff[0];
    5540          15 :                     state.dataDXCoils->DXCoil(DXCoilNum).C2Te = state.dataCurveManager->PerfCurve(indexSHCurve).coeff[1];
    5541          15 :                     state.dataDXCoils->DXCoil(DXCoilNum).C3Te = state.dataCurveManager->PerfCurve(indexSHCurve).coeff[2];
    5542             : 
    5543             :                 } else {
    5544           0 :                     ShowSevereError(
    5545           0 :                         state, std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    5546           0 :                     ShowContinueError(state,
    5547           0 :                                       format("...illegal {} type for this object = {}",
    5548             :                                              cAlphaFields(5),
    5549           0 :                                              Curve::objectNames[static_cast<int>(state.dataCurveManager->PerfCurve(indexSHCurve).curveType)]));
    5550           0 :                     ShowContinueError(state, "... Curve type must be Quadratic.");
    5551           0 :                     ErrorsFound = true;
    5552             :                 }
    5553             :             }
    5554             :         }
    5555             : 
    5556          15 :         state.dataDXCoils->DXCoil(DXCoilNum).CondensateCollectName = Alphas(6);
    5557          15 :         if (lAlphaBlanks(6)) {
    5558          15 :             state.dataDXCoils->DXCoil(DXCoilNum).CondensateCollectMode = CondensateCollectAction::Discard;
    5559             :         } else {
    5560           0 :             state.dataDXCoils->DXCoil(DXCoilNum).CondensateCollectMode = CondensateCollectAction::ToTank;
    5561           0 :             SetupTankSupplyComponent(state,
    5562           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,
    5563             :                                      CurrentModuleObject,
    5564           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).CondensateCollectName,
    5565             :                                      ErrorsFound,
    5566           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).CondensateTankID,
    5567           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).CondensateTankSupplyARRID);
    5568             :         }
    5569             :     }
    5570             : 
    5571         241 :     if (ErrorsFound) {
    5572           0 :         ShowFatalError(state,
    5573           0 :                        std::string{RoutineName} + "Errors found in getting " + CurrentModuleObject +
    5574             :                            " input. Preceding condition(s) causes termination.");
    5575             :     }
    5576             : 
    5577             :     // Loop over the VRF Heating Coils for VRF FluidTCtrl Model_zrp 2015
    5578         241 :     CurrentModuleObject = cAllCoilTypes(CoilVRF_FluidTCtrl_Heating);
    5579         256 :     for (DXCoilIndex = 1; DXCoilIndex <= state.dataDXCoils->NumVRFHeatingFluidTCtrlCoils; ++DXCoilIndex) {
    5580             : 
    5581          15 :         state.dataInputProcessing->inputProcessor->getObjectItem(state,
    5582             :                                                                  CurrentModuleObject,
    5583             :                                                                  DXCoilIndex,
    5584             :                                                                  Alphas,
    5585             :                                                                  NumAlphas,
    5586             :                                                                  Numbers,
    5587             :                                                                  NumNumbers,
    5588             :                                                                  IOStatus,
    5589             :                                                                  lNumericBlanks,
    5590             :                                                                  lAlphaBlanks,
    5591             :                                                                  cAlphaFields,
    5592             :                                                                  cNumericFields);
    5593             : 
    5594          15 :         ++DXCoilNum;
    5595             : 
    5596             :         // allocate single performance mode for numeric field strings used for sizing routine
    5597          15 :         state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode.allocate(1);
    5598          15 :         state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(1).FieldNames.allocate(MaxNumbers);
    5599          15 :         state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(1).FieldNames = cNumericFields;
    5600          15 :         UtilityRoutines::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    5601             :         // ErrorsFound will be set to True if problem was found, left untouched otherwise
    5602          15 :         VerifyUniqueCoilName(state, CurrentModuleObject, Alphas(1), ErrorsFound, CurrentModuleObject + " Name");
    5603             : 
    5604          15 :         state.dataDXCoils->DXCoil(DXCoilNum).Name = Alphas(1);
    5605          15 :         state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType = CurrentModuleObject;
    5606          15 :         state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num = CoilVRF_FluidTCtrl_Heating;
    5607          15 :         state.dataDXCoils->DXCoil(DXCoilNum).Schedule = Alphas(2);
    5608          15 :         if (lAlphaBlanks(2)) {
    5609           0 :             state.dataDXCoils->DXCoil(DXCoilNum).SchedPtr = DataGlobalConstants::ScheduleAlwaysOn;
    5610             :         } else {
    5611          15 :             state.dataDXCoils->DXCoil(DXCoilNum).SchedPtr = GetScheduleIndex(state, Alphas(2)); // convert schedule name to pointer
    5612          15 :             if (state.dataDXCoils->DXCoil(DXCoilNum).SchedPtr == 0) {
    5613           0 :                 ShowSevereError(state,
    5614           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    5615           0 :                 ShowContinueError(state, "..." + cAlphaFields(2) + "=\"" + Alphas(2) + "\".");
    5616           0 :                 ErrorsFound = true;
    5617             :             }
    5618             :         }
    5619             : 
    5620          15 :         state.dataDXCoils->DXCoil(DXCoilNum).AirInNode =
    5621          30 :             GetOnlySingleNode(state,
    5622          15 :                               Alphas(3),
    5623             :                               ErrorsFound,
    5624             :                               DataLoopNode::ConnectionObjectType::CoilHeatingDXVariableRefrigerantFlowFluidTemperatureControl,
    5625          15 :                               Alphas(1),
    5626             :                               DataLoopNode::NodeFluidType::Air,
    5627             :                               DataLoopNode::ConnectionType::Inlet,
    5628             :                               NodeInputManager::CompFluidStream::Primary,
    5629          15 :                               ObjectIsNotParent);
    5630          15 :         state.dataDXCoils->DXCoil(DXCoilNum).AirOutNode =
    5631          30 :             GetOnlySingleNode(state,
    5632          15 :                               Alphas(4),
    5633             :                               ErrorsFound,
    5634             :                               DataLoopNode::ConnectionObjectType::CoilHeatingDXVariableRefrigerantFlowFluidTemperatureControl,
    5635          15 :                               Alphas(1),
    5636             :                               DataLoopNode::NodeFluidType::Air,
    5637             :                               DataLoopNode::ConnectionType::Outlet,
    5638             :                               NodeInputManager::CompFluidStream::Primary,
    5639          15 :                               ObjectIsNotParent);
    5640          15 :         TestCompSet(state, CurrentModuleObject, Alphas(1), Alphas(3), Alphas(4), "Air Nodes");
    5641             : 
    5642          15 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(1) = Numbers(1);
    5643          15 :         state.dataDXCoils->DXCoil(DXCoilNum).SC = Numbers(2);
    5644             :         //@@ DXCoil( DXCoilNum ).RateBFVRFIUCond = 0.136;
    5645             : 
    5646          15 :         int indexSCCurve = GetCurveIndex(state, Alphas(5)); // convert curve name to index number
    5647             :         // Verify curve name and type
    5648          15 :         if (indexSCCurve == 0) {
    5649           0 :             if (lAlphaBlanks(5)) {
    5650           0 :                 ShowSevereError(state,
    5651           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", missing");
    5652           0 :                 ShowContinueError(state, "...required " + cAlphaFields(5) + " is blank.");
    5653             :             } else {
    5654           0 :                 ShowSevereError(state,
    5655           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    5656           0 :                 ShowContinueError(state, "...not found " + cAlphaFields(5) + "=\"" + Alphas(5) + "\".");
    5657             :             }
    5658           0 :             ErrorsFound = true;
    5659             :         } else {
    5660             :             {
    5661          15 :                 if (state.dataCurveManager->PerfCurve(indexSCCurve).curveType == Curve::CurveType::Quadratic) {
    5662          15 :                     state.dataDXCoils->DXCoil(DXCoilNum).C1Tc = state.dataCurveManager->PerfCurve(indexSCCurve).coeff[0];
    5663          15 :                     state.dataDXCoils->DXCoil(DXCoilNum).C2Tc = state.dataCurveManager->PerfCurve(indexSCCurve).coeff[1];
    5664          15 :                     state.dataDXCoils->DXCoil(DXCoilNum).C3Tc = state.dataCurveManager->PerfCurve(indexSCCurve).coeff[2];
    5665             : 
    5666             :                 } else {
    5667           0 :                     ShowSevereError(
    5668           0 :                         state, std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", invalid");
    5669           0 :                     ShowContinueError(state,
    5670           0 :                                       format("...illegal {} type for this object = {}",
    5671             :                                              cAlphaFields(5),
    5672           0 :                                              Curve::objectNames[static_cast<int>(state.dataCurveManager->PerfCurve(indexSCCurve).curveType)]));
    5673           0 :                     ShowContinueError(state, "... Curve type must be Quadratic.");
    5674           0 :                     ErrorsFound = true;
    5675             :                 }
    5676             :             }
    5677             :         }
    5678             :     }
    5679             : 
    5680         241 :     if (ErrorsFound) {
    5681           0 :         ShowFatalError(state,
    5682           0 :                        std::string{RoutineName} + "Errors found in getting " + CurrentModuleObject +
    5683             :                            " input. Preceding condition(s) causes termination.");
    5684             :     }
    5685             : 
    5686        1193 :     for (DXCoilNum = 1; DXCoilNum <= state.dataDXCoils->NumDXCoils; ++DXCoilNum) {
    5687             : 
    5688         952 :         DXCoilData &Coil = state.dataDXCoils->DXCoil(DXCoilNum);
    5689             : 
    5690         952 :         if (Coil.DXCoilType_Num == CoilDX_CoolingSingleSpeed || Coil.DXCoilType_Num == CoilDX_CoolingTwoStageWHumControl) {
    5691             :             // Setup Report Variables for Cooling Equipment
    5692             :             // CurrentModuleObject='Coil:Cooling:DX:SingleSpeed/Coil:Cooling:DX:TwoStageWithHumidityControlMode'
    5693        1232 :             SetupOutputVariable(state,
    5694             :                                 "Cooling Coil Total Cooling Rate",
    5695             :                                 OutputProcessor::Unit::W,
    5696             :                                 Coil.TotalCoolingEnergyRate,
    5697             :                                 OutputProcessor::SOVTimeStepType::System,
    5698             :                                 OutputProcessor::SOVStoreType::Average,
    5699         616 :                                 Coil.Name);
    5700        1232 :             SetupOutputVariable(state,
    5701             :                                 "Cooling Coil Total Cooling Energy",
    5702             :                                 OutputProcessor::Unit::J,
    5703             :                                 Coil.TotalCoolingEnergy,
    5704             :                                 OutputProcessor::SOVTimeStepType::System,
    5705             :                                 OutputProcessor::SOVStoreType::Summed,
    5706             :                                 Coil.Name,
    5707             :                                 _,
    5708             :                                 "ENERGYTRANSFER",
    5709             :                                 "COOLINGCOILS",
    5710             :                                 _,
    5711         616 :                                 "System");
    5712        1232 :             SetupOutputVariable(state,
    5713             :                                 "Cooling Coil Sensible Cooling Rate",
    5714             :                                 OutputProcessor::Unit::W,
    5715             :                                 Coil.SensCoolingEnergyRate,
    5716             :                                 OutputProcessor::SOVTimeStepType::System,
    5717             :                                 OutputProcessor::SOVStoreType::Average,
    5718         616 :                                 Coil.Name);
    5719        1232 :             SetupOutputVariable(state,
    5720             :                                 "Cooling Coil Sensible Cooling Energy",
    5721             :                                 OutputProcessor::Unit::J,
    5722             :                                 Coil.SensCoolingEnergy,
    5723             :                                 OutputProcessor::SOVTimeStepType::System,
    5724             :                                 OutputProcessor::SOVStoreType::Summed,
    5725         616 :                                 Coil.Name);
    5726        1232 :             SetupOutputVariable(state,
    5727             :                                 "Cooling Coil Latent Cooling Rate",
    5728             :                                 OutputProcessor::Unit::W,
    5729             :                                 Coil.LatCoolingEnergyRate,
    5730             :                                 OutputProcessor::SOVTimeStepType::System,
    5731             :                                 OutputProcessor::SOVStoreType::Average,
    5732         616 :                                 Coil.Name);
    5733        1232 :             SetupOutputVariable(state,
    5734             :                                 "Cooling Coil Latent Cooling Energy",
    5735             :                                 OutputProcessor::Unit::J,
    5736             :                                 Coil.LatCoolingEnergy,
    5737             :                                 OutputProcessor::SOVTimeStepType::System,
    5738             :                                 OutputProcessor::SOVStoreType::Summed,
    5739         616 :                                 Coil.Name);
    5740        1232 :             SetupOutputVariable(state,
    5741             :                                 "Cooling Coil Electricity Rate",
    5742             :                                 OutputProcessor::Unit::W,
    5743             :                                 Coil.ElecCoolingPower,
    5744             :                                 OutputProcessor::SOVTimeStepType::System,
    5745             :                                 OutputProcessor::SOVStoreType::Average,
    5746         616 :                                 Coil.Name);
    5747        1232 :             SetupOutputVariable(state,
    5748             :                                 "Cooling Coil Electricity Energy",
    5749             :                                 OutputProcessor::Unit::J,
    5750             :                                 Coil.ElecCoolingConsumption,
    5751             :                                 OutputProcessor::SOVTimeStepType::System,
    5752             :                                 OutputProcessor::SOVStoreType::Summed,
    5753             :                                 Coil.Name,
    5754             :                                 _,
    5755             :                                 "Electricity",
    5756             :                                 "COOLING",
    5757             :                                 _,
    5758         616 :                                 "System");
    5759        1232 :             SetupOutputVariable(state,
    5760             :                                 "Cooling Coil Runtime Fraction",
    5761             :                                 OutputProcessor::Unit::None,
    5762             :                                 Coil.CoolingCoilRuntimeFraction,
    5763             :                                 OutputProcessor::SOVTimeStepType::System,
    5764             :                                 OutputProcessor::SOVStoreType::Average,
    5765         616 :                                 Coil.Name);
    5766         616 :             if (Coil.IsSecondaryDXCoilInZone) {
    5767           2 :                 SetupOutputVariable(state,
    5768             :                                     "Secondary Coil Heat Rejection Rate",
    5769             :                                     OutputProcessor::Unit::W,
    5770             :                                     Coil.SecCoilSensibleHeatGainRate,
    5771             :                                     OutputProcessor::SOVTimeStepType::System,
    5772             :                                     OutputProcessor::SOVStoreType::Average,
    5773           1 :                                     Coil.Name);
    5774             :             }
    5775             : 
    5776             :             // do we report these even if no storage tank?
    5777         616 :             if (Coil.CondensateCollectMode == CondensateCollectAction::ToTank) {
    5778           0 :                 SetupOutputVariable(state,
    5779             :                                     "Cooling Coil Condensate Volume Flow Rate",
    5780             :                                     OutputProcessor::Unit::m3_s,
    5781             :                                     Coil.CondensateVdot,
    5782             :                                     OutputProcessor::SOVTimeStepType::System,
    5783             :                                     OutputProcessor::SOVStoreType::Average,
    5784           0 :                                     Coil.Name);
    5785           0 :                 SetupOutputVariable(state,
    5786             :                                     "Cooling Coil Condensate Volume",
    5787             :                                     OutputProcessor::Unit::m3,
    5788             :                                     Coil.CondensateVol,
    5789             :                                     OutputProcessor::SOVTimeStepType::System,
    5790             :                                     OutputProcessor::SOVStoreType::Summed,
    5791             :                                     Coil.Name,
    5792             :                                     _,
    5793             :                                     "OnSiteWater",
    5794             :                                     "Condensate",
    5795             :                                     _,
    5796           0 :                                     "System");
    5797             :             }
    5798             : 
    5799         616 :             if (Coil.ReportEvapCondVars) {
    5800           2 :                 SetupOutputVariable(state,
    5801             :                                     "Cooling Coil Condenser Inlet Temperature",
    5802             :                                     OutputProcessor::Unit::C,
    5803             :                                     Coil.CondInletTemp,
    5804             :                                     OutputProcessor::SOVTimeStepType::System,
    5805             :                                     OutputProcessor::SOVStoreType::Average,
    5806           1 :                                     Coil.Name);
    5807           2 :                 SetupOutputVariable(state,
    5808             :                                     "Cooling Coil Evaporative Condenser Water Volume",
    5809             :                                     OutputProcessor::Unit::m3,
    5810             :                                     Coil.EvapWaterConsump,
    5811             :                                     OutputProcessor::SOVTimeStepType::System,
    5812             :                                     OutputProcessor::SOVStoreType::Summed,
    5813             :                                     Coil.Name,
    5814             :                                     _,
    5815             :                                     "Water",
    5816             :                                     "Cooling",
    5817             :                                     _,
    5818           1 :                                     "System");
    5819           2 :                 SetupOutputVariable(state,
    5820             :                                     "Cooling Coil Evaporative Condenser Mains Supply Water Volume",
    5821             :                                     OutputProcessor::Unit::m3,
    5822             :                                     Coil.EvapWaterConsump,
    5823             :                                     OutputProcessor::SOVTimeStepType::System,
    5824             :                                     OutputProcessor::SOVStoreType::Summed,
    5825             :                                     Coil.Name,
    5826             :                                     _,
    5827             :                                     "MainsWater",
    5828             :                                     "Cooling",
    5829             :                                     _,
    5830           1 :                                     "System");
    5831           2 :                 SetupOutputVariable(state,
    5832             :                                     "Cooling Coil Evaporative Condenser Pump Electricity Rate",
    5833             :                                     OutputProcessor::Unit::W,
    5834             :                                     Coil.EvapCondPumpElecPower,
    5835             :                                     OutputProcessor::SOVTimeStepType::System,
    5836             :                                     OutputProcessor::SOVStoreType::Average,
    5837           1 :                                     Coil.Name);
    5838           2 :                 SetupOutputVariable(state,
    5839             :                                     "Cooling Coil Evaporative Condenser Pump Electricity Energy",
    5840             :                                     OutputProcessor::Unit::J,
    5841             :                                     Coil.EvapCondPumpElecConsumption,
    5842             :                                     OutputProcessor::SOVTimeStepType::System,
    5843             :                                     OutputProcessor::SOVStoreType::Summed,
    5844             :                                     Coil.Name,
    5845             :                                     _,
    5846             :                                     "Electricity",
    5847             :                                     "COOLING",
    5848             :                                     _,
    5849           1 :                                     "System");
    5850           1 :                 if (Coil.BasinHeaterPowerFTempDiff > 0.0) {
    5851           2 :                     SetupOutputVariable(state,
    5852             :                                         "Cooling Coil Basin Heater Electricity Rate",
    5853             :                                         OutputProcessor::Unit::W,
    5854             :                                         Coil.BasinHeaterPower,
    5855             :                                         OutputProcessor::SOVTimeStepType::System,
    5856             :                                         OutputProcessor::SOVStoreType::Average,
    5857           1 :                                         Coil.Name);
    5858           2 :                     SetupOutputVariable(state,
    5859             :                                         "Cooling Coil Basin Heater Electricity Energy",
    5860             :                                         OutputProcessor::Unit::J,
    5861             :                                         Coil.BasinHeaterConsumption,
    5862             :                                         OutputProcessor::SOVTimeStepType::System,
    5863             :                                         OutputProcessor::SOVStoreType::Summed,
    5864             :                                         Coil.Name,
    5865             :                                         _,
    5866             :                                         "Electricity",
    5867             :                                         "COOLING",
    5868             :                                         _,
    5869           1 :                                         "System");
    5870             :                 }
    5871             :             }
    5872             : 
    5873        1232 :             if (Coil.DXCoilType_Num == CoilDX_CoolingTwoStageWHumControl) {
    5874             :                 // Setup Report Variables for Cooling Equipment
    5875             :                 // CurrentModuleObject='Cooling:DX:TwoStageWithHumidityControlMode'
    5876          22 :                 SetupOutputVariable(state,
    5877             :                                     "Cooling Coil Stage 2 Runtime Fraction",
    5878             :                                     OutputProcessor::Unit::None,
    5879             :                                     Coil.CoolingCoilStg2RuntimeFrac,
    5880             :                                     OutputProcessor::SOVTimeStepType::System,
    5881             :                                     OutputProcessor::SOVStoreType::Average,
    5882          11 :                                     Coil.Name);
    5883          22 :                 SetupOutputVariable(state,
    5884             :                                     "Cooling Coil Dehumidification Mode",
    5885             :                                     OutputProcessor::Unit::None,
    5886             :                                     Coil.DehumidificationMode,
    5887             :                                     OutputProcessor::SOVTimeStepType::System,
    5888             :                                     OutputProcessor::SOVStoreType::Average,
    5889          11 :                                     Coil.Name);
    5890             :             }
    5891             : 
    5892             :         }
    5893             : 
    5894         336 :         else if (Coil.DXCoilType_Num == CoilDX_HeatingEmpirical) {
    5895             :             // Setup Report Variables for Heating Equipment
    5896             :             // CurrentModuleObject='Coil:Heating:DX:SingleSpeed'
    5897         146 :             SetupOutputVariable(state,
    5898             :                                 "Heating Coil Heating Rate",
    5899             :                                 OutputProcessor::Unit::W,
    5900             :                                 Coil.TotalHeatingEnergyRate,
    5901             :                                 OutputProcessor::SOVTimeStepType::System,
    5902             :                                 OutputProcessor::SOVStoreType::Average,
    5903          73 :                                 Coil.Name);
    5904         146 :             SetupOutputVariable(state,
    5905             :                                 "Heating Coil Heating Energy",
    5906             :                                 OutputProcessor::Unit::J,
    5907             :                                 Coil.TotalHeatingEnergy,
    5908             :                                 OutputProcessor::SOVTimeStepType::System,
    5909             :                                 OutputProcessor::SOVStoreType::Summed,
    5910             :                                 Coil.Name,
    5911             :                                 _,
    5912             :                                 "ENERGYTRANSFER",
    5913             :                                 "HEATINGCOILS",
    5914             :                                 _,
    5915          73 :                                 "System");
    5916         146 :             SetupOutputVariable(state,
    5917             :                                 "Heating Coil Electricity Rate",
    5918             :                                 OutputProcessor::Unit::W,
    5919             :                                 Coil.ElecHeatingPower,
    5920             :                                 OutputProcessor::SOVTimeStepType::System,
    5921             :                                 OutputProcessor::SOVStoreType::Average,
    5922          73 :                                 Coil.Name);
    5923         146 :             SetupOutputVariable(state,
    5924             :                                 "Heating Coil Electricity Energy",
    5925             :                                 OutputProcessor::Unit::J,
    5926             :                                 Coil.ElecHeatingConsumption,
    5927             :                                 OutputProcessor::SOVTimeStepType::System,
    5928             :                                 OutputProcessor::SOVStoreType::Summed,
    5929             :                                 Coil.Name,
    5930             :                                 _,
    5931             :                                 "Electricity",
    5932             :                                 "HEATING",
    5933             :                                 _,
    5934          73 :                                 "System");
    5935         146 :             SetupOutputVariable(state,
    5936             :                                 "Heating Coil Defrost Electricity Rate",
    5937             :                                 OutputProcessor::Unit::W,
    5938             :                                 Coil.DefrostPower,
    5939             :                                 OutputProcessor::SOVTimeStepType::System,
    5940             :                                 OutputProcessor::SOVStoreType::Average,
    5941          73 :                                 Coil.Name);
    5942         146 :             SetupOutputVariable(state,
    5943             :                                 "Heating Coil Defrost Electricity Energy",
    5944             :                                 OutputProcessor::Unit::J,
    5945             :                                 Coil.DefrostConsumption,
    5946             :                                 OutputProcessor::SOVTimeStepType::System,
    5947             :                                 OutputProcessor::SOVStoreType::Summed,
    5948             :                                 Coil.Name,
    5949             :                                 _,
    5950             :                                 "Electricity",
    5951             :                                 "HEATING",
    5952             :                                 _,
    5953          73 :                                 "System");
    5954         146 :             SetupOutputVariable(state,
    5955             :                                 "Heating Coil Crankcase Heater Electricity Rate",
    5956             :                                 OutputProcessor::Unit::W,
    5957             :                                 Coil.CrankcaseHeaterPower,
    5958             :                                 OutputProcessor::SOVTimeStepType::System,
    5959             :                                 OutputProcessor::SOVStoreType::Average,
    5960          73 :                                 Coil.Name);
    5961         146 :             SetupOutputVariable(state,
    5962             :                                 "Heating Coil Crankcase Heater Electricity Energy",
    5963             :                                 OutputProcessor::Unit::J,
    5964             :                                 Coil.CrankcaseHeaterConsumption,
    5965             :                                 OutputProcessor::SOVTimeStepType::System,
    5966             :                                 OutputProcessor::SOVStoreType::Summed,
    5967             :                                 Coil.Name,
    5968             :                                 _,
    5969             :                                 "Electricity",
    5970             :                                 "HEATING",
    5971             :                                 _,
    5972          73 :                                 "System");
    5973         146 :             SetupOutputVariable(state,
    5974             :                                 "Heating Coil Runtime Fraction",
    5975             :                                 OutputProcessor::Unit::None,
    5976             :                                 Coil.HeatingCoilRuntimeFraction,
    5977             :                                 OutputProcessor::SOVTimeStepType::System,
    5978             :                                 OutputProcessor::SOVStoreType::Average,
    5979          73 :                                 Coil.Name);
    5980          73 :             if (Coil.IsSecondaryDXCoilInZone) {
    5981           2 :                 SetupOutputVariable(state,
    5982             :                                     "Secondary Coil Total Heat Removal Rate",
    5983             :                                     OutputProcessor::Unit::W,
    5984             :                                     Coil.SecCoilTotalHeatRemovalRate,
    5985             :                                     OutputProcessor::SOVTimeStepType::System,
    5986             :                                     OutputProcessor::SOVStoreType::Average,
    5987           1 :                                     Coil.Name);
    5988           2 :                 SetupOutputVariable(state,
    5989             :                                     "Secondary Coil Sensible Heat Removal Rate",
    5990             :                                     OutputProcessor::Unit::W,
    5991             :                                     Coil.SecCoilSensibleHeatRemovalRate,
    5992             :                                     OutputProcessor::SOVTimeStepType::System,
    5993             :                                     OutputProcessor::SOVStoreType::Average,
    5994           1 :                                     Coil.Name);
    5995           2 :                 SetupOutputVariable(state,
    5996             :                                     "Secondary Coil Latent Heat Removal Rate",
    5997             :                                     OutputProcessor::Unit::W,
    5998             :                                     Coil.SecCoilLatentHeatRemovalRate,
    5999             :                                     OutputProcessor::SOVTimeStepType::System,
    6000             :                                     OutputProcessor::SOVStoreType::Average,
    6001           1 :                                     Coil.Name);
    6002           2 :                 SetupOutputVariable(state,
    6003             :                                     "Secondary Coil Sensible Heat Ratio",
    6004             :                                     OutputProcessor::Unit::None,
    6005             :                                     Coil.SecCoilSHR,
    6006             :                                     OutputProcessor::SOVTimeStepType::System,
    6007             :                                     OutputProcessor::SOVStoreType::Average,
    6008           1 :                                     Coil.Name);
    6009           2 :                 SetupOutputVariable(state,
    6010             :                                     "Secondary Coil Compressor Part Load Ratio",
    6011             :                                     OutputProcessor::Unit::None,
    6012             :                                     Coil.CompressorPartLoadRatio,
    6013             :                                     OutputProcessor::SOVTimeStepType::System,
    6014             :                                     OutputProcessor::SOVStoreType::Average,
    6015           1 :                                     Coil.Name);
    6016             :             }
    6017             :         }
    6018             : 
    6019         263 :         else if (Coil.DXCoilType_Num == CoilDX_CoolingTwoSpeed) {
    6020             :             // Setup Report Variables for Cooling Equipment
    6021             :             // CurrentModuleObject='Coil:Cooling:DX:TwoSpeed'
    6022         134 :             SetupOutputVariable(state,
    6023             :                                 "Cooling Coil Total Cooling Rate",
    6024             :                                 OutputProcessor::Unit::W,
    6025             :                                 Coil.TotalCoolingEnergyRate,
    6026             :                                 OutputProcessor::SOVTimeStepType::System,
    6027             :                                 OutputProcessor::SOVStoreType::Average,
    6028          67 :                                 Coil.Name);
    6029         134 :             SetupOutputVariable(state,
    6030             :                                 "Cooling Coil Total Cooling Energy",
    6031             :                                 OutputProcessor::Unit::J,
    6032             :                                 Coil.TotalCoolingEnergy,
    6033             :                                 OutputProcessor::SOVTimeStepType::System,
    6034             :                                 OutputProcessor::SOVStoreType::Summed,
    6035             :                                 Coil.Name,
    6036             :                                 _,
    6037             :                                 "ENERGYTRANSFER",
    6038             :                                 "COOLINGCOILS",
    6039             :                                 _,
    6040          67 :                                 "System");
    6041         134 :             SetupOutputVariable(state,
    6042             :                                 "Cooling Coil Sensible Cooling Rate",
    6043             :                                 OutputProcessor::Unit::W,
    6044             :                                 Coil.SensCoolingEnergyRate,
    6045             :                                 OutputProcessor::SOVTimeStepType::System,
    6046             :                                 OutputProcessor::SOVStoreType::Average,
    6047          67 :                                 Coil.Name);
    6048         134 :             SetupOutputVariable(state,
    6049             :                                 "Cooling Coil Sensible Cooling Energy",
    6050             :                                 OutputProcessor::Unit::J,
    6051             :                                 Coil.SensCoolingEnergy,
    6052             :                                 OutputProcessor::SOVTimeStepType::System,
    6053             :                                 OutputProcessor::SOVStoreType::Summed,
    6054          67 :                                 Coil.Name);
    6055         134 :             SetupOutputVariable(state,
    6056             :                                 "Cooling Coil Latent Cooling Rate",
    6057             :                                 OutputProcessor::Unit::W,
    6058             :                                 Coil.LatCoolingEnergyRate,
    6059             :                                 OutputProcessor::SOVTimeStepType::System,
    6060             :                                 OutputProcessor::SOVStoreType::Average,
    6061          67 :                                 Coil.Name);
    6062         134 :             SetupOutputVariable(state,
    6063             :                                 "Cooling Coil Latent Cooling Energy",
    6064             :                                 OutputProcessor::Unit::J,
    6065             :                                 Coil.LatCoolingEnergy,
    6066             :                                 OutputProcessor::SOVTimeStepType::System,
    6067             :                                 OutputProcessor::SOVStoreType::Summed,
    6068          67 :                                 Coil.Name);
    6069         134 :             SetupOutputVariable(state,
    6070             :                                 "Cooling Coil Electricity Rate",
    6071             :                                 OutputProcessor::Unit::W,
    6072             :                                 Coil.ElecCoolingPower,
    6073             :                                 OutputProcessor::SOVTimeStepType::System,
    6074             :                                 OutputProcessor::SOVStoreType::Average,
    6075          67 :                                 Coil.Name);
    6076         134 :             SetupOutputVariable(state,
    6077             :                                 "Cooling Coil Electricity Energy",
    6078             :                                 OutputProcessor::Unit::J,
    6079             :                                 Coil.ElecCoolingConsumption,
    6080             :                                 OutputProcessor::SOVTimeStepType::System,
    6081             :                                 OutputProcessor::SOVStoreType::Summed,
    6082             :                                 Coil.Name,
    6083             :                                 _,
    6084             :                                 "Electricity",
    6085             :                                 "COOLING",
    6086             :                                 _,
    6087          67 :                                 "System");
    6088         134 :             SetupOutputVariable(state,
    6089             :                                 "Cooling Coil Runtime Fraction",
    6090             :                                 OutputProcessor::Unit::None,
    6091             :                                 Coil.CoolingCoilRuntimeFraction,
    6092             :                                 OutputProcessor::SOVTimeStepType::System,
    6093             :                                 OutputProcessor::SOVStoreType::Average,
    6094          67 :                                 Coil.Name);
    6095          67 :             if (Coil.IsSecondaryDXCoilInZone) {
    6096           0 :                 SetupOutputVariable(state,
    6097             :                                     "Secondary Coil Heat Rejection Rate",
    6098             :                                     OutputProcessor::Unit::W,
    6099             :                                     Coil.SecCoilSensibleHeatGainRate,
    6100             :                                     OutputProcessor::SOVTimeStepType::System,
    6101             :                                     OutputProcessor::SOVStoreType::Average,
    6102           0 :                                     Coil.Name);
    6103             :             }
    6104             : 
    6105          67 :             if (Coil.ReportEvapCondVars) {
    6106           2 :                 SetupOutputVariable(state,
    6107             :                                     "Cooling Coil Condenser Inlet Temperature",
    6108             :                                     OutputProcessor::Unit::C,
    6109             :                                     Coil.CondInletTemp,
    6110             :                                     OutputProcessor::SOVTimeStepType::System,
    6111             :                                     OutputProcessor::SOVStoreType::Average,
    6112           1 :                                     Coil.Name);
    6113           2 :                 SetupOutputVariable(state,
    6114             :                                     "Cooling Coil Evaporative Condenser Water Volume",
    6115             :                                     OutputProcessor::Unit::m3,
    6116             :                                     Coil.EvapWaterConsump,
    6117             :                                     OutputProcessor::SOVTimeStepType::System,
    6118             :                                     OutputProcessor::SOVStoreType::Summed,
    6119             :                                     Coil.Name,
    6120             :                                     _,
    6121             :                                     "Water",
    6122             :                                     "Cooling",
    6123             :                                     _,
    6124           1 :                                     "System");
    6125           2 :                 SetupOutputVariable(state,
    6126             :                                     "Cooling Coil Evaporative Condenser Mains Supply Water Volume",
    6127             :                                     OutputProcessor::Unit::m3,
    6128             :                                     Coil.EvapWaterConsump,
    6129             :                                     OutputProcessor::SOVTimeStepType::System,
    6130             :                                     OutputProcessor::SOVStoreType::Summed,
    6131             :                                     Coil.Name,
    6132             :                                     _,
    6133             :                                     "MainsWater",
    6134             :                                     "Cooling",
    6135             :                                     _,
    6136           1 :                                     "System");
    6137           2 :                 SetupOutputVariable(state,
    6138             :                                     "Cooling Coil Evaporative Condenser Pump Electricity Rate",
    6139             :                                     OutputProcessor::Unit::W,
    6140             :                                     Coil.EvapCondPumpElecPower,
    6141             :                                     OutputProcessor::SOVTimeStepType::System,
    6142             :                                     OutputProcessor::SOVStoreType::Average,
    6143           1 :                                     Coil.Name);
    6144           2 :                 SetupOutputVariable(state,
    6145             :                                     "Cooling Coil Evaporative Condenser Pump Electricity Energy",
    6146             :                                     OutputProcessor::Unit::J,
    6147             :                                     Coil.EvapCondPumpElecConsumption,
    6148             :                                     OutputProcessor::SOVTimeStepType::System,
    6149             :                                     OutputProcessor::SOVStoreType::Summed,
    6150             :                                     Coil.Name,
    6151             :                                     _,
    6152             :                                     "Electricity",
    6153             :                                     "COOLING",
    6154             :                                     _,
    6155           1 :                                     "System");
    6156           1 :                 if (Coil.BasinHeaterPowerFTempDiff > 0.0) {
    6157           2 :                     SetupOutputVariable(state,
    6158             :                                         "Cooling Coil Basin Heater Electricity Rate",
    6159             :                                         OutputProcessor::Unit::W,
    6160             :                                         Coil.BasinHeaterPower,
    6161             :                                         OutputProcessor::SOVTimeStepType::System,
    6162             :                                         OutputProcessor::SOVStoreType::Average,
    6163           1 :                                         Coil.Name);
    6164           2 :                     SetupOutputVariable(state,
    6165             :                                         "Cooling Coil Basin Heater Electricity Energy",
    6166             :                                         OutputProcessor::Unit::J,
    6167             :                                         Coil.BasinHeaterConsumption,
    6168             :                                         OutputProcessor::SOVTimeStepType::System,
    6169             :                                         OutputProcessor::SOVStoreType::Summed,
    6170             :                                         Coil.Name,
    6171             :                                         _,
    6172             :                                         "Electricity",
    6173             :                                         "COOLING",
    6174             :                                         _,
    6175           1 :                                         "System");
    6176             :                 }
    6177             :             }
    6178             : 
    6179             :         }
    6180             : 
    6181         196 :         else if (Coil.DXCoilType_Num == CoilDX_HeatPumpWaterHeaterPumped || Coil.DXCoilType_Num == CoilDX_HeatPumpWaterHeaterWrapped) {
    6182             :             // Setup Report Variables for Cooling Equipment
    6183             :             // CurrentModuleObject='Coil:WaterHeating:AirToWaterHeatPump:Pumped'
    6184             :             // or 'Coil:WaterHeating:AirToWaterHeatPump:Wrapped'
    6185          32 :             SetupOutputVariable(state,
    6186             :                                 "Cooling Coil Total Cooling Rate",
    6187             :                                 OutputProcessor::Unit::W,
    6188             :                                 Coil.TotalCoolingEnergyRate,
    6189             :                                 OutputProcessor::SOVTimeStepType::System,
    6190             :                                 OutputProcessor::SOVStoreType::Average,
    6191          16 :                                 Coil.Name);
    6192             : 
    6193          16 :             if (Coil.IsDXCoilInZone) {
    6194          30 :                 SetupOutputVariable(state,
    6195             :                                     "Cooling Coil Total Cooling Energy",
    6196             :                                     OutputProcessor::Unit::J,
    6197             :                                     Coil.TotalCoolingEnergy,
    6198             :                                     OutputProcessor::SOVTimeStepType::System,
    6199             :                                     OutputProcessor::SOVStoreType::Summed,
    6200             :                                     Coil.Name,
    6201             :                                     _,
    6202             :                                     "ENERGYTRANSFER",
    6203             :                                     "COOLINGCOILS",
    6204             :                                     _,
    6205          15 :                                     "System");
    6206             :             } else {
    6207           2 :                 SetupOutputVariable(state,
    6208             :                                     "Cooling Coil Total Cooling Energy",
    6209             :                                     OutputProcessor::Unit::J,
    6210             :                                     Coil.TotalCoolingEnergy,
    6211             :                                     OutputProcessor::SOVTimeStepType::System,
    6212             :                                     OutputProcessor::SOVStoreType::Summed,
    6213           1 :                                     Coil.Name);
    6214             :             }
    6215             : 
    6216          32 :             SetupOutputVariable(state,
    6217             :                                 "Cooling Coil Sensible Cooling Rate",
    6218             :                                 OutputProcessor::Unit::W,
    6219             :                                 Coil.SensCoolingEnergyRate,
    6220             :                                 OutputProcessor::SOVTimeStepType::System,
    6221             :                                 OutputProcessor::SOVStoreType::Average,
    6222          16 :                                 Coil.Name);
    6223          32 :             SetupOutputVariable(state,
    6224             :                                 "Cooling Coil Sensible Cooling Energy",
    6225             :                                 OutputProcessor::Unit::J,
    6226             :                                 Coil.SensCoolingEnergy,
    6227             :                                 OutputProcessor::SOVTimeStepType::System,
    6228             :                                 OutputProcessor::SOVStoreType::Summed,
    6229          16 :                                 Coil.Name);
    6230          32 :             SetupOutputVariable(state,
    6231             :                                 "Cooling Coil Latent Cooling Rate",
    6232             :                                 OutputProcessor::Unit::W,
    6233             :                                 Coil.LatCoolingEnergyRate,
    6234             :                                 OutputProcessor::SOVTimeStepType::System,
    6235             :                                 OutputProcessor::SOVStoreType::Average,
    6236          16 :                                 Coil.Name);
    6237          32 :             SetupOutputVariable(state,
    6238             :                                 "Cooling Coil Latent Cooling Energy",
    6239             :                                 OutputProcessor::Unit::J,
    6240             :                                 Coil.LatCoolingEnergy,
    6241             :                                 OutputProcessor::SOVTimeStepType::System,
    6242             :                                 OutputProcessor::SOVStoreType::Summed,
    6243          16 :                                 Coil.Name);
    6244          32 :             SetupOutputVariable(state,
    6245             :                                 "Cooling Coil Runtime Fraction",
    6246             :                                 OutputProcessor::Unit::None,
    6247             :                                 Coil.CoolingCoilRuntimeFraction,
    6248             :                                 OutputProcessor::SOVTimeStepType::System,
    6249             :                                 OutputProcessor::SOVStoreType::Average,
    6250          16 :                                 Coil.Name);
    6251             : 
    6252          16 :             if (Coil.ReportCoolingCoilCrankcasePower) {
    6253          32 :                 SetupOutputVariable(state,
    6254             :                                     "Cooling Coil Crankcase Heater Electricity Rate",
    6255             :                                     OutputProcessor::Unit::W,
    6256             :                                     Coil.CrankcaseHeaterPower,
    6257             :                                     OutputProcessor::SOVTimeStepType::System,
    6258             :                                     OutputProcessor::SOVStoreType::Average,
    6259          16 :                                     Coil.Name);
    6260          32 :                 SetupOutputVariable(state,
    6261             :                                     "Cooling Coil Crankcase Heater Electricity Energy",
    6262             :                                     OutputProcessor::Unit::J,
    6263             :                                     Coil.CrankcaseHeaterConsumption,
    6264             :                                     OutputProcessor::SOVTimeStepType::System,
    6265             :                                     OutputProcessor::SOVStoreType::Summed,
    6266             :                                     Coil.Name,
    6267             :                                     _,
    6268             :                                     "Electricity",
    6269             :                                     "DHW",
    6270             :                                     _,
    6271          16 :                                     "Plant");
    6272             :             }
    6273             : 
    6274             :             // new report variables for a HP water heater DX coil
    6275          32 :             SetupOutputVariable(state,
    6276             :                                 "Cooling Coil Total Water Heating Rate",
    6277             :                                 OutputProcessor::Unit::W,
    6278             :                                 Coil.TotalHeatingEnergyRate,
    6279             :                                 OutputProcessor::SOVTimeStepType::System,
    6280             :                                 OutputProcessor::SOVStoreType::Average,
    6281          16 :                                 Coil.Name);
    6282          32 :             SetupOutputVariable(state,
    6283             :                                 "Cooling Coil Total Water Heating Energy",
    6284             :                                 OutputProcessor::Unit::J,
    6285             :                                 Coil.TotalHeatingEnergy,
    6286             :                                 OutputProcessor::SOVTimeStepType::System,
    6287             :                                 OutputProcessor::SOVStoreType::Summed,
    6288          16 :                                 Coil.Name); //, &
    6289             :             //                           ResourceTypeKey='ENERGYTRANSFER',EndUseKey='HEATING',GroupKey='Plant')
    6290          32 :             SetupOutputVariable(state,
    6291             :                                 "Cooling Coil Water Heating Electricity Rate",
    6292             :                                 OutputProcessor::Unit::W,
    6293             :                                 Coil.ElecWaterHeatingPower,
    6294             :                                 OutputProcessor::SOVTimeStepType::System,
    6295             :                                 OutputProcessor::SOVStoreType::Average,
    6296          16 :                                 Coil.Name);
    6297          32 :             SetupOutputVariable(state,
    6298             :                                 "Cooling Coil Water Heating Electricity Energy",
    6299             :                                 OutputProcessor::Unit::J,
    6300             :                                 Coil.ElecWaterHeatingConsumption,
    6301             :                                 OutputProcessor::SOVTimeStepType::System,
    6302             :                                 OutputProcessor::SOVStoreType::Summed,
    6303             :                                 Coil.Name,
    6304             :                                 _,
    6305             :                                 "Electricity",
    6306             :                                 "DHW",
    6307             :                                 _,
    6308          16 :                                 "Plant");
    6309             :         }
    6310             : 
    6311         180 :         else if (Coil.DXCoilType_Num == CoilDX_MultiSpeedCooling) {
    6312             :             // Setup Report Variables for Cooling Equipment:
    6313             :             // CurrentModuleObject='Coil:Cooling:DX:MultiSpeed'
    6314          96 :             SetupOutputVariable(state,
    6315             :                                 "Cooling Coil Total Cooling Rate",
    6316             :                                 OutputProcessor::Unit::W,
    6317             :                                 Coil.TotalCoolingEnergyRate,
    6318             :                                 OutputProcessor::SOVTimeStepType::System,
    6319             :                                 OutputProcessor::SOVStoreType::Average,
    6320          48 :                                 Coil.Name);
    6321          96 :             SetupOutputVariable(state,
    6322             :                                 "Cooling Coil Total Cooling Energy",
    6323             :                                 OutputProcessor::Unit::J,
    6324             :                                 Coil.TotalCoolingEnergy,
    6325             :                                 OutputProcessor::SOVTimeStepType::System,
    6326             :                                 OutputProcessor::SOVStoreType::Summed,
    6327             :                                 Coil.Name,
    6328             :                                 _,
    6329             :                                 "ENERGYTRANSFER",
    6330             :                                 "COOLINGCOILS",
    6331             :                                 _,
    6332          48 :                                 "System");
    6333          96 :             SetupOutputVariable(state,
    6334             :                                 "Cooling Coil Sensible Cooling Rate",
    6335             :                                 OutputProcessor::Unit::W,
    6336             :                                 Coil.SensCoolingEnergyRate,
    6337             :                                 OutputProcessor::SOVTimeStepType::System,
    6338             :                                 OutputProcessor::SOVStoreType::Average,
    6339          48 :                                 Coil.Name);
    6340          96 :             SetupOutputVariable(state,
    6341             :                                 "Cooling Coil Sensible Cooling Energy",
    6342             :                                 OutputProcessor::Unit::J,
    6343             :                                 Coil.SensCoolingEnergy,
    6344             :                                 OutputProcessor::SOVTimeStepType::System,
    6345             :                                 OutputProcessor::SOVStoreType::Summed,
    6346          48 :                                 Coil.Name);
    6347          96 :             SetupOutputVariable(state,
    6348             :                                 "Cooling Coil Latent Cooling Rate",
    6349             :                                 OutputProcessor::Unit::W,
    6350             :                                 Coil.LatCoolingEnergyRate,
    6351             :                                 OutputProcessor::SOVTimeStepType::System,
    6352             :                                 OutputProcessor::SOVStoreType::Average,
    6353          48 :                                 Coil.Name);
    6354          96 :             SetupOutputVariable(state,
    6355             :                                 "Cooling Coil Latent Cooling Energy",
    6356             :                                 OutputProcessor::Unit::J,
    6357             :                                 Coil.LatCoolingEnergy,
    6358             :                                 OutputProcessor::SOVTimeStepType::System,
    6359             :                                 OutputProcessor::SOVStoreType::Summed,
    6360          48 :                                 Coil.Name);
    6361          96 :             SetupOutputVariable(state,
    6362             :                                 "Cooling Coil Electricity Rate",
    6363             :                                 OutputProcessor::Unit::W,
    6364             :                                 Coil.ElecCoolingPower,
    6365             :                                 OutputProcessor::SOVTimeStepType::System,
    6366             :                                 OutputProcessor::SOVStoreType::Average,
    6367          48 :                                 Coil.Name);
    6368          96 :             SetupOutputVariable(state,
    6369             :                                 "Cooling Coil Electricity Energy",
    6370             :                                 OutputProcessor::Unit::J,
    6371             :                                 Coil.ElecCoolingConsumption,
    6372             :                                 OutputProcessor::SOVTimeStepType::System,
    6373             :                                 OutputProcessor::SOVStoreType::Summed,
    6374             :                                 Coil.Name,
    6375             :                                 _,
    6376             :                                 "Electricity",
    6377             :                                 "COOLING",
    6378             :                                 _,
    6379          48 :                                 "System");
    6380             : 
    6381          48 :             if (Coil.FuelTypeNum != DataGlobalConstants::ResourceType::Electricity) {
    6382          18 :                 SetupOutputVariable(state,
    6383          12 :                                     "Cooling Coil " + Coil.FuelType + " Rate",
    6384             :                                     OutputProcessor::Unit::W,
    6385             :                                     Coil.FuelUsed,
    6386             :                                     OutputProcessor::SOVTimeStepType::System,
    6387             :                                     OutputProcessor::SOVStoreType::Average,
    6388             :                                     Coil.Name);
    6389          18 :                 SetupOutputVariable(state,
    6390          12 :                                     "Cooling Coil " + Coil.FuelType + " Energy",
    6391             :                                     OutputProcessor::Unit::J,
    6392             :                                     Coil.FuelConsumed,
    6393             :                                     OutputProcessor::SOVTimeStepType::System,
    6394             :                                     OutputProcessor::SOVStoreType::Summed,
    6395             :                                     Coil.Name,
    6396             :                                     _,
    6397             :                                     Coil.FuelType,
    6398             :                                     "COOLING",
    6399             :                                     _,
    6400             :                                     "System");
    6401             :             }
    6402             : 
    6403          96 :             SetupOutputVariable(state,
    6404             :                                 "Cooling Coil Runtime Fraction",
    6405             :                                 OutputProcessor::Unit::None,
    6406             :                                 Coil.CoolingCoilRuntimeFraction,
    6407             :                                 OutputProcessor::SOVTimeStepType::System,
    6408             :                                 OutputProcessor::SOVStoreType::Average,
    6409          48 :                                 Coil.Name);
    6410             : 
    6411          48 :             if (Coil.ReportEvapCondVars) {
    6412           0 :                 SetupOutputVariable(state,
    6413             :                                     "Cooling Coil Condenser Inlet Temperature",
    6414             :                                     OutputProcessor::Unit::C,
    6415             :                                     Coil.CondInletTemp,
    6416             :                                     OutputProcessor::SOVTimeStepType::System,
    6417             :                                     OutputProcessor::SOVStoreType::Average,
    6418           0 :                                     Coil.Name);
    6419           0 :                 SetupOutputVariable(state,
    6420             :                                     "Cooling Coil Evaporative Condenser Water Volume",
    6421             :                                     OutputProcessor::Unit::m3,
    6422             :                                     Coil.EvapWaterConsump,
    6423             :                                     OutputProcessor::SOVTimeStepType::System,
    6424             :                                     OutputProcessor::SOVStoreType::Summed,
    6425             :                                     Coil.Name,
    6426             :                                     _,
    6427             :                                     "Water",
    6428             :                                     "Cooling",
    6429             :                                     _,
    6430           0 :                                     "System");
    6431           0 :                 SetupOutputVariable(state,
    6432             :                                     "Cooling Coil Evaporative Condenser Mains Supply Water Volume",
    6433             :                                     OutputProcessor::Unit::m3,
    6434             :                                     Coil.EvapWaterConsump,
    6435             :                                     OutputProcessor::SOVTimeStepType::System,
    6436             :                                     OutputProcessor::SOVStoreType::Summed,
    6437             :                                     Coil.Name,
    6438             :                                     _,
    6439             :                                     "MainsWater",
    6440             :                                     "Cooling",
    6441             :                                     _,
    6442           0 :                                     "System");
    6443           0 :                 SetupOutputVariable(state,
    6444             :                                     "Cooling Coil Evaporative Condenser Pump Electricity Rate",
    6445             :                                     OutputProcessor::Unit::W,
    6446             :                                     Coil.EvapCondPumpElecPower,
    6447             :                                     OutputProcessor::SOVTimeStepType::System,
    6448             :                                     OutputProcessor::SOVStoreType::Average,
    6449           0 :                                     Coil.Name);
    6450           0 :                 SetupOutputVariable(state,
    6451             :                                     "Cooling Coil Evaporative Condenser Pump Electricity Energy",
    6452             :                                     OutputProcessor::Unit::J,
    6453             :                                     Coil.EvapCondPumpElecConsumption,
    6454             :                                     OutputProcessor::SOVTimeStepType::System,
    6455             :                                     OutputProcessor::SOVStoreType::Summed,
    6456             :                                     Coil.Name,
    6457             :                                     _,
    6458             :                                     "Electricity",
    6459             :                                     "COOLING",
    6460             :                                     _,
    6461           0 :                                     "System");
    6462           0 :                 if (Coil.BasinHeaterPowerFTempDiff > 0.0) {
    6463           0 :                     SetupOutputVariable(state,
    6464             :                                         "Cooling Coil Basin Heater Electricity Rate",
    6465             :                                         OutputProcessor::Unit::W,
    6466             :                                         Coil.BasinHeaterPower,
    6467             :                                         OutputProcessor::SOVTimeStepType::System,
    6468             :                                         OutputProcessor::SOVStoreType::Average,
    6469           0 :                                         Coil.Name);
    6470           0 :                     SetupOutputVariable(state,
    6471             :                                         "Cooling Coil Basin Heater Electricity Energy",
    6472             :                                         OutputProcessor::Unit::J,
    6473             :                                         Coil.BasinHeaterConsumption,
    6474             :                                         OutputProcessor::SOVTimeStepType::System,
    6475             :                                         OutputProcessor::SOVStoreType::Summed,
    6476             :                                         Coil.Name,
    6477             :                                         _,
    6478             :                                         "Electricity",
    6479             :                                         "COOLING",
    6480             :                                         _,
    6481           0 :                                         "System");
    6482             :                 }
    6483             :             }
    6484          48 :             if (Coil.IsSecondaryDXCoilInZone) {
    6485           0 :                 SetupOutputVariable(state,
    6486             :                                     "Secondary Coil Heat Rejection Rate",
    6487             :                                     OutputProcessor::Unit::W,
    6488             :                                     Coil.SecCoilSensibleHeatGainRate,
    6489             :                                     OutputProcessor::SOVTimeStepType::System,
    6490             :                                     OutputProcessor::SOVStoreType::Average,
    6491           0 :                                     Coil.Name);
    6492             :             }
    6493             : 
    6494             :         }
    6495             : 
    6496         132 :         else if (Coil.DXCoilType_Num == CoilDX_MultiSpeedHeating) {
    6497             :             // Setup Report Variables for Heating Equipment:
    6498             :             // CurrentModuleObject='Coil:Heating:DX:MultiSpeed'
    6499          40 :             SetupOutputVariable(state,
    6500             :                                 "Heating Coil Heating Rate",
    6501             :                                 OutputProcessor::Unit::W,
    6502             :                                 Coil.TotalHeatingEnergyRate,
    6503             :                                 OutputProcessor::SOVTimeStepType::System,
    6504             :                                 OutputProcessor::SOVStoreType::Average,
    6505          20 :                                 Coil.Name);
    6506          40 :             SetupOutputVariable(state,
    6507             :                                 "Heating Coil Heating Energy",
    6508             :                                 OutputProcessor::Unit::J,
    6509             :                                 Coil.TotalHeatingEnergy,
    6510             :                                 OutputProcessor::SOVTimeStepType::System,
    6511             :                                 OutputProcessor::SOVStoreType::Summed,
    6512             :                                 Coil.Name,
    6513             :                                 _,
    6514             :                                 "ENERGYTRANSFER",
    6515             :                                 "HEATINGCOILS",
    6516             :                                 _,
    6517          20 :                                 "System");
    6518          40 :             SetupOutputVariable(state,
    6519             :                                 "Heating Coil Electricity Rate",
    6520             :                                 OutputProcessor::Unit::W,
    6521             :                                 Coil.ElecHeatingPower,
    6522             :                                 OutputProcessor::SOVTimeStepType::System,
    6523             :                                 OutputProcessor::SOVStoreType::Average,
    6524          20 :                                 Coil.Name);
    6525          40 :             SetupOutputVariable(state,
    6526             :                                 "Heating Coil Electricity Energy",
    6527             :                                 OutputProcessor::Unit::J,
    6528             :                                 Coil.ElecHeatingConsumption,
    6529             :                                 OutputProcessor::SOVTimeStepType::System,
    6530             :                                 OutputProcessor::SOVStoreType::Summed,
    6531             :                                 Coil.Name,
    6532             :                                 _,
    6533             :                                 "Electricity",
    6534             :                                 "HEATING",
    6535             :                                 _,
    6536          20 :                                 "System");
    6537             : 
    6538          20 :             if (Coil.FuelTypeNum != DataGlobalConstants::ResourceType::Electricity) {
    6539          12 :                 SetupOutputVariable(state,
    6540           8 :                                     "Heating Coil " + Coil.FuelType + " Rate",
    6541             :                                     OutputProcessor::Unit::W,
    6542             :                                     Coil.FuelUsed,
    6543             :                                     OutputProcessor::SOVTimeStepType::System,
    6544             :                                     OutputProcessor::SOVStoreType::Average,
    6545             :                                     Coil.Name);
    6546          12 :                 SetupOutputVariable(state,
    6547           8 :                                     "Heating Coil " + Coil.FuelType + " Energy",
    6548             :                                     OutputProcessor::Unit::J,
    6549             :                                     Coil.FuelConsumed,
    6550             :                                     OutputProcessor::SOVTimeStepType::System,
    6551             :                                     OutputProcessor::SOVStoreType::Summed,
    6552             :                                     Coil.Name,
    6553             :                                     _,
    6554             :                                     Coil.FuelType,
    6555             :                                     "HEATING",
    6556             :                                     _,
    6557             :                                     "System");
    6558             :             }
    6559             : 
    6560          24 :             if (Coil.FuelTypeNum != DataGlobalConstants::ResourceType::Electricity &&
    6561           4 :                 Coil.DefrostStrategy == StandardRatings::DefrostStrat::ReverseCycle) {
    6562          12 :                 SetupOutputVariable(state,
    6563           8 :                                     "Heating Coil Defrost " + Coil.FuelType + " Rate",
    6564             :                                     OutputProcessor::Unit::W,
    6565             :                                     Coil.DefrostPower,
    6566             :                                     OutputProcessor::SOVTimeStepType::System,
    6567             :                                     OutputProcessor::SOVStoreType::Average,
    6568             :                                     Coil.Name);
    6569          12 :                 SetupOutputVariable(state,
    6570           8 :                                     "Heating Coil Defrost " + Coil.FuelType + " Energy",
    6571             :                                     OutputProcessor::Unit::J,
    6572             :                                     Coil.DefrostConsumption,
    6573             :                                     OutputProcessor::SOVTimeStepType::System,
    6574             :                                     OutputProcessor::SOVStoreType::Summed,
    6575             :                                     Coil.Name,
    6576             :                                     _,
    6577             :                                     Coil.FuelType,
    6578             :                                     "HEATING",
    6579             :                                     _,
    6580             :                                     "System");
    6581             :             } else {
    6582          32 :                 SetupOutputVariable(state,
    6583             :                                     "Heating Coil Defrost Electricity Rate",
    6584             :                                     OutputProcessor::Unit::W,
    6585             :                                     Coil.DefrostPower,
    6586             :                                     OutputProcessor::SOVTimeStepType::System,
    6587             :                                     OutputProcessor::SOVStoreType::Average,
    6588          16 :                                     Coil.Name);
    6589          32 :                 SetupOutputVariable(state,
    6590             :                                     "Heating Coil Defrost Electricity Energy",
    6591             :                                     OutputProcessor::Unit::J,
    6592             :                                     Coil.DefrostConsumption,
    6593             :                                     OutputProcessor::SOVTimeStepType::System,
    6594             :                                     OutputProcessor::SOVStoreType::Summed,
    6595             :                                     Coil.Name,
    6596             :                                     _,
    6597             :                                     "Electricity",
    6598             :                                     "HEATING",
    6599             :                                     _,
    6600          16 :                                     "System");
    6601             :             }
    6602             : 
    6603          40 :             SetupOutputVariable(state,
    6604             :                                 "Heating Coil Crankcase Heater Electricity Rate",
    6605             :                                 OutputProcessor::Unit::W,
    6606             :                                 Coil.CrankcaseHeaterPower,
    6607             :                                 OutputProcessor::SOVTimeStepType::System,
    6608             :                                 OutputProcessor::SOVStoreType::Average,
    6609          20 :                                 Coil.Name);
    6610          40 :             SetupOutputVariable(state,
    6611             :                                 "Heating Coil Crankcase Heater Electricity Energy",
    6612             :                                 OutputProcessor::Unit::J,
    6613             :                                 Coil.CrankcaseHeaterConsumption,
    6614             :                                 OutputProcessor::SOVTimeStepType::System,
    6615             :                                 OutputProcessor::SOVStoreType::Summed,
    6616             :                                 Coil.Name,
    6617             :                                 _,
    6618             :                                 "Electricity",
    6619             :                                 "HEATING",
    6620             :                                 _,
    6621          20 :                                 "System");
    6622          40 :             SetupOutputVariable(state,
    6623             :                                 "Heating Coil Runtime Fraction",
    6624             :                                 OutputProcessor::Unit::None,
    6625             :                                 Coil.HeatingCoilRuntimeFraction,
    6626             :                                 OutputProcessor::SOVTimeStepType::System,
    6627             :                                 OutputProcessor::SOVStoreType::Average,
    6628          20 :                                 Coil.Name);
    6629             : 
    6630          20 :             if (Coil.IsSecondaryDXCoilInZone) {
    6631           0 :                 SetupOutputVariable(state,
    6632             :                                     "Secondary Coil Total Heat Removal Rate",
    6633             :                                     OutputProcessor::Unit::W,
    6634             :                                     Coil.SecCoilTotalHeatRemovalRate,
    6635             :                                     OutputProcessor::SOVTimeStepType::System,
    6636             :                                     OutputProcessor::SOVStoreType::Average,
    6637           0 :                                     Coil.Name);
    6638           0 :                 SetupOutputVariable(state,
    6639             :                                     "Secondary Coil Sensible Heat Removal Rate",
    6640             :                                     OutputProcessor::Unit::W,
    6641             :                                     Coil.SecCoilSensibleHeatRemovalRate,
    6642             :                                     OutputProcessor::SOVTimeStepType::System,
    6643             :                                     OutputProcessor::SOVStoreType::Average,
    6644           0 :                                     Coil.Name);
    6645           0 :                 SetupOutputVariable(state,
    6646             :                                     "Secondary Coil Latent Heat Removal Rate",
    6647             :                                     OutputProcessor::Unit::W,
    6648             :                                     Coil.SecCoilLatentHeatRemovalRate,
    6649             :                                     OutputProcessor::SOVTimeStepType::System,
    6650             :                                     OutputProcessor::SOVStoreType::Average,
    6651           0 :                                     Coil.Name);
    6652           0 :                 SetupOutputVariable(state,
    6653             :                                     "Secondary Coil Sensible Heat Ratio",
    6654             :                                     OutputProcessor::Unit::None,
    6655             :                                     Coil.SecCoilSHR,
    6656             :                                     OutputProcessor::SOVTimeStepType::System,
    6657             :                                     OutputProcessor::SOVStoreType::Average,
    6658           0 :                                     Coil.Name);
    6659             :             }
    6660             :         }
    6661             : 
    6662             :         // VRF cooling coil report variables
    6663         112 :         else if (Coil.DXCoilType_Num == CoilVRF_Cooling) {
    6664             :             // Setup Report Variables for Cooling Equipment:
    6665             :             // CurrentModuleObject='Coil:Cooling:DX:VariableRefrigerantFlow
    6666          82 :             SetupOutputVariable(state,
    6667             :                                 "Cooling Coil Total Cooling Rate",
    6668             :                                 OutputProcessor::Unit::W,
    6669             :                                 Coil.TotalCoolingEnergyRate,
    6670             :                                 OutputProcessor::SOVTimeStepType::System,
    6671             :                                 OutputProcessor::SOVStoreType::Average,
    6672          41 :                                 Coil.Name);
    6673          82 :             SetupOutputVariable(state,
    6674             :                                 "Cooling Coil Total Cooling Energy",
    6675             :                                 OutputProcessor::Unit::J,
    6676             :                                 Coil.TotalCoolingEnergy,
    6677             :                                 OutputProcessor::SOVTimeStepType::System,
    6678             :                                 OutputProcessor::SOVStoreType::Summed,
    6679             :                                 Coil.Name,
    6680             :                                 _,
    6681             :                                 "ENERGYTRANSFER",
    6682             :                                 "COOLINGCOILS",
    6683             :                                 _,
    6684          41 :                                 "System");
    6685          82 :             SetupOutputVariable(state,
    6686             :                                 "Cooling Coil Sensible Cooling Rate",
    6687             :                                 OutputProcessor::Unit::W,
    6688             :                                 Coil.SensCoolingEnergyRate,
    6689             :                                 OutputProcessor::SOVTimeStepType::System,
    6690             :                                 OutputProcessor::SOVStoreType::Average,
    6691          41 :                                 Coil.Name);
    6692          82 :             SetupOutputVariable(state,
    6693             :                                 "Cooling Coil Sensible Cooling Energy",
    6694             :                                 OutputProcessor::Unit::J,
    6695             :                                 Coil.SensCoolingEnergy,
    6696             :                                 OutputProcessor::SOVTimeStepType::System,
    6697             :                                 OutputProcessor::SOVStoreType::Summed,
    6698          41 :                                 Coil.Name);
    6699          82 :             SetupOutputVariable(state,
    6700             :                                 "Cooling Coil Latent Cooling Rate",
    6701             :                                 OutputProcessor::Unit::W,
    6702             :                                 Coil.LatCoolingEnergyRate,
    6703             :                                 OutputProcessor::SOVTimeStepType::System,
    6704             :                                 OutputProcessor::SOVStoreType::Average,
    6705          41 :                                 Coil.Name);
    6706          82 :             SetupOutputVariable(state,
    6707             :                                 "Cooling Coil Latent Cooling Energy",
    6708             :                                 OutputProcessor::Unit::J,
    6709             :                                 Coil.LatCoolingEnergy,
    6710             :                                 OutputProcessor::SOVTimeStepType::System,
    6711             :                                 OutputProcessor::SOVStoreType::Summed,
    6712          41 :                                 Coil.Name);
    6713          82 :             SetupOutputVariable(state,
    6714             :                                 "Cooling Coil Runtime Fraction",
    6715             :                                 OutputProcessor::Unit::None,
    6716             :                                 Coil.CoolingCoilRuntimeFraction,
    6717             :                                 OutputProcessor::SOVTimeStepType::System,
    6718             :                                 OutputProcessor::SOVStoreType::Average,
    6719          41 :                                 Coil.Name);
    6720          41 :             if (Coil.CondensateCollectMode == CondensateCollectAction::ToTank) {
    6721           0 :                 SetupOutputVariable(state,
    6722             :                                     "Cooling Coil Condensate Volume Flow Rate",
    6723             :                                     OutputProcessor::Unit::m3_s,
    6724             :                                     Coil.CondensateVdot,
    6725             :                                     OutputProcessor::SOVTimeStepType::System,
    6726             :                                     OutputProcessor::SOVStoreType::Average,
    6727           0 :                                     Coil.Name);
    6728           0 :                 SetupOutputVariable(state,
    6729             :                                     "Cooling Coil Condensate Volume",
    6730             :                                     OutputProcessor::Unit::m3,
    6731             :                                     Coil.CondensateVol,
    6732             :                                     OutputProcessor::SOVTimeStepType::System,
    6733             :                                     OutputProcessor::SOVStoreType::Summed,
    6734             :                                     Coil.Name,
    6735             :                                     _,
    6736             :                                     "OnSiteWater",
    6737             :                                     "Condensate",
    6738             :                                     _,
    6739           0 :                                     "System");
    6740             :             }
    6741             :         }
    6742             : 
    6743             :         // VRF heating coil report variables
    6744          71 :         else if (Coil.DXCoilType_Num == CoilVRF_Heating) {
    6745             :             // Setup Report Variables for Heating Equipment:
    6746             :             // CurrentModuleObject='Coil:Heating:DX:VariableRefrigerantFlow
    6747          82 :             SetupOutputVariable(state,
    6748             :                                 "Heating Coil Heating Rate",
    6749             :                                 OutputProcessor::Unit::W,
    6750             :                                 Coil.TotalHeatingEnergyRate,
    6751             :                                 OutputProcessor::SOVTimeStepType::System,
    6752             :                                 OutputProcessor::SOVStoreType::Average,
    6753          41 :                                 Coil.Name);
    6754          82 :             SetupOutputVariable(state,
    6755             :                                 "Heating Coil Heating Energy",
    6756             :                                 OutputProcessor::Unit::J,
    6757             :                                 Coil.TotalHeatingEnergy,
    6758             :                                 OutputProcessor::SOVTimeStepType::System,
    6759             :                                 OutputProcessor::SOVStoreType::Summed,
    6760             :                                 Coil.Name,
    6761             :                                 _,
    6762             :                                 "ENERGYTRANSFER",
    6763             :                                 "HEATINGCOILS",
    6764             :                                 _,
    6765          41 :                                 "System");
    6766          82 :             SetupOutputVariable(state,
    6767             :                                 "Heating Coil Runtime Fraction",
    6768             :                                 OutputProcessor::Unit::None,
    6769             :                                 Coil.HeatingCoilRuntimeFraction,
    6770             :                                 OutputProcessor::SOVTimeStepType::System,
    6771             :                                 OutputProcessor::SOVStoreType::Average,
    6772          41 :                                 Coil.Name);
    6773             :         }
    6774             : 
    6775             :         // VRF cooling coil for FluidTCtrl, report variables
    6776          30 :         else if (Coil.DXCoilType_Num == CoilVRF_FluidTCtrl_Cooling) {
    6777             :             // Setup Report Variables for Cooling Equipment:
    6778             :             // CurrentModuleObject='Coil:Cooling:DX:VariableRefrigerantFlow:FluidTemperatureControl
    6779          30 :             SetupOutputVariable(state,
    6780             :                                 "Cooling Coil Total Cooling Rate",
    6781             :                                 OutputProcessor::Unit::W,
    6782             :                                 Coil.TotalCoolingEnergyRate,
    6783             :                                 OutputProcessor::SOVTimeStepType::System,
    6784             :                                 OutputProcessor::SOVStoreType::Average,
    6785          15 :                                 Coil.Name);
    6786          30 :             SetupOutputVariable(state,
    6787             :                                 "Cooling Coil Total Cooling Energy",
    6788             :                                 OutputProcessor::Unit::J,
    6789             :                                 Coil.TotalCoolingEnergy,
    6790             :                                 OutputProcessor::SOVTimeStepType::System,
    6791             :                                 OutputProcessor::SOVStoreType::Summed,
    6792             :                                 Coil.Name,
    6793             :                                 _,
    6794             :                                 "ENERGYTRANSFER",
    6795             :                                 "COOLINGCOILS",
    6796             :                                 _,
    6797          15 :                                 "System");
    6798          30 :             SetupOutputVariable(state,
    6799             :                                 "Cooling Coil Sensible Cooling Rate",
    6800             :                                 OutputProcessor::Unit::W,
    6801             :                                 Coil.SensCoolingEnergyRate,
    6802             :                                 OutputProcessor::SOVTimeStepType::System,
    6803             :                                 OutputProcessor::SOVStoreType::Average,
    6804          15 :                                 Coil.Name);
    6805          30 :             SetupOutputVariable(state,
    6806             :                                 "Cooling Coil Sensible Cooling Energy",
    6807             :                                 OutputProcessor::Unit::J,
    6808             :                                 Coil.SensCoolingEnergy,
    6809             :                                 OutputProcessor::SOVTimeStepType::System,
    6810             :                                 OutputProcessor::SOVStoreType::Summed,
    6811          15 :                                 Coil.Name);
    6812          30 :             SetupOutputVariable(state,
    6813             :                                 "Cooling Coil Latent Cooling Rate",
    6814             :                                 OutputProcessor::Unit::W,
    6815             :                                 Coil.LatCoolingEnergyRate,
    6816             :                                 OutputProcessor::SOVTimeStepType::System,
    6817             :                                 OutputProcessor::SOVStoreType::Average,
    6818          15 :                                 Coil.Name);
    6819          30 :             SetupOutputVariable(state,
    6820             :                                 "Cooling Coil Latent Cooling Energy",
    6821             :                                 OutputProcessor::Unit::J,
    6822             :                                 Coil.LatCoolingEnergy,
    6823             :                                 OutputProcessor::SOVTimeStepType::System,
    6824             :                                 OutputProcessor::SOVStoreType::Summed,
    6825          15 :                                 Coil.Name);
    6826          30 :             SetupOutputVariable(state,
    6827             :                                 "Cooling Coil Runtime Fraction",
    6828             :                                 OutputProcessor::Unit::None,
    6829             :                                 Coil.CoolingCoilRuntimeFraction,
    6830             :                                 OutputProcessor::SOVTimeStepType::System,
    6831             :                                 OutputProcessor::SOVStoreType::Average,
    6832          15 :                                 Coil.Name);
    6833             :             // Followings for VRF_FluidTCtrl Only
    6834          30 :             SetupOutputVariable(state,
    6835             :                                 "Cooling Coil VRF Evaporating Temperature",
    6836             :                                 OutputProcessor::Unit::C,
    6837             :                                 Coil.EvaporatingTemp,
    6838             :                                 OutputProcessor::SOVTimeStepType::System,
    6839             :                                 OutputProcessor::SOVStoreType::Average,
    6840          15 :                                 Coil.Name);
    6841          30 :             SetupOutputVariable(state,
    6842             :                                 "Cooling Coil VRF Super Heating Degrees",
    6843             :                                 OutputProcessor::Unit::C,
    6844             :                                 Coil.ActualSH,
    6845             :                                 OutputProcessor::SOVTimeStepType::System,
    6846             :                                 OutputProcessor::SOVStoreType::Average,
    6847          15 :                                 Coil.Name);
    6848             : 
    6849          15 :             if (Coil.CondensateCollectMode == CondensateCollectAction::ToTank) {
    6850           0 :                 SetupOutputVariable(state,
    6851             :                                     "Cooling Coil Condensate Volume Flow Rate",
    6852             :                                     OutputProcessor::Unit::m3_s,
    6853             :                                     Coil.CondensateVdot,
    6854             :                                     OutputProcessor::SOVTimeStepType::System,
    6855             :                                     OutputProcessor::SOVStoreType::Average,
    6856           0 :                                     Coil.Name);
    6857           0 :                 SetupOutputVariable(state,
    6858             :                                     "Cooling Coil Condensate Volume",
    6859             :                                     OutputProcessor::Unit::m3,
    6860             :                                     Coil.CondensateVol,
    6861             :                                     OutputProcessor::SOVTimeStepType::System,
    6862             :                                     OutputProcessor::SOVStoreType::Summed,
    6863             :                                     Coil.Name,
    6864             :                                     _,
    6865             :                                     "OnSiteWater",
    6866             :                                     "Condensate",
    6867             :                                     _,
    6868           0 :                                     "System");
    6869             :             }
    6870             :         }
    6871             : 
    6872             :         // VRF heating coil for FluidTCtrl, report variables
    6873          15 :         else if (Coil.DXCoilType_Num == CoilVRF_FluidTCtrl_Heating) {
    6874             :             // Setup Report Variables for Heating Equipment:
    6875             :             // CurrentModuleObject='Coil:Heating:DX:VariableRefrigerantFlow:FluidTemperatureControl
    6876          30 :             SetupOutputVariable(state,
    6877             :                                 "Heating Coil Heating Rate",
    6878             :                                 OutputProcessor::Unit::W,
    6879             :                                 Coil.TotalHeatingEnergyRate,
    6880             :                                 OutputProcessor::SOVTimeStepType::System,
    6881             :                                 OutputProcessor::SOVStoreType::Average,
    6882          15 :                                 Coil.Name);
    6883          30 :             SetupOutputVariable(state,
    6884             :                                 "Heating Coil Heating Energy",
    6885             :                                 OutputProcessor::Unit::J,
    6886             :                                 Coil.TotalHeatingEnergy,
    6887             :                                 OutputProcessor::SOVTimeStepType::System,
    6888             :                                 OutputProcessor::SOVStoreType::Summed,
    6889             :                                 Coil.Name,
    6890             :                                 _,
    6891             :                                 "ENERGYTRANSFER",
    6892             :                                 "HEATINGCOILS",
    6893             :                                 _,
    6894          15 :                                 "System");
    6895          30 :             SetupOutputVariable(state,
    6896             :                                 "Heating Coil Runtime Fraction",
    6897             :                                 OutputProcessor::Unit::None,
    6898             :                                 Coil.HeatingCoilRuntimeFraction,
    6899             :                                 OutputProcessor::SOVTimeStepType::System,
    6900             :                                 OutputProcessor::SOVStoreType::Average,
    6901          15 :                                 Coil.Name);
    6902             :             // Followings for VRF_FluidTCtrl Only
    6903          30 :             SetupOutputVariable(state,
    6904             :                                 "Heating Coil VRF Condensing Temperature",
    6905             :                                 OutputProcessor::Unit::C,
    6906             :                                 Coil.CondensingTemp,
    6907             :                                 OutputProcessor::SOVTimeStepType::System,
    6908             :                                 OutputProcessor::SOVStoreType::Average,
    6909          15 :                                 Coil.Name);
    6910          30 :             SetupOutputVariable(state,
    6911             :                                 "Heating Coil VRF Subcooling Degrees",
    6912             :                                 OutputProcessor::Unit::C,
    6913             :                                 Coil.ActualSC,
    6914             :                                 OutputProcessor::SOVTimeStepType::System,
    6915             :                                 OutputProcessor::SOVStoreType::Average,
    6916          15 :                                 Coil.Name);
    6917             :         }
    6918             :     }
    6919             : 
    6920         241 :     if (state.dataGlobal->AnyEnergyManagementSystemInModel) {
    6921             :         // setup EMS sizing actuators for single speed DX
    6922         177 :         for (DXCoilNum = 1; DXCoilNum <= state.dataDXCoils->NumDoe2DXCoils; ++DXCoilNum) {
    6923         417 :             SetupEMSActuator(state,
    6924             :                              "Coil:Cooling:DX:SingleSpeed",
    6925         139 :                              state.dataDXCoils->DXCoil(DXCoilNum).Name,
    6926             :                              "Autosized Rated Air Flow Rate",
    6927             :                              "[m3/s]",
    6928         139 :                              state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRateEMSOverrideON(1),
    6929         417 :                              state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRateEMSOverrideValue(1));
    6930             : 
    6931         417 :             SetupEMSActuator(state,
    6932             :                              "Coil:Cooling:DX:SingleSpeed",
    6933         139 :                              state.dataDXCoils->DXCoil(DXCoilNum).Name,
    6934             :                              "Autosized Rated Sensible Heat Ratio",
    6935             :                              "[W/W]",
    6936         139 :                              state.dataDXCoils->DXCoil(DXCoilNum).RatedSHREMSOverrideOn(1),
    6937         417 :                              state.dataDXCoils->DXCoil(DXCoilNum).RatedSHREMSOverrideValue(1));
    6938             : 
    6939         417 :             SetupEMSActuator(state,
    6940             :                              "Coil:Cooling:DX:SingleSpeed",
    6941         139 :                              state.dataDXCoils->DXCoil(DXCoilNum).Name,
    6942             :                              "Autosized Rated Total Cooling Capacity",
    6943             :                              "[W]",
    6944         139 :                              state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCapEMSOverrideOn(1),
    6945         417 :                              state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCapEMSOverrideValue(1));
    6946             :         }
    6947             :     }
    6948         241 :     Alphas.deallocate();
    6949         241 :     cAlphaFields.deallocate();
    6950         241 :     cNumericFields.deallocate();
    6951         241 :     Numbers.deallocate();
    6952         241 :     lAlphaBlanks.deallocate();
    6953         241 :     lNumericBlanks.deallocate();
    6954             : 
    6955         241 :     Alphas2.deallocate();
    6956         241 :     cAlphaFields2.deallocate();
    6957         241 :     cNumericFields2.deallocate();
    6958         241 :     Numbers2.deallocate();
    6959         241 :     lAlphaBlanks2.deallocate();
    6960         241 :     lNumericBlanks2.deallocate();
    6961             :     bool anyEMSRan;
    6962         241 :     ManageEMS(state, EMSManager::EMSCallFrom::ComponentGetInput, anyEMSRan, ObjexxFCL::Optional_int_const());
    6963         241 : }
    6964             : 
    6965    65004606 : void InitDXCoil(EnergyPlusData &state, int const DXCoilNum) // number of the current DX coil unit being simulated
    6966             : {
    6967             : 
    6968             :     // SUBROUTINE INFORMATION:
    6969             :     //       AUTHOR         Fred Buhl
    6970             :     //       DATE WRITTEN   May 2000
    6971             :     //                      Feb 2005, M. J. Witte, GARD Analytics, Inc. Add new coil type COIL:DX:MultiMode:CoolingEmpirical:
    6972             :     //                      Jul 2005, R. Raustad, FSEC. Add new coil type COIL:DX:HEATPUMPWATERHEATER
    6973             :     //                      Jun 2007, L. Gu, FSEC. Add new coil type COIL:DX:MULTISPEED:COOLING and HEATING
    6974             :     //                      Aug 2015, R. Zhang, LBNL. Add new coil types for VRF_FluidTCtrl
    6975             : 
    6976             :     // PURPOSE OF THIS SUBROUTINE:
    6977             :     // This subroutine is for initializations of DX Coil Components.
    6978             : 
    6979             :     // METHODOLOGY EMPLOYED:
    6980             :     // Uses the status flags to trigger initializations.
    6981             : 
    6982             :     // SUBROUTINE PARAMETER DEFINITIONS:
    6983    65004606 :     constexpr Real64 SmallDifferenceTest(0.00000001);
    6984             :     static constexpr std::string_view RoutineName("InitDXCoil");
    6985             : 
    6986             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    6987    65004606 :     auto &MyEnvrnFlag = state.dataDXCoils->MyEnvrnFlag; // One time environment flag
    6988    65004606 :     auto &MySizeFlag = state.dataDXCoils->MySizeFlag;   // One time sizing flag
    6989             :     Real64 RatedHeatPumpIndoorAirTemp;                  // Indoor dry-bulb temperature to heat pump evaporator at rated conditions [C]
    6990             :     Real64 RatedHeatPumpIndoorHumRat;                   // Inlet humidity ratio to heat pump evaporator at rated conditions [kgWater/kgDryAir]
    6991             :     Real64 RatedVolFlowPerRatedTotCap;                  // Rated Air Volume Flow Rate divided by Rated Total Capacity [m3/s-W)
    6992             :     Real64 HPInletAirHumRat;                            // Rated inlet air humidity ratio for heat pump water heater [kgWater/kgDryAir]
    6993    65004606 :     bool ErrorsFound(false);                            // TRUE when errors found
    6994             :     int CapacityStageNum;                               // Loop index for 1,Number of capacity stages
    6995             :     int DehumidModeNum;                                 // Loop index for 1,Number of enhanced dehumidification modes
    6996             :     int Mode;                                           // Performance mode for MultiMode DX coil; Always 1 for other coil types
    6997             :     int DXCoilNumTemp;                                  // Counter for crankcase heater report variable DO loop
    6998             :     int AirInletNode;                                   // Air inlet node number
    6999             :     int SpeedNum;                                       // Speed number for multispeed coils
    7000             : 
    7001    65004606 :     auto &DXCT = state.dataHVACGlobal->DXCT;
    7002             : 
    7003    65004606 :     if (state.dataDXCoils->MyOneTimeFlag) {
    7004             :         // initialize the environment and sizing flags
    7005         237 :         MyEnvrnFlag.allocate(state.dataDXCoils->NumDXCoils);
    7006         237 :         MySizeFlag.allocate(state.dataDXCoils->NumDXCoils);
    7007         237 :         MyEnvrnFlag = true;
    7008         237 :         MySizeFlag = true;
    7009         237 :         state.dataDXCoils->MyOneTimeFlag = false;
    7010             :     }
    7011             :     // if "ISHundredPercentDOASDXCoil" =.TRUE., then set coil as 100% DOAS dx coil
    7012    65004606 :     if (state.dataDXCoils->DXCoil(DXCoilNum).ISHundredPercentDOASDXCoil) {
    7013       50176 :         DXCT = 2;
    7014             :     } else {
    7015    64954430 :         DXCT = 1;
    7016             :     }
    7017             : 
    7018   194350777 :     if ((state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_HeatPumpWaterHeaterPumped ||
    7019    66027786 :          state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_HeatPumpWaterHeaterWrapped) &&
    7020     1023180 :         MyEnvrnFlag(DXCoilNum)) {
    7021             : 
    7022          16 :         SizeDXCoil(state, DXCoilNum);
    7023             : 
    7024          16 :         RatedVolFlowPerRatedTotCap = state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(1) / state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap2;
    7025          32 :         if (((state.dataHVACGlobal->MinRatedVolFlowPerRatedTotCap(DXCT) - RatedVolFlowPerRatedTotCap) > SmallDifferenceTest) ||
    7026          16 :             ((RatedVolFlowPerRatedTotCap - state.dataHVACGlobal->MaxHeatVolFlowPerRatedTotCap(DXCT)) > SmallDifferenceTest)) {
    7027           6 :             ShowWarningError(state,
    7028           4 :                              state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + " \"" + state.dataDXCoils->DXCoil(DXCoilNum).Name +
    7029             :                                  "\": Rated air volume flow rate per watt of rated total water heating capacity is out of range");
    7030           6 :             ShowContinueError(state,
    7031           8 :                               format("Min Rated Vol Flow Per Watt=[{:.3T}], Rated Vol Flow Per Watt=[{:.3T}], Max Rated Vol Flow Per "
    7032             :                                      "Watt=[{:.3T}]. See Input-Output Reference Manual for valid range.",
    7033           2 :                                      state.dataHVACGlobal->MinRatedVolFlowPerRatedTotCap(DXCT),
    7034             :                                      RatedVolFlowPerRatedTotCap,
    7035           4 :                                      state.dataHVACGlobal->MaxHeatVolFlowPerRatedTotCap(DXCT)));
    7036             :         }
    7037          32 :         HPInletAirHumRat = PsyWFnTdbTwbPb(state,
    7038          16 :                                           state.dataDXCoils->DXCoil(DXCoilNum).RatedInletDBTemp,
    7039          16 :                                           state.dataDXCoils->DXCoil(DXCoilNum).RatedInletWBTemp,
    7040             :                                           DataEnvironment::StdPressureSeaLevel,
    7041             :                                           RoutineName);
    7042          16 :         state.dataHVACGlobal->HPWHInletDBTemp = state.dataDXCoils->DXCoil(DXCoilNum).RatedInletDBTemp;
    7043          16 :         state.dataHVACGlobal->HPWHInletWBTemp = state.dataDXCoils->DXCoil(DXCoilNum).RatedInletWBTemp;
    7044          16 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedAirMassFlowRate(1) =
    7045          32 :             state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(1) *
    7046          32 :             PsyRhoAirFnPbTdbW(
    7047          32 :                 state, state.dataEnvrn->StdBaroPress, state.dataDXCoils->DXCoil(DXCoilNum).RatedInletDBTemp, HPInletAirHumRat, RoutineName);
    7048             :         //   get rated coil bypass factor excluding fan heat
    7049             : 
    7050             :         //   call CalcHPWHDXCoil to determine DXCoil%RatedTotCap(1) for rated CBF calculation below
    7051          16 :         CalcHPWHDXCoil(state, DXCoilNum, 1.0);
    7052          16 :         if (MySizeFlag(DXCoilNum)) {
    7053          16 :             SizeDXCoil(state, DXCoilNum);
    7054          16 :             MySizeFlag(DXCoilNum) = false;
    7055             :         }
    7056             : 
    7057          96 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedCBF(1) = CalcCBF(state,
    7058          16 :                                                                    state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
    7059          16 :                                                                    state.dataDXCoils->DXCoil(DXCoilNum).Name,
    7060          16 :                                                                    state.dataDXCoils->DXCoil(DXCoilNum).RatedInletDBTemp,
    7061             :                                                                    HPInletAirHumRat,
    7062          16 :                                                                    state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(1),
    7063          16 :                                                                    state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(1),
    7064          16 :                                                                    state.dataDXCoils->DXCoil(DXCoilNum).RatedSHR(1),
    7065             :                                                                    true);
    7066          16 :         MyEnvrnFlag(DXCoilNum) = false;
    7067             :     }
    7068             : 
    7069   188252772 :     if ((state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_MultiSpeedCooling ||
    7070    76410386 :          state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_MultiSpeedHeating) &&
    7071    11405780 :         MyEnvrnFlag(DXCoilNum)) {
    7072          68 :         if (state.dataDXCoils->DXCoil(DXCoilNum).FuelTypeNum != DataGlobalConstants::ResourceType::Electricity) {
    7073          10 :             if (state.dataDXCoils->DXCoil(DXCoilNum).MSHPHeatRecActive) {
    7074           0 :                 for (SpeedNum = 1; SpeedNum <= state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds; ++SpeedNum) {
    7075           0 :                     if (state.dataDXCoils->DXCoil(DXCoilNum).MSWasteHeat(SpeedNum) == 0) {
    7076           0 :                         ShowWarningError(state,
    7077           0 :                                          "GetDXCoils:" + state.dataDXCoils->DXCoil(DXCoilNum).Name +
    7078             :                                              ". The value of Waste Heat Function of Temperature Curve is assumed to be 1. Simulation continues. ");
    7079           0 :                         break;
    7080             :                     }
    7081             :                 }
    7082             :             }
    7083             :         }
    7084          68 :         MyEnvrnFlag(DXCoilNum) = false;
    7085             :     }
    7086             : 
    7087             :     // Find the companion upstream coil (DX cooling coil) that is used with DX heating coils (HP AC units only)
    7088    65004606 :     if (state.dataDXCoils->DXCoil(DXCoilNum).FindCompanionUpStreamCoil) {
    7089     2467047 :         if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_HeatingEmpirical ||
    7090      700957 :             state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_MultiSpeedHeating) {
    7091     1765231 :             state.dataDXCoils->DXCoil(DXCoilNum).CompanionUpstreamDXCoil =
    7092     1765231 :                 GetHPCoolingCoilIndex(state, state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType, state.dataDXCoils->DXCoil(DXCoilNum).Name, DXCoilNum);
    7093     1765231 :             if (state.dataDXCoils->DXCoil(DXCoilNum).CompanionUpstreamDXCoil > 0) {
    7094          71 :                 state.dataDXCoils->DXCoil(state.dataDXCoils->DXCoil(DXCoilNum).CompanionUpstreamDXCoil).ReportCoolingCoilCrankcasePower = false;
    7095          71 :                 state.dataDXCoils->DXCoil(DXCoilNum).FindCompanionUpStreamCoil = false;
    7096             :                 //       Copy condenser node number from DX cooling coil when used with a companion DX heating coil
    7097         355 :                 for (Mode = 1; Mode <= MaxModes; ++Mode) {
    7098         284 :                     state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(Mode) =
    7099         284 :                         state.dataDXCoils->DXCoil(state.dataDXCoils->DXCoil(DXCoilNum).CompanionUpstreamDXCoil).CondenserInletNodeNum(Mode);
    7100             :                 }
    7101             :             }
    7102             :         } else {
    7103         859 :             state.dataDXCoils->DXCoil(DXCoilNum).FindCompanionUpStreamCoil = false;
    7104             :         }
    7105             :     } // IF(DXCoil(DXCoilNum)%FindCompanionUpStreamCoil)THEN
    7106             : 
    7107             :     // CR7308 - Wait for zone and air loop equipment to be simulated, then print out report variables
    7108    65004606 :     if (state.dataDXCoils->CrankcaseHeaterReportVarFlag) {
    7109        7579 :         if (state.dataAirLoop->AirLoopInputsFilled) {
    7110             :             //     Set report variables for DX cooling coils that will have a crankcase heater (all DX coils not used in a HP AC unit)
    7111        1189 :             for (DXCoilNumTemp = 1; DXCoilNumTemp <= state.dataDXCoils->NumDXCoils; ++DXCoilNumTemp) {
    7112        2845 :                 if ((state.dataDXCoils->DXCoil(DXCoilNumTemp).DXCoilType_Num == CoilDX_CoolingTwoStageWHumControl) ||
    7113        1288 :                     (state.dataDXCoils->DXCoil(DXCoilNumTemp).DXCoilType_Num == CoilDX_CoolingSingleSpeed) ||
    7114         336 :                     (state.dataDXCoils->DXCoil(DXCoilNumTemp).DXCoilType_Num == CoilDX_MultiSpeedCooling)) {
    7115         664 :                     if (state.dataDXCoils->DXCoil(DXCoilNumTemp).ReportCoolingCoilCrankcasePower) {
    7116        2372 :                         SetupOutputVariable(state,
    7117             :                                             "Cooling Coil Crankcase Heater Electricity Rate",
    7118             :                                             OutputProcessor::Unit::W,
    7119         593 :                                             state.dataDXCoils->DXCoil(DXCoilNumTemp).CrankcaseHeaterPower,
    7120             :                                             OutputProcessor::SOVTimeStepType::System,
    7121             :                                             OutputProcessor::SOVStoreType::Average,
    7122        1186 :                                             state.dataDXCoils->DXCoil(DXCoilNumTemp).Name);
    7123        2372 :                         SetupOutputVariable(state,
    7124             :                                             "Cooling Coil Crankcase Heater Electricity Energy",
    7125             :                                             OutputProcessor::Unit::J,
    7126         593 :                                             state.dataDXCoils->DXCoil(DXCoilNumTemp).CrankcaseHeaterConsumption,
    7127             :                                             OutputProcessor::SOVTimeStepType::System,
    7128             :                                             OutputProcessor::SOVStoreType::Summed,
    7129         593 :                                             state.dataDXCoils->DXCoil(DXCoilNumTemp).Name,
    7130             :                                             _,
    7131             :                                             "Electricity",
    7132             :                                             "COOLING",
    7133             :                                             _,
    7134         593 :                                             "System");
    7135         593 :                         state.dataDXCoils->DXCoil(DXCoilNumTemp).ReportCoolingCoilCrankcasePower = false;
    7136             :                     }
    7137             :                 }
    7138             :             }
    7139         237 :             state.dataDXCoils->CrankcaseHeaterReportVarFlag = false;
    7140             :         } //(AirLoopInputsFilled)THEN
    7141             :     }     //(CrankcaseHeaterReportVarFlag)THEN
    7142             : 
    7143    65004606 :     if (!state.dataGlobal->SysSizingCalc && MySizeFlag(DXCoilNum)) {
    7144             :         // for each coil, do the sizing once.
    7145         936 :         SizeDXCoil(state, DXCoilNum);
    7146         936 :         MySizeFlag(DXCoilNum) = false;
    7147             : 
    7148        2203 :         if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_CoolingSingleSpeed ||
    7149         595 :             state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_CoolingTwoSpeed ||
    7150        1423 :             state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilVRF_Cooling ||
    7151         223 :             state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilVRF_FluidTCtrl_Cooling) {
    7152             : 
    7153         728 :             Mode = 1;
    7154             :             // Check for zero capacity or zero max flow rate
    7155         728 :             if (state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode) <= 0.0) {
    7156           0 :                 ShowSevereError(state,
    7157           0 :                                 "Sizing: " + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + ' ' + state.dataDXCoils->DXCoil(DXCoilNum).Name +
    7158             :                                     " has zero rated total capacity");
    7159           0 :                 ErrorsFound = true;
    7160             :             }
    7161         728 :             if (state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(Mode) <= 0.0) {
    7162           0 :                 ShowSevereError(state,
    7163           0 :                                 "Sizing: " + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + ' ' + state.dataDXCoils->DXCoil(DXCoilNum).Name +
    7164             :                                     " has zero rated air flow rate");
    7165           0 :                 ErrorsFound = true;
    7166             :             }
    7167         728 :             if (ErrorsFound) {
    7168           0 :                 ShowFatalError(state, "Preceding condition causes termination.");
    7169             :             }
    7170             : 
    7171             :             // Check for valid range of (Rated Air Volume Flow Rate / Rated Total Capacity)
    7172         728 :             if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num !=
    7173             :                 CoilVRF_FluidTCtrl_Cooling) { // the VolFlowPerRatedTotCap check is not applicable for VRF-FluidTCtrl coil
    7174         713 :                 RatedVolFlowPerRatedTotCap =
    7175         713 :                     state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(Mode) / state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode);
    7176        1426 :                 if (((state.dataHVACGlobal->MinRatedVolFlowPerRatedTotCap(DXCT) - RatedVolFlowPerRatedTotCap) > SmallDifferenceTest) ||
    7177         713 :                     ((RatedVolFlowPerRatedTotCap - state.dataHVACGlobal->MaxRatedVolFlowPerRatedTotCap(DXCT)) > SmallDifferenceTest)) {
    7178           0 :                     ShowWarningError(state,
    7179           0 :                                      "Sizing: " + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + " \"" +
    7180           0 :                                          state.dataDXCoils->DXCoil(DXCoilNum).Name +
    7181             :                                          "\": Rated air volume flow rate per watt of rated total cooling capacity is out of range.");
    7182           0 :                     ShowContinueError(state,
    7183           0 :                                       format("Min Rated Vol Flow Per Watt=[{:.3T}], Rated Vol Flow Per Watt=[{:.3T}], Max Rated Vol Flow Per "
    7184             :                                              "Watt=[{:.3T}]. See Input Output Reference Manual for valid range.",
    7185           0 :                                              state.dataHVACGlobal->MinRatedVolFlowPerRatedTotCap(DXCT),
    7186             :                                              RatedVolFlowPerRatedTotCap,
    7187           0 :                                              state.dataHVACGlobal->MaxRatedVolFlowPerRatedTotCap(DXCT)));
    7188             :                 }
    7189             :             }
    7190             : 
    7191         728 :             state.dataDXCoils->DXCoil(DXCoilNum).RatedAirMassFlowRate(Mode) =
    7192        1456 :                 state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(Mode) *
    7193         728 :                 PsyRhoAirFnPbTdbW(state, state.dataEnvrn->StdBaroPress, RatedInletAirTemp, RatedInletAirHumRat, RoutineName);
    7194             :             // get high speed rated coil bypass factor
    7195        3640 :             state.dataDXCoils->DXCoil(DXCoilNum).RatedCBF(Mode) = CalcCBF(state,
    7196         728 :                                                                           state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
    7197         728 :                                                                           state.dataDXCoils->DXCoil(DXCoilNum).Name,
    7198             :                                                                           RatedInletAirTemp,
    7199             :                                                                           RatedInletAirHumRat,
    7200         728 :                                                                           state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode),
    7201         728 :                                                                           state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(Mode),
    7202         728 :                                                                           state.dataDXCoils->DXCoil(DXCoilNum).RatedSHR(Mode));
    7203             : 
    7204             :             // call coil model with everthing set at rating point
    7205         728 :             state.dataDXCoils->DXCoil(DXCoilNum).InletAirMassFlowRate = state.dataDXCoils->DXCoil(DXCoilNum).RatedAirMassFlowRate(Mode);
    7206         728 :             state.dataDXCoils->DXCoil(DXCoilNum).InletAirMassFlowRateMax = state.dataDXCoils->DXCoil(DXCoilNum).RatedAirMassFlowRate(Mode);
    7207         728 :             state.dataDXCoils->DXCoil(DXCoilNum).InletAirTemp = RatedInletAirTemp;
    7208             :             Real64 tempInletAirHumRat =
    7209         728 :                 Psychrometrics::PsyWFnTdbTwbPb(state, RatedInletAirTemp, RatedInletWetBulbTemp, DataEnvironment::StdPressureSeaLevel, RoutineName);
    7210             :             // DXCoil( DXCoilNum ).InletAirHumRat = RatedInletAirHumRat; // this seems inconsistent with dry bulb and wetbulb, filed NREL issue
    7211             :             // #5934  Real64 tempInletAirWetBulb = Psychrometrics::PsyTwbFnTdbWPb( RatedInletAirTemp, RatedInletAirHumRat,
    7212             :             // DataEnvironment::StdPressureSeaLevel );
    7213         728 :             state.dataDXCoils->DXCoil(DXCoilNum).InletAirHumRat = tempInletAirHumRat;
    7214         728 :             state.dataDXCoils->DXCoil(DXCoilNum).InletAirEnthalpy = Psychrometrics::PsyHFnTdbW(RatedInletAirTemp, tempInletAirHumRat);
    7215             : 
    7216             :             // store environment data fill back in after rating point calc is over
    7217         728 :             Real64 holdOutDryBulbTemp = state.dataEnvrn->OutDryBulbTemp;
    7218         728 :             Real64 holdOutHumRat = state.dataEnvrn->OutHumRat;
    7219         728 :             Real64 holdOutWetBulb = state.dataEnvrn->OutWetBulbTemp;
    7220         728 :             Real64 holdOutBaroPress = state.dataEnvrn->OutBaroPress;
    7221         728 :             Real64 ratedOutdoorAirWetBulb = 23.9; // from I/O ref. more precise value?
    7222         728 :             state.dataEnvrn->OutDryBulbTemp = RatedOutdoorAirTemp;
    7223         728 :             state.dataEnvrn->OutWetBulbTemp = ratedOutdoorAirWetBulb;
    7224         728 :             state.dataEnvrn->OutBaroPress = DataEnvironment::StdPressureSeaLevel; // assume rating is for sea level.
    7225         728 :             state.dataEnvrn->OutHumRat =
    7226         728 :                 Psychrometrics::PsyWFnTdbTwbPb(state, RatedOutdoorAirTemp, ratedOutdoorAirWetBulb, DataEnvironment::StdPressureSeaLevel, RoutineName);
    7227         728 :             if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(1) > 0) { // set condenser inlet node values
    7228         157 :                 state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(1)).Temp = RatedOutdoorAirTemp;
    7229         157 :                 state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(1)).HumRat = state.dataEnvrn->OutHumRat;
    7230         157 :                 state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(1)).OutAirWetBulb = ratedOutdoorAirWetBulb;
    7231             :             }
    7232             : 
    7233             :             // calculate coil model at rating point
    7234         728 :             if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == DataHVACGlobals::CoilDX_CoolingSingleSpeed) {
    7235         605 :                 CalcDoe2DXCoil(state, DXCoilNum, CompressorOperation::On, false, 1.0, 1.0, _, 1.0);
    7236         123 :             } else if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == DataHVACGlobals::CoilDX_CoolingTwoSpeed) {
    7237          67 :                 CalcMultiSpeedDXCoil(state, DXCoilNum, 1.0, 1.0);
    7238          56 :             } else if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == DataHVACGlobals::CoilVRF_Cooling) {
    7239          41 :                 CalcVRFCoolingCoil(state, DXCoilNum, CompressorOperation::On, false, 1.0, 1.0, 1.0, _, _, _);
    7240          15 :             } else if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == DataHVACGlobals::CoilVRF_FluidTCtrl_Cooling) {
    7241          15 :                 CalcVRFCoolingCoil_FluidTCtrl(state, DXCoilNum, CompressorOperation::On, false, 1.0, 1.0, 1.0, _, _);
    7242             :             }
    7243             : 
    7244             :             // coil outlets
    7245         728 :             Real64 RatedOutletWetBulb(0.0);
    7246        1456 :             RatedOutletWetBulb = Psychrometrics::PsyTwbFnTdbWPb(state,
    7247         728 :                                                                 state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp,
    7248         728 :                                                                 state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat,
    7249             :                                                                 DataEnvironment::StdPressureSeaLevel,
    7250             :                                                                 RoutineName);
    7251             : 
    7252        8008 :             state.dataRptCoilSelection->coilSelectionReportObj->setRatedCoilConditions(
    7253             :                 state,
    7254         728 :                 state.dataDXCoils->DXCoil(DXCoilNum).Name,
    7255         728 :                 state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
    7256         728 :                 state.dataDXCoils->DXCoil(DXCoilNum).TotalCoolingEnergyRate, // this is the report variable
    7257         728 :                 state.dataDXCoils->DXCoil(DXCoilNum).SensCoolingEnergyRate,  // this is the report variable
    7258         728 :                 state.dataDXCoils->DXCoil(DXCoilNum).InletAirMassFlowRate,
    7259         728 :                 state.dataDXCoils->DXCoil(DXCoilNum).InletAirTemp,
    7260         728 :                 state.dataDXCoils->DXCoil(DXCoilNum).InletAirHumRat,
    7261             :                 RatedInletWetBulbTemp,
    7262         728 :                 state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp,
    7263         728 :                 state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat,
    7264             :                 RatedOutletWetBulb,
    7265             :                 RatedOutdoorAirTemp,
    7266             :                 ratedOutdoorAirWetBulb,
    7267         728 :                 state.dataDXCoils->DXCoil(DXCoilNum).RatedCBF(Mode),
    7268             :                 -999.0); // coil effectiveness not define for DX
    7269             : 
    7270             :             // now replace the outdoor air conditions set above for one time rating point calc
    7271         728 :             state.dataEnvrn->OutDryBulbTemp = holdOutDryBulbTemp;
    7272         728 :             state.dataEnvrn->OutHumRat = holdOutHumRat;
    7273         728 :             state.dataEnvrn->OutWetBulbTemp = holdOutWetBulb;
    7274         728 :             state.dataEnvrn->OutBaroPress = holdOutBaroPress;
    7275             :         }
    7276             : 
    7277         936 :         if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_CoolingTwoStageWHumControl) {
    7278          29 :             for (DehumidModeNum = 0; DehumidModeNum <= state.dataDXCoils->DXCoil(DXCoilNum).NumDehumidModes; ++DehumidModeNum) {
    7279          53 :                 for (CapacityStageNum = 1; CapacityStageNum <= state.dataDXCoils->DXCoil(DXCoilNum).NumCapacityStages; ++CapacityStageNum) {
    7280          35 :                     Mode = DehumidModeNum * 2 + CapacityStageNum;
    7281             :                     // Check for zero capacity or zero max flow rate
    7282          35 :                     if (state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode) <= 0.0) {
    7283           0 :                         ShowSevereError(state,
    7284           0 :                                         "Sizing: " + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + ' ' +
    7285           0 :                                             state.dataDXCoils->DXCoil(DXCoilNum).Name + " has zero rated total capacity");
    7286           0 :                         ShowContinueError(state,
    7287           0 :                                           "for CoilPerformance:DX:Cooling mode: " + state.dataDXCoils->DXCoil(DXCoilNum).CoilPerformanceName(Mode));
    7288           0 :                         ErrorsFound = true;
    7289             :                     }
    7290          35 :                     if (state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(Mode) <= 0.0) {
    7291           0 :                         ShowSevereError(state,
    7292           0 :                                         "Sizing: " + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + ' ' +
    7293           0 :                                             state.dataDXCoils->DXCoil(DXCoilNum).Name + " has zero rated air flow rate");
    7294           0 :                         ShowContinueError(state,
    7295           0 :                                           "for CoilPerformance:DX:Cooling mode: " + state.dataDXCoils->DXCoil(DXCoilNum).CoilPerformanceName(Mode));
    7296           0 :                         ErrorsFound = true;
    7297             :                     }
    7298          35 :                     if (ErrorsFound) {
    7299           0 :                         ShowFatalError(state, "Preceding condition causes termination.");
    7300             :                     }
    7301             :                     // Check for valid range of (Rated Air Volume Flow Rate / Rated Total Capacity)
    7302          35 :                     RatedVolFlowPerRatedTotCap =
    7303          35 :                         state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(Mode) / state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode);
    7304          70 :                     if (((state.dataHVACGlobal->MinRatedVolFlowPerRatedTotCap(DXCT) - RatedVolFlowPerRatedTotCap) > SmallDifferenceTest) ||
    7305          35 :                         ((RatedVolFlowPerRatedTotCap - state.dataHVACGlobal->MaxRatedVolFlowPerRatedTotCap(DXCT)) > SmallDifferenceTest)) {
    7306           0 :                         ShowWarningError(state,
    7307           0 :                                          "Sizing: " + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + " \"" +
    7308           0 :                                              state.dataDXCoils->DXCoil(DXCoilNum).Name +
    7309             :                                              "\": Rated air volume flow rate per watt of rated total cooling capacity is out of range.");
    7310           0 :                         ShowContinueError(state,
    7311           0 :                                           format("Min Rated Vol Flow Per Watt=[{:.3T}], Rated Vol Flow Per Watt=[{:.3T}], Max Rated Vol Flow Per "
    7312             :                                                  "Watt=[{:.3T}]. See Input Output Reference Manual for valid range.",
    7313           0 :                                                  state.dataHVACGlobal->MinRatedVolFlowPerRatedTotCap(DXCT),
    7314             :                                                  RatedVolFlowPerRatedTotCap,
    7315           0 :                                                  state.dataHVACGlobal->MaxRatedVolFlowPerRatedTotCap(DXCT)));
    7316           0 :                         ShowContinueError(state,
    7317           0 :                                           "for CoilPerformance:DX:Cooling mode: " + state.dataDXCoils->DXCoil(DXCoilNum).CoilPerformanceName(Mode));
    7318             :                     }
    7319          35 :                     state.dataDXCoils->DXCoil(DXCoilNum).RatedAirMassFlowRate(Mode) =
    7320          70 :                         state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(Mode) *
    7321          35 :                         PsyRhoAirFnPbTdbW(state, state.dataEnvrn->StdBaroPress, RatedInletAirTemp, RatedInletAirHumRat, RoutineName);
    7322             :                     // get rated coil bypass factor
    7323         210 :                     state.dataDXCoils->DXCoil(DXCoilNum).RatedCBF(Mode) = CalcCBF(state,
    7324          70 :                                                                                   state.dataDXCoils->DXCoil(DXCoilNum).CoilPerformanceType(Mode),
    7325          70 :                                                                                   state.dataDXCoils->DXCoil(DXCoilNum).CoilPerformanceName(Mode),
    7326             :                                                                                   RatedInletAirTemp,
    7327             :                                                                                   RatedInletAirHumRat,
    7328          35 :                                                                                   state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode),
    7329          35 :                                                                                   state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(Mode),
    7330          35 :                                                                                   state.dataDXCoils->DXCoil(DXCoilNum).RatedSHR(Mode));
    7331             :                 } // End capacity stages loop
    7332             :             }     // End dehumidification modes loop
    7333             :         }
    7334             : 
    7335        2735 :         if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_HeatingEmpirical ||
    7336        1758 :             state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilVRF_Heating ||
    7337         822 :             state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilVRF_FluidTCtrl_Heating) {
    7338             : 
    7339         129 :             Mode = 1;
    7340         129 :             if (state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode) <= 0.0) {
    7341           0 :                 ShowSevereError(state,
    7342           0 :                                 "Sizing: " + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + ' ' + state.dataDXCoils->DXCoil(DXCoilNum).Name +
    7343             :                                     " has zero rated total capacity");
    7344           0 :                 ErrorsFound = true;
    7345             :             }
    7346         129 :             if (state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(Mode) <= 0.0) {
    7347           0 :                 ShowSevereError(state,
    7348           0 :                                 "Sizing: " + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + ' ' + state.dataDXCoils->DXCoil(DXCoilNum).Name +
    7349             :                                     " has zero rated air flow rate");
    7350           0 :                 ErrorsFound = true;
    7351             :             }
    7352         129 :             if (ErrorsFound) {
    7353           0 :                 ShowFatalError(state, "Preceding condition causes termination.");
    7354             :             }
    7355         129 :             RatedHeatPumpIndoorAirTemp = 21.11;  // 21.11C or 70F
    7356         129 :             RatedHeatPumpIndoorHumRat = 0.00881; // Humidity ratio corresponding to 70F dry bulb/60F wet bulb
    7357         129 :             state.dataDXCoils->DXCoil(DXCoilNum).RatedAirMassFlowRate(Mode) =
    7358         258 :                 state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(Mode) *
    7359         129 :                 PsyRhoAirFnPbTdbW(state, state.dataEnvrn->StdBaroPress, RatedHeatPumpIndoorAirTemp, RatedHeatPumpIndoorHumRat, RoutineName);
    7360             : 
    7361             :             // Check for valid range of (Rated Air Volume Flow Rate / Rated Total Capacity)
    7362         129 :             if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num !=
    7363             :                 CoilVRF_FluidTCtrl_Heating) { // the VolFlowPerRatedTotCap check is not applicable for VRF-FluidTCtrl coil
    7364         114 :                 RatedVolFlowPerRatedTotCap =
    7365         114 :                     state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(Mode) / state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode);
    7366         228 :                 if (((state.dataHVACGlobal->MinRatedVolFlowPerRatedTotCap(DXCT) - RatedVolFlowPerRatedTotCap) > SmallDifferenceTest) ||
    7367         114 :                     ((RatedVolFlowPerRatedTotCap - state.dataHVACGlobal->MaxRatedVolFlowPerRatedTotCap(DXCT)) > SmallDifferenceTest)) {
    7368           0 :                     ShowWarningError(state,
    7369           0 :                                      "Sizing: " + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + ' ' + state.dataDXCoils->DXCoil(DXCoilNum).Name +
    7370             :                                          ": Rated air volume flow rate per watt of rated total heating capacity is out of range.");
    7371           0 :                     ShowContinueError(state,
    7372           0 :                                       format("Min Rated Vol Flow Per Watt=[{:.3T}], Rated Vol Flow Per Watt=[{:.3T}], Max Rated Vol Flow Per "
    7373             :                                              "Watt=[{:.3T}]. See Input-Output Reference Manual for valid range.",
    7374           0 :                                              state.dataHVACGlobal->MinRatedVolFlowPerRatedTotCap(DXCT),
    7375             :                                              RatedVolFlowPerRatedTotCap,
    7376           0 :                                              state.dataHVACGlobal->MaxRatedVolFlowPerRatedTotCap(DXCT)));
    7377             :                 }
    7378             :             }
    7379             : 
    7380             :             // call coil model with everthing set at rating point
    7381         129 :             state.dataDXCoils->DXCoil(DXCoilNum).InletAirMassFlowRate = state.dataDXCoils->DXCoil(DXCoilNum).RatedAirMassFlowRate(Mode);
    7382         129 :             state.dataDXCoils->DXCoil(DXCoilNum).InletAirMassFlowRateMax = state.dataDXCoils->DXCoil(DXCoilNum).RatedAirMassFlowRate(Mode);
    7383             : 
    7384         129 :             state.dataDXCoils->DXCoil(DXCoilNum).InletAirTemp = RatedInletAirTempHeat;
    7385             :             Real64 tempInletAirHumRat = Psychrometrics::PsyWFnTdbTwbPb(
    7386         129 :                 state, RatedInletAirTempHeat, RatedInletWetBulbTempHeat, DataEnvironment::StdPressureSeaLevel, RoutineName);
    7387         129 :             state.dataDXCoils->DXCoil(DXCoilNum).InletAirHumRat = tempInletAirHumRat;
    7388         129 :             state.dataDXCoils->DXCoil(DXCoilNum).InletAirEnthalpy = Psychrometrics::PsyHFnTdbW(RatedInletAirTempHeat, tempInletAirHumRat);
    7389             : 
    7390             :             // store environment data fill back in after rating point calc is over
    7391         129 :             Real64 holdOutDryBulbTemp = state.dataEnvrn->OutDryBulbTemp;
    7392         129 :             Real64 holdOutHumRat = state.dataEnvrn->OutHumRat;
    7393         129 :             Real64 holdOutWetBulb = state.dataEnvrn->OutWetBulbTemp;
    7394         129 :             Real64 holdOutBaroPress = state.dataEnvrn->OutBaroPress;
    7395             : 
    7396         129 :             state.dataEnvrn->OutDryBulbTemp = RatedOutdoorAirTempHeat;
    7397             : 
    7398         129 :             Real64 ratedOutdoorAirWetBulb = 6.11; // from I/O ref. more precise value?
    7399         129 :             state.dataEnvrn->OutWetBulbTemp = ratedOutdoorAirWetBulb;
    7400         129 :             state.dataEnvrn->OutBaroPress = DataEnvironment::StdPressureSeaLevel; // assume rating is for sea level.
    7401         129 :             state.dataEnvrn->OutHumRat = Psychrometrics::PsyWFnTdbTwbPb(
    7402             :                 state, RatedOutdoorAirTempHeat, ratedOutdoorAirWetBulb, DataEnvironment::StdPressureSeaLevel, RoutineName);
    7403             : 
    7404         129 :             if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(1) > 0) { // set condenser inlet node values
    7405          56 :                 state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(1)).Temp = RatedOutdoorAirTempHeat;
    7406          56 :                 state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(1)).HumRat = state.dataEnvrn->OutHumRat;
    7407          56 :                 state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(1)).OutAirWetBulb = ratedOutdoorAirWetBulb;
    7408             :             }
    7409             : 
    7410             :             // calculate coil model at rating point
    7411         129 :             if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_HeatingEmpirical) {
    7412          73 :                 CalcDXHeatingCoil(state, DXCoilNum, 1.0, 1.0, 1.0);
    7413          56 :             } else if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilVRF_Heating) {
    7414          41 :                 CalcDXHeatingCoil(state, DXCoilNum, 1.0, 1.0, _, _);
    7415          15 :             } else if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilVRF_FluidTCtrl_Heating) {
    7416          15 :                 CalcVRFHeatingCoil_FluidTCtrl(state, CompressorOperation::On, DXCoilNum, 1.0, 1.0, _, _);
    7417             :             }
    7418             :             // coil outlets
    7419         129 :             Real64 RatedOutletWetBulb(0.0);
    7420         258 :             RatedOutletWetBulb = Psychrometrics::PsyTwbFnTdbWPb(state,
    7421         129 :                                                                 state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp,
    7422         129 :                                                                 state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat,
    7423             :                                                                 DataEnvironment::StdPressureSeaLevel,
    7424             :                                                                 RoutineName);
    7425             : 
    7426        1419 :             state.dataRptCoilSelection->coilSelectionReportObj->setRatedCoilConditions(
    7427             :                 state,
    7428         129 :                 state.dataDXCoils->DXCoil(DXCoilNum).Name,
    7429         129 :                 state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
    7430         129 :                 state.dataDXCoils->DXCoil(DXCoilNum).TotalHeatingEnergyRate, // this is the report variable
    7431         129 :                 state.dataDXCoils->DXCoil(DXCoilNum).TotalHeatingEnergyRate, // this is the report variable
    7432         129 :                 state.dataDXCoils->DXCoil(DXCoilNum).InletAirMassFlowRate,
    7433         129 :                 state.dataDXCoils->DXCoil(DXCoilNum).InletAirTemp,
    7434         129 :                 state.dataDXCoils->DXCoil(DXCoilNum).InletAirHumRat,
    7435             :                 RatedInletWetBulbTempHeat,
    7436         129 :                 state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp,
    7437         129 :                 state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat,
    7438             :                 RatedOutletWetBulb,
    7439             :                 RatedOutdoorAirTempHeat,
    7440             :                 ratedOutdoorAirWetBulb,
    7441         129 :                 state.dataDXCoils->DXCoil(DXCoilNum).RatedCBF(Mode),
    7442             :                 -999.0); // coil effectiveness not define for DX
    7443             : 
    7444             :             // now replace the outdoor air conditions set above for one time rating point calc
    7445         129 :             state.dataEnvrn->OutDryBulbTemp = holdOutDryBulbTemp;
    7446         129 :             state.dataEnvrn->OutHumRat = holdOutHumRat;
    7447         129 :             state.dataEnvrn->OutWetBulbTemp = holdOutWetBulb;
    7448         129 :             state.dataEnvrn->OutBaroPress = holdOutBaroPress;
    7449             :         }
    7450             : 
    7451         936 :         if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_CoolingTwoSpeed) {
    7452             :             // Check for valid range of (Rated Air Volume Flow Rate / Rated Total Capacity)
    7453          67 :             RatedVolFlowPerRatedTotCap =
    7454          67 :                 state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate2 / state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap2;
    7455         134 :             if (((state.dataHVACGlobal->MinRatedVolFlowPerRatedTotCap(DXCT) - RatedVolFlowPerRatedTotCap) > SmallDifferenceTest) ||
    7456          67 :                 ((RatedVolFlowPerRatedTotCap - state.dataHVACGlobal->MaxRatedVolFlowPerRatedTotCap(DXCT)) > SmallDifferenceTest)) {
    7457          15 :                 ShowWarningError(state,
    7458          10 :                                  "Coil:Cooling:DX:TwoSpeed \"" + state.dataDXCoils->DXCoil(DXCoilNum).Name +
    7459             :                                      "\": At low speed rated air volume flow rate per watt of rated total cooling capacity is out of range.");
    7460          15 :                 ShowContinueError(state,
    7461          20 :                                   format("Min Rated Vol Flow Per Watt=[{:.3T}], Rated Vol Flow Per Watt=[{:.3T}], Max Rated Vol Flow Per "
    7462             :                                          "Watt=[{:.3T}]. See Input-Output Reference Manual for valid range.",
    7463           5 :                                          state.dataHVACGlobal->MinRatedVolFlowPerRatedTotCap(DXCT),
    7464             :                                          RatedVolFlowPerRatedTotCap,
    7465          10 :                                          state.dataHVACGlobal->MaxRatedVolFlowPerRatedTotCap(DXCT)));
    7466             :             }
    7467             : 
    7468          67 :             state.dataDXCoils->DXCoil(DXCoilNum).RatedAirMassFlowRate2 =
    7469         134 :                 state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate2 *
    7470          67 :                 PsyRhoAirFnPbTdbW(state, state.dataEnvrn->StdBaroPress, RatedInletAirTemp, RatedInletAirHumRat, RoutineName);
    7471             :             // get low speed rated coil bypass factor
    7472         335 :             state.dataDXCoils->DXCoil(DXCoilNum).RatedCBF2 = CalcCBF(state,
    7473          67 :                                                                      state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
    7474          67 :                                                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,
    7475             :                                                                      RatedInletAirTemp,
    7476             :                                                                      RatedInletAirHumRat,
    7477          67 :                                                                      state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap2,
    7478          67 :                                                                      state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate2,
    7479          67 :                                                                      state.dataDXCoils->DXCoil(DXCoilNum).RatedSHR2);
    7480             : 
    7481             :             // call for standard ratings for two-speeed DX coil
    7482          67 :             if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(1) == DataHeatBalance::RefrigCondenserType::Air) {
    7483          66 :                 CalcTwoSpeedDXCoilStandardRating(state, DXCoilNum);
    7484             :             }
    7485             :         }
    7486             : 
    7487             :         // Multispeed Cooling
    7488         936 :         if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_MultiSpeedCooling) {
    7489         157 :             for (Mode = 1; Mode <= state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds; ++Mode) {
    7490             :                 // Check for zero capacity or zero max flow rate
    7491         109 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(Mode) <= 0.0) {
    7492           0 :                     ShowSevereError(state,
    7493           0 :                                     format("Sizing: {} {} has zero rated total capacity at speed {}",
    7494           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
    7495           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).Name,
    7496           0 :                                            Mode));
    7497           0 :                     ErrorsFound = true;
    7498             :                 }
    7499         109 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirVolFlowRate(Mode) <= 0.0) {
    7500           0 :                     ShowSevereError(state,
    7501           0 :                                     format("Sizing: {} {} has zero rated air flow rate at speed {}",
    7502           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
    7503           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).Name,
    7504           0 :                                            Mode));
    7505           0 :                     ErrorsFound = true;
    7506             :                 }
    7507         109 :                 if (ErrorsFound) {
    7508           0 :                     ShowFatalError(state, "Preceding condition causes termination.");
    7509             :                 }
    7510             :                 // Check for valid range of (Rated Air Volume Flow Rate / Rated Total Capacity)
    7511         109 :                 RatedVolFlowPerRatedTotCap =
    7512         109 :                     state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirVolFlowRate(Mode) / state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(Mode);
    7513         218 :                 if (((state.dataHVACGlobal->MinRatedVolFlowPerRatedTotCap(DXCT) - RatedVolFlowPerRatedTotCap) > SmallDifferenceTest) ||
    7514         109 :                     ((RatedVolFlowPerRatedTotCap - state.dataHVACGlobal->MaxRatedVolFlowPerRatedTotCap(DXCT)) > SmallDifferenceTest)) {
    7515          87 :                     ShowWarningError(
    7516             :                         state,
    7517         116 :                         format("Sizing: {} \"{}\": Rated air volume flow rate per watt of rated total cooling capacity is out of range at speed {}",
    7518          29 :                                state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
    7519          29 :                                state.dataDXCoils->DXCoil(DXCoilNum).Name,
    7520          29 :                                Mode));
    7521          87 :                     ShowContinueError(state,
    7522         116 :                                       format("Min Rated Vol Flow Per Watt=[{:.3T}], Rated Vol Flow Per Watt=[{:.3T}], Max Rated Vol Flow Per "
    7523             :                                              "Watt=[{:.3T}]. See Input Output Reference Manual for valid range.",
    7524          29 :                                              state.dataHVACGlobal->MinRatedVolFlowPerRatedTotCap(DXCT),
    7525             :                                              RatedVolFlowPerRatedTotCap,
    7526          58 :                                              state.dataHVACGlobal->MaxRatedVolFlowPerRatedTotCap(DXCT)));
    7527             :                 }
    7528         109 :                 state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirMassFlowRate(Mode) =
    7529         218 :                     state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirVolFlowRate(Mode) *
    7530         109 :                     PsyRhoAirFnPbTdbW(state, state.dataEnvrn->StdBaroPress, RatedInletAirTemp, RatedInletAirHumRat, RoutineName);
    7531             :                 // get high speed rated coil bypass factor
    7532         545 :                 state.dataDXCoils->DXCoil(DXCoilNum).MSRatedCBF(Mode) = CalcCBF(state,
    7533         109 :                                                                                 state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
    7534         109 :                                                                                 state.dataDXCoils->DXCoil(DXCoilNum).Name,
    7535             :                                                                                 RatedInletAirTemp,
    7536             :                                                                                 RatedInletAirHumRat,
    7537         109 :                                                                                 state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(Mode),
    7538         109 :                                                                                 state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirVolFlowRate(Mode),
    7539         109 :                                                                                 state.dataDXCoils->DXCoil(DXCoilNum).MSRatedSHR(Mode));
    7540             :             }
    7541             :         }
    7542             : 
    7543             :         // Multispeed Heating
    7544         936 :         if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_MultiSpeedHeating) {
    7545          20 :             RatedHeatPumpIndoorAirTemp = 21.11;  // 21.11C or 70F
    7546          20 :             RatedHeatPumpIndoorHumRat = 0.00881; // Humidity ratio corresponding to 70F dry bulb/60F wet bulb
    7547          82 :             for (Mode = 1; Mode <= state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds; ++Mode) {
    7548             : 
    7549          62 :                 state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirMassFlowRate(Mode) =
    7550         124 :                     state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirVolFlowRate(Mode) *
    7551          62 :                     PsyRhoAirFnPbTdbW(state, state.dataEnvrn->StdBaroPress, RatedHeatPumpIndoorAirTemp, RatedHeatPumpIndoorHumRat, RoutineName);
    7552             :                 // Check for valid range of (Rated Air Volume Flow Rate / Rated Total Capacity)
    7553          62 :                 RatedVolFlowPerRatedTotCap =
    7554          62 :                     state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirVolFlowRate(Mode) / state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(Mode);
    7555         124 :                 if (((state.dataHVACGlobal->MinRatedVolFlowPerRatedTotCap(DXCT) - RatedVolFlowPerRatedTotCap) > SmallDifferenceTest) ||
    7556          62 :                     ((RatedVolFlowPerRatedTotCap - state.dataHVACGlobal->MaxRatedVolFlowPerRatedTotCap(DXCT)) > SmallDifferenceTest)) {
    7557          18 :                     ShowWarningError(state,
    7558          18 :                                      format("Coil:Heating:DX:MultiSpeed {}: Rated air volume flow rate per watt of rated total heating capacity "
    7559             :                                             "is out of range at speed {}",
    7560           6 :                                             state.dataDXCoils->DXCoil(DXCoilNum).Name,
    7561           6 :                                             Mode));
    7562          18 :                     ShowContinueError(state,
    7563          24 :                                       format("Min Rated Vol Flow Per Watt=[{:.3T}], Rated Vol Flow Per Watt=[{:.3T}], Max Rated Vol Flow Per "
    7564             :                                              "Watt=[{:.3T}]. See Input Output Reference Manual for valid range.",
    7565           6 :                                              state.dataHVACGlobal->MinRatedVolFlowPerRatedTotCap(DXCT),
    7566             :                                              RatedVolFlowPerRatedTotCap,
    7567          12 :                                              state.dataHVACGlobal->MaxRatedVolFlowPerRatedTotCap(DXCT)));
    7568             :                 }
    7569             :             }
    7570             :         }
    7571             : 
    7572             :         // store fan info for coil
    7573         936 :         if (state.dataDXCoils->DXCoil(DXCoilNum).SupplyFan_TypeNum == DataHVACGlobals::FanType_SystemModelObject) {
    7574          14 :             if (state.dataDXCoils->DXCoil(DXCoilNum).SupplyFanIndex > -1) {
    7575          70 :                 state.dataRptCoilSelection->coilSelectionReportObj->setCoilSupplyFanInfo(state,
    7576          14 :                                                                                          state.dataDXCoils->DXCoil(DXCoilNum).Name,
    7577          14 :                                                                                          state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
    7578          14 :                                                                                          state.dataDXCoils->DXCoil(DXCoilNum).SupplyFanName,
    7579             :                                                                                          DataAirSystems::ObjectVectorOOFanSystemModel,
    7580          14 :                                                                                          state.dataDXCoils->DXCoil(DXCoilNum).SupplyFanIndex);
    7581             :             }
    7582             : 
    7583             :         } else {
    7584         922 :             if (state.dataDXCoils->DXCoil(DXCoilNum).SupplyFanIndex > 0) {
    7585        1210 :                 state.dataRptCoilSelection->coilSelectionReportObj->setCoilSupplyFanInfo(state,
    7586         242 :                                                                                          state.dataDXCoils->DXCoil(DXCoilNum).Name,
    7587         242 :                                                                                          state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
    7588         242 :                                                                                          state.dataDXCoils->DXCoil(DXCoilNum).SupplyFanName,
    7589             :                                                                                          DataAirSystems::StructArrayLegacyFanModels,
    7590         242 :                                                                                          state.dataDXCoils->DXCoil(DXCoilNum).SupplyFanIndex);
    7591             :             }
    7592             :         }
    7593             :     }
    7594             : 
    7595    65004606 :     AirInletNode = state.dataDXCoils->DXCoil(DXCoilNum).AirInNode;
    7596             : 
    7597             :     // Each iteration, load the coil data structure with the inlet conditions
    7598             : 
    7599    65004606 :     state.dataDXCoils->DXCoil(DXCoilNum).InletAirMassFlowRate = state.dataLoopNodes->Node(AirInletNode).MassFlowRate;
    7600    65004606 :     state.dataDXCoils->DXCoil(DXCoilNum).InletAirMassFlowRateMax =
    7601    65004606 :         max(state.dataLoopNodes->Node(AirInletNode).MassFlowRateMax, state.dataLoopNodes->Node(AirInletNode).MassFlowRate);
    7602    65004606 :     state.dataDXCoils->DXCoil(DXCoilNum).InletAirTemp = state.dataLoopNodes->Node(AirInletNode).Temp;
    7603    65004606 :     state.dataDXCoils->DXCoil(DXCoilNum).InletAirHumRat = state.dataLoopNodes->Node(AirInletNode).HumRat;
    7604    65004606 :     state.dataDXCoils->DXCoil(DXCoilNum).InletAirEnthalpy = state.dataLoopNodes->Node(AirInletNode).Enthalpy;
    7605             :     //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
    7606             :     //  DXCoil(DXCoilNum)%InletAirPressure        = Node(AirInletNode)%Press
    7607             : 
    7608   122598678 :     if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_HeatingEmpirical ||
    7609    57594072 :         state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_MultiSpeedHeating) {
    7610    12055268 :         if (state.dataDXCoils->DXCoil(DXCoilNum).IsSecondaryDXCoilInZone) {
    7611       83892 :             state.dataDXCoils->DXCoil(DXCoilNum).EvapInletWetBulb =
    7612      251676 :                 PsyTwbFnTdbWPb(state,
    7613       83892 :                                state.dataZoneTempPredictorCorrector->zoneHeatBalance(state.dataDXCoils->DXCoil(DXCoilNum).SecZonePtr).ZT,
    7614       83892 :                                state.dataZoneTempPredictorCorrector->zoneHeatBalance(state.dataDXCoils->DXCoil(DXCoilNum).SecZonePtr).ZoneAirHumRat,
    7615       83892 :                                state.dataEnvrn->OutBaroPress,
    7616             :                                RoutineName);
    7617             :         }
    7618             :     }
    7619             : 
    7620   129346171 :     if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_HeatPumpWaterHeaterPumped ||
    7621    64341565 :         state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_HeatPumpWaterHeaterWrapped) {
    7622     1023180 :         state.dataDXCoils->DXCoil(DXCoilNum).TotalHeatingEnergyRate = 0.0;
    7623     1023180 :         state.dataDXCoils->DXCoil(DXCoilNum).ElecWaterHeatingPower = 0.0;
    7624             :         //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
    7625             :         //  DXCoil(DXCoilNum)%InletAirPressure         = StdBaroPress
    7626             : 
    7627             :         //   HPWH's that use an inlet air temperature schedule also need to have a valid barometric pressure
    7628             :         //   The DX Coil used in HPWH's does not know if it is using a scheduled inlet temperature so check the node pressure
    7629     1023180 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(1) > 0) {
    7630     1023180 :             if (state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(1)).Press == 0.0) {
    7631           2 :                 state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(1)).Press = state.dataEnvrn->StdBaroPress;
    7632             :             }
    7633             :         }
    7634             :     }
    7635    65004606 :     state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterPower = 0.0;
    7636             : 
    7637    65004606 :     if (state.dataDXCoils->DXCoil(DXCoilNum).IsSecondaryDXCoilInZone) {
    7638      167785 :         state.dataDXCoils->DXCoil(DXCoilNum).CompressorPartLoadRatio = 0.0;
    7639      167785 :         state.dataDXCoils->DXCoil(DXCoilNum).SecCoilSensibleHeatGainRate = 0.0;
    7640      167785 :         state.dataDXCoils->DXCoil(DXCoilNum).SecCoilTotalHeatRemovalRate = 0.0;
    7641      167785 :         state.dataDXCoils->DXCoil(DXCoilNum).SecCoilSensibleHeatRemovalRate = 0.0;
    7642      167785 :         state.dataDXCoils->DXCoil(DXCoilNum).SecCoilLatentHeatRemovalRate = 0.0;
    7643             :     }
    7644    65004606 : }
    7645             : 
    7646         968 : void SizeDXCoil(EnergyPlusData &state, int const DXCoilNum)
    7647             : {
    7648             : 
    7649             :     // SUBROUTINE INFORMATION:
    7650             :     //       AUTHOR         Fred Buhl
    7651             :     //       DATE WRITTEN   January 2002
    7652             :     //                      Feb 2005, M. J. Witte, GARD Analytics, Inc. Add new coil type COIL:DX:MultiMode:CoolingEmpirical.
    7653             :     //                      Jul 2005, R. Raustad, FSEC. Add new coil type COIL:DX:HEATPUMPWATERHEATER
    7654             :     //                      Jun 2007, L. Gu, FSEC. Add new coil type COIL:DX:MULTISPEED:COOLING and HEATING
    7655             :     //                      Jan 2011, B. Griffithn, NREL. add EMS overrides for autosized fields
    7656             :     //                      Aug 2013, D. Kang. add component sizing table entries
    7657             :     //                      May 2014, R. Raustad, FSEC. moved sizing calculations to common routine
    7658             :     //                      Aug 2015, R. Zhang, LBNL. Add new coil types for VRF_FluidTCtrl
    7659             :     //       RE-ENGINEERED  na
    7660             : 
    7661             :     // PURPOSE OF THIS SUBROUTINE:
    7662             :     // This subroutine is for sizing DX Coil components for which nominal capacity and air flow rate
    7663             :     // have not been specified in the input.
    7664             : 
    7665             :     // METHODOLOGY EMPLOYED:
    7666             :     // Obtains cooling capacities and air flow rates from the zone or system sizing arrays.
    7667             : 
    7668             :     // Using/Aliasing
    7669             :     using namespace DataSizing;
    7670             :     using Curve::CurveValue;
    7671             : 
    7672             :     using namespace OutputReportPredefined;
    7673             :     using StandardRatings::CalcDXCoilStandardRating;
    7674             : 
    7675             :     // SUBROUTINE PARAMETER DEFINITIONS:
    7676             :     static constexpr std::string_view RoutineName("SizeDXCoil");
    7677             : 
    7678             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    7679             :     Real64 CoilInTemp;       // DX coil inlet temperature
    7680             :     int CapacityStageNum;    // Loop index for 1,Number of capacity stages
    7681             :     int DehumidModeNum;      // Loop index for 1,Number of enhanced dehumidification modes
    7682             :     int Mode;                // Operating mode for MultiMode DX coil; Always 1 for other coil types
    7683             :     int NumOfSpeedCompanion; // Number of speed for a companion cooling coil (Multispeed HO heating coil only
    7684        1936 :     std::string equipName;
    7685             :     Real64 RatedAirVolFlowRateDes;          // Design rated air volume flow for reporting
    7686             :     Real64 RatedAirVolFlowRateUser;         // Hard-sized rated air volume flow for reporting
    7687             :     Real64 RatedAirVolFlowRate2Des;         // Design rated low speed air volume flow for reporting
    7688             :     Real64 RatedAirVolFlowRate2User;        // Hard-sized rated low speed air volume flow for reporting
    7689             :     Real64 RatedTotCapDes;                  // Design rated total capacity for reproting
    7690             :     Real64 RatedTotCapUser;                 // Hard-sized rated total capacity for reproting
    7691             :     Real64 RatedTotCap2Des;                 // Design rated low speed total capacity for reproting
    7692             :     Real64 RatedTotCap2User;                // Hard-sized rated low speed total capacity for reproting
    7693             :     Real64 RatedSHRDes;                     // Design ratd SHR for reporting
    7694             :     Real64 RatedSHRUser;                    // Hard-sized ratd SHR for reporting
    7695             :     Real64 RatedSHR2Des;                    // Design ratd low speed SHR for reporting
    7696             :     Real64 RatedSHR2User;                   // Hard-sized ratd low speed SHR for reporting
    7697             :     Real64 EvapCondAirFlowDes;              // Design evaporative condenser air flow for reporting
    7698             :     Real64 EvapCondAirFlowUser;             // Hard-sized evaporative condenser air flow for reporting
    7699             :     Real64 EvapCondAirFlow2Des;             // Design low speed evaporative condenser air flow for reporting
    7700             :     Real64 EvapCondAirFlow2User;            // Hard-sized low speed evaporative condenser air flow for reporting
    7701             :     Real64 EvapCondPumpElecNomPowerDes;     // Design evaporative condenser pump rated power consumption for reporting
    7702             :     Real64 EvapCondPumpElecNomPowerUser;    // Hard-sized evaporative condenser pump rated power consumption for reporting
    7703             :     Real64 EvapCondPumpElecNomPower2Des;    // Design low speed condenser pump rated power consumption for reporting
    7704             :     Real64 EvapCondPumpElecNomPower2User;   // Hard-sized low speed condenser pump rated power consumption for reporting
    7705             :     Real64 DefrostCapacityDes;              // Design defrost heater capacity for reporting
    7706             :     Real64 DefrostCapacityUser;             // Hard-sized defrost heater capacity for reporting
    7707             :     Real64 MSRatedAirVolFlowRateDes;        // Design multispeed rated air volume flow rate for reporting
    7708             :     Real64 MSRatedAirVolFlowRateUser;       // Hard-sized multispeed rated air volume flow rate for reporting
    7709             :     Real64 MSRatedTotCapDesAtMaxSpeed;      // Design multispeed rated total capacity for reporting (at maximum speed)
    7710             :     Real64 MSRatedTotCapUser;               // Hard-sized multispeed rated total capacity for reporting
    7711             :     Real64 MSRatedSHRDes;                   // Design multispeed rated SHR for reporting
    7712             :     Real64 MSRatedSHRUser;                  // Hard-sized multispeed rated SHR for reporting
    7713             :     Real64 MSEvapCondAirFlowDes;            // Design evaporative condenser air flow for reporting
    7714             :     Real64 MSEvapCondAirFlowUser;           // Hard-sized evaporative condenser air flow for reporting
    7715             :     Real64 MSEvapCondAirFlow2Des;           // Design low speed evaporative condenser air flow for reporting
    7716             :     Real64 MSEvapCondAirFlow2User;          // Hard-sized low speed evaporative condenser air flow for reporting
    7717             :     Real64 MSEvapCondPumpElecNomPowerDes;   // Design evaporative condenser pump rated power consumption for reporting
    7718             :     Real64 MSEvapCondPumpElecNomPowerUser;  // Hard-sized evaporative condenser pump rated power consumption for reporting
    7719             :     Real64 MSEvapCondPumpElecNomPower2Des;  // Design low speed condenser pump rated power consumption for reporting
    7720             :     Real64 MSEvapCondPumpElecNomPower2User; // Hard-sized low speed condenser pump rated power consumption for reporting
    7721             :     Real64 MSDefrostCapacityDes;            // Design defrost heater capacity for reporting
    7722             :     Real64 MSDefrostCapacityUser;           // Hard-sized defrost heater capacity for reporting
    7723             :     bool HardSizeNoDesRun;                  // Indicator to a hard-sized field with no design sizing data
    7724             :     bool IsAutoSize;                        // Indicator to autosize for reporting
    7725             :     bool IsCoolCoilCapAutoSize;             // Indicator to cooling capacity autosize for reporting
    7726             :     bool SizingDesRunThisAirSys;            // true if a particular air system had a Sizing:System object and system sizing done
    7727             :     bool SizingDesRunThisZone;              // true if a particular zone had a Sizing:Zone object and zone sizing was done
    7728        1936 :     std::string CompName;                   // component name
    7729        1936 :     std::string CompType;                   // component type
    7730        1936 :     std::string SizingString;               // input field sizing description (e.g., Nominal Capacity)
    7731         968 :     bool bPRINT = true;                     // TRUE if sizing is reported to output (eio)
    7732             :     Real64 TempSize;                        // autosized value of coil input field
    7733         968 :     int FieldNum = 2;                       // IDD numeric field number where input field description is found
    7734             :     int SizingMethod;                       // Integer representation of sizing method (e.g., CoolingAirflowSizing, HeatingCapacitySizing, etc.)
    7735             :     bool PrintFlag;                         // TRUE when sizing information is reported in the eio file
    7736             :     bool SizeSecDXCoil;                     // if true do sizing calculation for secondary coil
    7737             :     Real64 SecCoilAirFlowDes;               // Design secondary DX coil air flow for reporting
    7738             :     Real64 SecCoilAirFlowUser;              // Hard-sized secondary DX coil air flow for reporting
    7739             : 
    7740             :     // Initiate all reporting variables
    7741         968 :     if (state.dataSize->SysSizingRunDone || state.dataSize->ZoneSizingRunDone) {
    7742         838 :         HardSizeNoDesRun = false;
    7743             :     } else {
    7744         130 :         HardSizeNoDesRun = true;
    7745             :     }
    7746             : 
    7747         968 :     if (state.dataSize->CurSysNum > 0) {
    7748         605 :         CheckThisAirSystemForSizing(state, state.dataSize->CurSysNum, SizingDesRunThisAirSys);
    7749             :     } else {
    7750         363 :         SizingDesRunThisAirSys = false;
    7751             :     }
    7752         968 :     if (state.dataSize->CurZoneEqNum > 0) {
    7753         339 :         CheckThisZoneForSizing(state, state.dataSize->CurZoneEqNum, SizingDesRunThisZone);
    7754             :     } else {
    7755         629 :         SizingDesRunThisZone = false;
    7756             :     }
    7757             : 
    7758         968 :     IsAutoSize = false;
    7759         968 :     IsCoolCoilCapAutoSize = false;
    7760         968 :     SizeSecDXCoil = false;
    7761         968 :     RatedAirVolFlowRateDes = 0.0;
    7762         968 :     RatedAirVolFlowRateUser = 0.0;
    7763         968 :     RatedAirVolFlowRate2Des = 0.0;
    7764         968 :     RatedAirVolFlowRate2User = 0.0;
    7765         968 :     RatedTotCapDes = 0.0;
    7766         968 :     RatedTotCapUser = 0.0;
    7767         968 :     RatedTotCap2Des = 0.0;
    7768         968 :     RatedTotCap2User = 0.0;
    7769         968 :     MSRatedTotCapDesAtMaxSpeed = 0.0;
    7770         968 :     RatedSHRDes = 0.0;
    7771         968 :     RatedSHRUser = 0.0;
    7772         968 :     RatedSHR2Des = 0.0;
    7773         968 :     RatedSHR2User = 0.0;
    7774         968 :     EvapCondAirFlowDes = 0.0;
    7775         968 :     EvapCondAirFlowUser = 0.0;
    7776         968 :     EvapCondAirFlow2Des = 0.0;
    7777         968 :     EvapCondAirFlow2User = 0.0;
    7778         968 :     EvapCondPumpElecNomPowerDes = 0.0;
    7779         968 :     EvapCondPumpElecNomPowerUser = 0.0;
    7780         968 :     EvapCondPumpElecNomPower2Des = 0.0;
    7781         968 :     EvapCondPumpElecNomPower2User = 0.0;
    7782         968 :     DefrostCapacityDes = 0.0;
    7783         968 :     DefrostCapacityUser = 0.0;
    7784         968 :     MSRatedAirVolFlowRateDes = 0.0;
    7785         968 :     MSRatedAirVolFlowRateUser = 0.0;
    7786             :     // MSRatedTotCapDes = 0.0;
    7787         968 :     MSRatedTotCapUser = 0.0;
    7788         968 :     MSRatedSHRDes = 0.0;
    7789         968 :     MSRatedSHRUser = 0.0;
    7790         968 :     MSEvapCondAirFlowDes = 0.0;
    7791         968 :     MSEvapCondAirFlowUser = 0.0;
    7792         968 :     MSEvapCondAirFlow2Des = 0.0;
    7793         968 :     MSEvapCondAirFlow2User = 0.0;
    7794         968 :     MSEvapCondPumpElecNomPowerDes = 0.0;
    7795         968 :     MSEvapCondPumpElecNomPowerUser = 0.0;
    7796         968 :     MSEvapCondPumpElecNomPower2Des = 0.0;
    7797         968 :     MSEvapCondPumpElecNomPower2User = 0.0;
    7798         968 :     MSDefrostCapacityDes = 0.0;
    7799         968 :     MSDefrostCapacityUser = 0.0;
    7800         968 :     SecCoilAirFlowDes = 0.0;
    7801         968 :     SecCoilAirFlowUser = 0.0;
    7802             : 
    7803             :     // Sizer classes
    7804        1936 :     CoolingSHRSizer sizerCoolingSHR;
    7805         968 :     bool ErrorsFound = false;
    7806             : 
    7807             :     // NOTE: we are sizing COIL:DX:HeatingEmpirical on the COOLING load. Thus the cooling and
    7808             :     // and heating capacities of a DX heat pump system will be identical. In real life the AHRI
    7809             :     // heating and cooling capacities are close but not identical.
    7810        1943 :     for (DehumidModeNum = 0; DehumidModeNum <= state.dataDXCoils->DXCoil(DXCoilNum).NumDehumidModes; ++DehumidModeNum) {
    7811        1967 :         for (CapacityStageNum = 1; CapacityStageNum <= state.dataDXCoils->DXCoil(DXCoilNum).NumCapacityStages; ++CapacityStageNum) {
    7812         992 :             Mode = DehumidModeNum * 2 + CapacityStageNum;
    7813        1958 :             if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_HeatPumpWaterHeaterPumped ||
    7814         966 :                 state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_HeatPumpWaterHeaterWrapped) {
    7815          32 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(1) == DataGlobalConstants::AutoCalculate) {
    7816             :                     // report autocalculated sizing
    7817           6 :                     PrintFlag = true;
    7818           6 :                     CompName = state.dataDXCoils->DXCoil(DXCoilNum).Name;
    7819           6 :                     CompType = state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType;
    7820             :                     // DXCoil( DXCoilNum ).RatedAirVolFlowRate( 1 ) = DXCoil( DXCoilNum ).RatedTotCap2 * 0.00005035
    7821           6 :                     state.dataSize->DataConstantUsedForSizing = state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap2;
    7822           6 :                     state.dataSize->DataFractionUsedForSizing = 0.00005035;
    7823           6 :                     TempSize = AutoSize;
    7824          12 :                     AutoCalculateSizer sizerHPRatedAirVolFlow;
    7825          12 :                     std::string stringOverride = "Rated Evaporator Air Flow Rate [m3/s]";
    7826           6 :                     if (state.dataGlobal->isEpJSON) stringOverride = "rated_evaporator_air_flow_rate [m3/s]";
    7827           6 :                     sizerHPRatedAirVolFlow.overrideSizingString(stringOverride);
    7828           6 :                     sizerHPRatedAirVolFlow.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName);
    7829           6 :                     state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(1) = sizerHPRatedAirVolFlow.size(state, TempSize, ErrorsFound);
    7830           6 :                     PrintFlag = false;
    7831             :                 }
    7832             : 
    7833          32 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).RatedHPWHCondWaterFlow == DataGlobalConstants::AutoCalculate) {
    7834             :                     // report autocalculated sizing
    7835           6 :                     PrintFlag = true;
    7836           6 :                     CompName = state.dataDXCoils->DXCoil(DXCoilNum).Name;
    7837           6 :                     CompType = state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType;
    7838             :                     // DXCoil( DXCoilNum ).RatedAirVolFlowRate( 1 ) = DXCoil( DXCoilNum ).RatedTotCap2 * 0.00000004487
    7839           6 :                     state.dataSize->DataConstantUsedForSizing = state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap2;
    7840           6 :                     state.dataSize->DataFractionUsedForSizing = 0.00000004487;
    7841           6 :                     TempSize = AutoSize;
    7842          12 :                     AutoCalculateSizer sizerHPWHCondWaterFlow;
    7843          12 :                     std::string stringOverride = "Rated Condenser Water Flow Rate [m3/s]";
    7844           6 :                     if (state.dataGlobal->isEpJSON) stringOverride = "rated_condenser_water_flow_rate [m3/s]";
    7845           6 :                     sizerHPWHCondWaterFlow.overrideSizingString(stringOverride);
    7846           6 :                     sizerHPWHCondWaterFlow.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName);
    7847           6 :                     state.dataDXCoils->DXCoil(DXCoilNum).RatedHPWHCondWaterFlow = sizerHPWHCondWaterFlow.size(state, TempSize, ErrorsFound);
    7848           6 :                     PrintFlag = false;
    7849             :                 }
    7850             :             } else {
    7851         960 :                 PrintFlag = true;
    7852         960 :                 FieldNum = 0;
    7853         960 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_CoolingTwoStageWHumControl) {
    7854          35 :                     CompName = state.dataDXCoils->DXCoil(DXCoilNum).Name + ":" + state.dataDXCoils->DXCoil(DXCoilNum).CoilPerformanceName(Mode);
    7855          35 :                     FieldNum = 4;
    7856          35 :                     state.dataSize->DataBypassFrac = state.dataDXCoils->DXCoil(DXCoilNum).BypassedFlowFrac(Mode);
    7857         925 :                 } else if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_HeatingEmpirical) {
    7858          73 :                     CompName = state.dataDXCoils->DXCoil(DXCoilNum).Name;
    7859          73 :                     FieldNum = 3;
    7860             :                     // doesn't look like this is needed for air flow sizing, only for heating capacity sizing
    7861          73 :                     state.dataSize->DataCoolCoilCap =
    7862          73 :                         state.dataSize->DXCoolCap; // pass global variable used only for heat pumps (i.e., DX cooling and heating coils)
    7863          74 :                     if ((state.dataDXCoils->DXCoil(DXCoilNum).IsSecondaryDXCoilInZone) &&
    7864           1 :                         (state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(1) ==
    7865             :                          DataHeatBalance::RefrigCondenserType::Air)) { // seconday DX coil in secondary zone is specified
    7866           1 :                         SizeSecDXCoil = true;
    7867             :                     }
    7868         852 :                 } else if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilVRF_Heating) {
    7869          41 :                     CompName = state.dataDXCoils->DXCoil(DXCoilNum).Name;
    7870          41 :                     FieldNum = 2;
    7871         811 :                 } else if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilVRF_Cooling) {
    7872          41 :                     CompName = state.dataDXCoils->DXCoil(DXCoilNum).Name;
    7873          41 :                     FieldNum = 3;
    7874         770 :                 } else if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilVRF_FluidTCtrl_Heating) {
    7875          15 :                     CompName = state.dataDXCoils->DXCoil(DXCoilNum).Name;
    7876         755 :                 } else if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilVRF_FluidTCtrl_Cooling) {
    7877          15 :                     CompName = state.dataDXCoils->DXCoil(DXCoilNum).Name;
    7878         740 :                 } else if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_MultiSpeedCooling) {
    7879          48 :                     state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(Mode) =
    7880          48 :                         state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirVolFlowRate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    7881          48 :                     CompName = state.dataDXCoils->DXCoil(DXCoilNum).Name;
    7882          48 :                     PrintFlag = false;
    7883         692 :                 } else if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_MultiSpeedHeating) {
    7884          20 :                     state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(Mode) =
    7885          20 :                         state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirVolFlowRate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    7886          20 :                     CompName = state.dataDXCoils->DXCoil(DXCoilNum).Name;
    7887          20 :                     PrintFlag = false;
    7888             :                 } else {
    7889         672 :                     CompName = state.dataDXCoils->DXCoil(DXCoilNum).Name;
    7890         672 :                     FieldNum = 4;
    7891             :                 }
    7892             : 
    7893         960 :                 TempSize = state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(Mode);
    7894         960 :                 if (FieldNum > 0) {
    7895         862 :                     SizingString = state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(Mode).FieldNames(FieldNum) + " [m3/s]";
    7896             :                 } else {
    7897          98 :                     SizingString = "Rated Air Flow Rate [m3/s]";
    7898             :                 }
    7899         960 :                 CompType = state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType;
    7900         960 :                 state.dataSize->DataIsDXCoil = true;
    7901         960 :                 state.dataSize->DataEMSOverrideON = state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRateEMSOverrideON(Mode);
    7902         960 :                 state.dataSize->DataEMSOverride = state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRateEMSOverrideValue(Mode);
    7903        2860 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_MultiSpeedHeating ||
    7904        1865 :                     state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilVRF_FluidTCtrl_Heating ||
    7905        2769 :                     state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilVRF_Heating ||
    7906         884 :                     state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_HeatingEmpirical) {
    7907         149 :                     bool errorsFound = false;
    7908         298 :                     HeatingAirFlowSizer sizingHeatingAirFlow;
    7909         149 :                     sizingHeatingAirFlow.overrideSizingString(SizingString);
    7910             :                     // sizingHeatingAirFlow.setHVACSizingIndexData(FanCoil(FanCoilNum).HVACSizingIndex);
    7911         149 :                     sizingHeatingAirFlow.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName);
    7912         149 :                     state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(Mode) = sizingHeatingAirFlow.size(state, TempSize, errorsFound);
    7913             :                 } else {
    7914         811 :                     bool errorsFound = false;
    7915        1622 :                     CoolingAirFlowSizer sizingCoolingAirFlow;
    7916         811 :                     sizingCoolingAirFlow.overrideSizingString(SizingString);
    7917             :                     // sizingCoolingAirFlow.setHVACSizingIndexData(FanCoil(FanCoilNum).HVACSizingIndex);
    7918         811 :                     sizingCoolingAirFlow.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName);
    7919         811 :                     state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(Mode) = sizingCoolingAirFlow.size(state, TempSize, errorsFound);
    7920             :                 }
    7921         960 :                 state.dataSize->DataIsDXCoil = false;
    7922         960 :                 state.dataSize->DataEMSOverrideON = false;
    7923         960 :                 state.dataSize->DataEMSOverride = 0.0;
    7924         960 :                 state.dataSize->DataBypassFrac = 0.0;
    7925             :             }
    7926             : 
    7927         992 :             state.dataSize->DataFlowUsedForSizing = state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(Mode);
    7928             :             // get autosized air flow for capacity calc's if capacity is not autosized
    7929             :             // *** RAR this if block is a last minute addition to correct capacity reporting when not autosized and a sizing run is done. Test
    7930             :             // suite was not run with this code included. *** The question here is if the autosized air flow rate or the user specified air flow
    7931             :             // rate should be used to calculate capacity removing this for now until more is known
    7932             :             //                if ( DXCoil( DXCoilNum ).RatedTotCap( Mode ) != AutoSize && ( ( SysSizingRunDone && CurSysNum > 0 ) ||
    7933             :             //(  ZoneSizingRunDone && CurZoneEqNum > 0 ) ) ) {                     if ( DXCoil( DXCoilNum ).DXCoilType_Num ==
    7934             :             // CoilDX_CoolingTwoStageWHumControl ) {                         SizingMethod = CoolingAirflowSizing;
    7935             :             //                        DataBypassFrac = DXCoil ( DXCoilNum ).BypassedFlowFrac ( Mode );
    7936             :             //                    } else if ( DXCoil( DXCoilNum ).DXCoilType_Num == CoilDX_HeatingEmpirical ) {
    7937             :             //                        SizingMethod = HeatingAirflowSizing;
    7938             :             ////                        DataCoolCoilCap = DXCoolCap; // pass global variable used only for heat pumps (i.e.,
    7939             :             /// DX  cooling  and  heating coils)
    7940             :             //                    } else if ( DXCoil( DXCoilNum ).DXCoilType_Num == CoilVRF_Heating ) {
    7941             :             //                        SizingMethod = HeatingAirflowSizing;
    7942             :             //                    } else if ( DXCoil( DXCoilNum ).DXCoilType_Num == CoilVRF_Cooling ) {
    7943             :             //                        SizingMethod = CoolingAirflowSizing;
    7944             :             //                    } else {
    7945             :             //                        SizingMethod = CoolingAirflowSizing;
    7946             :             //                    }
    7947             :             //                    CompName = DXCoil( DXCoilNum ).Name;
    7948             :             //                    TempSize = AutoSize;
    7949             :             //                    SizingString.clear(); // don't care
    7950             :             //                    CompType = DXCoil( DXCoilNum ).DXCoilType;
    7951             :             //                    DataIsDXCoil = true;
    7952             :             //                    DataEMSOverrideON = DXCoil ( DXCoilNum ).RatedAirVolFlowRateEMSOverrideON ( Mode );
    7953             :             //                    DataEMSOverride = DXCoil( DXCoilNum ).RatedAirVolFlowRateEMSOverrideValue( Mode );
    7954             :             //                  CoolingAirFlowSizer sizingCoolingAirFlow;
    7955             :             //                  sizingCoolingAirFlow.setHVACSizingIndexData(FanCoil(FanCoilNum).HVACSizingIndex);
    7956             :             //                  sizingCoolingAirFlow.initializeWithinEP(state, CompType, CompName, bPRINT, RoutineName);
    7957             :             //                  DataAirFlowUsedForSizing = sizingCoolingAirFlow.size(state, TempSize, errorsFound);
    7958             :             //                    DataIsDXCoil = false; // don't need this and next 2, they are just overwritten below. Delete
    7959             :             // on  next  pass so testing will show problems if any.                     DataEMSOverrideON = false;
    7960             :             //                    DataEMSOverride = 0.0;
    7961             :             //                    DataBypassFrac = 0.0;
    7962             :             //                }
    7963         992 :             PrintFlag = true;
    7964         992 :             state.dataSize->DataTotCapCurveIndex = state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(Mode);
    7965         992 :             if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_CoolingTwoStageWHumControl) {
    7966          35 :                 SizingMethod = CoolingCapacitySizing;
    7967          35 :                 CompName = state.dataDXCoils->DXCoil(DXCoilNum).Name + ":" + state.dataDXCoils->DXCoil(DXCoilNum).CoilPerformanceName(Mode);
    7968          35 :                 FieldNum = 1;
    7969          35 :                 TempSize = state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode);
    7970          35 :                 SizingString = state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(Mode).FieldNames(FieldNum) + " [W]";
    7971        2798 :             } else if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_HeatingEmpirical ||
    7972        1800 :                        state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilVRF_Heating ||
    7973         843 :                        state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilVRF_FluidTCtrl_Heating) {
    7974         129 :                 SizingMethod = HeatingCapacitySizing;
    7975         129 :                 CompName = state.dataDXCoils->DXCoil(DXCoilNum).Name;
    7976         129 :                 FieldNum = 1;
    7977         129 :                 TempSize = state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode);
    7978         129 :                 SizingString = state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(Mode).FieldNames(FieldNum) + " [W]";
    7979         129 :                 state.dataSize->DataCoolCoilCap = state.dataSize->DXCoolCap;
    7980        1630 :             } else if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_HeatPumpWaterHeaterPumped ||
    7981         802 :                        state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_HeatPumpWaterHeaterWrapped) {
    7982          32 :                 SizingMethod = CoolingCapacitySizing;
    7983          32 :                 CompName = state.dataDXCoils->DXCoil(DXCoilNum).Name;
    7984          32 :                 FieldNum = 1;
    7985          32 :                 TempSize = state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode);
    7986          32 :                 SizingString = state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(Mode).FieldNames(FieldNum) + " [W]";
    7987          32 :                 PrintFlag = false;
    7988          32 :                 state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(DXCoilNum).WaterInNode).Temp =
    7989          32 :                     state.dataDXCoils->DXCoil(DXCoilNum).RatedInletWaterTemp; // set the rated water inlet node for HPWHs for use in CalcHPWHDXCoil
    7990         796 :             } else if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilVRF_FluidTCtrl_Cooling) {
    7991          15 :                 SizingMethod = CoolingCapacitySizing;
    7992          15 :                 CompName = state.dataDXCoils->DXCoil(DXCoilNum).Name;
    7993          15 :                 FieldNum = 1;
    7994          15 :                 TempSize = state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode);
    7995          15 :                 SizingString = state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(Mode).FieldNames(FieldNum) + " [W]";
    7996          15 :                 if (state.dataSize->CurZoneEqNum > 0) {
    7997          15 :                     CoilInTemp =
    7998          15 :                         state.dataSize->ZoneSizingRunDone ? state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).DesCoolCoilInTemp : 26;
    7999             :                 } else {
    8000           0 :                     if (state.dataSize->CurOASysNum > 0) {
    8001           0 :                         CoilInTemp =
    8002           0 :                             state.dataSize->SysSizingRunDone ? state.dataSize->FinalSysSizing(state.dataSize->CurSysNum).OutTempAtCoolPeak : 32;
    8003             :                     } else {
    8004           0 :                         CoilInTemp =
    8005           0 :                             state.dataSize->SysSizingRunDone ? state.dataSize->FinalSysSizing(state.dataSize->CurSysNum).MixTempAtCoolPeak : 26;
    8006             :                     }
    8007             :                 }
    8008          15 :                 CalcVRFCoilCapModFac(state, 0, _, CompName, CoilInTemp, _, _, _, state.dataSize->DataTotCapCurveValue);
    8009         781 :             } else if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_MultiSpeedCooling) {
    8010          48 :                 SizingMethod = CoolingCapacitySizing;
    8011          48 :                 CompName = state.dataDXCoils->DXCoil(DXCoilNum).Name;
    8012          48 :                 FieldNum = 7 + (state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds - 1) * 13;
    8013          48 :                 state.dataSize->DataTotCapCurveIndex =
    8014          48 :                     state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFTemp(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    8015          48 :                 TempSize = state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    8016          48 :                 PrintFlag = false;
    8017          48 :                 SizingString = state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(Mode).FieldNames(FieldNum) + " [W]";
    8018         733 :             } else if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_MultiSpeedHeating) {
    8019          20 :                 SizingMethod = HeatingCapacitySizing;
    8020          20 :                 CompName = state.dataDXCoils->DXCoil(DXCoilNum).Name;
    8021          20 :                 FieldNum = 10 + (state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds - 1) * 5;
    8022          20 :                 state.dataSize->DataTotCapCurveIndex =
    8023          20 :                     state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFTemp(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    8024          20 :                 TempSize = state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    8025          20 :                 PrintFlag = false;
    8026          20 :                 SizingString = state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(Mode).FieldNames(FieldNum) + " [W]";
    8027             :             } else {
    8028         713 :                 SizingMethod = CoolingCapacitySizing;
    8029         713 :                 CompName = state.dataDXCoils->DXCoil(DXCoilNum).Name;
    8030         713 :                 FieldNum = 1;
    8031         713 :                 TempSize = state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode);
    8032         713 :                 SizingString = state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(Mode).FieldNames(FieldNum) + " [W]";
    8033             :             }
    8034         992 :             CompType = state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType;
    8035         992 :             state.dataSize->DataIsDXCoil = true;
    8036         992 :             state.dataSize->DataEMSOverrideON = state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCapEMSOverrideOn(Mode);
    8037         992 :             state.dataSize->DataEMSOverride = state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCapEMSOverrideValue(Mode);
    8038        2956 :             if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_MultiSpeedHeating ||
    8039        1871 :                 state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_HeatingEmpirical ||
    8040        2749 :                 state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilVRF_Heating ||
    8041         858 :                 state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilVRF_FluidTCtrl_Heating) {
    8042         298 :                 HeatingCapacitySizer sizerHeatingCapacity;
    8043         149 :                 sizerHeatingCapacity.overrideSizingString(SizingString);
    8044         149 :                 sizerHeatingCapacity.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName);
    8045         149 :                 state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode) = sizerHeatingCapacity.size(state, TempSize, ErrorsFound);
    8046             :             } else {
    8047        1686 :                 CoolingCapacitySizer sizerCoolingCapacity;
    8048         843 :                 sizerCoolingCapacity.overrideSizingString(SizingString);
    8049         843 :                 sizerCoolingCapacity.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName);
    8050         843 :                 state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode) = sizerCoolingCapacity.size(state, TempSize, ErrorsFound);
    8051             :             }
    8052         992 :             state.dataSize->DataIsDXCoil = false;
    8053         992 :             state.dataSize->DataFlowUsedForSizing = 0.0;
    8054         992 :             state.dataSize->DataCoolCoilCap = 0.0;
    8055         992 :             state.dataSize->DataTotCapCurveIndex = 0;
    8056         992 :             state.dataSize->DataEMSOverrideON = false;
    8057         992 :             state.dataSize->DataEMSOverride = 0.0;
    8058         992 :             state.dataSize->DataConstantUsedForSizing = 0.0;
    8059         992 :             state.dataSize->DataFractionUsedForSizing = 0.0;
    8060         992 :             state.dataSize->DataTotCapCurveValue = 0.0;
    8061             : 
    8062             :             // Cooling coil capacity
    8063        2371 :             if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_CoolingSingleSpeed ||
    8064         707 :                 state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_CoolingTwoSpeed ||
    8065         605 :                 state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_CoolingTwoStageWHumControl ||
    8066        1521 :                 state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilVRF_Cooling ||
    8067         244 :                 state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilVRF_FluidTCtrl_Cooling) {
    8068         763 :                 state.dataSize->DXCoolCap = state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode);
    8069             :             }
    8070             : 
    8071             :             // Sizing DX cooling coil SHR
    8072        2371 :             if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_CoolingSingleSpeed ||
    8073         707 :                 state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_CoolingTwoSpeed ||
    8074         605 :                 state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_CoolingTwoStageWHumControl ||
    8075        1521 :                 state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilVRF_Cooling ||
    8076         244 :                 state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilVRF_FluidTCtrl_Cooling) {
    8077             : 
    8078         763 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_CoolingTwoStageWHumControl) {
    8079          35 :                     CompName = state.dataDXCoils->DXCoil(DXCoilNum).Name + ":" + state.dataDXCoils->DXCoil(DXCoilNum).CoilPerformanceName(Mode);
    8080             :                 } else {
    8081         728 :                     CompName = state.dataDXCoils->DXCoil(DXCoilNum).Name;
    8082             :                 }
    8083         763 :                 CompType = state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType;
    8084         763 :                 TempSize = state.dataDXCoils->DXCoil(DXCoilNum).RatedSHR(Mode);
    8085         763 :                 state.dataSize->DataDXSpeedNum = Mode;
    8086         763 :                 state.dataSize->DataFlowUsedForSizing = state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(Mode);
    8087         763 :                 state.dataSize->DataCapacityUsedForSizing = state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode);
    8088         763 :                 state.dataSize->DataEMSOverrideON = state.dataDXCoils->DXCoil(DXCoilNum).RatedSHREMSOverrideOn(Mode);
    8089         763 :                 state.dataSize->DataEMSOverride = state.dataDXCoils->DXCoil(DXCoilNum).RatedSHREMSOverrideValue(Mode);
    8090         763 :                 bool ErrorsFound = false;
    8091         763 :                 sizerCoolingSHR.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName);
    8092         763 :                 state.dataDXCoils->DXCoil(DXCoilNum).RatedSHR(Mode) = sizerCoolingSHR.size(state, TempSize, ErrorsFound);
    8093         763 :                 state.dataSize->DataDXSpeedNum = 0;
    8094         763 :                 state.dataSize->DataFlowUsedForSizing = 0.0;
    8095         763 :                 state.dataSize->DataCapacityUsedForSizing = 0.0;
    8096         763 :                 state.dataSize->DataEMSOverrideON = false;
    8097         763 :                 state.dataSize->DataEMSOverride = 0.0;
    8098             : 
    8099             :             } // End of Rated SHR
    8100             : 
    8101             :             // Sizing evaporator condenser air flow
    8102        1986 :             if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(1) == DataHeatBalance::RefrigCondenserType::Evap &&
    8103         992 :                 state.dataDXCoils->DXCoil(DXCoilNum).EvapCondAirFlow(Mode) != 0.0 &&
    8104           0 :                 (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_CoolingSingleSpeed ||
    8105           0 :                  state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_CoolingTwoSpeed ||
    8106           0 :                  state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_CoolingTwoStageWHumControl)) {
    8107             : 
    8108           0 :                 AutoCalculateSizer sizerEvapCondAirFlow;
    8109           0 :                 std::string stringOverride = "Evaporative Condenser Air Flow Rate [m3/s]";
    8110           0 :                 if (state.dataGlobal->isEpJSON) stringOverride = "evaporative_condenser_air_flow_rate [m3/s]";
    8111           0 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_CoolingTwoStageWHumControl) {
    8112           0 :                     CompName = state.dataDXCoils->DXCoil(DXCoilNum).Name + ":" + state.dataDXCoils->DXCoil(DXCoilNum).CoilPerformanceName(Mode);
    8113             :                 } else {
    8114           0 :                     CompName = state.dataDXCoils->DXCoil(DXCoilNum).Name;
    8115           0 :                     if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_CoolingTwoSpeed) {
    8116           0 :                         stringOverride = "High Speed Evaporative Condenser Air Flow Rate [m3/s]";
    8117           0 :                         if (state.dataGlobal->isEpJSON) stringOverride = "high_speed_evaporative_condenser_air_flow_rate [m3/s]";
    8118             :                     } else {
    8119           0 :                         stringOverride = "Evaporative Condenser Air Flow Rate [m3/s]";
    8120           0 :                         if (state.dataGlobal->isEpJSON) stringOverride = "evaporative_condenser_air_flow_rate [m3/s]";
    8121             :                     }
    8122             :                 }
    8123           0 :                 CompType = state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType;
    8124             :                 // Auto size condenser air flow to Total Capacity * 0.000114 m3/s/w (850 cfm/ton)
    8125           0 :                 state.dataSize->DataConstantUsedForSizing = state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode);
    8126           0 :                 state.dataSize->DataFractionUsedForSizing = 0.000114;
    8127           0 :                 TempSize = state.dataDXCoils->DXCoil(DXCoilNum).EvapCondAirFlow(Mode);
    8128           0 :                 sizerEvapCondAirFlow.overrideSizingString(stringOverride);
    8129           0 :                 sizerEvapCondAirFlow.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName);
    8130           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).EvapCondAirFlow(Mode) = sizerEvapCondAirFlow.size(state, TempSize, ErrorsFound);
    8131             :             }
    8132             : 
    8133         992 :             if (SizeSecDXCoil) { // autosize secondary coil air flow rate for AirCooled condenser type
    8134           1 :                 IsAutoSize = false;
    8135           1 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).SecCoilAirFlow == AutoSize) {
    8136           1 :                     IsAutoSize = true;
    8137             :                 }
    8138             :                 // Auto size Primary Coil Air Flow * Secondary Coil Scaling Factor
    8139           1 :                 SecCoilAirFlowDes =
    8140           1 :                     state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(1) * state.dataDXCoils->DXCoil(DXCoilNum).SecCoilAirFlowScalingFactor;
    8141           1 :                 if (IsAutoSize) {
    8142           1 :                     state.dataDXCoils->DXCoil(DXCoilNum).SecCoilAirFlow = SecCoilAirFlowDes;
    8143           3 :                     BaseSizer::reportSizerOutput(state,
    8144           1 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
    8145           1 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).Name,
    8146             :                                                  "Design Size Secondary Coil Air Flow Rate [m3/s]",
    8147           1 :                                                  SecCoilAirFlowDes);
    8148             :                 } else {
    8149           0 :                     if (state.dataDXCoils->DXCoil(DXCoilNum).SecCoilAirFlow > 0.0 && SecCoilAirFlowDes > 0.0 && !HardSizeNoDesRun) {
    8150           0 :                         SecCoilAirFlowUser = state.dataDXCoils->DXCoil(DXCoilNum).SecCoilAirFlow;
    8151           0 :                         BaseSizer::reportSizerOutput(state,
    8152           0 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
    8153           0 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,
    8154             :                                                      "Design Size Secondary Coil Air Flow Rate [m3/s]",
    8155             :                                                      SecCoilAirFlowDes,
    8156             :                                                      "User-Specified Secondary Coil Air Flow Rate [m3/s]",
    8157           0 :                                                      SecCoilAirFlowUser);
    8158           0 :                         if (state.dataGlobal->DisplayExtraWarnings) {
    8159           0 :                             if ((std::abs(SecCoilAirFlowDes - SecCoilAirFlowUser) / SecCoilAirFlowUser) > state.dataSize->AutoVsHardSizingThreshold) {
    8160           0 :                                 ShowMessage(state,
    8161           0 :                                             "SizeDxCoil: Potential issue with equipment sizing for " +
    8162           0 :                                                 state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + ' ' + state.dataDXCoils->DXCoil(DXCoilNum).Name);
    8163           0 :                                 ShowContinueError(state, format("User-Specified Secondary Coil Air Flow Rate of {:.5R} [m3/s]", SecCoilAirFlowUser));
    8164           0 :                                 ShowContinueError(
    8165           0 :                                     state, format("differs from Design Size Secondary Coil Air Flow Rate of {:.5R} [m3/s]", SecCoilAirFlowDes));
    8166           0 :                                 ShowContinueError(state, "This may, or may not, indicate mismatched component sizes.");
    8167           0 :                                 ShowContinueError(state, "Verify that the value entered is intended and is consistent with other components.");
    8168             :                             }
    8169             :                         }
    8170             :                     }
    8171             :                 }
    8172             :             }
    8173             : 
    8174             :             // Sizing evaporative condenser air flow 2
    8175         992 :             PrintFlag = true;
    8176        1986 :             if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(1) == DataHeatBalance::RefrigCondenserType::Evap &&
    8177         992 :                 state.dataDXCoils->DXCoil(DXCoilNum).EvapCondAirFlow2 != 0.0 &&
    8178           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_CoolingTwoSpeed) {
    8179           0 :                 CompName = state.dataDXCoils->DXCoil(DXCoilNum).Name;
    8180           0 :                 FieldNum = 15; // Low Speed Evaporative Condenser Air Flow Rate
    8181           0 :                 SizingString = state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(Mode).FieldNames(FieldNum) + " [m3/s]";
    8182           0 :                 SizingMethod = AutoCalculateSizing;
    8183           0 :                 CompType = state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType;
    8184             :                 // Auto size low speed condenser air flow to 1/3 Total Capacity * 0.000114 m3/s/w (850 cfm/ton)
    8185           0 :                 state.dataSize->DataConstantUsedForSizing = state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode);
    8186           0 :                 state.dataSize->DataFractionUsedForSizing = 0.000114 * 0.3333;
    8187           0 :                 TempSize = state.dataDXCoils->DXCoil(DXCoilNum).EvapCondAirFlow2;
    8188           0 :                 AutoCalculateSizer sizerEvapCondAirFlow2;
    8189           0 :                 std::string stringOverride = "Low Speed Evaporative Condenser Air Flow Rate [m3/s]";
    8190           0 :                 if (state.dataGlobal->isEpJSON) stringOverride = "low_speed_evaporative_condenser_air_flow_rate [m3/s]";
    8191           0 :                 sizerEvapCondAirFlow2.overrideSizingString(stringOverride);
    8192           0 :                 sizerEvapCondAirFlow2.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName);
    8193           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).EvapCondAirFlow2 = sizerEvapCondAirFlow2.size(state, TempSize, ErrorsFound);
    8194             :             }
    8195             : 
    8196             :             // Sizing evaporative condenser pump electric nominal power
    8197        1986 :             if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(1) == DataHeatBalance::RefrigCondenserType::Evap &&
    8198         992 :                 state.dataDXCoils->DXCoil(DXCoilNum).EvapCondPumpElecNomPower(Mode) != 0.0 &&
    8199           0 :                 (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_CoolingSingleSpeed ||
    8200           0 :                  state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_CoolingTwoSpeed ||
    8201           0 :                  state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_CoolingTwoStageWHumControl)) {
    8202             : 
    8203           0 :                 AutoCalculateSizer sizerEvapCondPumpPower;
    8204           0 :                 std::string stringOverride = "Evaporative Condenser Pump Rated Power Consumption [W]";
    8205           0 :                 if (state.dataGlobal->isEpJSON) stringOverride = "evaporative_condenser_pump_rated_power_consumption [W]";
    8206           0 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_CoolingTwoStageWHumControl) {
    8207           0 :                     CompName = state.dataDXCoils->DXCoil(DXCoilNum).Name + ":" + state.dataDXCoils->DXCoil(DXCoilNum).CoilPerformanceName(Mode);
    8208             :                 } else {
    8209           0 :                     CompName = state.dataDXCoils->DXCoil(DXCoilNum).Name;
    8210           0 :                     if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_CoolingTwoSpeed) {
    8211           0 :                         stringOverride = "High Speed Evaporative Condenser Pump Rated Power Consumption [W]";
    8212           0 :                         if (state.dataGlobal->isEpJSON) stringOverride = "high_speed_evaporative_condenser_pump_rated_power_consumption [W]";
    8213             :                     } else {
    8214           0 :                         stringOverride = "Evaporative Condenser Pump Rated Power Consumption [W]";
    8215           0 :                         if (state.dataGlobal->isEpJSON) stringOverride = "evaporative_condenser_pump_rated_power_consumption [W]";
    8216             :                     }
    8217             :                 }
    8218           0 :                 SizingMethod = AutoCalculateSizing;
    8219           0 :                 CompType = state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType;
    8220             :                 // Auto size high speed evap condenser pump power to Total Capacity * 0.004266 w/w (15 w/ton)
    8221           0 :                 state.dataSize->DataConstantUsedForSizing = state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode);
    8222           0 :                 state.dataSize->DataFractionUsedForSizing = 0.004266;
    8223           0 :                 TempSize = state.dataDXCoils->DXCoil(DXCoilNum).EvapCondPumpElecNomPower(Mode);
    8224           0 :                 sizerEvapCondPumpPower.overrideSizingString(stringOverride);
    8225           0 :                 sizerEvapCondPumpPower.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName);
    8226           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).EvapCondPumpElecNomPower(Mode) = sizerEvapCondPumpPower.size(state, TempSize, ErrorsFound);
    8227             :             }
    8228             : 
    8229             :             // Sizing low speed evaporative condenser pump electric nominal power
    8230        1986 :             if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(1) == DataHeatBalance::RefrigCondenserType::Evap &&
    8231         992 :                 state.dataDXCoils->DXCoil(DXCoilNum).EvapCondPumpElecNomPower2 != 0.0 &&
    8232           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_CoolingTwoSpeed) {
    8233           0 :                 CompName = state.dataDXCoils->DXCoil(DXCoilNum).Name;
    8234           0 :                 CompType = state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType;
    8235             :                 // Auto size low speed evap condenser pump power to 1/3 Total Capacity * 0.004266 w/w (15 w/ton)
    8236           0 :                 state.dataSize->DataConstantUsedForSizing = state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode);
    8237           0 :                 state.dataSize->DataFractionUsedForSizing = 0.004266 * 0.3333;
    8238           0 :                 TempSize = state.dataDXCoils->DXCoil(DXCoilNum).EvapCondPumpElecNomPower2;
    8239           0 :                 AutoCalculateSizer sizerEvapCondPumpPower2;
    8240           0 :                 std::string stringOverride = "Low Speed Evaporative Condenser Pump Rated Power Consumption [W]";
    8241           0 :                 if (state.dataGlobal->isEpJSON) stringOverride = "low_speed_evaporative_condenser_pump_rated_power_consumption [W]";
    8242           0 :                 sizerEvapCondPumpPower2.overrideSizingString(stringOverride);
    8243           0 :                 sizerEvapCondPumpPower2.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName);
    8244           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).EvapCondPumpElecNomPower2 = sizerEvapCondPumpPower2.size(state, TempSize, ErrorsFound);
    8245             :             }
    8246             : 
    8247             :             //                // Sizing rated low speed air flow rate
    8248         992 :             if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_CoolingTwoSpeed) {
    8249          67 :                 CompName = state.dataDXCoils->DXCoil(DXCoilNum).Name;
    8250          67 :                 CompType = state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType;
    8251             :                 // Auto size low speed air flow rate to 1/3 high speed air flow rate
    8252          67 :                 state.dataSize->DataConstantUsedForSizing = state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(Mode);
    8253          67 :                 state.dataSize->DataFractionUsedForSizing = 0.3333;
    8254          67 :                 TempSize = state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate2;
    8255         134 :                 AutoCalculateSizer sizerLowSpdAirFlow;
    8256         134 :                 std::string stringOverride = "Low Speed Rated Air Flow Rate [m3/s]";
    8257          67 :                 if (state.dataGlobal->isEpJSON) stringOverride = "low_speed_rated_air_flow_rate [m3/s]";
    8258          67 :                 sizerLowSpdAirFlow.overrideSizingString(stringOverride);
    8259          67 :                 sizerLowSpdAirFlow.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName);
    8260          67 :                 state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate2 = sizerLowSpdAirFlow.size(state, TempSize, ErrorsFound);
    8261             :             }
    8262             : 
    8263             :             //                // Sizing rated low speed total cooling capacity
    8264         992 :             if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_CoolingTwoSpeed) {
    8265          67 :                 CompName = state.dataDXCoils->DXCoil(DXCoilNum).Name;
    8266          67 :                 CompType = state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType;
    8267             :                 // Auto size low speed capacity to 1/3 high speed capacity
    8268          67 :                 state.dataSize->DataConstantUsedForSizing = state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode);
    8269          67 :                 state.dataSize->DataFractionUsedForSizing = 0.3333;
    8270          67 :                 TempSize = state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap2;
    8271         134 :                 AutoCalculateSizer sizerLowSpdCap;
    8272         134 :                 std::string stringOverride = "Low Speed Gross Rated Total Cooling Capacity [W]";
    8273          67 :                 if (state.dataGlobal->isEpJSON) stringOverride = "low_speed_gross_rated_total_cooling_capacity [W]";
    8274          67 :                 sizerLowSpdCap.overrideSizingString(stringOverride);
    8275          67 :                 sizerLowSpdCap.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName);
    8276          67 :                 state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap2 = sizerLowSpdCap.size(state, TempSize, ErrorsFound);
    8277             :             }
    8278             : 
    8279         992 :             if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_CoolingTwoSpeed) {
    8280          67 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).EvapCondAirFlow2 > state.dataDXCoils->DXCoil(DXCoilNum).EvapCondAirFlow(Mode)) {
    8281           0 :                     ShowSevereError(state,
    8282           0 :                                     "SizeDXCoil: " + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + ' ' +
    8283           0 :                                         state.dataDXCoils->DXCoil(DXCoilNum).Name +
    8284             :                                         ", Evaporative Condenser low speed air flow must be less than or equal to high speed air flow.");
    8285           0 :                     ShowContinueError(state,
    8286           0 :                                       format("Instead, {:.2R} > {:.2R}",
    8287           0 :                                              state.dataDXCoils->DXCoil(DXCoilNum).EvapCondAirFlow2,
    8288           0 :                                              state.dataDXCoils->DXCoil(DXCoilNum).EvapCondAirFlow(Mode)));
    8289           0 :                     ShowFatalError(state, "Preceding conditions cause termination.");
    8290             :                 }
    8291             : 
    8292         134 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).EvapCondPumpElecNomPower2 >
    8293          67 :                     state.dataDXCoils->DXCoil(DXCoilNum).EvapCondPumpElecNomPower(Mode)) {
    8294           0 :                     ShowSevereError(state,
    8295           0 :                                     "SizeDXCoil: " + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + ' ' +
    8296           0 :                                         state.dataDXCoils->DXCoil(DXCoilNum).Name +
    8297             :                                         ", Evaporative Condenser low speed pump power must be less than or equal to high speed pump power.");
    8298           0 :                     ShowContinueError(state,
    8299           0 :                                       format("Instead, {:.2R} > {:.2R}",
    8300           0 :                                              state.dataDXCoils->DXCoil(DXCoilNum).EvapCondPumpElecNomPower2,
    8301           0 :                                              state.dataDXCoils->DXCoil(DXCoilNum).EvapCondPumpElecNomPower(Mode)));
    8302           0 :                     ShowFatalError(state, "Preceding conditions cause termination.");
    8303             :                 }
    8304             : 
    8305          67 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap2 > state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode)) {
    8306           0 :                     ShowSevereError(
    8307             :                         state,
    8308           0 :                         "SizeDXCoil: " + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + ' ' + state.dataDXCoils->DXCoil(DXCoilNum).Name +
    8309             :                             ", Rated Total Cooling Capacity, Low Speed must be less than or equal to Rated Total Cooling Capacity, High Speed.");
    8310           0 :                     ShowContinueError(state,
    8311           0 :                                       format("Instead, {:.2R} > {:.2R}",
    8312           0 :                                              state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap2,
    8313           0 :                                              state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode)));
    8314           0 :                     ShowFatalError(state, "Preceding conditions cause termination.");
    8315             :                 }
    8316             : 
    8317          67 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate2 > state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(Mode)) {
    8318           0 :                     ShowFatalError(
    8319             :                         state,
    8320           0 :                         "SizeDXCoil: " + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + ' ' + state.dataDXCoils->DXCoil(DXCoilNum).Name +
    8321             :                             ", Rated Air Volume Flow Rate, low speed must be less than or equal to Rated Air Volume Flow Rate, high speed.");
    8322           0 :                     ShowContinueError(state,
    8323           0 :                                       format("Instead, {:.2R} > {:.2R}",
    8324           0 :                                              state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate2,
    8325           0 :                                              state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(Mode)));
    8326           0 :                     ShowFatalError(state, "Preceding conditions cause termination.");
    8327             :                 }
    8328             :             }
    8329             : 
    8330             :             //                // Sizing rated low speed SHR2
    8331         992 :             if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_CoolingTwoSpeed) {
    8332          67 :                 CompName = state.dataDXCoils->DXCoil(DXCoilNum).Name;
    8333          67 :                 FieldNum = 7;
    8334          67 :                 SizingString = state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(Mode).FieldNames(FieldNum);
    8335          67 :                 SizingMethod = AutoCalculateSizing;
    8336          67 :                 CompType = state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType;
    8337             :                 // Auto size low speed SHR to be the same as high speed SHR
    8338          67 :                 state.dataSize->DataConstantUsedForSizing = state.dataDXCoils->DXCoil(DXCoilNum).RatedSHR(Mode);
    8339          67 :                 state.dataSize->DataFractionUsedForSizing = 1.0;
    8340          67 :                 state.dataSize->DataDXSpeedNum = 2; // refers to low speed in sizer
    8341          67 :                 bool ErrorsFound = false;
    8342          67 :                 TempSize = state.dataDXCoils->DXCoil(DXCoilNum).RatedSHR2;
    8343          67 :                 sizerCoolingSHR.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName);
    8344          67 :                 state.dataDXCoils->DXCoil(DXCoilNum).RatedSHR2 = sizerCoolingSHR.size(state, TempSize, ErrorsFound);
    8345          67 :                 state.dataSize->DataConstantUsedForSizing = 0.0;
    8346          67 :                 state.dataSize->DataFractionUsedForSizing = 0.0;
    8347          67 :                 state.dataSize->DataDXSpeedNum = 0;
    8348             :             }
    8349             : 
    8350             :             //                // Sizing resistive defrost heater capacity
    8351        2935 :             if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num != CoilVRF_Heating &&
    8352        1928 :                 state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num != CoilVRF_FluidTCtrl_Heating &&
    8353         936 :                 state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num != CoilDX_MultiSpeedHeating) {
    8354             :                 // IF (DXCoil(DXCoilNum)%DXCoilType_Num == CoilDX_MultiSpeedHeating .OR. &
    8355             :                 //    DXCoil(DXCoilNum)%DXCoilType_Num == Coil_HeatingAirToAirVariableSpeed) THEN
    8356         916 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).DefrostStrategy == StandardRatings::DefrostStrat::Resistive) {
    8357          46 :                     CompName = state.dataDXCoils->DXCoil(DXCoilNum).Name;
    8358          46 :                     CompType = state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType;
    8359             :                     // Auto size low speed capacity to 1/3 high speed capacity
    8360          46 :                     state.dataSize->DataConstantUsedForSizing = state.dataSize->DXCoolCap;
    8361          46 :                     state.dataSize->DataFractionUsedForSizing = 1.0;
    8362          46 :                     TempSize = state.dataDXCoils->DXCoil(DXCoilNum).DefrostCapacity;
    8363          92 :                     AutoCalculateSizer sizerResDefCap;
    8364          92 :                     std::string stringOverride = "Resistive Defrost Heater Capacity [W]";
    8365          46 :                     if (state.dataGlobal->isEpJSON) stringOverride = "resistive_defrost_heater_capacity [W]";
    8366          46 :                     sizerResDefCap.overrideSizingString(stringOverride);
    8367          46 :                     sizerResDefCap.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName);
    8368          46 :                     state.dataDXCoils->DXCoil(DXCoilNum).DefrostCapacity = sizerResDefCap.size(state, TempSize, ErrorsFound);
    8369             :                 } else {
    8370         870 :                     state.dataDXCoils->DXCoil(DXCoilNum).DefrostCapacity = 0.0;
    8371             :                 }
    8372             :             }
    8373             : 
    8374             :         } // End capacity stages loop
    8375             :     }     // End dehumidification modes loop
    8376             : 
    8377             :     // Autosizing for multispeed cooling coil
    8378         968 :     if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_MultiSpeedCooling) {
    8379             :         // flow rate auto size
    8380         157 :         for (Mode = state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds; Mode >= 1; --Mode) {
    8381             :             // Sizing multispeed air volume flow rate
    8382         109 :             IsAutoSize = false;
    8383         109 :             if (state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirVolFlowRate(Mode) == AutoSize) {
    8384           3 :                 IsAutoSize = true;
    8385             :             }
    8386         109 :             state.dataSize->DataIsDXCoil = true;
    8387         109 :             CompName = state.dataDXCoils->DXCoil(DXCoilNum).Name;
    8388         109 :             CompType = state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType;
    8389         109 :             if (Mode == state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds) {
    8390          48 :                 FieldNum = 10 + (Mode - 1) * 13;
    8391          48 :                 SizingString = state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(1).FieldNames(FieldNum) + " [m3/s]";
    8392          48 :                 TempSize = state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirVolFlowRate(Mode);
    8393          48 :                 state.dataSize->DataEMSOverrideON = state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRateEMSOverrideON(Mode);
    8394          48 :                 state.dataSize->DataEMSOverride = state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRateEMSOverrideValue(Mode);
    8395          48 :                 bool errorsFound = false;
    8396          96 :                 CoolingAirFlowSizer sizingCoolingAirFlow;
    8397          48 :                 sizingCoolingAirFlow.overrideSizingString(SizingString);
    8398             :                 // sizingCoolingAirFlow.setHVACSizingIndexData(FanCoil(FanCoilNum).HVACSizingIndex);
    8399          48 :                 sizingCoolingAirFlow.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName);
    8400          48 :                 TempSize = sizingCoolingAirFlow.size(state, TempSize, errorsFound);
    8401          48 :                 state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirVolFlowRate(Mode) = TempSize;
    8402          48 :                 state.dataSize->DataEMSOverrideON = false;
    8403          48 :                 state.dataSize->DataEMSOverride = 0.0;
    8404          48 :                 if (!IsAutoSize && !HardSizeNoDesRun) {
    8405          36 :                     TempSize = AutoSize;
    8406          36 :                     bPRINT = false;
    8407          36 :                     sizingCoolingAirFlow.initializeWithinEP(state, CompType, CompName, bPRINT, RoutineName);
    8408          36 :                     MSRatedAirVolFlowRateDes = sizingCoolingAirFlow.size(state, TempSize, errorsFound);
    8409          36 :                     bPRINT = true;
    8410             :                 }
    8411          48 :                 if (IsAutoSize) {
    8412           1 :                     MSRatedAirVolFlowRateDes = TempSize;
    8413             :                 }
    8414             :             } else {
    8415          61 :                 FieldNum = 10 + (Mode - 1) * 13;
    8416          61 :                 SizingString = state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(1).FieldNames(FieldNum) + " [m3/s]";
    8417          61 :                 if (IsAutoSize || !HardSizeNoDesRun) {
    8418          38 :                     SizingMethod = AutoCalculateSizing;
    8419             :                     // Auto size low speed flow to fraction of the highest speed flow
    8420          38 :                     state.dataSize->DataConstantUsedForSizing =
    8421          38 :                         state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirVolFlowRate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    8422          38 :                     if (!IsAutoSize && !HardSizeNoDesRun) state.dataSize->DataConstantUsedForSizing = MSRatedAirVolFlowRateDes;
    8423          38 :                     state.dataSize->DataFractionUsedForSizing = (float)Mode / state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds;
    8424             :                 }
    8425          61 :                 TempSize = state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirVolFlowRate(Mode);
    8426          61 :                 state.dataSize->DataEMSOverrideON = state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRateEMSOverrideON(Mode);
    8427          61 :                 state.dataSize->DataEMSOverride = state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRateEMSOverrideValue(Mode);
    8428          61 :                 bool errorsFound = false;
    8429         122 :                 CoolingAirFlowSizer sizingCoolingAirFlow;
    8430          61 :                 sizingCoolingAirFlow.overrideSizingString(SizingString);
    8431          61 :                 sizingCoolingAirFlow.initializeWithinEP(state, CompType, CompName, bPRINT, RoutineName);
    8432          61 :                 state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirVolFlowRate(Mode) = sizingCoolingAirFlow.size(state, TempSize, errorsFound);
    8433             :             }
    8434         109 :             state.dataSize->DataEMSOverride = 0.0;
    8435         109 :             state.dataSize->DataEMSOverrideON = false;
    8436         109 :             state.dataSize->DataIsDXCoil = false;
    8437         109 :             state.dataSize->DataTotCapCurveIndex = 0;
    8438         109 :             state.dataSize->DataConstantUsedForSizing = 0.0;
    8439         109 :             state.dataSize->DataFractionUsedForSizing = 0.0;
    8440             :         }
    8441             : 
    8442             :         // Ensure flow rate at lower speed must be lower or equal to the flow rate at higher speed. Otherwise, a severe error is isssued.
    8443         109 :         for (Mode = 1; Mode <= state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds - 1; ++Mode) {
    8444         122 :             if (state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirVolFlowRate(Mode) >
    8445          61 :                 state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirVolFlowRate(Mode + 1)) {
    8446           0 :                 ShowWarningError(state,
    8447           0 :                                  format("SizeDXCoil: {} {}, Speed {} Rated Air Flow Rate must be less than or equal to Speed {} Rated Air Flow Rate.",
    8448           0 :                                         state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
    8449           0 :                                         state.dataDXCoils->DXCoil(DXCoilNum).Name,
    8450             :                                         Mode,
    8451           0 :                                         Mode + 1));
    8452           0 :                 ShowContinueError(state,
    8453           0 :                                   format("Instead, {:.2R} > {:.2R}",
    8454           0 :                                          state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirVolFlowRate(Mode),
    8455           0 :                                          state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirVolFlowRate(Mode + 1)));
    8456           0 :                 ShowFatalError(state, "Preceding conditions cause termination.");
    8457             :             }
    8458             :         }
    8459             : 
    8460             :         // Sizing multispeed rated total cooling capacity
    8461         157 :         for (Mode = state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds; Mode >= 1; --Mode) {
    8462         109 :             IsAutoSize = false;
    8463         109 :             if (state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(Mode) == AutoSize) {
    8464           3 :                 IsAutoSize = true;
    8465             :             }
    8466         109 :             CompName = state.dataDXCoils->DXCoil(DXCoilNum).Name;
    8467         109 :             CompType = state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType;
    8468         109 :             state.dataSize->DataIsDXCoil = true;
    8469         109 :             state.dataSize->DataTotCapCurveIndex = state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFTemp(Mode);
    8470         109 :             if (Mode == state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds) {
    8471          48 :                 PrintFlag = true;
    8472          48 :                 state.dataSize->DataFlowUsedForSizing = state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirVolFlowRate(Mode);
    8473          48 :                 SizingMethod = CoolingCapacitySizing;
    8474          48 :                 FieldNum = 7 + (Mode - 1) * 13;
    8475          48 :                 SizingString = state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(1).FieldNames(FieldNum) + " [W]";
    8476          48 :                 state.dataSize->DataEMSOverrideON = state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCapEMSOverrideOn(Mode);
    8477          48 :                 state.dataSize->DataEMSOverride = state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCapEMSOverrideValue(Mode);
    8478          48 :                 MSRatedTotCapDesAtMaxSpeed = state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(Mode);
    8479          48 :                 if (!HardSizeNoDesRun) {
    8480          37 :                     PrintFlag = false;
    8481          37 :                     TempSize = DataSizing::AutoSize;
    8482             :                     // Auto size capacity at the highest speed
    8483          74 :                     CoolingCapacitySizer sizerCoolingCapacity;
    8484          37 :                     sizerCoolingCapacity.overrideSizingString(SizingString);
    8485          37 :                     sizerCoolingCapacity.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName);
    8486          37 :                     TempSize = sizerCoolingCapacity.size(state, TempSize, ErrorsFound);
    8487          37 :                     SizingMethod = AutoCalculateSizing;
    8488          37 :                     state.dataSize->DataConstantUsedForSizing = TempSize;
    8489          37 :                     state.dataSize->DataFractionUsedForSizing = 1.0;
    8490          37 :                     MSRatedTotCapDesAtMaxSpeed = TempSize;
    8491          37 :                     state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCapDes(Mode) = TempSize;
    8492          37 :                     PrintFlag = true;
    8493             :                 }
    8494          48 :                 TempSize = state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(Mode);
    8495          96 :                 CoolingCapacitySizer sizerCoolingCapacity2;
    8496          48 :                 sizerCoolingCapacity2.overrideSizingString(SizingString);
    8497          48 :                 sizerCoolingCapacity2.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName);
    8498          48 :                 TempSize = sizerCoolingCapacity2.size(state, TempSize, ErrorsFound);
    8499          48 :                 state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(Mode) = TempSize;
    8500          48 :                 if (IsAutoSize) {
    8501           1 :                     MSRatedTotCapDesAtMaxSpeed = TempSize;
    8502           1 :                     state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCapDes(Mode) = TempSize;
    8503             :                 }
    8504             :             } else {
    8505             :                 // cooling capacity at lower speeds
    8506          61 :                 PrintFlag = true;
    8507          61 :                 SizingMethod = CoolingCapacitySizing;
    8508          61 :                 FieldNum = 7 + (Mode - 1) * 13;
    8509          61 :                 SizingString = state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(1).FieldNames(FieldNum) + " [W]";
    8510          61 :                 if (IsAutoSize || !HardSizeNoDesRun) {
    8511          38 :                     SizingMethod = AutoCalculateSizing;
    8512             :                     // auto size low speed capacity to fraction of the highest speed capacity
    8513          38 :                     if (!HardSizeNoDesRun) {
    8514          38 :                         state.dataSize->DataConstantUsedForSizing = MSRatedTotCapDesAtMaxSpeed;
    8515             :                     } else {
    8516           0 :                         state.dataSize->DataConstantUsedForSizing =
    8517           0 :                             state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    8518             :                     }
    8519          38 :                     state.dataSize->DataFractionUsedForSizing = (float)Mode / state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds;
    8520          38 :                     state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCapDes(Mode) =
    8521          38 :                         state.dataSize->DataConstantUsedForSizing * state.dataSize->DataFractionUsedForSizing;
    8522             :                 }
    8523          61 :                 TempSize = state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(Mode);
    8524          61 :                 state.dataSize->DataEMSOverrideON = state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCapEMSOverrideOn(Mode);
    8525          61 :                 state.dataSize->DataEMSOverride = state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCapEMSOverrideValue(Mode);
    8526         122 :                 CoolingCapacitySizer sizerCoolingCapacity;
    8527          61 :                 sizerCoolingCapacity.overrideSizingString(SizingString);
    8528          61 :                 sizerCoolingCapacity.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName);
    8529          61 :                 state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(Mode) = sizerCoolingCapacity.size(state, TempSize, ErrorsFound);
    8530             :             }
    8531         109 :             state.dataSize->DataEMSOverride = 0.0;
    8532         109 :             state.dataSize->DataEMSOverrideON = false;
    8533         109 :             state.dataSize->DataIsDXCoil = false;
    8534         109 :             state.dataSize->DataCoolCoilCap = 0.0;
    8535         109 :             state.dataSize->DataTotCapCurveIndex = 0;
    8536         109 :             state.dataSize->DataConstantUsedForSizing = 0.0;
    8537         109 :             state.dataSize->DataFractionUsedForSizing = 0.0;
    8538             :         }
    8539             : 
    8540             :         // Ensure capacity at lower speed must be lower or equal to the capacity at higher speed.
    8541         109 :         for (Mode = 1; Mode <= state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds - 1; ++Mode) {
    8542          61 :             if (state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(Mode) > state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(Mode + 1)) {
    8543           0 :                 ShowWarningError(state,
    8544           0 :                                  format("SizeDXCoil: {} {}, Speed {} Rated Total Cooling Capacity must be less than or equal to Speed {} Rated "
    8545             :                                         "Total Cooling Capacity.",
    8546           0 :                                         state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
    8547           0 :                                         state.dataDXCoils->DXCoil(DXCoilNum).Name,
    8548             :                                         Mode,
    8549           0 :                                         Mode + 1));
    8550           0 :                 ShowContinueError(state,
    8551           0 :                                   format("Instead, {:.2R} > {:.2R}",
    8552           0 :                                          state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(Mode),
    8553           0 :                                          state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(Mode + 1)));
    8554           0 :                 ShowFatalError(state, "Preceding conditions cause termination.");
    8555             :             }
    8556             :         }
    8557             : 
    8558             :         // Rated SHR
    8559         157 :         for (Mode = state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds; Mode >= 1; --Mode) {
    8560         109 :             IsAutoSize = false;
    8561         109 :             if (state.dataDXCoils->DXCoil(DXCoilNum).MSRatedSHR(Mode) == AutoSize) {
    8562           3 :                 IsAutoSize = true;
    8563             :             }
    8564         109 :             if (Mode == state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds) {
    8565          48 :                 CompType = state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType;
    8566          48 :                 CompName = state.dataDXCoils->DXCoil(DXCoilNum).Name;
    8567          48 :                 TempSize = state.dataDXCoils->DXCoil(DXCoilNum).MSRatedSHR(Mode);
    8568          48 :                 state.dataSize->DataFlowUsedForSizing = MSRatedAirVolFlowRateDes;
    8569          48 :                 state.dataSize->DataCapacityUsedForSizing = MSRatedTotCapDesAtMaxSpeed;
    8570          48 :                 state.dataSize->DataEMSOverrideON = state.dataDXCoils->DXCoil(DXCoilNum).RatedSHREMSOverrideOn(Mode);
    8571          48 :                 state.dataSize->DataEMSOverride = state.dataDXCoils->DXCoil(DXCoilNum).RatedSHREMSOverrideValue(Mode);
    8572          48 :                 bool ErrorsFound = false;
    8573          48 :                 state.dataSize->DataDXSpeedNum = Mode;
    8574          48 :                 sizerCoolingSHR.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName);
    8575          48 :                 state.dataDXCoils->DXCoil(DXCoilNum).MSRatedSHR(Mode) = sizerCoolingSHR.size(state, TempSize, ErrorsFound);
    8576             :                 // added for rated sensible cooling capacity estimate for html reporting, issue #7381
    8577          48 :                 state.dataDXCoils->DXCoil(DXCoilNum).RatedSHR(1) = state.dataDXCoils->DXCoil(DXCoilNum).MSRatedSHR(Mode);
    8578             :                 // design SHR value at the maxiumum speed calculated above was supposed to be used for all speeds
    8579             :                 // Now user specified SHR value is used when the SHR field is not autosized and design day run is
    8580             :                 // set to yes unless the code below is commented out
    8581          48 :                 MSRatedSHRDes = state.dataDXCoils->DXCoil(DXCoilNum).MSRatedSHR(Mode);
    8582             :             } else {
    8583          61 :                 TempSize = state.dataDXCoils->DXCoil(DXCoilNum).MSRatedSHR(Mode);
    8584          61 :                 bool ErrorsFound = false;
    8585          61 :                 state.dataSize->DataDXSpeedNum = Mode;
    8586          61 :                 state.dataSize->DataFractionUsedForSizing = MSRatedSHRDes;
    8587          61 :                 state.dataSize->DataConstantUsedForSizing = 1.0;
    8588          61 :                 sizerCoolingSHR.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName);
    8589          61 :                 state.dataDXCoils->DXCoil(DXCoilNum).MSRatedSHR(Mode) = sizerCoolingSHR.size(state, TempSize, ErrorsFound);
    8590             :             }
    8591             :         }
    8592          48 :         state.dataSize->DataFlowUsedForSizing = 0.0;
    8593          48 :         state.dataSize->DataCapacityUsedForSizing = 0.0;
    8594          48 :         state.dataSize->DataEMSOverrideON = false;
    8595          48 :         state.dataSize->DataEMSOverride = 0.0;
    8596          48 :         state.dataSize->DataDXSpeedNum = 0;
    8597          48 :         state.dataSize->DataFractionUsedForSizing = 0.0;
    8598          48 :         state.dataSize->DataConstantUsedForSizing = 0.0;
    8599             : 
    8600             :         // Rated Evapovative condenser airflow rates
    8601         157 :         for (Mode = 1; Mode <= state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds; ++Mode) {
    8602         109 :             IsAutoSize = false;
    8603         109 :             if (state.dataDXCoils->DXCoil(DXCoilNum).MSEvapCondAirFlow(Mode) == AutoSize) {
    8604           0 :                 IsAutoSize = true;
    8605             :             }
    8606         109 :             if (IsAutoSize || !HardSizeNoDesRun) {
    8607             :                 // Auto size condenser air flow to Total Capacity * 0.000114 m3/s/w (850 cfm/ton)
    8608          75 :                 MSEvapCondAirFlowDes = ((float)Mode / state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds) * MSRatedTotCapDesAtMaxSpeed * 0.000114;
    8609             :             } else {
    8610             :                 // this is done to duplicate any existing calc method
    8611          34 :                 MSEvapCondAirFlowDes = state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(Mode) * 0.000114;
    8612             :             }
    8613         109 :             if (IsAutoSize) {
    8614           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).MSEvapCondAirFlow(Mode) = MSEvapCondAirFlowDes;
    8615           0 :                 BaseSizer::reportSizerOutput(state,
    8616           0 :                                              state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
    8617           0 :                                              state.dataDXCoils->DXCoil(DXCoilNum).Name,
    8618           0 :                                              format("Design Size Speed {} Evaporative Condenser Air Flow Rate [m3/s]", Mode),
    8619             :                                              MSEvapCondAirFlowDes);
    8620             :             } else {
    8621         109 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).MSEvapCondAirFlow(Mode) > 0.0 && MSEvapCondAirFlowDes > 0.0 && !HardSizeNoDesRun) {
    8622           8 :                     MSEvapCondAirFlowUser = state.dataDXCoils->DXCoil(DXCoilNum).MSEvapCondAirFlow(Mode);
    8623          56 :                     BaseSizer::reportSizerOutput(state,
    8624           8 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
    8625           8 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).Name,
    8626          16 :                                                  format("Design Size Speed {} Evaporative Condenser Air Flow Rate [m3/s]", Mode),
    8627             :                                                  MSEvapCondAirFlowDes,
    8628          16 :                                                  format("User-Specified Speed {} Evaporative Condenser Air Flow Rate [m3/s]", Mode),
    8629             :                                                  MSEvapCondAirFlowUser);
    8630           8 :                     if (state.dataGlobal->DisplayExtraWarnings) {
    8631           0 :                         if ((std::abs(MSEvapCondAirFlowDes - MSEvapCondAirFlowUser) / MSEvapCondAirFlowUser) >
    8632           0 :                             state.dataSize->AutoVsHardSizingThreshold) {
    8633           0 :                             ShowMessage(state,
    8634           0 :                                         "SizeDxCoil: Potential issue with equipment sizing for " + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType +
    8635           0 :                                             ' ' + state.dataDXCoils->DXCoil(DXCoilNum).Name);
    8636           0 :                             ShowContinueError(state,
    8637           0 :                                               format("User-Specified Evaporative Condenser Air Flow Rate of {:.5R} [m3/s]", MSEvapCondAirFlowUser));
    8638           0 :                             ShowContinueError(
    8639           0 :                                 state, format("differs from Design Size Evaporative Condenser Air Flow Rate of {:.5R} [m3/s]", MSEvapCondAirFlowDes));
    8640           0 :                             ShowContinueError(state, "This may, or may not, indicate mismatched component sizes.");
    8641           0 :                             ShowContinueError(state, "Verify that the value entered is intended and is consistent with other components.");
    8642             :                         }
    8643             :                     }
    8644             :                 }
    8645             :             }
    8646             :         }
    8647             : 
    8648             :         // Ensure evaporative condenser airflow rate at lower speed must be lower or equal to one at higher speed.
    8649         109 :         for (Mode = 1; Mode <= state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds - 1; ++Mode) {
    8650          61 :             if (state.dataDXCoils->DXCoil(DXCoilNum).MSEvapCondAirFlow(Mode) > state.dataDXCoils->DXCoil(DXCoilNum).MSEvapCondAirFlow(Mode + 1)) {
    8651           0 :                 ShowWarningError(state,
    8652           0 :                                  format("SizeDXCoil: {} {}, Speed {} Evaporative Condenser Air Flow Rate must be less than or equal to Speed {} "
    8653             :                                         "Evaporative Condenser Air Flow Rate.",
    8654           0 :                                         state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
    8655           0 :                                         state.dataDXCoils->DXCoil(DXCoilNum).Name,
    8656             :                                         Mode,
    8657           0 :                                         Mode + 1));
    8658           0 :                 ShowContinueError(state,
    8659           0 :                                   format("Instead, {:.2R} > {:.2R}",
    8660           0 :                                          state.dataDXCoils->DXCoil(DXCoilNum).MSEvapCondAirFlow(Mode),
    8661           0 :                                          state.dataDXCoils->DXCoil(DXCoilNum).MSEvapCondAirFlow(Mode + 1)));
    8662           0 :                 ShowFatalError(state, "Preceding conditions cause termination.");
    8663             :             }
    8664             :         }
    8665             : 
    8666             :         // Sizing multispeed rated evapovative condenser pump power
    8667         157 :         for (Mode = 1; Mode <= state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds; ++Mode) {
    8668         109 :             IsAutoSize = false;
    8669         109 :             if (state.dataDXCoils->DXCoil(DXCoilNum).MSEvapCondPumpElecNomPower(Mode) == AutoSize) {
    8670           0 :                 IsAutoSize = true;
    8671             :             }
    8672             : 
    8673         109 :             if (IsAutoSize || !HardSizeNoDesRun) {
    8674             :                 // Auto size low speed evap condenser pump power to 1/3 Total Capacity * 0.004266 w/w (15 w/ton)
    8675          75 :                 MSEvapCondPumpElecNomPowerDes =
    8676          75 :                     ((float)Mode / state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds) * MSRatedTotCapDesAtMaxSpeed * 0.004266;
    8677             :             } else {
    8678             :                 // this is done to duplicate any existing calc method
    8679          34 :                 MSEvapCondPumpElecNomPowerDes = state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(Mode) * 0.004266;
    8680             :             }
    8681             :             // Design Size data is always available
    8682         109 :             if (IsAutoSize) {
    8683           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).MSEvapCondPumpElecNomPower(Mode) = MSEvapCondPumpElecNomPowerDes;
    8684           0 :                 BaseSizer::reportSizerOutput(state,
    8685           0 :                                              state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
    8686           0 :                                              state.dataDXCoils->DXCoil(DXCoilNum).Name,
    8687           0 :                                              format("Design Size Speed {} Rated Evaporative Condenser Pump Power Consumption [W]", Mode),
    8688             :                                              MSEvapCondPumpElecNomPowerDes);
    8689             :             } else {
    8690         151 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).MSEvapCondPumpElecNomPower(Mode) > 0.0 && MSEvapCondPumpElecNomPowerDes > 0.0 &&
    8691          42 :                     !HardSizeNoDesRun) {
    8692           8 :                     MSEvapCondPumpElecNomPowerUser = state.dataDXCoils->DXCoil(DXCoilNum).MSEvapCondPumpElecNomPower(Mode);
    8693          56 :                     BaseSizer::reportSizerOutput(state,
    8694           8 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
    8695           8 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).Name,
    8696          16 :                                                  format("Design Size Speed {} Rated Evaporative Condenser Pump Power Consumption [W]", Mode),
    8697             :                                                  MSEvapCondPumpElecNomPowerDes,
    8698          16 :                                                  format("User-Specified Speed {} Rated Evaporative Condenser Pump Power Consumption [W]", Mode),
    8699             :                                                  MSEvapCondPumpElecNomPowerUser);
    8700           8 :                     if (state.dataGlobal->DisplayExtraWarnings) {
    8701           0 :                         if ((std::abs(MSEvapCondPumpElecNomPowerDes - MSEvapCondPumpElecNomPowerUser) / MSEvapCondPumpElecNomPowerUser) >
    8702           0 :                             state.dataSize->AutoVsHardSizingThreshold) {
    8703           0 :                             ShowMessage(state,
    8704           0 :                                         "SizeDxCoil: Potential issue with equipment sizing for " + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType +
    8705           0 :                                             ' ' + state.dataDXCoils->DXCoil(DXCoilNum).Name);
    8706           0 :                             ShowContinueError(state,
    8707           0 :                                               format("User-Specified Evaporative Condenser Pump Rated Power Consumption of {:.2R} [W]",
    8708           0 :                                                      MSEvapCondPumpElecNomPowerUser));
    8709           0 :                             ShowContinueError(state,
    8710           0 :                                               format("differs from Design Size Evaporative Condenser Pump Rated Power Consumption of {:.2R} [W]",
    8711           0 :                                                      MSEvapCondPumpElecNomPowerDes));
    8712           0 :                             ShowContinueError(state, "This may, or may not, indicate mismatched component sizes.");
    8713           0 :                             ShowContinueError(state, "Verify that the value entered is intended and is consistent with other components.");
    8714             :                         }
    8715             :                     }
    8716             :                 }
    8717             :             }
    8718             :         }
    8719             : 
    8720             :         // Ensure evaporative condesner pump power at lower speed must be lower or equal to one at higher speed.
    8721         109 :         for (Mode = 1; Mode <= state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds - 1; ++Mode) {
    8722         122 :             if (state.dataDXCoils->DXCoil(DXCoilNum).MSEvapCondPumpElecNomPower(Mode) >
    8723          61 :                 state.dataDXCoils->DXCoil(DXCoilNum).MSEvapCondPumpElecNomPower(Mode + 1)) {
    8724           0 :                 ShowWarningError(state,
    8725           0 :                                  format("SizeDXCoil: {} {}, Speed {} Rated Evaporative Condenser Pump Power Consumption must be less than or "
    8726             :                                         "equal to Speed {} Rated Evaporative Condenser Pump Power Consumption.",
    8727           0 :                                         state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
    8728           0 :                                         state.dataDXCoils->DXCoil(DXCoilNum).Name,
    8729             :                                         Mode,
    8730           0 :                                         Mode + 1));
    8731           0 :                 ShowContinueError(state,
    8732           0 :                                   format("Instead, {:.2R} > {:.2R}",
    8733           0 :                                          state.dataDXCoils->DXCoil(DXCoilNum).MSEvapCondPumpElecNomPower(Mode),
    8734           0 :                                          state.dataDXCoils->DXCoil(DXCoilNum).MSEvapCondPumpElecNomPower(Mode + 1)));
    8735           0 :                 ShowFatalError(state, "Preceding conditions cause termination.");
    8736             :             }
    8737             :         }
    8738             :     }
    8739             : 
    8740             :     // Autosizing for multispeed heating coil
    8741         968 :     if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_MultiSpeedHeating) {
    8742             :         // flow rate auto size
    8743          82 :         for (Mode = state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds; Mode >= 1; --Mode) {
    8744          62 :             IsAutoSize = false;
    8745          62 :             if (state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirVolFlowRate(Mode) == AutoSize) {
    8746          24 :                 IsAutoSize = true;
    8747             :             }
    8748          62 :             state.dataSize->DataIsDXCoil = true;
    8749          62 :             CompName = state.dataDXCoils->DXCoil(DXCoilNum).Name;
    8750          62 :             CompType = state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType;
    8751             :             // Sizing rated air flow rate
    8752          62 :             if (Mode == state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds) {
    8753          20 :                 FieldNum = 12 + (Mode - 1) * 5;
    8754          20 :                 SizingString = state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(1).FieldNames(FieldNum) + " [m3/s]";
    8755          20 :                 TempSize = state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirVolFlowRate(Mode);
    8756          20 :                 state.dataSize->DataEMSOverrideON = state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRateEMSOverrideON(Mode);
    8757          20 :                 state.dataSize->DataEMSOverride = state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRateEMSOverrideValue(Mode);
    8758          20 :                 bool errorsFound = false;
    8759          40 :                 HeatingAirFlowSizer sizingHeatingAirFlow;
    8760          20 :                 sizingHeatingAirFlow.overrideSizingString(SizingString);
    8761             :                 // sizingHeatingAirFlow.setHVACSizingIndexData(FanCoil(FanCoilNum).HVACSizingIndex);
    8762          20 :                 sizingHeatingAirFlow.initializeWithinEP(state, CompType, CompName, bPRINT, RoutineName);
    8763          20 :                 state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirVolFlowRate(Mode) = sizingHeatingAirFlow.size(state, TempSize, errorsFound);
    8764          20 :                 if (!IsAutoSize && !HardSizeNoDesRun) {
    8765           5 :                     TempSize = AutoSize;
    8766           5 :                     bPRINT = false;
    8767           5 :                     errorsFound = false;
    8768          10 :                     HeatingAirFlowSizer sizingHeatingAirFlow2;
    8769           5 :                     sizingHeatingAirFlow2.overrideSizingString(SizingString);
    8770             :                     // sizingHeatingAirFlow.setHVACSizingIndexData(FanCoil(FanCoilNum).HVACSizingIndex);
    8771           5 :                     sizingHeatingAirFlow2.initializeWithinEP(state, CompType, CompName, bPRINT, RoutineName);
    8772           5 :                     MSRatedAirVolFlowRateDes = sizingHeatingAirFlow2.size(state, TempSize, errorsFound);
    8773           5 :                     bPRINT = true;
    8774             :                 }
    8775             :             } else {
    8776          42 :                 FieldNum = 12 + (Mode - 1) * 5;
    8777          42 :                 SizingString = state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(1).FieldNames(FieldNum) + " [m3/s]";
    8778          42 :                 if (IsAutoSize || !HardSizeNoDesRun) {
    8779          25 :                     SizingMethod = AutoCalculateSizing;
    8780             :                     // Auto size low speed flow to fraction of the highest speed capacity
    8781          25 :                     state.dataSize->DataConstantUsedForSizing =
    8782          25 :                         state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirVolFlowRate(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    8783          25 :                     if (!IsAutoSize && !HardSizeNoDesRun) state.dataSize->DataConstantUsedForSizing = MSRatedAirVolFlowRateDes;
    8784          25 :                     state.dataSize->DataFractionUsedForSizing = (float)Mode / state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds;
    8785             :                 }
    8786          42 :                 TempSize = state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirVolFlowRate(Mode);
    8787          42 :                 bool errorsFound = false;
    8788          84 :                 HeatingAirFlowSizer sizingHeatingAirFlow;
    8789          42 :                 sizingHeatingAirFlow.overrideSizingString(SizingString);
    8790             :                 // sizingHeatingAirFlow.setHVACSizingIndexData(FanCoil(FanCoilNum).HVACSizingIndex);
    8791          42 :                 sizingHeatingAirFlow.initializeWithinEP(state, CompType, CompName, bPRINT, RoutineName);
    8792          42 :                 state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirVolFlowRate(Mode) = sizingHeatingAirFlow.size(state, TempSize, errorsFound);
    8793             :             }
    8794          62 :             state.dataSize->DataEMSOverride = 0.0;
    8795          62 :             state.dataSize->DataEMSOverrideON = false;
    8796          62 :             state.dataSize->DataIsDXCoil = false;
    8797          62 :             state.dataSize->DataTotCapCurveIndex = 0;
    8798          62 :             state.dataSize->DataConstantUsedForSizing = 0.0;
    8799          62 :             state.dataSize->DataFractionUsedForSizing = 0.0;
    8800             :         }
    8801             : 
    8802             :         // Ensure flow rate at lower speed must be lower or equal to the flow rate at higher speed. Otherwise, a severe error is isssued.
    8803          62 :         for (Mode = 1; Mode <= state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds - 1; ++Mode) {
    8804          84 :             if (state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirVolFlowRate(Mode) >
    8805          42 :                 state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirVolFlowRate(Mode + 1)) {
    8806           0 :                 ShowWarningError(state,
    8807           0 :                                  format("SizeDXCoil: {} {}, Speed {} Rated Air Flow Rate must be less than or equal to Speed {} Rated Air Flow Rate.",
    8808           0 :                                         state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
    8809           0 :                                         state.dataDXCoils->DXCoil(DXCoilNum).Name,
    8810             :                                         Mode,
    8811           0 :                                         Mode + 1));
    8812           0 :                 ShowContinueError(state,
    8813           0 :                                   format("Instead, {:.2R} > {:.2R}",
    8814           0 :                                          state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirVolFlowRate(Mode),
    8815           0 :                                          state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirVolFlowRate(Mode + 1)));
    8816           0 :                 ShowFatalError(state, "Preceding conditions cause termination.");
    8817             :             }
    8818             :         }
    8819             :         // Rated Secondary Coil Airflow Rates for AirCooled condenser type
    8820          20 :         if (state.dataDXCoils->DXCoil(DXCoilNum).IsSecondaryDXCoilInZone) {
    8821           0 :             for (Mode = state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds; Mode >= 1; --Mode) {
    8822           0 :                 IsAutoSize = false;
    8823           0 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).MSSecCoilAirFlow(Mode) == AutoSize) {
    8824           0 :                     IsAutoSize = true;
    8825             :                 }
    8826             :                 // Auto size Primary Coil air flow * Secondary Coil Scaling Factor
    8827           0 :                 SecCoilAirFlowDes = state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirVolFlowRate(Mode) *
    8828           0 :                                     state.dataDXCoils->DXCoil(DXCoilNum).MSSecCoilAirFlowScalingFactor(Mode);
    8829           0 :                 if (IsAutoSize) {
    8830           0 :                     state.dataDXCoils->DXCoil(DXCoilNum).MSSecCoilAirFlow(Mode) = SecCoilAirFlowDes;
    8831           0 :                     BaseSizer::reportSizerOutput(state,
    8832           0 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
    8833           0 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).Name,
    8834           0 :                                                  format("Design Size Speed {} Secondary Coil Air Flow Rate [m3/s]", Mode),
    8835             :                                                  SecCoilAirFlowDes);
    8836             :                 } else {
    8837           0 :                     if (state.dataDXCoils->DXCoil(DXCoilNum).MSSecCoilAirFlow(Mode) > 0.0 && SecCoilAirFlowDes > 0.0 && !HardSizeNoDesRun) {
    8838           0 :                         SecCoilAirFlowUser = state.dataDXCoils->DXCoil(DXCoilNum).MSSecCoilAirFlow(Mode);
    8839           0 :                         BaseSizer::reportSizerOutput(state,
    8840           0 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
    8841           0 :                                                      state.dataDXCoils->DXCoil(DXCoilNum).Name,
    8842           0 :                                                      format("Design Size Speed {} Secondary Coil Air Flow Rate [m3/s]", Mode),
    8843             :                                                      SecCoilAirFlowDes,
    8844           0 :                                                      format("User-Specified Speed {} Secondary Coil Air Flow Rate [m3/s]", Mode),
    8845             :                                                      SecCoilAirFlowUser);
    8846           0 :                         if (state.dataGlobal->DisplayExtraWarnings) {
    8847           0 :                             if ((std::abs(SecCoilAirFlowDes - SecCoilAirFlowUser) / SecCoilAirFlowUser) > state.dataSize->AutoVsHardSizingThreshold) {
    8848           0 :                                 ShowMessage(state,
    8849           0 :                                             "SizeDxCoil: Potential issue with equipment sizing for " +
    8850           0 :                                                 state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + ' ' + state.dataDXCoils->DXCoil(DXCoilNum).Name);
    8851           0 :                                 ShowContinueError(state, format("User-Specified Secondary Coil Air Flow Rate of {:.5R} [m3/s]", SecCoilAirFlowUser));
    8852           0 :                                 ShowContinueError(
    8853           0 :                                     state, format("differs from Design Size Secondary Coil Air Flow Rate of {:.5R} [m3/s]", SecCoilAirFlowDes));
    8854           0 :                                 ShowContinueError(state, "This may, or may not, indicate mismatched component sizes.");
    8855           0 :                                 ShowContinueError(state, "Verify that the value entered is intended and is consistent with other components.");
    8856             :                             }
    8857             :                         }
    8858             :                     }
    8859             :                 }
    8860             :             }
    8861             :         }
    8862             : 
    8863             :         // Sizing rated total heating capacity
    8864          82 :         for (Mode = state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds; Mode >= 1; --Mode) {
    8865          62 :             IsAutoSize = false;
    8866          62 :             if (state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(Mode) == AutoSize) {
    8867          28 :                 IsAutoSize = true;
    8868             :             }
    8869          62 :             state.dataSize->DataIsDXCoil = true;
    8870          62 :             CompName = state.dataDXCoils->DXCoil(DXCoilNum).Name;
    8871          62 :             CompType = state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType;
    8872          62 :             if (Mode == state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds) {
    8873          20 :                 SizingMethod = HeatingCapacitySizing;
    8874          20 :                 state.dataSize->DataFlowUsedForSizing = state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirVolFlowRate(Mode);
    8875          20 :                 FieldNum = 10 + (Mode - 1) * 5;
    8876          20 :                 SizingString = state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(1).FieldNames(FieldNum) + " [W]";
    8877          20 :                 state.dataSize->DataTotCapCurveIndex = state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFTemp(Mode);
    8878          20 :                 if (IsAutoSize || !HardSizeNoDesRun) {
    8879             :                     // Heating capacity is assumed to be equal to the cooling capacity
    8880          11 :                     PrintFlag = false;
    8881          11 :                     SizingMethod = AutoCalculateSizing;
    8882          11 :                     state.dataSize->DataFractionUsedForSizing = 1.0;
    8883          11 :                     if (state.dataDXCoils->DXCoil(DXCoilNum).CompanionUpstreamDXCoil > 0) {
    8884           4 :                         NumOfSpeedCompanion = state.dataDXCoils->DXCoil(state.dataDXCoils->DXCoil(DXCoilNum).CompanionUpstreamDXCoil).NumOfSpeeds;
    8885           4 :                         state.dataSize->DataConstantUsedForSizing =
    8886           4 :                             state.dataDXCoils->DXCoil(state.dataDXCoils->DXCoil(DXCoilNum).CompanionUpstreamDXCoil)
    8887           4 :                                 .MSRatedTotCapDes(NumOfSpeedCompanion);
    8888             :                     } else {
    8889           7 :                         state.dataSize->DataConstantUsedForSizing = state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(1); // sized above
    8890             :                     }
    8891          11 :                     TempSize = DataSizing::AutoSize;
    8892          11 :                     state.dataSize->DataEMSOverrideON = state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCapEMSOverrideOn(Mode);
    8893          11 :                     state.dataSize->DataEMSOverride = state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCapEMSOverrideValue(Mode);
    8894          22 :                     HeatingCapacitySizer sizerHeatingCapacity;
    8895          11 :                     sizerHeatingCapacity.overrideSizingString(SizingString);
    8896          11 :                     sizerHeatingCapacity.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName);
    8897          11 :                     MSRatedTotCapDesAtMaxSpeed = sizerHeatingCapacity.size(state, TempSize, ErrorsFound);
    8898          11 :                     SizingMethod = AutoCalculateSizing;
    8899          11 :                     state.dataSize->DataConstantUsedForSizing = MSRatedTotCapDesAtMaxSpeed;
    8900          11 :                     state.dataSize->DataFractionUsedForSizing = 1.0;
    8901             :                 }
    8902          20 :                 PrintFlag = true;
    8903          20 :                 TempSize = state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(Mode);
    8904          20 :                 state.dataSize->DataEMSOverrideON = state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCapEMSOverrideOn(Mode);
    8905          20 :                 state.dataSize->DataEMSOverride = state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCapEMSOverrideValue(Mode);
    8906          40 :                 HeatingCapacitySizer sizerHeatingCapacity;
    8907          20 :                 sizerHeatingCapacity.overrideSizingString(SizingString);
    8908          20 :                 sizerHeatingCapacity.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName);
    8909          20 :                 TempSize = sizerHeatingCapacity.size(state, TempSize, ErrorsFound);
    8910          20 :                 state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(Mode) = TempSize;
    8911          20 :                 if (IsAutoSize) {
    8912           8 :                     MSRatedTotCapDesAtMaxSpeed = TempSize;
    8913             :                 }
    8914             :             } else {
    8915          42 :                 PrintFlag = true;
    8916          42 :                 SizingMethod = HeatingCapacitySizing;
    8917          42 :                 FieldNum = 10 + (Mode - 1) * 5;
    8918          42 :                 SizingString = state.dataDXCoils->DXCoilNumericFields(DXCoilNum).PerfMode(1).FieldNames(FieldNum) + " [W]";
    8919          42 :                 if (IsAutoSize || !HardSizeNoDesRun) {
    8920          25 :                     SizingMethod = AutoCalculateSizing;
    8921             :                     // auto size low speed capacity to fraction of the highest speed capacity
    8922          25 :                     if (!HardSizeNoDesRun) {
    8923          25 :                         state.dataSize->DataConstantUsedForSizing = MSRatedTotCapDesAtMaxSpeed;
    8924             :                     } else {
    8925           0 :                         state.dataSize->DataConstantUsedForSizing =
    8926           0 :                             state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds);
    8927             :                     }
    8928          25 :                     state.dataSize->DataFractionUsedForSizing = (float)Mode / state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds;
    8929             :                 }
    8930          42 :                 TempSize = state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(Mode);
    8931          42 :                 state.dataSize->DataEMSOverrideON = state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCapEMSOverrideOn(Mode);
    8932          42 :                 state.dataSize->DataEMSOverride = state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCapEMSOverrideValue(Mode);
    8933          84 :                 HeatingCapacitySizer sizerHeatingCapacity;
    8934          42 :                 sizerHeatingCapacity.overrideSizingString(SizingString);
    8935          42 :                 sizerHeatingCapacity.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName);
    8936          42 :                 TempSize = sizerHeatingCapacity.size(state, TempSize, ErrorsFound);
    8937          42 :                 state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(Mode) = TempSize;
    8938             :             }
    8939          62 :             PrintFlag = false;
    8940          62 :             state.dataSize->DataEMSOverrideON = false;
    8941          62 :             state.dataSize->DataEMSOverride = 0.0;
    8942          62 :             state.dataSize->DataIsDXCoil = false;
    8943          62 :             state.dataSize->DataFlowUsedForSizing = 0.0;
    8944          62 :             state.dataSize->DataCoolCoilCap = 0.0;
    8945          62 :             state.dataSize->DataTotCapCurveIndex = 0;
    8946          62 :             state.dataSize->DataConstantUsedForSizing = 0.0;
    8947          62 :             state.dataSize->DataFractionUsedForSizing = 0.0;
    8948             :         }
    8949             :         // Ensure capacity at lower speed must be lower or equal to the capacity at higher speed.
    8950          62 :         for (Mode = 1; Mode <= state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds - 1; ++Mode) {
    8951          42 :             if (state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(Mode) > state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(Mode + 1)) {
    8952           0 :                 ShowWarningError(state,
    8953           0 :                                  format("SizeDXCoil: {} {}, Speed {} Rated Total Heating Capacity must be less than or equal to Speed {} Rated "
    8954             :                                         "Total Heating Capacity.",
    8955           0 :                                         state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
    8956           0 :                                         state.dataDXCoils->DXCoil(DXCoilNum).Name,
    8957             :                                         Mode,
    8958           0 :                                         Mode + 1));
    8959           0 :                 ShowContinueError(state,
    8960           0 :                                   format("Instead, {:.2R} > {:.2R}",
    8961           0 :                                          state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(Mode),
    8962           0 :                                          state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(Mode + 1)));
    8963           0 :                 ShowFatalError(state, "Preceding conditions cause termination.");
    8964             :             }
    8965             :         }
    8966             : 
    8967             :         // Resistive Defrost Heater Capacity = capacity at the first stage
    8968             :         // Sizing defrost heater capacity
    8969          20 :         IsAutoSize = false;
    8970          20 :         if (state.dataDXCoils->DXCoil(DXCoilNum).DefrostCapacity == AutoSize) {
    8971           6 :             IsAutoSize = true;
    8972             :         }
    8973          20 :         if (state.dataDXCoils->DXCoil(DXCoilNum).DefrostStrategy == StandardRatings::DefrostStrat::Resistive) {
    8974           0 :             DefrostCapacityDes = state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(1);
    8975             :         } else {
    8976          20 :             DefrostCapacityDes = 0.0;
    8977             :         }
    8978          20 :         if (IsAutoSize) {
    8979           6 :             state.dataDXCoils->DXCoil(DXCoilNum).DefrostCapacity = DefrostCapacityDes;
    8980          18 :             BaseSizer::reportSizerOutput(state,
    8981           6 :                                          state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
    8982           6 :                                          state.dataDXCoils->DXCoil(DXCoilNum).Name,
    8983             :                                          "Design Size Resistive Defrost Heater Capacity",
    8984           6 :                                          DefrostCapacityDes);
    8985             :         } else {
    8986          14 :             if (state.dataDXCoils->DXCoil(DXCoilNum).DefrostCapacity > 0.0 && DefrostCapacityDes > 0.0 && !HardSizeNoDesRun) {
    8987           0 :                 DefrostCapacityUser = state.dataDXCoils->DXCoil(DXCoilNum).DefrostCapacity;
    8988           0 :                 BaseSizer::reportSizerOutput(state,
    8989           0 :                                              state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
    8990           0 :                                              state.dataDXCoils->DXCoil(DXCoilNum).Name,
    8991             :                                              "Design Size Resistive Defrost Heater Capacity",
    8992             :                                              DefrostCapacityDes,
    8993             :                                              "User-Specified Resistive Defrost Heater Capacity",
    8994           0 :                                              DefrostCapacityUser);
    8995           0 :                 if (state.dataGlobal->DisplayExtraWarnings) {
    8996           0 :                     if ((std::abs(DefrostCapacityDes - DefrostCapacityUser) / DefrostCapacityUser) > state.dataSize->AutoVsHardSizingThreshold) {
    8997           0 :                         ShowWarningMessage(state,
    8998           0 :                                            "SizeDxCoil: Potential issue with equipment sizing for " +
    8999           0 :                                                state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + ' ' + state.dataDXCoils->DXCoil(DXCoilNum).Name);
    9000           0 :                         ShowContinueError(state, format("User-Specified Resistive Defrost Heater Capacity of {:.2R}[W]", DefrostCapacityUser));
    9001           0 :                         ShowContinueError(state,
    9002           0 :                                           format("differs from Design Size Resistive Defrost Heater Capacity of {:.2R}[W]", DefrostCapacityDes));
    9003           0 :                         ShowContinueError(state, "This may, or may not, indicate mismatched component sizes.");
    9004           0 :                         ShowContinueError(state, "Verify that the value entered is intended and is consistent with other components.");
    9005             :                     }
    9006             :                 }
    9007             :             }
    9008             :         }
    9009             :     }
    9010             : 
    9011             :     // Call routine that computes AHRI certified rating for single-speed DX Coils
    9012        2541 :     if ((state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_CoolingSingleSpeed &&
    9013        1332 :          state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(1) == DataHeatBalance::RefrigCondenserType::Air) ||
    9014         364 :         state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_HeatingEmpirical) {
    9015       12863 :         CalcDXCoilStandardRating(state,
    9016         677 :                                  state.dataDXCoils->DXCoil(DXCoilNum).Name,
    9017         677 :                                  state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
    9018         677 :                                  state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num,
    9019             :                                  1,
    9020         677 :                                  state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(1),
    9021         677 :                                  state.dataDXCoils->DXCoil(DXCoilNum).RatedCOP(1),
    9022         677 :                                  state.dataDXCoils->DXCoil(DXCoilNum).CCapFFlow(1),
    9023         677 :                                  state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(1),
    9024         677 :                                  state.dataDXCoils->DXCoil(DXCoilNum).EIRFFlow(1),
    9025         677 :                                  state.dataDXCoils->DXCoil(DXCoilNum).EIRFTemp(1),
    9026         677 :                                  state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(1),
    9027         677 :                                  state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(1),
    9028         677 :                                  state.dataDXCoils->DXCoil(DXCoilNum).FanPowerPerEvapAirFlowRate(1),
    9029         677 :                                  state.dataDXCoils->DXCoil(DXCoilNum).FanPowerPerEvapAirFlowRate_2023(1),
    9030         677 :                                  state.dataDXCoils->DXCoil(DXCoilNum).RegionNum,
    9031         677 :                                  state.dataDXCoils->DXCoil(DXCoilNum).MinOATCompressor,
    9032         677 :                                  state.dataDXCoils->DXCoil(DXCoilNum).OATempCompressorOn,
    9033         677 :                                  state.dataDXCoils->DXCoil(DXCoilNum).OATempCompressorOnOffBlank,
    9034         677 :                                  state.dataDXCoils->DXCoil(DXCoilNum).DefrostControl,
    9035         677 :                                  state.dataDXCoils->DXCoil(DXCoilNum).ASHRAE127StdRprt);
    9036             :     }
    9037             :     // Call routine that computes AHRI certified rating for multi-speed DX cooling Coils
    9038        1888 :     if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_MultiSpeedCooling ||
    9039         920 :         state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_MultiSpeedHeating) {
    9040        1292 :         CalcDXCoilStandardRating(state,
    9041          68 :                                  state.dataDXCoils->DXCoil(DXCoilNum).Name,
    9042          68 :                                  state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
    9043          68 :                                  state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num,
    9044          68 :                                  state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds,
    9045          68 :                                  state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap,
    9046          68 :                                  state.dataDXCoils->DXCoil(DXCoilNum).MSRatedCOP,
    9047          68 :                                  state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFFlow,
    9048          68 :                                  state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFTemp,
    9049          68 :                                  state.dataDXCoils->DXCoil(DXCoilNum).MSEIRFFlow,
    9050          68 :                                  state.dataDXCoils->DXCoil(DXCoilNum).MSEIRFTemp,
    9051          68 :                                  state.dataDXCoils->DXCoil(DXCoilNum).MSPLFFPLR,
    9052          68 :                                  state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirVolFlowRate,
    9053          68 :                                  state.dataDXCoils->DXCoil(DXCoilNum).MSFanPowerPerEvapAirFlowRate,
    9054          68 :                                  state.dataDXCoils->DXCoil(DXCoilNum).MSFanPowerPerEvapAirFlowRate_2023,
    9055          68 :                                  state.dataDXCoils->DXCoil(DXCoilNum).RegionNum,
    9056          68 :                                  state.dataDXCoils->DXCoil(DXCoilNum).MinOATCompressor,
    9057          68 :                                  state.dataDXCoils->DXCoil(DXCoilNum).OATempCompressorOn,
    9058          68 :                                  state.dataDXCoils->DXCoil(DXCoilNum).OATempCompressorOnOffBlank,
    9059          68 :                                  state.dataDXCoils->DXCoil(DXCoilNum).DefrostControl,
    9060         136 :                                  ObjexxFCL::Optional_bool_const());
    9061             :     }
    9062             : 
    9063             :     // create predefined report entries
    9064         968 :     equipName = state.dataDXCoils->DXCoil(DXCoilNum).Name;
    9065             :     // put tables for cooling and heating separate
    9066         968 :     switch (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num) {
    9067         731 :     case CoilDX_CoolingSingleSpeed:
    9068             :     case CoilDX_CoolingTwoSpeed:
    9069             :     case CoilDX_CoolingTwoStageWHumControl:
    9070             :     case CoilDX_MultiSpeedCooling: {
    9071         731 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoolCoilType, equipName, state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType);
    9072         731 :         if (state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds == 0) {
    9073         683 :             if (state.dataDXCoils->DXCoil(DXCoilNum).NumCapacityStages == 1) {
    9074        2019 :                 PreDefTableEntry(
    9075        1346 :                     state, state.dataOutRptPredefined->pdchCoolCoilTotCap, equipName, state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(1));
    9076        2019 :                 PreDefTableEntry(state,
    9077         673 :                                  state.dataOutRptPredefined->pdchCoolCoilSensCap,
    9078             :                                  equipName,
    9079         673 :                                  state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(1) * state.dataDXCoils->DXCoil(DXCoilNum).RatedSHR(1));
    9080        2019 :                 PreDefTableEntry(state,
    9081         673 :                                  state.dataOutRptPredefined->pdchCoolCoilLatCap,
    9082             :                                  equipName,
    9083         673 :                                  state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(1) -
    9084         673 :                                      state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(1) * state.dataDXCoils->DXCoil(DXCoilNum).RatedSHR(1));
    9085         673 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoolCoilSHR, equipName, state.dataDXCoils->DXCoil(DXCoilNum).RatedSHR(1));
    9086         673 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoolCoilNomEff, equipName, state.dataDXCoils->DXCoil(DXCoilNum).RatedCOP(1));
    9087             :             } else {
    9088          30 :                 PreDefTableEntry(
    9089          20 :                     state, state.dataOutRptPredefined->pdchCoolCoilTotCap, equipName, state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(2));
    9090          30 :                 PreDefTableEntry(state,
    9091          10 :                                  state.dataOutRptPredefined->pdchCoolCoilSensCap,
    9092             :                                  equipName,
    9093          10 :                                  state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(2) * state.dataDXCoils->DXCoil(DXCoilNum).RatedSHR(2));
    9094          30 :                 PreDefTableEntry(state,
    9095          10 :                                  state.dataOutRptPredefined->pdchCoolCoilLatCap,
    9096             :                                  equipName,
    9097          10 :                                  state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(2) -
    9098          10 :                                      state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(2) * state.dataDXCoils->DXCoil(DXCoilNum).RatedSHR(2));
    9099          10 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoolCoilSHR, equipName, state.dataDXCoils->DXCoil(DXCoilNum).RatedSHR(2));
    9100          10 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoolCoilNomEff, equipName, state.dataDXCoils->DXCoil(DXCoilNum).RatedCOP(2));
    9101             :             }
    9102             :         } else {
    9103         157 :             for (Mode = 1; Mode <= state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds; ++Mode) {
    9104         327 :                 PreDefTableEntry(
    9105         218 :                     state, state.dataOutRptPredefined->pdchCoolCoilTotCap, equipName, state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(Mode));
    9106         327 :                 PreDefTableEntry(state,
    9107         109 :                                  state.dataOutRptPredefined->pdchCoolCoilSensCap,
    9108             :                                  equipName,
    9109         109 :                                  state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(Mode) * state.dataDXCoils->DXCoil(DXCoilNum).MSRatedSHR(Mode));
    9110         327 :                 PreDefTableEntry(state,
    9111         109 :                                  state.dataOutRptPredefined->pdchCoolCoilLatCap,
    9112             :                                  equipName,
    9113         109 :                                  state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(Mode) -
    9114         218 :                                      state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(Mode) *
    9115         109 :                                          state.dataDXCoils->DXCoil(DXCoilNum).MSRatedSHR(Mode));
    9116         327 :                 PreDefTableEntry(
    9117         218 :                     state, state.dataOutRptPredefined->pdchCoolCoilSHR, equipName, state.dataDXCoils->DXCoil(DXCoilNum).MSRatedSHR(Mode));
    9118         327 :                 PreDefTableEntry(
    9119         218 :                     state, state.dataOutRptPredefined->pdchCoolCoilNomEff, equipName, state.dataDXCoils->DXCoil(DXCoilNum).MSRatedCOP(Mode));
    9120             :             }
    9121             :         }
    9122         731 :         addFootNoteSubTable(state,
    9123         731 :                             state.dataOutRptPredefined->pdstCoolCoil,
    9124         731 :                             "Nominal values are gross at rated conditions, i.e., the supply air fan heat and electric power NOT accounted for.");
    9125         731 :     } break;
    9126         125 :     case CoilDX_HeatingEmpirical:
    9127             :     case CoilDX_MultiSpeedHeating:
    9128             :     case CoilDX_HeatPumpWaterHeaterPumped:
    9129             :     case CoilDX_HeatPumpWaterHeaterWrapped: {
    9130         125 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchHeatCoilType, equipName, state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType);
    9131         125 :         if (state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds == 0) {
    9132         105 :             if (state.dataDXCoils->DXCoil(DXCoilNum).NumCapacityStages == 1) {
    9133         315 :                 PreDefTableEntry(
    9134         210 :                     state, state.dataOutRptPredefined->pdchHeatCoilNomCap, equipName, state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(1));
    9135         105 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchHeatCoilNomEff, equipName, state.dataDXCoils->DXCoil(DXCoilNum).RatedCOP(1));
    9136             :             } else {
    9137           0 :                 PreDefTableEntry(
    9138           0 :                     state, state.dataOutRptPredefined->pdchHeatCoilNomCap, equipName, state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(2));
    9139           0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchHeatCoilNomEff, equipName, state.dataDXCoils->DXCoil(DXCoilNum).RatedCOP(2));
    9140             :             }
    9141             :         } else {
    9142          82 :             for (Mode = 1; Mode <= state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds; ++Mode) {
    9143         186 :                 PreDefTableEntry(
    9144         124 :                     state, state.dataOutRptPredefined->pdchHeatCoilNomCap, equipName, state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(Mode));
    9145         186 :                 PreDefTableEntry(
    9146         124 :                     state, state.dataOutRptPredefined->pdchHeatCoilNomEff, equipName, state.dataDXCoils->DXCoil(DXCoilNum).MSRatedCOP(Mode));
    9147             :             }
    9148             :         }
    9149         125 :         addFootNoteSubTable(state,
    9150         125 :                             state.dataOutRptPredefined->pdstHeatCoil,
    9151         125 :                             "Nominal values are gross at rated conditions, i.e., the supply air fan heat and electric power NOT accounted for.");
    9152         125 :     } break;
    9153         112 :     default:
    9154         112 :         break;
    9155             :     }
    9156         968 : }
    9157             : 
    9158     1779114 : void CalcHPWHDXCoil(EnergyPlusData &state,
    9159             :                     int const DXCoilNum,       // the number of the DX coil to be simulated
    9160             :                     Real64 const PartLoadRatio // sensible water heating load / full load sensible water heating capacity
    9161             : )
    9162             : {
    9163             : 
    9164             :     // SUBROUTINE INFORMATION:
    9165             :     //       AUTHOR         Richard Raustad
    9166             :     //       DATE WRITTEN   May 2005
    9167             : 
    9168             :     // PURPOSE OF THIS SUBROUTINE:
    9169             :     // Calculates the gross cooling capacity of a heat pump water heater evaporator and
    9170             :     // heating capacity of the condenser coil given the rated heating capacity and COP.
    9171             : 
    9172             :     // METHODOLOGY EMPLOYED:
    9173             :     // The routine requires the user to enter the total heating capacity and COP for the
    9174             :     // heat pump water heater along with logicals defining if fan and condenser pump are included.
    9175             :     // Since manufacturer's can rate their HPWH equipment with or without including condenser
    9176             :     // pump heat, this information is required to accurately determine the condenser's leaving
    9177             :     // water temperature. In addition, knowledge of the fan heat is required to back into
    9178             :     // a compressor COP.
    9179             : 
    9180             :     // Using/Aliasing
    9181             :     using Curve::CurveValue;
    9182     1779114 :     auto &DXCoilTotalCapacity = state.dataHVACGlobal->DXCoilTotalCapacity;
    9183     1779114 :     auto &HPWHInletDBTemp = state.dataHVACGlobal->HPWHInletDBTemp;
    9184     1779114 :     auto &HPWHInletWBTemp = state.dataHVACGlobal->HPWHInletWBTemp;
    9185             : 
    9186             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    9187             :     Real64 RatedHeatingCapacity;     // Water heating rated capacity with or without condenser water pump heat (W)
    9188             :     Real64 RatedHeatingCOP;          // Water heating rated COP with or without evap fan and cond water pump heat (W/W)
    9189             :     Real64 OperatingHeatingCapacity; // Water heating operating capacity including the impact of capacity and COP curves (W)
    9190             :     Real64 OperatingHeatingCOP;      // Water heating operating COP including the impact of capacity and COP curves (W/W)
    9191             :     Real64 OperatingHeatingPower;    // Water heating operating Power (W)
    9192             :     Real64 CompressorPower;          // Power consumed by compressor only (W)
    9193             : 
    9194             :     Real64 TotalTankHeatingCapacity; // Water heating capacity corrected for condenser water pump heat (W)
    9195             :     Real64 TankHeatingCOP;           // Water heating COP corrected for fan and condenser water pump power (W/W)
    9196             :     // (these previous 2 variables also include the impact of capacity and COP curves)
    9197             :     Real64 EvapCoolingCapacity;   // Air cooling capacity corrected for evap fan and cond water pump heat (W)
    9198             :     Real64 InletWaterTemp;        // Condenser water inlet temperature (C)
    9199             :     Real64 OutletWaterTemp;       // Condenser water outlet temperature (C)
    9200             :     Real64 EvapInletMassFlowRate; // Evaporator air inlet mass flow rate (m3/s)
    9201             :     Real64 CondInletMassFlowRate; // Condenser water inlet mass flow rate (m3/s)
    9202             :     Real64 CpWater;               // Specific heat of condenser inlet water (J/Kg/k)
    9203             :     Real64 InletAirTemp;          // HPWH inlet air temperature (dry-bulb or wet-bulb) (C)
    9204             :     Real64 HeatCapFTemp;          // Output of HPWH Heating Capacity as a Function of Temperature curve
    9205             :     Real64 HeatCapFAirFlow;       // Output of HPWH Heating Capacity as a Function of Air Flow Rate Ratio curve
    9206             :     Real64 HeatCapFWaterFlow;     // Output of HPWH Heating Capacity as a Function of Water Flow Rate Ratio curve
    9207             :     Real64 HeatCOPFTemp;          // Output of HPWH COP as a Function of Temperature curve
    9208             :     Real64 HeatCOPFAirFlow;       // Output of HPWH COP as a Function of Air Flow Rate Ratio curve
    9209             :     Real64 HeatCOPFWaterFlow;     // Output of HPWH COP as a Function of Water Flow Rate Ratio curve
    9210             :     Real64 AirFlowRateRatio;      // Ratio of evaporator inlet air mass flow rate to rated mass flow rate
    9211             :     Real64 WaterFlowRateRatio;    // Ratio of evaporator inlet water mass flow rate to rated mass flow rate
    9212             :     Real64 PartLoadFraction;      // Output of Part Load Fraction as a Function of Part Load Ratio curve
    9213             :     Real64 PumpHeatToWater;       // Amount of pump heat attributed to heating water
    9214             :     Real64 HPRTF;                 // Heat pump run time fraction
    9215             : 
    9216             :     // References to Coil and Node struct
    9217     1779114 :     DXCoilData &Coil = state.dataDXCoils->DXCoil(DXCoilNum);
    9218     1779114 :     NodeData &AirInletNode = state.dataLoopNodes->Node(Coil.AirInNode);
    9219     1779114 :     NodeData &WaterInletNode = state.dataLoopNodes->Node(Coil.WaterInNode);
    9220     1779114 :     NodeData &WaterOutletNode = state.dataLoopNodes->Node(Coil.WaterOutNode);
    9221             : 
    9222             :     // If heat pump water heater is OFF, set outlet to inlet and RETURN
    9223             :     // Also set the heating energy rate to zero
    9224     1779114 :     if (PartLoadRatio == 0.0) {
    9225      591932 :         WaterOutletNode = WaterInletNode;
    9226      591932 :         Coil.TotalHeatingEnergyRate = 0.0;
    9227      591932 :         return;
    9228             :     } else {
    9229     1187182 :         RatedHeatingCapacity = Coil.RatedTotCap2;
    9230     1187182 :         RatedHeatingCOP = Coil.RatedCOP(1);
    9231     1187182 :         InletWaterTemp = WaterInletNode.Temp;
    9232     1187182 :         CondInletMassFlowRate = WaterInletNode.MassFlowRate / PartLoadRatio;
    9233     1187182 :         EvapInletMassFlowRate = AirInletNode.MassFlowRate / PartLoadRatio;
    9234     1187182 :         CpWater = CPHW(InletWaterTemp);
    9235     1187182 :         CompressorPower = 0.0;
    9236     1187182 :         OperatingHeatingPower = 0.0;
    9237     1187182 :         TankHeatingCOP = 0.0;
    9238             :     }
    9239             : 
    9240             :     // determine inlet air temperature type for curve objects
    9241     1187182 :     if (Coil.InletAirTemperatureType == WetBulbIndicator) {
    9242     1187182 :         InletAirTemp = HPWHInletWBTemp;
    9243             :     } else {
    9244           0 :         InletAirTemp = HPWHInletDBTemp;
    9245             :     }
    9246             : 
    9247             :     // get output of Heating Capacity and Heating COP curves (curves default to 1 if user has not specified curve name)
    9248     1187182 :     if (Coil.HCapFTemp > 0) {
    9249     1187182 :         if (state.dataCurveManager->PerfCurve(Coil.HCapFTemp).numDims == 1) {
    9250           0 :             HeatCapFTemp = CurveValue(state, Coil.HCapFTemp, InletAirTemp);
    9251             :         } else {
    9252     1187182 :             HeatCapFTemp = CurveValue(state, Coil.HCapFTemp, InletAirTemp, InletWaterTemp);
    9253             :         }
    9254             :         //   Warn user if curve output goes negative
    9255     1187182 :         if (HeatCapFTemp < 0.0) {
    9256           0 :             if (Coil.HCapFTempErrorIndex == 0) {
    9257           0 :                 ShowWarningMessage(state, Coil.DXCoilType + " \"" + Coil.Name + "\":");
    9258           0 :                 ShowContinueError(
    9259           0 :                     state, format(" HPWH Heating Capacity Modifier curve (function of temperature) output is negative ({:.3T}).", HeatCapFTemp));
    9260           0 :                 if (state.dataCurveManager->PerfCurve(Coil.HCapFTemp).numDims == 2) {
    9261           0 :                     ShowContinueError(
    9262             :                         state,
    9263           0 :                         format(" Negative value occurs using an inlet air temperature of {:.1T} and an inlet water temperature of {:.1T}.",
    9264             :                                InletAirTemp,
    9265           0 :                                InletWaterTemp));
    9266             :                 } else {
    9267           0 :                     ShowContinueError(state, format(" Negative value occurs using an inlet air temperature of {:.1T}.", InletAirTemp));
    9268             :                 }
    9269           0 :                 ShowContinueErrorTimeStamp(state, " Resetting curve output to zero and continuing simulation.");
    9270             :             }
    9271           0 :             ShowRecurringWarningErrorAtEnd(
    9272             :                 state,
    9273           0 :                 Coil.DXCoilType + " \"" + Coil.Name +
    9274             :                     "\": HPWH Heating Capacity Modifier curve (function of temperature) output is negative warning continues...",
    9275             :                 Coil.HCapFTempErrorIndex,
    9276             :                 HeatCapFTemp,
    9277             :                 HeatCapFTemp,
    9278             :                 _,
    9279             :                 "[C]",
    9280             :                 "[C]");
    9281           0 :             HeatCapFTemp = 0.0;
    9282             :         }
    9283             :     } else {
    9284           0 :         HeatCapFTemp = 1.0;
    9285             :     }
    9286             : 
    9287     1187182 :     if (Coil.HCOPFTemp > 0) {
    9288     1187182 :         if (state.dataCurveManager->PerfCurve(Coil.HCOPFTemp).numDims == 1) {
    9289           0 :             HeatCOPFTemp = CurveValue(state, Coil.HCOPFTemp, InletAirTemp);
    9290             :         } else {
    9291     1187182 :             HeatCOPFTemp = CurveValue(state, Coil.HCOPFTemp, InletAirTemp, InletWaterTemp);
    9292             :         }
    9293             :         //   Warn user if curve output goes negative
    9294     1187182 :         if (HeatCOPFTemp < 0.0) {
    9295           0 :             if (Coil.HCOPFTempErrorIndex == 0) {
    9296           0 :                 ShowWarningMessage(state, Coil.DXCoilType + " \"" + Coil.Name + "\":");
    9297           0 :                 ShowContinueError(state,
    9298           0 :                                   format(" HPWH Heating COP Modifier curve (function of temperature) output is negative ({:.3T}).", HeatCOPFTemp));
    9299           0 :                 if (state.dataCurveManager->PerfCurve(Coil.HCOPFTemp).numDims == 2) {
    9300           0 :                     ShowContinueError(
    9301             :                         state,
    9302           0 :                         format(" Negative value occurs using an inlet air temperature of {:.1T} and an inlet water temperature of {:.1T}.",
    9303             :                                InletAirTemp,
    9304           0 :                                InletWaterTemp));
    9305             :                 } else {
    9306           0 :                     ShowContinueError(state, format(" Negative value occurs using an inlet air temperature of {:.1T}.", InletAirTemp));
    9307             :                 }
    9308           0 :                 ShowContinueErrorTimeStamp(state, " Resetting curve output to zero and continuing simulation.");
    9309             :             }
    9310           0 :             ShowRecurringWarningErrorAtEnd(
    9311             :                 state,
    9312           0 :                 Coil.DXCoilType + " \"" + Coil.Name +
    9313             :                     "\": HPWH Heating COP Modifier curve (function of temperature) output is negative warning continues...",
    9314             :                 Coil.HCOPFTempErrorIndex,
    9315             :                 HeatCOPFTemp,
    9316             :                 HeatCOPFTemp,
    9317             :                 _,
    9318             :                 "[C]",
    9319             :                 "[C]");
    9320           0 :             HeatCOPFTemp = 0.0;
    9321             :         }
    9322             :     } else {
    9323           0 :         HeatCOPFTemp = 1.0;
    9324             :     }
    9325             : 
    9326     1187182 :     if (Coil.HCapFAirFlow > 0) {
    9327           0 :         AirFlowRateRatio = EvapInletMassFlowRate / (Coil.RatedAirMassFlowRate(1));
    9328           0 :         HeatCapFAirFlow = CurveValue(state, Coil.HCapFAirFlow, AirFlowRateRatio);
    9329             :         //   Warn user if curve output goes negative
    9330           0 :         if (HeatCapFAirFlow < 0.0) {
    9331           0 :             if (Coil.HCapFAirFlowErrorIndex == 0) {
    9332           0 :                 ShowWarningMessage(state, Coil.DXCoilType + " \"" + Coil.Name + "\":");
    9333           0 :                 ShowContinueError(
    9334             :                     state,
    9335           0 :                     format(" HPWH Heating Capacity Modifier curve (function of air flow fraction) output is negative ({:.3T}).", HeatCapFAirFlow));
    9336           0 :                 ShowContinueError(state, format(" Negative value occurs using an air flow fraction of {:.3T}.", AirFlowRateRatio));
    9337           0 :                 ShowContinueErrorTimeStamp(state, " Resetting curve output to zero and continuing simulation.");
    9338             :             }
    9339           0 :             ShowRecurringWarningErrorAtEnd(
    9340             :                 state,
    9341           0 :                 Coil.DXCoilType + " \"" + Coil.Name +
    9342             :                     "\": HPWH Heating Capacity Modifier curve (function of air flow fraction) output is negative warning continues...",
    9343             :                 Coil.HCapFAirFlowErrorIndex,
    9344             :                 HeatCapFAirFlow,
    9345             :                 HeatCapFAirFlow);
    9346           0 :             HeatCapFAirFlow = 0.0;
    9347             :         }
    9348             :     } else {
    9349     1187182 :         HeatCapFAirFlow = 1.0;
    9350             :     }
    9351             : 
    9352     1187182 :     if (Coil.HCOPFAirFlow > 0) {
    9353           0 :         AirFlowRateRatio = EvapInletMassFlowRate / (Coil.RatedAirMassFlowRate(1));
    9354           0 :         HeatCOPFAirFlow = CurveValue(state, Coil.HCOPFAirFlow, AirFlowRateRatio);
    9355             :         //   Warn user if curve output goes negative
    9356           0 :         if (HeatCOPFAirFlow < 0.0) {
    9357           0 :             if (Coil.HCOPFAirFlowErrorIndex == 0) {
    9358           0 :                 ShowWarningMessage(state, Coil.DXCoilType + " \"" + Coil.Name + "\":");
    9359           0 :                 ShowContinueError(
    9360           0 :                     state, format(" HPWH Heating COP Modifier curve (function of air flow fraction) output is negative ({:.3T}).", HeatCOPFAirFlow));
    9361           0 :                 ShowContinueError(state, format(" Negative value occurs using an air flow fraction of {:.3T}.", AirFlowRateRatio));
    9362           0 :                 ShowContinueErrorTimeStamp(state, " Resetting curve output to zero and continuing simulation.");
    9363             :             }
    9364           0 :             ShowRecurringWarningErrorAtEnd(
    9365             :                 state,
    9366           0 :                 Coil.DXCoilType + " \"" + Coil.Name +
    9367             :                     "\": HPWH Heating COP Modifier curve (function of air flow fraction) output is negative warning continues...",
    9368             :                 Coil.HCOPFAirFlowErrorIndex,
    9369             :                 HeatCOPFAirFlow,
    9370             :                 HeatCOPFAirFlow);
    9371           0 :             HeatCOPFAirFlow = 0.0;
    9372             :         }
    9373             :     } else {
    9374     1187182 :         HeatCOPFAirFlow = 1.0;
    9375             :     }
    9376             : 
    9377     1187182 :     if (Coil.HCapFWaterFlow > 0) {
    9378           0 :         WaterFlowRateRatio = CondInletMassFlowRate / (Coil.RatedHPWHCondWaterFlow * RhoH2O(InletWaterTemp));
    9379           0 :         HeatCapFWaterFlow = CurveValue(state, Coil.HCapFWaterFlow, WaterFlowRateRatio);
    9380             :         //   Warn user if curve output goes negative
    9381           0 :         if (HeatCapFWaterFlow < 0.0) {
    9382           0 :             if (Coil.HCapFWaterFlowErrorIndex == 0) {
    9383           0 :                 ShowWarningMessage(state, Coil.DXCoilType + " \"" + Coil.Name + "\":");
    9384           0 :                 ShowContinueError(state,
    9385           0 :                                   format(" HPWH Heating Capacity Modifier curve (function of water flow fraction) output is negative ({:.3T}).",
    9386           0 :                                          HeatCapFWaterFlow));
    9387           0 :                 ShowContinueError(state, format(" Negative value occurs using a water flow fraction of {:.3T}.", WaterFlowRateRatio));
    9388           0 :                 ShowContinueErrorTimeStamp(state, " Resetting curve output to zero and continuing simulation.");
    9389             :             }
    9390           0 :             ShowRecurringWarningErrorAtEnd(
    9391             :                 state,
    9392           0 :                 Coil.DXCoilType + " \"" + Coil.Name +
    9393             :                     "\": HPWH Heating Capacity Modifier curve (function of water flow fraction) output is negative warning continues...",
    9394             :                 Coil.HCapFWaterFlowErrorIndex,
    9395             :                 HeatCapFWaterFlow,
    9396             :                 HeatCapFWaterFlow);
    9397           0 :             HeatCapFWaterFlow = 0.0;
    9398             :         }
    9399             :     } else {
    9400     1187182 :         HeatCapFWaterFlow = 1.0;
    9401             :     }
    9402             : 
    9403     1187182 :     if (Coil.HCOPFWaterFlow > 0) {
    9404           0 :         WaterFlowRateRatio = CondInletMassFlowRate / (Coil.RatedHPWHCondWaterFlow * RhoH2O(InletWaterTemp));
    9405           0 :         HeatCOPFWaterFlow = CurveValue(state, Coil.HCOPFWaterFlow, WaterFlowRateRatio);
    9406             :         //   Warn user if curve output goes negative
    9407           0 :         if (HeatCOPFWaterFlow < 0.0) {
    9408           0 :             if (Coil.HCOPFWaterFlowErrorIndex == 0) {
    9409           0 :                 ShowWarningMessage(state, Coil.DXCoilType + " \"" + Coil.Name + "\":");
    9410           0 :                 ShowContinueError(
    9411             :                     state,
    9412           0 :                     format(" HPWH Heating COP Modifier curve (function of water flow fraction) output is negative ({:.3T}).", HeatCOPFWaterFlow));
    9413           0 :                 ShowContinueError(state, format(" Negative value occurs using a water flow fraction of {:.3T}.", WaterFlowRateRatio));
    9414           0 :                 ShowContinueErrorTimeStamp(state, " Resetting curve output to zero and continuing simulation.");
    9415             :             }
    9416           0 :             ShowRecurringWarningErrorAtEnd(
    9417             :                 state,
    9418           0 :                 Coil.DXCoilType + " \"" + Coil.Name +
    9419             :                     "\": HPWH Heating COP Modifier curve (function of water flow fraction) output is negative warning continues...",
    9420             :                 Coil.HCOPFWaterFlowErrorIndex,
    9421             :                 HeatCOPFWaterFlow,
    9422             :                 HeatCOPFWaterFlow);
    9423           0 :             HeatCOPFWaterFlow = 0.0;
    9424             :         }
    9425             :     } else {
    9426     1187182 :         HeatCOPFWaterFlow = 1.0;
    9427             :     }
    9428             : 
    9429             :     // adjust Heating Capacity and COP for off-design conditions
    9430     1187182 :     OperatingHeatingCapacity = RatedHeatingCapacity * HeatCapFTemp * HeatCapFAirFlow * HeatCapFWaterFlow;
    9431     1187182 :     OperatingHeatingCOP = RatedHeatingCOP * HeatCOPFTemp * HeatCOPFAirFlow * HeatCOPFWaterFlow;
    9432             : 
    9433     1187182 :     if (OperatingHeatingCOP > 0.0) OperatingHeatingPower = OperatingHeatingCapacity / OperatingHeatingCOP;
    9434             : 
    9435     1187182 :     PumpHeatToWater = Coil.HPWHCondPumpElecNomPower * Coil.HPWHCondPumpFracToWater;
    9436     1187182 :     TankHeatingCOP = OperatingHeatingCOP;
    9437             : 
    9438             :     // account for pump heat if not included in total water heating capacity
    9439     1187182 :     if (Coil.CondPumpHeatInCapacity) {
    9440           0 :         TotalTankHeatingCapacity = OperatingHeatingCapacity;
    9441             :     } else {
    9442     1187182 :         TotalTankHeatingCapacity = OperatingHeatingCapacity + PumpHeatToWater;
    9443             :     }
    9444             : 
    9445             :     // find part load fraction to calculate RTF
    9446     1187182 :     if (Coil.PLFFPLR(1) > 0) {
    9447     1187182 :         PartLoadFraction = max(0.7, CurveValue(state, Coil.PLFFPLR(1), PartLoadRatio));
    9448             :     } else {
    9449           0 :         PartLoadFraction = 1.0;
    9450             :     }
    9451             : 
    9452     1187182 :     HPRTF = min(1.0, (PartLoadRatio / PartLoadFraction));
    9453             : 
    9454     1187182 :     Real64 locFanElecPower = 0.0;
    9455     1187182 :     if (Coil.SupplyFan_TypeNum == DataHVACGlobals::FanType_SystemModelObject) {
    9456      409053 :         locFanElecPower = state.dataHVACFan->fanObjs[Coil.SupplyFanIndex]->fanPower();
    9457             :     } else {
    9458      778129 :         locFanElecPower = Fans::GetFanPower(state, Coil.SupplyFanIndex);
    9459             :     }
    9460             : 
    9461             :     // calculate evaporator total cooling capacity
    9462     1187182 :     if (HPRTF > 0.0) {
    9463     1187182 :         if (Coil.FanPowerIncludedInCOP) {
    9464      765814 :             if (Coil.CondPumpPowerInCOP) {
    9465             :                 //       make sure fan power is full load fan power
    9466           0 :                 CompressorPower = OperatingHeatingPower - locFanElecPower / HPRTF - Coil.HPWHCondPumpElecNomPower;
    9467           0 :                 if (OperatingHeatingPower > 0.0) TankHeatingCOP = TotalTankHeatingCapacity / OperatingHeatingPower;
    9468             :             } else {
    9469      765814 :                 CompressorPower = OperatingHeatingPower - locFanElecPower / HPRTF;
    9470      765814 :                 if ((OperatingHeatingPower + Coil.HPWHCondPumpElecNomPower) > 0.0)
    9471      765814 :                     TankHeatingCOP = TotalTankHeatingCapacity / (OperatingHeatingPower + Coil.HPWHCondPumpElecNomPower);
    9472             :             }
    9473             :         } else {
    9474      421368 :             if (Coil.CondPumpPowerInCOP) {
    9475             :                 //       make sure fan power is full load fan power
    9476           0 :                 CompressorPower = OperatingHeatingPower - Coil.HPWHCondPumpElecNomPower;
    9477           0 :                 if ((OperatingHeatingPower + locFanElecPower / HPRTF) > 0.0)
    9478           0 :                     TankHeatingCOP = TotalTankHeatingCapacity / (OperatingHeatingPower + locFanElecPower / HPRTF);
    9479             :             } else {
    9480      421368 :                 CompressorPower = OperatingHeatingPower;
    9481      421368 :                 if ((OperatingHeatingPower + locFanElecPower / HPRTF + Coil.HPWHCondPumpElecNomPower) > 0.0)
    9482      421368 :                     TankHeatingCOP = TotalTankHeatingCapacity / (OperatingHeatingPower + locFanElecPower / HPRTF + Coil.HPWHCondPumpElecNomPower);
    9483             :             }
    9484             :         }
    9485             :     }
    9486             : 
    9487     1187182 :     if (Coil.CondPumpHeatInCapacity) {
    9488           0 :         EvapCoolingCapacity = TotalTankHeatingCapacity - PumpHeatToWater - CompressorPower;
    9489             :     } else {
    9490     1187182 :         EvapCoolingCapacity = TotalTankHeatingCapacity - CompressorPower;
    9491             :     }
    9492             : 
    9493             :     // set evaporator total cooling capacity prior to CalcDOE2DXCoil subroutine
    9494     1187182 :     Coil.RatedTotCap(1) = EvapCoolingCapacity;
    9495             : 
    9496             :     // determine condenser water inlet/outlet condition at full capacity
    9497     1187182 :     if (CondInletMassFlowRate == 0.0) {
    9498      761295 :         OutletWaterTemp = InletWaterTemp;
    9499             :     } else {
    9500      425887 :         OutletWaterTemp = InletWaterTemp + TotalTankHeatingCapacity / (CpWater * CondInletMassFlowRate);
    9501             :     }
    9502             : 
    9503     1187182 :     WaterOutletNode.Temp = OutletWaterTemp;
    9504             : 
    9505     1187182 :     WaterOutletNode.MassFlowRate = WaterInletNode.MassFlowRate;
    9506             : 
    9507             :     // send heating capacity and COP to water heater module for standards rating calculation
    9508             :     // total heating capacity including condenser pump
    9509     1187182 :     state.dataDXCoils->HPWHHeatingCapacity = TotalTankHeatingCapacity;
    9510             :     // total heating COP including compressor, fan, and condenser pump
    9511     1187182 :     state.dataDXCoils->HPWHHeatingCOP = TankHeatingCOP;
    9512             : 
    9513             :     // send DX coil total cooling capacity to HPWH for reporting
    9514     1187182 :     DXCoilTotalCapacity = EvapCoolingCapacity;
    9515             : 
    9516     1187182 :     Coil.TotalHeatingEnergyRate = TotalTankHeatingCapacity * PartLoadRatio;
    9517             : 
    9518             :     // calculate total compressor plus condenser pump power, fan power reported in fan module
    9519     1187182 :     Coil.ElecWaterHeatingPower = (CompressorPower + Coil.HPWHCondPumpElecNomPower) * HPRTF;
    9520             : }
    9521             : 
    9522    42209621 : void CalcDoe2DXCoil(EnergyPlusData &state,
    9523             :                     int const DXCoilNum,                      // the number of the DX coil to be simulated
    9524             :                     CompressorOperation const CompressorOp,   // compressor operation; 1=on, 0=off
    9525             :                     bool const FirstHVACIteration,            // true if this is the first iteration of HVAC
    9526             :                     Real64 const PartLoadRatio,               // sensible cooling load / full load sensible cooling capacity
    9527             :                     int const FanOpMode,                      // Allows parent object to control fan operation
    9528             :                     Optional_int_const PerfMode,              // Performance mode for MultiMode DX coil; Always 1 for other coil types
    9529             :                     Optional<Real64 const> OnOffAirFlowRatio, // ratio of compressor on airflow to compressor off airflow
    9530             :                     Optional<Real64 const> CoolingHeatingPLR  // used for cycling fan RH control
    9531             : )
    9532             : {
    9533             : 
    9534             :     // SUBROUTINE INFORMATION:
    9535             :     //       AUTHOR         Fred Buhl
    9536             :     //       DATE WRITTEN   May 2000
    9537             :     //       MODIFIED       Shirey, Feb/October 2001, Feb/Mar 2004
    9538             :     //                      Feb 2005 M. J. Witte, GARD Analytics, Inc.
    9539             :     //                        Add new coil type COIL:DX:MultiMode:CoolingEmpirical:
    9540             :     //                      April 2010 Chandan Sharma, FSEC, Added basin heater
    9541             :     //       RE-ENGINEERED  Don Shirey, Aug/Sept 2000
    9542             : 
    9543             :     // PURPOSE OF THIS SUBROUTINE:
    9544             :     // Calculates the air-side performance and electrical energy use of a direct-
    9545             :     // expansion, air-cooled cooling unit.
    9546             : 
    9547             :     // METHODOLOGY EMPLOYED:
    9548             :     // This routine simulates the performance of air-cooled DX cooling equipment.
    9549             :     // The routine requires the user to enter the total cooling capacity, sensible heat ratio,
    9550             :     // and COP for the unit at ARI 210/240 rating conditions (26.67C [80F] dry-bulb, 19.44C [67F]
    9551             :     // wet-bulb air entering the cooling coil, 35C [95F] dry-bulb air entering the outdoor
    9552             :     // condenser. Since different manufacturer's rate their equipment at different air flow rates,
    9553             :     // the supply air flow rate corresponding to the rated capacities and rated COP must also be
    9554             :     // entered (should be between 300 cfm/ton and 450 cfm/ton). The rated information entered by
    9555             :     // the user should NOT include the thermal or electrical impacts of the supply air fan, as
    9556             :     // this is addressed by another module.
    9557             : 
    9558             :     // With the rated performance data entered by the user, the model employs some of the
    9559             :     // DOE-2.1E curve fits to adjust the capacity and efficiency of the unit as a function
    9560             :     // of entering air temperatures and supply air flow rate (actual vs rated flow). The model
    9561             :     // does NOT employ the exact same methodology to calculate performance as DOE-2, although
    9562             :     // some of the DOE-2 curve fits are employed by this model.
    9563             : 
    9564             :     // The model checks for coil dryout conditions, and adjusts the calculated performance
    9565             :     // appropriately.
    9566             : 
    9567             :     // REFERENCES:
    9568             :     // ASHRAE HVAC 2 Toolkit page 4-81.
    9569             :     // Henderson, H.I. Jr., K. Rengarajan and D.B. Shirey, III. 1992.The impact of comfort
    9570             :     // control on air conditioner energy use in humid climates. ASHRAE Transactions 98(2):
    9571             :     // 104-113.
    9572             :     // Henderson, H.I. Jr., Danny Parker and Y.J. Huang. 2000.Improving DOE-2's RESYS routine:
    9573             :     // User Defined Functions to Provide More Accurate Part Load Energy Use and Humidity
    9574             :     // Predictions. Proceedings of ACEEE Conference.
    9575             : 
    9576             :     // Using/Aliasing
    9577             :     using Curve::CurveValue;
    9578    42209621 :     auto &HPWHCrankcaseDBTemp = state.dataHVACGlobal->HPWHCrankcaseDBTemp;
    9579    42209621 :     auto &SysTimeElapsed = state.dataHVACGlobal->SysTimeElapsed;
    9580    42209621 :     auto &TimeStepSys = state.dataHVACGlobal->TimeStepSys;
    9581             :     using General::CreateSysTimeIntervalString;
    9582             : 
    9583             :     // SUBROUTINE PARAMETER DEFINITIONS:
    9584             :     static constexpr std::string_view RoutineName("CalcDoe2DXCoil: ");
    9585             :     static constexpr std::string_view calcDoe2DXCoil("CalcDoe2DXCoil");
    9586             : 
    9587             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    9588             :     Real64 AirMassFlow;       // dry air mass flow rate through coil [kg/s] (adjusted for bypass if any)
    9589             :     Real64 AirMassFlowRatio;  // Ratio of actual air mass flow to rated air mass flow (adjusted for bypass if any)
    9590             :     Real64 AirVolumeFlowRate; // Air volume flow rate across the cooling coil [m3/s] (adjusted for bypass if any)
    9591             :     // (average flow if cycling fan, full flow if constant fan)
    9592             :     Real64 VolFlowperRatedTotCap; // Air volume flow rate divided by rated total cooling capacity [m3/s-W] (adjusted for bypass)
    9593             :     Real64 BypassFlowFraction;    // Fraction of total flow which is bypassed around the cooling coil
    9594             :     Real64 TotCap;                // gross total cooling capacity at off-rated conditions [W]
    9595             :     Real64 TotCapTempModFac;      // Total capacity modifier (function of entering wetbulb, outside drybulb)
    9596             :     Real64 TotCapFlowModFac;      // Total capacity modifier (function of actual supply air flow vs rated flow)
    9597             :     Real64 InletAirWetBulbC;      // wetbulb temperature of inlet air [C]
    9598             :     Real64 InletAirDryBulbTemp;   // inlet air dry bulb temperature [C]
    9599             :     Real64 InletAirEnthalpy;      // inlet air enthalpy [J/kg]
    9600             :     Real64 InletAirHumRat;        // inlet air humidity ratio [kg/kg]
    9601             :     Real64 InletAirHumRatTemp;    // inlet air humidity ratio used in ADP/BF loop [kg/kg]
    9602             :     //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
    9603             :     // REAL(r64) :: InletAirPressure      ! inlet air pressure [Pa]
    9604             :     Real64 RatedCBF;             // coil bypass factor at rated conditions
    9605             :     Real64 SHR;                  // Sensible Heat Ratio (sensible/total) of the cooling coil
    9606             :     Real64 CBF;                  // coil bypass factor at off rated conditions
    9607             :     Real64 A0;                   // NTU * air mass flow rate, used in CBF calculation
    9608             :     Real64 hDelta;               // Change in air enthalpy across the cooling coil [J/kg]
    9609             :     Real64 hADP;                 // Apparatus dew point enthalpy [J/kg]
    9610             :     Real64 hTinwADP;             // Enthalpy at inlet dry-bulb and wADP [J/kg]
    9611             :     Real64 hTinwout;             // Enthalpy at inlet dry-bulb and outlet humidity ratio [J/kg]
    9612             :     Real64 tADP;                 // Apparatus dew point temperature [C]
    9613             :     Real64 wADP;                 // Apparatus dew point humidity ratio [kg/kg]
    9614             :     Real64 FullLoadOutAirEnth;   // outlet full load enthalpy [J/kg]
    9615             :     Real64 FullLoadOutAirHumRat; // outlet humidity ratio at full load
    9616             :     Real64 FullLoadOutAirTemp;   // outlet air temperature at full load [C]
    9617             :     Real64 EIRTempModFac;        // EIR modifier (function of entering wetbulb, outside drybulb)
    9618             :     Real64 EIRFlowModFac;        // EIR modifier (function of actual supply air flow vs rated flow)
    9619             :     Real64 EIR;                  // EIR at part load and off rated conditions
    9620             :     Real64 PLF;                  // Part load factor, accounts for thermal lag at compressor startup, used in power calculation
    9621             :     Real64 QLatActual;           // operating latent capacity of DX coil
    9622             :     Real64 QLatRated;            // Rated latent capacity of DX coil
    9623             :     Real64 SHRUnadjusted;        // SHR prior to latent degradation effective SHR calculation
    9624             :     int Counter;                 // Counter for dry evaporator iterations
    9625             :     int MaxIter;                 // Maximum number of iterations for dry evaporator calculations
    9626             :     Real64 RF;                   // Relaxation factor for dry evaporator iterations
    9627             :     Real64 Tolerance;            // Error tolerance for dry evaporator iterations
    9628             :     Real64 werror;               // Deviation of humidity ratio in dry evaporator iteration loop
    9629             :     Real64 CondInletTemp;        // Condenser inlet temperature (C). Outdoor dry-bulb temp for air-cooled condenser.
    9630             :     // Outdoor Wetbulb +(1 - effectiveness)*(outdoor drybulb - outdoor wetbulb) for evap condenser.
    9631             :     Real64 CondInletHumRat; // Condenser inlet humidity ratio (kg/kg). Zero for air-cooled condenser.
    9632             :     // For evap condenser, its the humidity ratio of the air leaving the evap cooling pads.
    9633             :     Real64 CondAirMassFlow;       // Condenser air mass flow rate [kg/s]
    9634             :     Real64 RhoAir;                // Density of air [kg/m3]
    9635             :     Real64 RhoWater;              // Density of water [kg/m3]
    9636             :     Real64 CrankcaseHeatingPower; // power due to crankcase heater
    9637    42209621 :     Real64 CompAmbTemp(0.0);      // Ambient temperature at compressor
    9638             :     Real64 AirFlowRatio;          // ratio of compressor on airflow to average timestep airflow
    9639             :     // used when constant fan mode yields different air flow rates when compressor is ON and OFF
    9640             :     // (e.g. Packaged Terminal Heat Pump)
    9641             :     Real64 OutdoorDryBulb;  // Outdoor dry-bulb temperature at condenser (C)
    9642             :     Real64 OutdoorWetBulb;  // Outdoor wet-bulb temperature at condenser (C)
    9643             :     Real64 OutdoorHumRat;   // Outdoor humidity ratio at condenser (kg/kg)
    9644             :     Real64 OutdoorPressure; // Outdoor barometric pressure at condenser (Pa)
    9645             : 
    9646    42209621 :     auto &CurrentEndTime = state.dataDXCoils->CurrentEndTime;
    9647             :     int Mode;                    // Performance mode for Multimode DX coil; Always 1 for other coil types
    9648             :     Real64 OutletAirTemp;        // Supply air temperature (average value if constant fan, full output if cycling fan)
    9649             :     Real64 OutletAirHumRat;      // Supply air humidity ratio (average value if constant fan, full output if cycling fan)
    9650             :     Real64 OutletAirEnthalpy;    // Supply air enthalpy (average value if constant fan, full output if cycling fan)
    9651             :     Real64 ADiff;                // Used for exponential
    9652             :     Real64 DXcoolToHeatPLRRatio; // ratio of cooling PLR to heating PLR, used for cycling fan RH control
    9653             :     Real64 HeatRTF;              // heating coil part-load ratio, used for cycling fan RH control
    9654             :     Real64 HeatingCoilPLF;       // heating coil PLF (function of PLR), used for cycling fan RH control
    9655             : 
    9656    42209621 :     auto &DXCT = state.dataHVACGlobal->DXCT;
    9657    42209621 :     auto &OnOffFanPartLoadFraction = state.dataHVACGlobal->OnOffFanPartLoadFraction;
    9658             : 
    9659             :     // If Performance mode not present, then set to 1.  Used only by Multimode/Multispeed DX coil (otherwise mode = 1)
    9660    42209621 :     if (present(PerfMode)) {
    9661      281485 :         Mode = PerfMode;
    9662             :     } else {
    9663    41928136 :         Mode = 1;
    9664             :     }
    9665             : 
    9666             :     // If AirFlowRatio not present, then set to 1. Used only by DX coils with different air flow
    9667             :     // during cooling and when no cooling is required (constant fan, fan speed changes)
    9668    42209621 :     if (present(OnOffAirFlowRatio)) {
    9669    38421689 :         AirFlowRatio = OnOffAirFlowRatio;
    9670             :     } else {
    9671     3787932 :         AirFlowRatio = 1.0;
    9672             :     }
    9673             : 
    9674             :     // If CoolingHeatingPLR not present, then set to 1. Used for cycling fan systems where
    9675             :     // heating PLR is greater than cooling PLR, otherwise CoolingHeatingPLR = 1.
    9676    42209621 :     if (present(CoolingHeatingPLR)) {
    9677    30855161 :         DXcoolToHeatPLRRatio = CoolingHeatingPLR;
    9678             :     } else {
    9679    11354460 :         DXcoolToHeatPLRRatio = 1.0;
    9680             :     }
    9681             : 
    9682    42209621 :     MaxIter = 30;
    9683    42209621 :     RF = 0.4;
    9684    42209621 :     Counter = 0;
    9685    42209621 :     Tolerance = 0.01;
    9686    42209621 :     CondInletTemp = 0.0;
    9687    42209621 :     CondInletHumRat = 0.0;
    9688    42209621 :     BypassFlowFraction = state.dataDXCoils->DXCoil(DXCoilNum).BypassedFlowFrac(Mode);
    9689    42209621 :     AirMassFlow = state.dataDXCoils->DXCoil(DXCoilNum).InletAirMassFlowRate * (1.0 - BypassFlowFraction);
    9690    42209621 :     InletAirDryBulbTemp = state.dataDXCoils->DXCoil(DXCoilNum).InletAirTemp;
    9691    42209621 :     InletAirEnthalpy = state.dataDXCoils->DXCoil(DXCoilNum).InletAirEnthalpy;
    9692    42209621 :     InletAirHumRat = state.dataDXCoils->DXCoil(DXCoilNum).InletAirHumRat;
    9693             :     //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
    9694             :     // InletAirPressure    = DXCoil(DXCoilNum)%InletAirPressure
    9695    42209621 :     state.dataHeatBal->HeatReclaimDXCoil(DXCoilNum).AvailCapacity = 0.0;
    9696    42209621 :     state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction = 0.0;
    9697    42209621 :     state.dataDXCoils->DXCoil(DXCoilNum).PartLoadRatio = 0.0;
    9698    42209621 :     state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterPower = 0.0;
    9699             : 
    9700    42209621 :     if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(Mode) != DataHeatBalance::RefrigCondenserType::WaterHeater) {
    9701    41186441 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(Mode) != 0) {
    9702     8593943 :             OutdoorPressure = state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(Mode)).Press;
    9703             :             // If node is not connected to anything, pressure = default, use weather data
    9704     8593943 :             if (OutdoorPressure == state.dataLoopNodes->DefaultNodeValues.Press) {
    9705           0 :                 OutdoorDryBulb = state.dataEnvrn->OutDryBulbTemp;
    9706           0 :                 OutdoorHumRat = state.dataEnvrn->OutHumRat;
    9707           0 :                 OutdoorPressure = state.dataEnvrn->OutBaroPress;
    9708           0 :                 OutdoorWetBulb = state.dataEnvrn->OutWetBulbTemp;
    9709             :             } else {
    9710     8593943 :                 OutdoorDryBulb = state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(Mode)).Temp;
    9711     8593943 :                 OutdoorHumRat = state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(Mode)).HumRat;
    9712             :                 // this should use Node%WetBulbTemp or a PSYC function, not OAWB
    9713     8593943 :                 OutdoorWetBulb = state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(Mode)).OutAirWetBulb;
    9714             :             }
    9715             :         } else {
    9716    32592498 :             OutdoorDryBulb = state.dataEnvrn->OutDryBulbTemp;
    9717    32592498 :             OutdoorHumRat = state.dataEnvrn->OutHumRat;
    9718    32592498 :             OutdoorPressure = state.dataEnvrn->OutBaroPress;
    9719    32592498 :             OutdoorWetBulb = state.dataEnvrn->OutWetBulbTemp;
    9720             :         }
    9721    41186441 :         if (state.dataDXCoils->DXCoil(DXCoilNum).IsSecondaryDXCoilInZone) {
    9722       83894 :             auto &secZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(state.dataDXCoils->DXCoil(DXCoilNum).SecZonePtr);
    9723       83894 :             OutdoorDryBulb = secZoneHB.ZT;
    9724       83894 :             OutdoorHumRat = secZoneHB.ZoneAirHumRat;
    9725       83894 :             OutdoorWetBulb = state.dataDXCoils->DXCoil(DXCoilNum).EvapInletWetBulb;
    9726       83894 :             OutdoorPressure = state.dataEnvrn->OutBaroPress;
    9727             :         }
    9728             :     } else {
    9729     1023180 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(Mode) != 0) {
    9730     1023180 :             OutdoorPressure = state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(Mode)).Press;
    9731             :             // If node is not connected to anything, pressure = default, use weather data
    9732     1023180 :             if (OutdoorPressure == state.dataLoopNodes->DefaultNodeValues.Press)
    9733           0 :                 OutdoorPressure = state.dataEnvrn->OutBaroPress; // node not connected
    9734             :         } else {
    9735           0 :             OutdoorPressure = state.dataEnvrn->OutBaroPress;
    9736             :         }
    9737             :     }
    9738             : 
    9739    42209621 :     if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(Mode) == DataHeatBalance::RefrigCondenserType::Air) {
    9740    41130027 :         CondInletTemp = OutdoorDryBulb; // Outdoor dry-bulb temp
    9741    41130027 :         CompAmbTemp = OutdoorDryBulb;
    9742    41130027 :         if (state.dataDXCoils->DXCoil(DXCoilNum).IsSecondaryDXCoilInZone) {
    9743       83894 :             auto &secZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(state.dataDXCoils->DXCoil(DXCoilNum).SecZonePtr);
    9744       83894 :             CondInletTemp = secZoneHB.ZT;
    9745       83894 :             CompAmbTemp = CondInletTemp; // assumes compressor is in same location as secondary coil
    9746       83894 :             OutdoorDryBulb = CondInletTemp;
    9747       83894 :             OutdoorHumRat = secZoneHB.ZoneAirHumRat;
    9748       83894 :             OutdoorWetBulb = state.dataDXCoils->DXCoil(DXCoilNum).EvapInletWetBulb;
    9749       83894 :             OutdoorPressure = state.dataEnvrn->OutBaroPress;
    9750             :         }
    9751     1079594 :     } else if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(Mode) == DataHeatBalance::RefrigCondenserType::Evap) {
    9752       56414 :         RhoAir = PsyRhoAirFnPbTdbW(state, OutdoorPressure, OutdoorDryBulb, OutdoorHumRat);
    9753       56414 :         CondAirMassFlow = RhoAir * state.dataDXCoils->DXCoil(DXCoilNum).EvapCondAirFlow(Mode);
    9754             :         // (Outdoor wet-bulb temp from DataEnvironment) + (1.0-EvapCondEffectiveness) * (drybulb - wetbulb)
    9755       56414 :         CondInletTemp = OutdoorWetBulb + (OutdoorDryBulb - OutdoorWetBulb) * (1.0 - state.dataDXCoils->DXCoil(DXCoilNum).EvapCondEffect(Mode));
    9756       56414 :         CondInletHumRat = PsyWFnTdbTwbPb(state, CondInletTemp, OutdoorWetBulb, OutdoorPressure);
    9757       56414 :         CompAmbTemp = OutdoorDryBulb;
    9758     1023180 :     } else if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(Mode) == DataHeatBalance::RefrigCondenserType::WaterHeater) {
    9759     1023180 :         CompAmbTemp = HPWHCrankcaseDBTemp;   // Temperature at HP water heater compressor
    9760     1023180 :         CondInletTemp = HPWHCrankcaseDBTemp; // Temperature at HP water heater compressor
    9761             :     }
    9762             : 
    9763             :     // Initialize crankcase heater, operates below OAT defined in input deck for HP DX cooling coil
    9764             :     // If used in a heat pump, the value of MaxOAT in the heating coil overrides that in the cooling coil (in GetInput)
    9765    42209621 :     if (CompAmbTemp < state.dataDXCoils->DXCoil(DXCoilNum).MaxOATCrankcaseHeater) {
    9766    13027718 :         CrankcaseHeatingPower = state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterCapacity;
    9767             :     } else {
    9768    29181903 :         CrankcaseHeatingPower = 0.0;
    9769             :     }
    9770             : 
    9771             :     // calculate end time of current time step to determine if error messages should be printed
    9772    42209621 :     CurrentEndTime = state.dataGlobal->CurrentTime + SysTimeElapsed;
    9773             : 
    9774             :     //   Print warning messages only when valid and only for the first ocurrance. Let summary provide statistics.
    9775             :     //   Wait for next time step to print warnings. If simulation iterates, print out
    9776             :     //   the warning for the last iteration only. Must wait for next time step to accomplish this.
    9777             :     //   If a warning occurs and the simulation down shifts, the warning is not valid.
    9778    42209621 :     if (state.dataDXCoils->DXCoil(DXCoilNum).PrintLowAmbMessage) { // .AND. &
    9779        6431 :         if (CurrentEndTime > state.dataDXCoils->DXCoil(DXCoilNum).CurrentEndTimeLast &&
    9780         635 :             TimeStepSys >= state.dataDXCoils->DXCoil(DXCoilNum).TimeStepSysLast) {
    9781         635 :             if (state.dataDXCoils->DXCoil(DXCoilNum).LowAmbErrIndex == 0) {
    9782          12 :                 ShowWarningMessage(state, std::string{RoutineName} + state.dataDXCoils->DXCoil(DXCoilNum).LowAmbBuffer1);
    9783          12 :                 ShowContinueError(state, state.dataDXCoils->DXCoil(DXCoilNum).LowAmbBuffer2);
    9784          12 :                 ShowContinueError(state, "... Operation at low ambient temperatures may require special performance curves.");
    9785             :             }
    9786         635 :             if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(Mode) == DataHeatBalance::RefrigCondenserType::Air) {
    9787        3810 :                 ShowRecurringWarningErrorAtEnd(state,
    9788        1270 :                                                std::string{RoutineName} + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + "=\"" +
    9789        1905 :                                                    state.dataDXCoils->DXCoil(DXCoilNum).Name +
    9790             :                                                    "\" - Low condenser dry-bulb temperature error continues...",
    9791         635 :                                                state.dataDXCoils->DXCoil(DXCoilNum).LowAmbErrIndex,
    9792         635 :                                                state.dataDXCoils->DXCoil(DXCoilNum).LowTempLast,
    9793         635 :                                                state.dataDXCoils->DXCoil(DXCoilNum).LowTempLast,
    9794             :                                                _,
    9795             :                                                "[C]",
    9796             :                                                "[C]");
    9797             :             } else {
    9798           0 :                 ShowRecurringWarningErrorAtEnd(state,
    9799           0 :                                                std::string{RoutineName} + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + "=\"" +
    9800           0 :                                                    state.dataDXCoils->DXCoil(DXCoilNum).Name +
    9801             :                                                    "\" - Low condenser wet-bulb temperature error continues...",
    9802           0 :                                                state.dataDXCoils->DXCoil(DXCoilNum).LowAmbErrIndex,
    9803           0 :                                                state.dataDXCoils->DXCoil(DXCoilNum).LowTempLast,
    9804           0 :                                                state.dataDXCoils->DXCoil(DXCoilNum).LowTempLast,
    9805             :                                                _,
    9806             :                                                "[C]",
    9807             :                                                "[C]");
    9808             :             }
    9809             :         }
    9810             :     }
    9811             : 
    9812    42209621 :     if (state.dataDXCoils->DXCoil(DXCoilNum).PrintLowOutTempMessage) {
    9813        5243 :         if (CurrentEndTime > state.dataDXCoils->DXCoil(DXCoilNum).CurrentEndTimeLast &&
    9814         762 :             TimeStepSys >= state.dataDXCoils->DXCoil(DXCoilNum).TimeStepSysLast) {
    9815         762 :             if (state.dataDXCoils->DXCoil(DXCoilNum).LowOutletTempIndex == 0) {
    9816          10 :                 ShowWarningMessage(state, std::string{RoutineName} + state.dataDXCoils->DXCoil(DXCoilNum).LowOutTempBuffer1);
    9817          10 :                 ShowContinueError(state, state.dataDXCoils->DXCoil(DXCoilNum).LowOutTempBuffer2);
    9818          10 :                 ShowContinueError(state, "... Possible reasons for low outlet air dry-bulb temperatures are: This DX coil");
    9819          30 :                 ShowContinueError(state,
    9820          30 :                                   format("   1) may have a low inlet air dry-bulb temperature. Inlet air temperature = {:.3T} C.",
    9821          20 :                                          state.dataDXCoils->DXCoil(DXCoilNum).FullLoadInletAirTempLast));
    9822          10 :                 ShowContinueError(state, "   2) may have a low air flow rate per watt of cooling capacity. Check inputs.");
    9823          10 :                 ShowContinueError(state,
    9824             :                                   "   3) is used as part of a HX assisted cooling coil which uses a high sensible effectiveness. Check inputs.");
    9825             :             }
    9826        4572 :             ShowRecurringWarningErrorAtEnd(state,
    9827        1524 :                                            std::string{RoutineName} + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + "=\"" +
    9828        2286 :                                                state.dataDXCoils->DXCoil(DXCoilNum).Name +
    9829             :                                                "\" - Full load outlet temperature indicates a possibility of frost/freeze error continues. "
    9830             :                                                "Outlet air temperature statistics follow:",
    9831         762 :                                            state.dataDXCoils->DXCoil(DXCoilNum).LowOutletTempIndex,
    9832         762 :                                            state.dataDXCoils->DXCoil(DXCoilNum).FullLoadOutAirTempLast,
    9833         762 :                                            state.dataDXCoils->DXCoil(DXCoilNum).FullLoadOutAirTempLast);
    9834             :         }
    9835             :     }
    9836             : 
    9837             :     // save last system time step and last end time of current time step (used to determine if warning is valid)
    9838    42209621 :     state.dataDXCoils->DXCoil(DXCoilNum).TimeStepSysLast = TimeStepSys;
    9839    42209621 :     state.dataDXCoils->DXCoil(DXCoilNum).CurrentEndTimeLast = CurrentEndTime;
    9840    42209621 :     state.dataDXCoils->DXCoil(DXCoilNum).PrintLowAmbMessage = false;
    9841    42209621 :     state.dataDXCoils->DXCoil(DXCoilNum).PrintLowOutTempMessage = false;
    9842             : 
    9843    75630526 :     if ((AirMassFlow > 0.0) &&
    9844    34012288 :         (GetCurrentScheduleValue(state, state.dataDXCoils->DXCoil(DXCoilNum).SchedPtr) > 0.0 ||
    9845     1016561 :          state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_HeatPumpWaterHeaterPumped ||
    9846    33685964 :          state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_HeatPumpWaterHeaterWrapped) &&
    9847   108767571 :         (PartLoadRatio > 0.0) && (CompressorOp == CompressorOperation::On) &&
    9848    16636255 :         CompAmbTemp > state.dataDXCoils->DXCoil(DXCoilNum).MinOATCompressor) { // criteria for coil operation
    9849    16636255 :         if (FanOpMode == CycFanCycCoil) {
    9850     8659033 :             AirMassFlow /= (PartLoadRatio / DXcoolToHeatPLRRatio);
    9851     7977222 :         } else if (FanOpMode == ContFanCycCoil && state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num != CoilDX_CoolingTwoSpeed) {
    9852     7977222 :             AirMassFlow *= AirFlowRatio;
    9853             :         } else {
    9854           0 :             AirMassFlow = state.dataDXCoils->DXCoil(DXCoilNum).RatedAirMassFlowRate(Mode);
    9855             :         }
    9856             : 
    9857             :         // Check for valid air volume flow per rated total cooling capacity (200 - 500 cfm/ton)
    9858             : 
    9859             :         // for some reason there are diff's when using coil inlet air pressure
    9860             :         // these lines (more to follow) are commented out for the time being
    9861             : 
    9862    16636255 :         InletAirWetBulbC = PsyTwbFnTdbWPb(state, InletAirDryBulbTemp, InletAirHumRat, OutdoorPressure);
    9863    16636255 :         AirVolumeFlowRate = AirMassFlow / PsyRhoAirFnPbTdbW(state, OutdoorPressure, InletAirDryBulbTemp, InletAirHumRat);
    9864             :         //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
    9865             :         //  InletAirWetBulbC = PsyTwbFnTdbWPb(InletAirDryBulbTemp,InletAirHumRat,InletAirPressure)
    9866             :         //  AirVolumeFlowRate = AirMassFlow/ PsyRhoAirFnPbTdbW(InletAirPressure,InletAirDryBulbTemp, InletAirHumRat)
    9867    16636255 :         if (state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode) <= 0.0) {
    9868           0 :             ShowFatalError(state,
    9869           0 :                            std::string{RoutineName} + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + "=\"" +
    9870           0 :                                state.dataDXCoils->DXCoil(DXCoilNum).Name + "\" - Rated total cooling capacity is zero or less.");
    9871             :         }
    9872    33106305 :         if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_HeatPumpWaterHeaterPumped ||
    9873    16470050 :             state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_HeatPumpWaterHeaterWrapped) {
    9874      431264 :             VolFlowperRatedTotCap = AirVolumeFlowRate / state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap2;
    9875             :         } else {
    9876    16204991 :             VolFlowperRatedTotCap = AirVolumeFlowRate / state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode);
    9877             :         }
    9878    45967130 :         if (!FirstHVACIteration && !state.dataGlobal->WarmupFlag &&
    9879     2716804 :             state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num != CoilDX_HeatPumpWaterHeaterPumped &&
    9880    19326427 :             state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num != CoilDX_HeatPumpWaterHeaterWrapped &&
    9881     2665104 :             ((VolFlowperRatedTotCap < state.dataHVACGlobal->MinOperVolFlowPerRatedTotCap(DXCT)) ||
    9882     1331309 :              (VolFlowperRatedTotCap > state.dataHVACGlobal->MaxCoolVolFlowPerRatedTotCap(DXCT)))) {
    9883        2486 :             if (state.dataDXCoils->DXCoil(DXCoilNum).ErrIndex1 == 0) {
    9884           9 :                 ShowWarningMessage(
    9885             :                     state,
    9886          12 :                     format("{}{}=\"{}\" - Air volume flow rate per watt of rated total cooling capacity is out of range at {:.3R} m3/s/W.",
    9887             :                            RoutineName,
    9888           3 :                            state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
    9889           3 :                            state.dataDXCoils->DXCoil(DXCoilNum).Name,
    9890           3 :                            VolFlowperRatedTotCap));
    9891           3 :                 ShowContinueErrorTimeStamp(state, "");
    9892           9 :                 ShowContinueError(state,
    9893          12 :                                   format("Expected range for VolumeFlowPerRatedTotalCapacity=[{:.3R}--{:.3R}]",
    9894           3 :                                          state.dataHVACGlobal->MinOperVolFlowPerRatedTotCap(DXCT),
    9895           6 :                                          state.dataHVACGlobal->MaxCoolVolFlowPerRatedTotCap(DXCT)));
    9896           3 :                 ShowContinueError(state, "Possible causes include inconsistent air flow rates in system components,");
    9897           3 :                 ShowContinueError(state, "or variable air volume [VAV] system using incorrect coil type.");
    9898             :             }
    9899        9944 :             ShowRecurringWarningErrorAtEnd(
    9900             :                 state,
    9901        4972 :                 std::string{RoutineName} + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name +
    9902             :                     "\" - Air volume flow rate per watt of rated total cooling capacity is out of range error continues...",
    9903        2486 :                 state.dataDXCoils->DXCoil(DXCoilNum).ErrIndex1,
    9904             :                 VolFlowperRatedTotCap,
    9905             :                 VolFlowperRatedTotCap);
    9906    35425608 :         } else if (!state.dataGlobal->WarmupFlag && state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_HeatPumpWaterHeaterPumped &&
    9907    16652719 :                    state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_HeatPumpWaterHeaterWrapped &&
    9908           0 :                    ((VolFlowperRatedTotCap < state.dataHVACGlobal->MinOperVolFlowPerRatedTotCap(DXCT)) ||
    9909           0 :                     (VolFlowperRatedTotCap > state.dataHVACGlobal->MaxHeatVolFlowPerRatedTotCap(DXCT)))) {
    9910           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).ErrIndex1 == 0) {
    9911           0 :                 ShowWarningMessage(
    9912             :                     state,
    9913           0 :                     format("{}{}=\"{}\" - Air volume flow rate per watt of rated total water heating capacity is out of range at {:.2R} m3/s/W.",
    9914             :                            RoutineName,
    9915           0 :                            state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
    9916           0 :                            state.dataDXCoils->DXCoil(DXCoilNum).Name,
    9917           0 :                            VolFlowperRatedTotCap));
    9918           0 :                 ShowContinueErrorTimeStamp(state, "");
    9919           0 :                 ShowContinueError(state,
    9920           0 :                                   format("Expected range for VolumeFlowPerRatedTotalCapacity=[{:.3R}--{:.3R}]",
    9921           0 :                                          state.dataHVACGlobal->MinOperVolFlowPerRatedTotCap(DXCT),
    9922           0 :                                          state.dataHVACGlobal->MaxHeatVolFlowPerRatedTotCap(DXCT)));
    9923           0 :                 ShowContinueError(state,
    9924             :                                   "Possible causes may be that the parent object is calling for an actual supply air flow rate that is much "
    9925             :                                   "higher or lower than the DX coil rated supply air flow rate.");
    9926             :             }
    9927           0 :             ShowRecurringWarningErrorAtEnd(
    9928             :                 state,
    9929           0 :                 std::string{RoutineName} + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name +
    9930             :                     "\" - Air volume flow rate per watt of rated total water heating capacity is out of range error continues...",
    9931           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).ErrIndex1,
    9932             :                 VolFlowperRatedTotCap,
    9933             :                 VolFlowperRatedTotCap);
    9934             :         }
    9935             :         //    Adjust coil bypass factor for actual air flow rate. Use relation CBF = exp(-NTU) where
    9936             :         //    NTU = A0/(m*cp). Relationship models the cooling coil as a heat exchanger with Cmin/Cmax = 0.
    9937             : 
    9938    16636255 :         RatedCBF = state.dataDXCoils->DXCoil(DXCoilNum).RatedCBF(Mode);
    9939    16636255 :         if (RatedCBF > 0.0) {
    9940    16636255 :             A0 = -std::log(RatedCBF) * state.dataDXCoils->DXCoil(DXCoilNum).RatedAirMassFlowRate(Mode);
    9941             :         } else {
    9942           0 :             A0 = 0.0;
    9943             :         }
    9944    16636255 :         ADiff = -A0 / AirMassFlow;
    9945    16636255 :         if (ADiff >= DataPrecisionGlobals::EXP_LowerLimit) {
    9946    16613651 :             CBF = std::exp(ADiff);
    9947             :         } else {
    9948       22604 :             CBF = 0.0;
    9949             :         }
    9950             : 
    9951             :         //   check boundary for low ambient temperature and post warnings to individual DX coil buffers to print at end of time step
    9952    16636255 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(Mode) == DataHeatBalance::RefrigCondenserType::Air) {
    9953    16182422 :             if (OutdoorDryBulb < 0.0 && !state.dataGlobal->WarmupFlag) { // Same threshold as for air-cooled electric chiller
    9954        5796 :                 state.dataDXCoils->DXCoil(DXCoilNum).PrintLowAmbMessage = true;
    9955        5796 :                 state.dataDXCoils->DXCoil(DXCoilNum).LowTempLast = OutdoorDryBulb;
    9956        5796 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).LowAmbErrIndex == 0) {
    9957         260 :                     state.dataDXCoils->DXCoil(DXCoilNum).LowAmbBuffer1 =
    9958         520 :                         format("{} \"{}\" - Air-cooled condenser inlet dry-bulb temperature below 0 C. Outdoor dry-bulb temperature = {:.2R}",
    9959         130 :                                state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
    9960         130 :                                state.dataDXCoils->DXCoil(DXCoilNum).Name,
    9961         260 :                                OutdoorDryBulb);
    9962         520 :                     state.dataDXCoils->DXCoil(DXCoilNum).LowAmbBuffer2 = " ... Occurrence info = " + state.dataEnvrn->EnvironmentName + ", " +
    9963         650 :                                                                          state.dataEnvrn->CurMnDy + ' ' + CreateSysTimeIntervalString(state);
    9964             :                 }
    9965             :             }
    9966      453833 :         } else if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(Mode) == DataHeatBalance::RefrigCondenserType::Evap) {
    9967       22569 :             if (OutdoorWetBulb < 10.0 && !state.dataGlobal->WarmupFlag) { // Same threshold as for evap-cooled electric chiller
    9968           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).PrintLowAmbMessage = true;
    9969           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).LowTempLast = OutdoorWetBulb;
    9970           0 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).LowAmbErrIndex == 0) {
    9971           0 :                     state.dataDXCoils->DXCoil(DXCoilNum).LowAmbBuffer1 =
    9972           0 :                         format("{} \"{}\" - Evap-cooled condenser inlet wet-bulb temperature below 10 C. Outdoor wet-bulb temperature = {:.2R}",
    9973           0 :                                state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
    9974           0 :                                state.dataDXCoils->DXCoil(DXCoilNum).Name,
    9975           0 :                                OutdoorWetBulb);
    9976           0 :                     state.dataDXCoils->DXCoil(DXCoilNum).LowAmbBuffer2 = " ... Occurrence info = " + state.dataEnvrn->EnvironmentName + ", " +
    9977           0 :                                                                          state.dataEnvrn->CurMnDy + ' ' + CreateSysTimeIntervalString(state);
    9978             :                 }
    9979             :             }
    9980             :         }
    9981             : 
    9982             :         //  Get total capacity modifying factor (function of temperature) for off-rated conditions
    9983             :         //  InletAirHumRat may be modified in this ADP/BF loop, use temporary varible for calculations
    9984    16636255 :         InletAirHumRatTemp = InletAirHumRat;
    9985    16636255 :         AirMassFlowRatio = AirMassFlow / state.dataDXCoils->DXCoil(DXCoilNum).RatedAirMassFlowRate(Mode);
    9986             :         while (true) {
    9987    60561150 :             if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_HeatPumpWaterHeaterPumped ||
    9988    25621665 :                 state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_HeatPumpWaterHeaterWrapped) {
    9989             :                 // Coil:DX:HeatPumpWaterHeater does not have total cooling capacity as a function of temp or flow curve
    9990      705477 :                 TotCapTempModFac = 1.0;
    9991      705477 :                 TotCapFlowModFac = 1.0;
    9992             :             } else {
    9993    25082393 :                 if (state.dataCurveManager->PerfCurve(state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(Mode)).numDims == 2) {
    9994    25082393 :                     TotCapTempModFac = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(Mode), InletAirWetBulbC, CondInletTemp);
    9995             :                 } else {
    9996           0 :                     TotCapTempModFac = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(Mode), CondInletTemp);
    9997             :                 }
    9998             : 
    9999             :                 //    Warn user if curve output goes negative
   10000    25082393 :                 if (TotCapTempModFac < 0.0) {
   10001           0 :                     if (state.dataDXCoils->DXCoil(DXCoilNum).CCapFTempErrorIndex == 0) {
   10002           0 :                         ShowWarningMessage(state,
   10003           0 :                                            std::string{RoutineName} + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + " \"" +
   10004           0 :                                                state.dataDXCoils->DXCoil(DXCoilNum).Name + "\":");
   10005           0 :                         ShowContinueError(state,
   10006           0 :                                           format(" Total Cooling Capacity Modifier curve (function of temperature) output is negative ({:.3T}).",
   10007           0 :                                                  TotCapTempModFac));
   10008           0 :                         if (state.dataCurveManager->PerfCurve(state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(Mode)).numDims == 2) {
   10009           0 :                             ShowContinueError(state,
   10010           0 :                                               format(" Negative value occurs using a condenser inlet air temperature of {:.1T} and an inlet air "
   10011             :                                                      "wet-bulb temperature of {:.1T}.",
   10012             :                                                      CondInletTemp,
   10013           0 :                                                      InletAirWetBulbC));
   10014             :                         } else {
   10015           0 :                             ShowContinueError(state,
   10016           0 :                                               format(" Negative value occurs using a condenser inlet air temperature of {:.1T}.", CondInletTemp));
   10017             :                         }
   10018           0 :                         if (Mode > 1) {
   10019           0 :                             ShowContinueError(state, format(" Negative output results from stage {} compressor operation.", Mode));
   10020             :                         }
   10021           0 :                         ShowContinueErrorTimeStamp(state, " Resetting curve output to zero and continuing simulation.");
   10022             :                     }
   10023           0 :                     ShowRecurringWarningErrorAtEnd(
   10024             :                         state,
   10025           0 :                         std::string{RoutineName} + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + " \"" +
   10026           0 :                             state.dataDXCoils->DXCoil(DXCoilNum).Name +
   10027             :                             "\": Total Cooling Capacity Modifier curve (function of temperature) output is negative warning continues...",
   10028           0 :                         state.dataDXCoils->DXCoil(DXCoilNum).CCapFTempErrorIndex,
   10029             :                         TotCapTempModFac,
   10030             :                         TotCapTempModFac);
   10031           0 :                     TotCapTempModFac = 0.0;
   10032             :                 }
   10033             : 
   10034             :                 //    Get total capacity modifying factor (function of mass flow) for off-rated conditions
   10035    25082393 :                 TotCapFlowModFac = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).CCapFFlow(Mode), AirMassFlowRatio);
   10036             :                 //    Warn user if curve output goes negative
   10037    25082393 :                 if (TotCapFlowModFac < 0.0) {
   10038           0 :                     if (state.dataDXCoils->DXCoil(DXCoilNum).CCapFFlowErrorIndex == 0) {
   10039           0 :                         ShowWarningMessage(state,
   10040           0 :                                            std::string{RoutineName} + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + " \"" +
   10041           0 :                                                state.dataDXCoils->DXCoil(DXCoilNum).Name + "\":");
   10042           0 :                         ShowContinueError(state,
   10043           0 :                                           format(" Total Cooling Capacity Modifier curve (function of flow fraction) output is negative ({:.3T}).",
   10044           0 :                                                  TotCapFlowModFac));
   10045           0 :                         ShowContinueError(state, format(" Negative value occurs using an air flow fraction of {:.3T}.", AirMassFlowRatio));
   10046           0 :                         ShowContinueErrorTimeStamp(state, " Resetting curve output to zero and continuing simulation.");
   10047           0 :                         if (Mode > 1) {
   10048           0 :                             ShowContinueError(state, format(" Negative output results from stage {} compressor operation.", Mode));
   10049             :                         }
   10050             :                     }
   10051           0 :                     ShowRecurringWarningErrorAtEnd(
   10052             :                         state,
   10053           0 :                         std::string{RoutineName} + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + " \"" +
   10054           0 :                             state.dataDXCoils->DXCoil(DXCoilNum).Name +
   10055             :                             "\": Total Cooling Capacity Modifier curve (function of flow fraction) output is negative warning continues...",
   10056           0 :                         state.dataDXCoils->DXCoil(DXCoilNum).CCapFFlowErrorIndex,
   10057             :                         TotCapFlowModFac,
   10058             :                         TotCapFlowModFac);
   10059           0 :                     TotCapFlowModFac = 0.0;
   10060             :                 }
   10061             :             }
   10062    25787870 :             TotCap = state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode) * TotCapFlowModFac * TotCapTempModFac;
   10063             :             // if user specified SHR modifier curves are available calculate the SHR as follows:
   10064    25787870 :             if (state.dataDXCoils->DXCoil(DXCoilNum).UserSHRCurveExists) {
   10065           0 :                 SHR = CalcSHRUserDefinedCurves(state,
   10066             :                                                InletAirDryBulbTemp,
   10067             :                                                InletAirWetBulbC,
   10068             :                                                AirMassFlowRatio,
   10069           0 :                                                state.dataDXCoils->DXCoil(DXCoilNum).SHRFTemp(Mode),
   10070           0 :                                                state.dataDXCoils->DXCoil(DXCoilNum).SHRFFlow(Mode),
   10071           0 :                                                state.dataDXCoils->DXCoil(DXCoilNum).RatedSHR(Mode));
   10072           0 :                 hDelta = TotCap / AirMassFlow;
   10073           0 :                 break;
   10074             :             } else {
   10075             :                 // Calculate apparatus dew point conditions using TotCap and CBF
   10076    25787870 :                 hDelta = TotCap / AirMassFlow;
   10077    25787870 :                 hADP = InletAirEnthalpy - hDelta / (1.0 - CBF);
   10078    25787870 :                 tADP = PsyTsatFnHPb(state, hADP, OutdoorPressure, calcDoe2DXCoil);
   10079             :                 //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   10080             :                 //  tADP = PsyTsatFnHPb(hADP,InletAirPressure)
   10081    25787870 :                 wADP = PsyWFnTdbH(state, tADP, hADP, calcDoe2DXCoil);
   10082    25787870 :                 hTinwADP = PsyHFnTdbW(InletAirDryBulbTemp, wADP);
   10083    25787870 :                 if ((InletAirEnthalpy - hADP) > 1.e-10) {
   10084    25787870 :                     SHR = min((hTinwADP - hADP) / (InletAirEnthalpy - hADP), 1.0);
   10085             :                 } else {
   10086           0 :                     SHR = 1.0;
   10087             :                 }
   10088             :                 // Check for dry evaporator conditions (win < wadp)
   10089    25787870 :                 if (wADP > InletAirHumRatTemp || (Counter >= 1 && Counter < MaxIter)) {
   10090    11740830 :                     if (InletAirHumRatTemp == 0.0) InletAirHumRatTemp = 0.00001;
   10091    11740830 :                     werror = (InletAirHumRatTemp - wADP) / InletAirHumRatTemp;
   10092             :                     // Increase InletAirHumRatTemp at constant InletAirTemp to find coil dry-out point. Then use the
   10093             :                     // capacity at the dry-out point to determine exiting conditions from coil. This is required
   10094             :                     // since the TotCapTempModFac doesn't work properly with dry-coil conditions.
   10095    11740830 :                     InletAirHumRatTemp = RF * wADP + (1.0 - RF) * InletAirHumRatTemp;
   10096    11740830 :                     InletAirWetBulbC = PsyTwbFnTdbWPb(state, InletAirDryBulbTemp, InletAirHumRatTemp, OutdoorPressure);
   10097             :                     //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment
   10098             :                     //  line InletAirWetBulbC = PsyTwbFnTdbWPb(InletAirDryBulbTemp,InletAirHumRatTemp,InletAirPressure)
   10099    11740830 :                     ++Counter;
   10100    11740830 :                     if (std::abs(werror) > Tolerance) continue; // Recalculate with modified inlet conditions
   10101     2589215 :                     break;
   10102             :                 } else {
   10103             :                     break;
   10104             :                 }
   10105             :             }
   10106             :         } // end of DO iteration loop
   10107             : 
   10108    16636255 :         if (state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(Mode) > 0) {
   10109    16636255 :             PLF = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(Mode), PartLoadRatio); // Calculate part-load factor
   10110             :         } else {
   10111           0 :             PLF = 1.0;
   10112             :         }
   10113             : 
   10114    16636255 :         if (PLF < 0.7) {
   10115           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).ErrIndex2 == 0) {
   10116           0 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_HeatPumpWaterHeaterPumped ||
   10117           0 :                     state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_HeatPumpWaterHeaterWrapped) {
   10118           0 :                     ShowWarningMessage(state,
   10119           0 :                                        std::string{RoutineName} + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + "=\"" +
   10120           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", PLF curve value");
   10121           0 :                     ShowContinueError(state, format("The PLF curve value = {:.3T} for part-load ratio = {:.3T}", PLF, PartLoadRatio));
   10122           0 :                     ShowContinueErrorTimeStamp(state, "PLF curve values must be >= 0.7. PLF has been reset to 0.7 and simulation is continuing.");
   10123           0 :                     ShowContinueError(
   10124           0 :                         state, "Check the IO reference manual for PLF curve guidance [" + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + "].");
   10125             :                 } else {
   10126           0 :                     ShowWarningMessage(state,
   10127           0 :                                        std::string{RoutineName} + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + "=\"" +
   10128           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", PLF curve value");
   10129           0 :                     ShowContinueError(state, format("The PLF curve value = {:.3T} for part-load ratio = {:.3T}", PLF, PartLoadRatio));
   10130           0 :                     ShowContinueErrorTimeStamp(state, "PLF curve values must be >= 0.7. PLF has been reset to 0.7 and simulation is continuing.");
   10131           0 :                     ShowContinueError(
   10132           0 :                         state, "Check the IO reference manual for PLF curve guidance [" + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + "].");
   10133             :                 }
   10134             :             }
   10135           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_HeatPumpWaterHeaterPumped ||
   10136           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_HeatPumpWaterHeaterWrapped) {
   10137           0 :                 ShowRecurringWarningErrorAtEnd(state,
   10138           0 :                                                state.dataDXCoils->DXCoil(DXCoilNum).Name + ", " + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType +
   10139             :                                                    " PLF curve < 0.7 warning continues...",
   10140           0 :                                                state.dataDXCoils->DXCoil(DXCoilNum).ErrIndex2,
   10141             :                                                PLF,
   10142             :                                                PLF);
   10143             :             } else {
   10144           0 :                 ShowRecurringWarningErrorAtEnd(state,
   10145           0 :                                                state.dataDXCoils->DXCoil(DXCoilNum).Name + ", " + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType +
   10146             :                                                    " PLF curve < 0.7 warning continues...",
   10147           0 :                                                state.dataDXCoils->DXCoil(DXCoilNum).ErrIndex2,
   10148             :                                                PLF,
   10149             :                                                PLF);
   10150             :             }
   10151           0 :             PLF = 0.7;
   10152             :         }
   10153             : 
   10154    16636255 :         state.dataDXCoils->DXCoil(DXCoilNum).PartLoadRatio = PartLoadRatio;
   10155    16636255 :         state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction = PartLoadRatio / PLF;
   10156    17359763 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction > 1.0 &&
   10157      723508 :             std::abs(state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction - 1.0) > 0.001) {
   10158           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).ErrIndex3 == 0) {
   10159           0 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_HeatPumpWaterHeaterPumped ||
   10160           0 :                     state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_HeatPumpWaterHeaterWrapped) {
   10161           0 :                     ShowWarningMessage(state,
   10162           0 :                                        std::string{RoutineName} + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + "=\"" +
   10163           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", runtime fraction");
   10164           0 :                     ShowWarningMessage(
   10165             :                         state,
   10166           0 :                         format("The runtime fraction exceeded 1.0. [{:.4R}].", state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction));
   10167           0 :                     ShowContinueError(state, "Runtime fraction reset to 1 and the simulation will continue.");
   10168           0 :                     ShowContinueError(
   10169           0 :                         state, "Check the IO reference manual for PLF curve guidance [" + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + "].");
   10170           0 :                     ShowContinueErrorTimeStamp(state, "");
   10171             :                 } else {
   10172           0 :                     ShowWarningMessage(state,
   10173           0 :                                        std::string{RoutineName} + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + "=\"" +
   10174           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).Name + "\", runtime fraction");
   10175           0 :                     ShowWarningMessage(
   10176             :                         state,
   10177           0 :                         format("The runtime fraction exceeded 1.0. [{:.4R}].", state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction));
   10178           0 :                     ShowContinueError(state, "Runtime fraction reset to 1 and the simulation will continue.");
   10179           0 :                     ShowContinueError(
   10180           0 :                         state, "Check the IO reference manual for PLF curve guidance [" + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + "].");
   10181           0 :                     ShowContinueErrorTimeStamp(state, "");
   10182             :                 }
   10183             :             }
   10184           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_HeatPumpWaterHeaterPumped ||
   10185           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_HeatPumpWaterHeaterWrapped) {
   10186           0 :                 ShowRecurringWarningErrorAtEnd(state,
   10187           0 :                                                state.dataDXCoils->DXCoil(DXCoilNum).Name + ", " + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType +
   10188             :                                                    " runtime fraction > 1.0 warning continues...",
   10189           0 :                                                state.dataDXCoils->DXCoil(DXCoilNum).ErrIndex3,
   10190           0 :                                                state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction,
   10191           0 :                                                state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction);
   10192             :             } else {
   10193           0 :                 ShowRecurringWarningErrorAtEnd(state,
   10194           0 :                                                state.dataDXCoils->DXCoil(DXCoilNum).Name + ", " + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType +
   10195             :                                                    " runtime fraction > 1.0 warning continues...",
   10196           0 :                                                state.dataDXCoils->DXCoil(DXCoilNum).ErrIndex3,
   10197           0 :                                                state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction,
   10198           0 :                                                state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction);
   10199             :             }
   10200           0 :             state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction = 1.0; // Reset coil runtime fraction to 1.0
   10201    16636255 :         } else if (state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction > 1.0) {
   10202      723508 :             state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction = 1.0; // Reset coil runtime fraction to 1.0
   10203             :         }
   10204             : 
   10205             :         // If cycling fan, send coil part-load fraction to on/off fan via HVACDataGlobals
   10206    16636255 :         if (FanOpMode == CycFanCycCoil) OnOffFanPartLoadFraction = PLF;
   10207             : 
   10208             :         //  Calculate full load output conditions
   10209    16636255 :         if (state.dataDXCoils->DXCoil(DXCoilNum).UserSHRCurveExists) {
   10210           0 :             FullLoadOutAirEnth = InletAirEnthalpy - hDelta;
   10211           0 :             if (SHR < 1.0) {
   10212           0 :                 hTinwout = InletAirEnthalpy - (1.0 - SHR) * hDelta;
   10213           0 :                 FullLoadOutAirHumRat = PsyWFnTdbH(state, InletAirDryBulbTemp, hTinwout);
   10214           0 :                 if (FullLoadOutAirHumRat <= 0.0) {
   10215           0 :                     FullLoadOutAirHumRat = min(DryCoilOutletHumRatioMin, InletAirHumRat);
   10216             :                 }
   10217             :             } else {
   10218           0 :                 SHR = 1.0;
   10219           0 :                 FullLoadOutAirHumRat = InletAirHumRat;
   10220             :             }
   10221             :         } else {
   10222    16636255 :             if (SHR > 1.0 || Counter > 0) SHR = 1.0;
   10223    16636255 :             FullLoadOutAirEnth = InletAirEnthalpy - TotCap / AirMassFlow;
   10224    16636255 :             hTinwout = InletAirEnthalpy - (1.0 - SHR) * hDelta;
   10225    16636255 :             if (SHR < 1.0) {
   10226    14047040 :                 FullLoadOutAirHumRat = PsyWFnTdbH(state, InletAirDryBulbTemp, hTinwout);
   10227             :             } else {
   10228     2589215 :                 FullLoadOutAirHumRat = InletAirHumRat;
   10229             :             }
   10230             :         }
   10231    16636255 :         FullLoadOutAirTemp = PsyTdbFnHW(FullLoadOutAirEnth, FullLoadOutAirHumRat);
   10232             : 
   10233             :         // Check for saturation error and modify temperature at constant enthalpy
   10234    16636255 :         if (FullLoadOutAirTemp < PsyTsatFnHPb(state, FullLoadOutAirEnth, OutdoorPressure)) {
   10235      231514 :             FullLoadOutAirTemp = PsyTsatFnHPb(state, FullLoadOutAirEnth, OutdoorPressure);
   10236             :             //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   10237             :             //   IF(FullLoadOutAirTemp .LT. PsyTsatFnHPb(FullLoadOutAirEnth,InletAirPressure)) THEN
   10238             :             //    FullLoadOutAirTemp = PsyTsatFnHPb(FullLoadOutAirEnth,InletAirPressure)
   10239      231514 :             FullLoadOutAirHumRat = PsyWFnTdbH(state, FullLoadOutAirTemp, FullLoadOutAirEnth);
   10240             :         }
   10241             : 
   10242             :         // Store actual outlet conditions when DX coil is ON for use in heat recovery module
   10243    16636255 :         state.dataDXCoils->DXCoilFullLoadOutAirTemp(DXCoilNum) = FullLoadOutAirTemp;
   10244    16636255 :         state.dataDXCoils->DXCoilFullLoadOutAirHumRat(DXCoilNum) = FullLoadOutAirHumRat;
   10245             : 
   10246             :         // Add warning message for cold cooling coil (FullLoadOutAirTemp < 2 C)
   10247    16636255 :         if (FullLoadOutAirTemp < 2.0 && !FirstHVACIteration && !state.dataGlobal->WarmupFlag) {
   10248        4485 :             state.dataDXCoils->DXCoil(DXCoilNum).PrintLowOutTempMessage = true;
   10249        4485 :             state.dataDXCoils->DXCoil(DXCoilNum).FullLoadOutAirTempLast = FullLoadOutAirTemp;
   10250        4485 :             if (state.dataDXCoils->DXCoil(DXCoilNum).LowOutletTempIndex == 0) {
   10251          78 :                 state.dataDXCoils->DXCoil(DXCoilNum).FullLoadInletAirTempLast = InletAirDryBulbTemp;
   10252         156 :                 state.dataDXCoils->DXCoil(DXCoilNum).LowOutTempBuffer1 =
   10253         312 :                     format("{} \"{}\" - Full load outlet air dry-bulb temperature < 2C. This indicates the "
   10254             :                            "possibility of coil frost/freeze. Outlet temperature = {:.2R} C.",
   10255          78 :                            state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
   10256          78 :                            state.dataDXCoils->DXCoil(DXCoilNum).Name,
   10257         156 :                            FullLoadOutAirTemp);
   10258         312 :                 state.dataDXCoils->DXCoil(DXCoilNum).LowOutTempBuffer2 = " ...Occurrence info = " + state.dataEnvrn->EnvironmentName + ", " +
   10259         390 :                                                                          state.dataEnvrn->CurMnDy + ' ' + CreateSysTimeIntervalString(state);
   10260             :             }
   10261             :         }
   10262             : 
   10263             :         //  If constant fan with cycling compressor, call function to determine "effective SHR"
   10264             :         //  which includes the part-load degradation on latent capacity
   10265    16636255 :         if (FanOpMode == ContFanCycCoil) {
   10266     7977222 :             QLatRated = state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode) * (1.0 - state.dataDXCoils->DXCoil(DXCoilNum).RatedSHR(Mode));
   10267     7977222 :             QLatActual = TotCap * (1.0 - SHR);
   10268     7977222 :             SHRUnadjusted = SHR;
   10269    15954444 :             SHR = CalcEffectiveSHR(state,
   10270             :                                    DXCoilNum,
   10271             :                                    SHR,
   10272     7977222 :                                    state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction,
   10273             :                                    QLatRated,
   10274             :                                    QLatActual,
   10275             :                                    InletAirDryBulbTemp,
   10276             :                                    InletAirWetBulbC,
   10277             :                                    Mode);
   10278             :             // For multimode coil, if stage-2 operation (modes 2 or 4), adjust Stage1&2 SHR to account for
   10279             :             // Stage 1 operating at full load, so there is no degradation for that portion
   10280             :             // Use the stage 1 bypass fraction to allocate
   10281     7977222 :             if (Mode == 2 || Mode == 4) {
   10282      196768 :                 SHR = SHRUnadjusted * (1.0 - state.dataDXCoils->DXCoil(DXCoilNum).BypassedFlowFrac(Mode - 1)) +
   10283       98384 :                       SHR * state.dataDXCoils->DXCoil(DXCoilNum).BypassedFlowFrac(Mode - 1);
   10284             :             }
   10285             : 
   10286             :             //  Calculate full load output conditions
   10287     7977222 :             if (state.dataDXCoils->DXCoil(DXCoilNum).UserSHRCurveExists) {
   10288           0 :                 FullLoadOutAirEnth = InletAirEnthalpy - hDelta;
   10289           0 :                 if (SHR < 1.0) {
   10290           0 :                     hTinwout = InletAirEnthalpy - (1.0 - SHR) * hDelta;
   10291           0 :                     FullLoadOutAirHumRat = PsyWFnTdbH(state, InletAirDryBulbTemp, hTinwout);
   10292           0 :                     if (FullLoadOutAirHumRat <= 0.0) {
   10293           0 :                         FullLoadOutAirHumRat = min(DryCoilOutletHumRatioMin, InletAirHumRat);
   10294             :                     }
   10295             :                 } else {
   10296           0 :                     SHR = 1.0;
   10297           0 :                     FullLoadOutAirHumRat = InletAirHumRat;
   10298             :                 }
   10299             :             } else {
   10300     7977222 :                 if (SHR > 1.0 || Counter > 0) SHR = 1.0;
   10301     7977222 :                 FullLoadOutAirEnth = InletAirEnthalpy - TotCap / AirMassFlow;
   10302     7977222 :                 hTinwout = InletAirEnthalpy - (1.0 - SHR) * hDelta;
   10303     7977222 :                 if (SHR < 1.0) {
   10304     6511744 :                     FullLoadOutAirHumRat = PsyWFnTdbH(state, InletAirDryBulbTemp, hTinwout);
   10305             :                 } else {
   10306     1465478 :                     FullLoadOutAirHumRat = InletAirHumRat;
   10307             :                 }
   10308             :             }
   10309     7977222 :             FullLoadOutAirTemp = PsyTdbFnHW(FullLoadOutAirEnth, FullLoadOutAirHumRat);
   10310             : 
   10311             :             // apply latent degradation model to cycling fan when RH control is desired and heating coil operates
   10312             :             // longer than the cooling coil. DXcoolToHeatPLRRatio = Cooling coil PLR / Heating coil PLR.
   10313     8659033 :         } else if (FanOpMode == CycFanCycCoil) {
   10314     8659033 :             if (DXcoolToHeatPLRRatio < 1.0) {
   10315           0 :                 QLatRated = state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode) * (1.0 - state.dataDXCoils->DXCoil(DXCoilNum).RatedSHR(Mode));
   10316           0 :                 QLatActual = TotCap * (1.0 - SHR);
   10317           0 :                 HeatRTF = PartLoadRatio / DXcoolToHeatPLRRatio;
   10318           0 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilPLFCurvePTR > 0) {
   10319           0 :                     HeatingCoilPLF = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilPLFCurvePTR, HeatRTF);
   10320           0 :                     if (HeatingCoilPLF > 0) HeatRTF /= HeatingCoilPLF;
   10321             :                 }
   10322           0 :                 SHRUnadjusted = SHR;
   10323           0 :                 SHR = CalcEffectiveSHR(state,
   10324             :                                        DXCoilNum,
   10325             :                                        SHR,
   10326           0 :                                        state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction,
   10327             :                                        QLatRated,
   10328             :                                        QLatActual,
   10329             :                                        InletAirDryBulbTemp,
   10330             :                                        InletAirWetBulbC,
   10331             :                                        Mode,
   10332             :                                        HeatRTF);
   10333             :                 //   Calculate full load output conditions
   10334           0 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).UserSHRCurveExists) {
   10335           0 :                     FullLoadOutAirEnth = InletAirEnthalpy - hDelta;
   10336           0 :                     if (SHR < 1.0) {
   10337           0 :                         hTinwout = InletAirEnthalpy - (1.0 - SHR) * hDelta;
   10338           0 :                         FullLoadOutAirHumRat = PsyWFnTdbH(state, InletAirDryBulbTemp, hTinwout);
   10339           0 :                         if (FullLoadOutAirHumRat <= 0.0) {
   10340           0 :                             FullLoadOutAirHumRat = min(DryCoilOutletHumRatioMin, InletAirHumRat);
   10341             :                         }
   10342             :                     } else {
   10343           0 :                         SHR = 1.0;
   10344           0 :                         FullLoadOutAirHumRat = InletAirHumRat;
   10345             :                     }
   10346             :                 } else {
   10347           0 :                     if (SHR > 1.0 || Counter > 0) SHR = 1.0;
   10348           0 :                     FullLoadOutAirEnth = InletAirEnthalpy - TotCap / AirMassFlow;
   10349           0 :                     hTinwout = InletAirEnthalpy - (1.0 - SHR) * hDelta;
   10350           0 :                     if (SHR < 1.0) {
   10351           0 :                         FullLoadOutAirHumRat = PsyWFnTdbH(state, InletAirDryBulbTemp, hTinwout);
   10352             :                     } else {
   10353           0 :                         FullLoadOutAirHumRat = InletAirHumRat;
   10354             :                     }
   10355             :                 }
   10356           0 :                 FullLoadOutAirTemp = PsyTdbFnHW(FullLoadOutAirEnth, FullLoadOutAirHumRat);
   10357             :             }
   10358             :         }
   10359             : 
   10360             :         //  Calculate actual outlet conditions for the input part load ratio
   10361             :         //  Actual outlet conditions are "average" for time step
   10362             : 
   10363             :         // For multimode coil, if stage-2 operation (modes 2 or 4), return "full load" outlet conditions
   10364    16636255 :         if (((FanOpMode == ContFanCycCoil) && (Mode == 1)) || (Mode == 3)) {
   10365             :             // Continuous fan, cycling compressor
   10366     7878838 :             OutletAirEnthalpy = ((PartLoadRatio * AirFlowRatio) * FullLoadOutAirEnth + (1.0 - (PartLoadRatio * AirFlowRatio)) * InletAirEnthalpy);
   10367     7878838 :             OutletAirHumRat = ((PartLoadRatio * AirFlowRatio) * FullLoadOutAirHumRat + (1.0 - (PartLoadRatio * AirFlowRatio)) * InletAirHumRat);
   10368     7878838 :             OutletAirTemp = PsyTdbFnHW(OutletAirEnthalpy, OutletAirHumRat);
   10369             :         } else {
   10370             :             // Default to cycling fan, cycling compressor
   10371             :             // Also return this result for stage 2 operation of multimode coil
   10372             :             // Cycling fan typically provides full outlet conditions. When RH control is used, account for additional
   10373             :             // heating run time by using cooing/heating ratio the same as constant fan (otherwise PLRRatio = 1).
   10374     8757417 :             OutletAirEnthalpy = FullLoadOutAirEnth * DXcoolToHeatPLRRatio + InletAirEnthalpy * (1.0 - DXcoolToHeatPLRRatio);
   10375     8757417 :             OutletAirHumRat = FullLoadOutAirHumRat * DXcoolToHeatPLRRatio + InletAirHumRat * (1.0 - DXcoolToHeatPLRRatio);
   10376     8757417 :             OutletAirTemp = FullLoadOutAirTemp * DXcoolToHeatPLRRatio + InletAirDryBulbTemp * (1.0 - DXcoolToHeatPLRRatio);
   10377             :         }
   10378             : 
   10379             :         // Check for saturation error and modify temperature at constant enthalpy
   10380    16636255 :         if (OutletAirTemp < PsyTsatFnHPb(state, OutletAirEnthalpy, OutdoorPressure, calcDoe2DXCoil)) {
   10381      157498 :             OutletAirTemp = PsyTsatFnHPb(state, OutletAirEnthalpy, OutdoorPressure);
   10382             :             //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   10383             :             //   IF(OutletAirTemp .LT. PsyTsatFnHPb(OutletAirEnthalpy,InletAirPressure)) THEN
   10384             :             //    OutletAirTemp = PsyTsatFnHPb(OutletAirEnthalpy,InletAirPressure)
   10385      157498 :             OutletAirHumRat = PsyWFnTdbH(state, OutletAirTemp, OutletAirEnthalpy);
   10386             :         }
   10387             : 
   10388             :         // Mix with air that was bypassed around coil, if any
   10389    16636255 :         if (BypassFlowFraction > 0.0) {
   10390      103680 :             OutletAirEnthalpy = (1.0 - BypassFlowFraction) * OutletAirEnthalpy + BypassFlowFraction * InletAirEnthalpy;
   10391      103680 :             OutletAirHumRat = (1.0 - BypassFlowFraction) * OutletAirHumRat + BypassFlowFraction * InletAirHumRat;
   10392      103680 :             OutletAirTemp = PsyTdbFnHW(OutletAirEnthalpy, OutletAirHumRat);
   10393             :             // Check for saturation error and modify temperature at constant enthalpy
   10394      103680 :             if (OutletAirTemp < PsyTsatFnHPb(state, OutletAirEnthalpy, OutdoorPressure)) {
   10395           0 :                 OutletAirTemp = PsyTsatFnHPb(state, OutletAirEnthalpy, OutdoorPressure);
   10396             :                 //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   10397             :                 //     IF(OutletAirTemp .LT. PsyTsatFnHPb(OutletAirEnthalpy,InletAirPressure)) THEN
   10398             :                 //       OutletAirTemp = PsyTsatFnHPb(OutletAirEnthalpy,InletAirPressure)
   10399           0 :                 OutletAirHumRat = PsyWFnTdbH(state, OutletAirTemp, OutletAirEnthalpy);
   10400             :             }
   10401             :         }
   10402             : 
   10403             :         // Calculate electricity consumed. First, get EIR modifying factors for off-rated conditions
   10404    33106305 :         if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_HeatPumpWaterHeaterPumped ||
   10405    16470050 :             state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_HeatPumpWaterHeaterWrapped) {
   10406             :             //   Coil:DX:HeatPumpWaterHeater does not have EIR temp or flow curves
   10407      431264 :             EIRTempModFac = 1.0;
   10408      431264 :             EIRFlowModFac = 1.0;
   10409             :         } else {
   10410    16204991 :             EIRTempModFac = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).EIRFTemp(Mode), InletAirWetBulbC, CondInletTemp);
   10411             : 
   10412             :             //   Warn user if curve output goes negative
   10413    16204991 :             if (EIRTempModFac < 0.0) {
   10414           0 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).EIRFTempErrorIndex == 0) {
   10415           0 :                     ShowWarningMessage(state,
   10416           0 :                                        std::string{RoutineName} + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + "=\"" +
   10417           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).Name + "\":");
   10418           0 :                     ShowContinueError(
   10419           0 :                         state, format(" Energy Input Ratio Modifier curve (function of temperature) output is negative ({:.3T}).", EIRTempModFac));
   10420           0 :                     if (state.dataCurveManager->PerfCurve(state.dataDXCoils->DXCoil(DXCoilNum).EIRFTemp(Mode)).numDims == 2) {
   10421           0 :                         ShowContinueError(state,
   10422           0 :                                           format(" Negative value occurs using a condenser inlet air temperature of {:.1T} and an inlet air "
   10423             :                                                  "wet-bulb temperature of {:.1T}.",
   10424             :                                                  CondInletTemp,
   10425           0 :                                                  InletAirWetBulbC));
   10426             :                     } else {
   10427           0 :                         ShowContinueError(state, format(" Negative value occurs using a condenser inlet air temperature of {:.1T}.", CondInletTemp));
   10428             :                     }
   10429           0 :                     if (Mode > 1) {
   10430           0 :                         ShowContinueError(state, format(" Negative output results from stage {} compressor operation.", Mode));
   10431             :                     }
   10432           0 :                     ShowContinueErrorTimeStamp(state, " Resetting curve output to zero and continuing simulation.");
   10433             :                 }
   10434           0 :                 ShowRecurringWarningErrorAtEnd(
   10435             :                     state,
   10436           0 :                     std::string{RoutineName} + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name +
   10437             :                         "\": Energy Input Ratio Modifier curve (function of temperature) output is negative warning continues...",
   10438           0 :                     state.dataDXCoils->DXCoil(DXCoilNum).EIRFTempErrorIndex,
   10439             :                     EIRTempModFac,
   10440             :                     EIRTempModFac);
   10441           0 :                 EIRTempModFac = 0.0;
   10442             :             }
   10443             : 
   10444    16204991 :             EIRFlowModFac = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).EIRFFlow(Mode), AirMassFlowRatio);
   10445             : 
   10446             :             //   Warn user if curve output goes negative
   10447    16204991 :             if (EIRFlowModFac < 0.0) {
   10448           0 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).EIRFFlowErrorIndex == 0) {
   10449           0 :                     ShowWarningMessage(state,
   10450           0 :                                        std::string{RoutineName} + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + "=\"" +
   10451           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).Name + "\":");
   10452           0 :                     ShowContinueError(
   10453           0 :                         state, format(" Energy Input Ratio Modifier curve (function of flow fraction) output is negative ({:.3T}).", EIRFlowModFac));
   10454           0 :                     ShowContinueError(state, format(" Negative value occurs using an air flow fraction of {:.3T}.", AirMassFlowRatio));
   10455           0 :                     ShowContinueErrorTimeStamp(state, " Resetting curve output to zero and continuing simulation.");
   10456           0 :                     if (Mode > 1) {
   10457           0 :                         ShowContinueError(state, format(" Negative output results from stage {} compressor operation.", Mode));
   10458             :                     }
   10459             :                 }
   10460           0 :                 ShowRecurringWarningErrorAtEnd(
   10461             :                     state,
   10462           0 :                     std::string{RoutineName} + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + "=\"" + state.dataDXCoils->DXCoil(DXCoilNum).Name +
   10463             :                         "\": Energy Input Ratio Modifier curve (function of flow fraction) output is negative warning continues...",
   10464           0 :                     state.dataDXCoils->DXCoil(DXCoilNum).EIRFFlowErrorIndex,
   10465             :                     EIRFlowModFac,
   10466             :                     EIRFlowModFac);
   10467           0 :                 EIRFlowModFac = 0.0;
   10468             :             }
   10469             :         }
   10470             : 
   10471    16636255 :         EIR = state.dataDXCoils->DXCoil(DXCoilNum).RatedEIR(Mode) * EIRFlowModFac * EIRTempModFac;
   10472             : 
   10473             :         // For multimode coil, if stage-2 operation (Modes 2 or 4), return "full load" power adjusted for PLF
   10474    16636255 :         if (Mode == 1 || Mode == 3) {
   10475    16537871 :             state.dataDXCoils->DXCoil(DXCoilNum).ElecCoolingPower = TotCap * EIR * state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction;
   10476             :         } else {
   10477       98384 :             state.dataDXCoils->DXCoil(DXCoilNum).ElecCoolingPower =
   10478       98384 :                 TotCap * EIR * state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction / PartLoadRatio;
   10479             :         }
   10480             : 
   10481             :         // Reset AirMassFlow to inlet node air mass flow for final total, sensible and latent calculations
   10482             :         // since AirMassFlow might have been modified above (in this subroutine):
   10483             :         //     IF (FanOpMode .EQ. CycFanCycCoil) AirMassFlow = AirMassFlow / PartLoadRatio
   10484             :         // For multimode coil, this should be full flow including bypassed fraction
   10485    16636255 :         AirMassFlow = state.dataDXCoils->DXCoil(DXCoilNum).InletAirMassFlowRate;
   10486    49908765 :         CalcComponentSensibleLatentOutput(AirMassFlow,
   10487             :                                           InletAirDryBulbTemp,
   10488             :                                           InletAirHumRat,
   10489             :                                           OutletAirTemp,
   10490             :                                           OutletAirHumRat,
   10491    16636255 :                                           state.dataDXCoils->DXCoil(DXCoilNum).SensCoolingEnergyRate,
   10492    16636255 :                                           state.dataDXCoils->DXCoil(DXCoilNum).LatCoolingEnergyRate,
   10493    16636255 :                                           state.dataDXCoils->DXCoil(DXCoilNum).TotalCoolingEnergyRate);
   10494             : 
   10495             :         // Set DataHeatGlobal heat reclaim variable for use by heat reclaim coil (part load ratio is accounted for)
   10496             :         // Calculation for heat reclaim needs to be corrected to use compressor power (not including condenser fan power)
   10497    16636255 :         state.dataHeatBal->HeatReclaimDXCoil(DXCoilNum).AvailCapacity =
   10498    16636255 :             state.dataDXCoils->DXCoil(DXCoilNum).TotalCoolingEnergyRate + state.dataDXCoils->DXCoil(DXCoilNum).ElecCoolingPower;
   10499             : 
   10500             :         // Calculate crankcase heater power using the runtime fraction for this DX cooling coil only if there is no companion DX coil.
   10501             :         // Else use the largest runtime fraction of this DX cooling coil and the companion DX heating coil.
   10502    16636255 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CompanionUpstreamDXCoil == 0) {
   10503    16636255 :             state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterPower =
   10504    16636255 :                 CrankcaseHeatingPower * (1.0 - state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction);
   10505             :         } else {
   10506           0 :             state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterPower =
   10507           0 :                 CrankcaseHeatingPower *
   10508           0 :                 (1.0 - max(state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction,
   10509           0 :                            state.dataDXCoils->DXCoil(state.dataDXCoils->DXCoil(DXCoilNum).CompanionUpstreamDXCoil).HeatingCoilRuntimeFraction));
   10510             :         }
   10511             : 
   10512    16636255 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(Mode) == DataHeatBalance::RefrigCondenserType::Evap) {
   10513             :             //******************
   10514             :             //             WATER CONSUMPTION IN m3 OF WATER FOR DIRECT
   10515             :             //             H2O [m3/s] = Delta W[kgWater/kgDryAir]*Mass Flow Air[kgDryAir/s]
   10516             :             //                                /RhoWater [kgWater/m3]
   10517             :             //******************
   10518       22569 :             RhoWater = RhoH2O(OutdoorDryBulb);
   10519       22569 :             state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterConsumpRate =
   10520       22569 :                 (CondInletHumRat - OutdoorHumRat) * CondAirMassFlow / RhoWater * state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction;
   10521       22569 :             state.dataDXCoils->DXCoil(DXCoilNum).EvapCondPumpElecPower =
   10522       22569 :                 state.dataDXCoils->DXCoil(DXCoilNum).EvapCondPumpElecNomPower(Mode) * state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction;
   10523             :             // Calculate basin heater power
   10524       90276 :             CalcBasinHeaterPower(state,
   10525       22569 :                                  state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterPowerFTempDiff,
   10526       22569 :                                  state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterSchedulePtr,
   10527       22569 :                                  state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterSetPointTemp,
   10528       22569 :                                  state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterPower);
   10529       22569 :             if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_CoolingSingleSpeed) {
   10530       22569 :                 state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterPower *= (1.0 - state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction);
   10531             :             }
   10532             :         }
   10533             : 
   10534    16636255 :         state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp = OutletAirTemp;
   10535    16636255 :         state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat = OutletAirHumRat;
   10536    16636255 :         state.dataDXCoils->DXCoil(DXCoilNum).OutletAirEnthalpy = OutletAirEnthalpy;
   10537             : 
   10538             :     } else {
   10539             : 
   10540             :         // DX coil is off; just pass through conditions
   10541    25573366 :         state.dataDXCoils->DXCoil(DXCoilNum).OutletAirEnthalpy = state.dataDXCoils->DXCoil(DXCoilNum).InletAirEnthalpy;
   10542    25573366 :         state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat = state.dataDXCoils->DXCoil(DXCoilNum).InletAirHumRat;
   10543    25573366 :         state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp = state.dataDXCoils->DXCoil(DXCoilNum).InletAirTemp;
   10544             : 
   10545    25573366 :         state.dataDXCoils->DXCoil(DXCoilNum).ElecCoolingPower = 0.0;
   10546    25573366 :         state.dataDXCoils->DXCoil(DXCoilNum).TotalCoolingEnergyRate = 0.0;
   10547    25573366 :         state.dataDXCoils->DXCoil(DXCoilNum).SensCoolingEnergyRate = 0.0;
   10548    25573366 :         state.dataDXCoils->DXCoil(DXCoilNum).LatCoolingEnergyRate = 0.0;
   10549    25573366 :         state.dataDXCoils->DXCoil(DXCoilNum).EvapCondPumpElecPower = 0.0;
   10550    25573366 :         state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterConsumpRate = 0.0;
   10551             : 
   10552             :         // Reset globals when DX coil is OFF for use in heat recovery module
   10553    25573366 :         state.dataDXCoils->DXCoilFullLoadOutAirTemp(DXCoilNum) = 0.0;
   10554    25573366 :         state.dataDXCoils->DXCoilFullLoadOutAirHumRat(DXCoilNum) = 0.0;
   10555             : 
   10556             :         // Calculate crankcase heater power using the runtime fraction for this DX cooling coil (here DXCoolingCoilRTF=0) if
   10557             :         // there is no companion DX coil, or the runtime fraction of the companion DX heating coil (here DXHeatingCoilRTF>=0).
   10558    25573366 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CompanionUpstreamDXCoil == 0) {
   10559    25573366 :             state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterPower = CrankcaseHeatingPower;
   10560             :         } else {
   10561           0 :             state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterPower =
   10562           0 :                 CrankcaseHeatingPower *
   10563           0 :                 (1.0 - state.dataDXCoils->DXCoil(state.dataDXCoils->DXCoil(DXCoilNum).CompanionUpstreamDXCoil).HeatingCoilRuntimeFraction);
   10564             :         }
   10565             : 
   10566             :         // Calculate basin heater power
   10567    25573366 :         if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_CoolingTwoStageWHumControl) {
   10568       76105 :             if (any_eq(state.dataDXCoils->DXCoil(DXCoilNum).CondenserType, DataHeatBalance::RefrigCondenserType::Evap)) {
   10569           0 :                 CalcBasinHeaterPower(state,
   10570           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterPowerFTempDiff,
   10571           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterSchedulePtr,
   10572           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterSetPointTemp,
   10573           0 :                                      state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterPower);
   10574             :             }
   10575             :         } else {
   10576    25497261 :             if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(Mode) == DataHeatBalance::RefrigCondenserType::Evap) {
   10577      135380 :                 CalcBasinHeaterPower(state,
   10578       33845 :                                      state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterPowerFTempDiff,
   10579       33845 :                                      state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterSchedulePtr,
   10580       33845 :                                      state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterSetPointTemp,
   10581       33845 :                                      state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterPower);
   10582             :             }
   10583             :         }
   10584             : 
   10585             :     } // end of on/off if - else
   10586             : 
   10587             :     // set water system demand request (if needed)
   10588    42209621 :     if (state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterSupplyMode == EvapWaterSupply::FromTank) {
   10589           0 :         state.dataWaterData->WaterStorage(state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterSupTankID)
   10590           0 :             .VdotRequestDemand(state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterTankDemandARRID) =
   10591           0 :             state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterConsumpRate;
   10592             :     }
   10593             : 
   10594    42209621 :     state.dataDXCoils->DXCoilOutletTemp(DXCoilNum) = state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp;
   10595    42209621 :     state.dataDXCoils->DXCoilOutletHumRat(DXCoilNum) = state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat;
   10596    42209621 :     state.dataDXCoils->DXCoilPartLoadRatio(DXCoilNum) = state.dataDXCoils->DXCoil(DXCoilNum).PartLoadRatio;
   10597    42209621 :     state.dataDXCoils->DXCoilFanOpMode(DXCoilNum) = FanOpMode;
   10598    42209621 :     state.dataDXCoils->DXCoil(DXCoilNum).CondInletTemp = CondInletTemp;
   10599             : 
   10600             :     // set outlet node conditions
   10601    42209621 :     int airOutletNode = state.dataDXCoils->DXCoil(DXCoilNum).AirOutNode;
   10602    42209621 :     state.dataLoopNodes->Node(airOutletNode).Temp = state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp;
   10603    42209621 :     state.dataLoopNodes->Node(airOutletNode).HumRat = state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat;
   10604             : 
   10605             :     // calc secondary coil if specified
   10606    42209621 :     if (state.dataDXCoils->DXCoil(DXCoilNum).IsSecondaryDXCoilInZone) {
   10607       83894 :         CalcSecondaryDXCoils(state, DXCoilNum);
   10608             :     }
   10609    42209621 : }
   10610             : 
   10611     1553952 : void CalcVRFCoolingCoil(EnergyPlusData &state,
   10612             :                         int const DXCoilNum,                      // the number of the DX coil to be simulated
   10613             :                         CompressorOperation const CompressorOp,   // compressor operation; 1=on, 0=off
   10614             :                         bool const FirstHVACIteration,            // true if this is the first iteration of HVAC
   10615             :                         Real64 const PartLoadRatio,               // sensible cooling load / full load sensible cooling capacity
   10616             :                         int const FanOpMode,                      // Allows parent object to control fan operation
   10617             :                         Real64 const CompCycRatio,                // cycling ratio of VRF condenser
   10618             :                         Optional_int_const PerfMode,              // Performance mode for MultiMode DX coil; Always 1 for other coil types
   10619             :                         Optional<Real64 const> OnOffAirFlowRatio, // ratio of compressor on airflow to compressor off airflow
   10620             :                         Optional<Real64 const> MaxCoolCap         // maximum capacity of DX coil
   10621             : )
   10622             : {
   10623             : 
   10624             :     // SUBROUTINE INFORMATION:
   10625             :     //       AUTHOR         Richard Raustad
   10626             :     //       DATE WRITTEN   August 2010
   10627             : 
   10628             :     // PURPOSE OF THIS SUBROUTINE:
   10629             :     // Calculates the air-side performance of a direct-expansion, air-cooled
   10630             :     // VRF terminal unit cooling coil.
   10631             :     // A new subroutine was created in case this DX coil model is significantly
   10632             :     // different from the existing CalcDoe2DXCoil subroutine. The VRF heating coil
   10633             :     // uses the existing DX heating coil subroutine (CalcDXHeatingCoil).
   10634             : 
   10635             :     // METHODOLOGY EMPLOYED:
   10636             :     // This routine simulates the performance of a variable refrigerant flow cooling coil.
   10637             :     // The routine requires the user to enter the total cooling capacity and sensible heat ratio.
   10638             :     // Since different manufacturer's rate their equipment at different air flow rates,
   10639             :     // the supply air flow rate corresponding to the rated capacities must also be
   10640             :     // entered (should be between 300 cfm/ton and 450 cfm/ton). The rated information entered by
   10641             :     // the user should NOT include the thermal or electrical impacts of the supply air fan, as
   10642             :     // this is addressed by another module.
   10643             : 
   10644             :     // With the rated performance data entered by the user, the model employs some of the
   10645             :     // DOE-2.1E curve fits to adjust the capacity and efficiency of the unit as a function
   10646             :     // of entering air temperatures and supply air flow rate (actual vs rated flow). The model
   10647             :     // does NOT employ the exact same methodology to calculate performance as DOE-2.
   10648             :     // This VRF cooling coil model adjusts the rated total cooling capacity by the CAPFT
   10649             :     // and CAP funciton of flow curve/model currently used by the existing DX coil model.
   10650             :     // The part-load ratio is then applied to the total operating capacity to find the capacity
   10651             :     // required to meet the load. This VRF model then uses the ADP/bypass method to find the
   10652             :     // SHR and resulting outlet conditions given that total capacity (or delta H).
   10653             : 
   10654             :     // The model checks for coil dryout conditions, and adjusts the calculated performance
   10655             :     // appropriately.
   10656             : 
   10657             :     // Using/Aliasing
   10658             :     using Curve::CurveValue;
   10659     1553952 :     auto &SysTimeElapsed = state.dataHVACGlobal->SysTimeElapsed;
   10660     1553952 :     auto &TimeStepSys = state.dataHVACGlobal->TimeStepSys;
   10661             :     using General::CreateSysTimeIntervalString;
   10662             : 
   10663             :     // SUBROUTINE ARGUMENT DEFINITIONS:
   10664             :     //  REAL(r64), INTENT(IN), OPTIONAL :: CoolingHeatingPLR   ! used for cycling fan RH control
   10665             : 
   10666             :     // SUBROUTINE PARAMETER DEFINITIONS:
   10667             :     static constexpr std::string_view RoutineName("CalcVRFCoolingCoil");
   10668             : 
   10669             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   10670             :     Real64 AirMassFlow;       // dry air mass flow rate through coil [kg/s] (adjusted for bypass if any)
   10671             :     Real64 AirMassFlowRatio;  // Ratio of actual air mass flow to rated air mass flow (adjusted for bypass if any)
   10672             :     Real64 AirVolumeFlowRate; // Air volume flow rate across the cooling coil [m3/s] (adjusted for bypass if any)
   10673             :     // (average flow if cycling fan, full flow if constant fan)
   10674             :     Real64 VolFlowperRatedTotCap; // Air volume flow rate divided by rated total cooling capacity [m3/s-W] (adjusted for bypass)
   10675             :     Real64 TotCap;                // gross total cooling capacity at off-rated conditions [W]
   10676             :     Real64 TotCapTempModFac;      // Total capacity modifier (function of entering wetbulb, outside drybulb)
   10677             :     Real64 TotCapFlowModFac;      // Total capacity modifier (function of actual supply air flow vs rated flow)
   10678             :     Real64 InletAirWetBulbC;      // wetbulb temperature of inlet air [C]
   10679             :     Real64 InletAirDryBulbTemp;   // inlet air dry bulb temperature [C]
   10680             :     Real64 InletAirEnthalpy;      // inlet air enthalpy [J/kg]
   10681             :     Real64 InletAirHumRat;        // inlet air humidity ratio [kg/kg]
   10682             :     Real64 InletAirHumRatTemp;    // inlet air humidity ratio used in ADP/BF loop [kg/kg]
   10683             :     //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   10684             :     // REAL(r64) :: InletAirPressure      ! inlet air pressure [Pa]
   10685             :     Real64 RatedCBF;             // coil bypass factor at rated conditions
   10686             :     Real64 SHR;                  // Sensible Heat Ratio (sensible/total) of the cooling coil
   10687             :     Real64 CBF;                  // coil bypass factor at off rated conditions
   10688             :     Real64 A0;                   // NTU * air mass flow rate, used in CBF calculation
   10689             :     Real64 hDelta;               // Change in air enthalpy across the cooling coil [J/kg]
   10690             :     Real64 hADP;                 // Apparatus dew point enthalpy [J/kg]
   10691             :     Real64 hTinwADP;             // Enthalpy at inlet dry-bulb and wADP [J/kg]
   10692             :     Real64 hTinwout;             // Enthalpy at inlet dry-bulb and outlet humidity ratio [J/kg]
   10693             :     Real64 tADP;                 // Apparatus dew point temperature [C]
   10694             :     Real64 wADP;                 // Apparatus dew point humidity ratio [kg/kg]
   10695             :     Real64 FullLoadOutAirEnth;   // outlet full load enthalpy [J/kg]
   10696             :     Real64 FullLoadOutAirHumRat; // outlet humidity ratio at full load
   10697             :     Real64 FullLoadOutAirTemp;   // outlet air temperature at full load [C]
   10698             :     Real64 PLF;                  // Part load factor, accounts for thermal lag at compressor startup, used in power calculation
   10699             :     Real64 QLatActual;           // operating latent capacity of DX coil
   10700             :     Real64 QLatRated;            // Rated latent capacity of DX coil
   10701             :     Real64 SHRUnadjusted;        // SHR prior to latent degradation effective SHR calculation
   10702             :     int Counter;                 // Counter for dry evaporator iterations
   10703             :     int MaxIter;                 // Maximum number of iterations for dry evaporator calculations
   10704             :     Real64 RF;                   // Relaxation factor for dry evaporator iterations
   10705             :     Real64 Tolerance;            // Error tolerance for dry evaporator iterations
   10706             :     Real64 werror;               // Deviation of humidity ratio in dry evaporator iteration loop
   10707             :     Real64 CondInletTemp;        // Condenser inlet temperature (C). Outdoor dry-bulb temp for air-cooled condenser.
   10708             :     // Outdoor Wetbulb +(1 - effectiveness)*(outdoor drybulb - outdoor wetbulb) for evap condenser.
   10709             :     Real64 CondInletHumRat; // Condenser inlet humidity ratio (kg/kg). Zero for air-cooled condenser.
   10710             :     // For evap condenser, its the humidity ratio of the air leaving the evap cooling pads.
   10711             :     Real64 CondAirMassFlow;       // Condenser air mass flow rate [kg/s]
   10712             :     Real64 RhoAir;                // Density of air [kg/m3]
   10713             :     Real64 CrankcaseHeatingPower; // power due to crankcase heater
   10714     1553952 :     Real64 CompAmbTemp(0.0);      // Ambient temperature at compressor
   10715             :     Real64 AirFlowRatio;          // ratio of compressor on airflow to average timestep airflow
   10716             :     // used when constant fan mode yields different air flow rates when compressor is ON and OFF
   10717             :     // (e.g. Packaged Terminal Heat Pump)
   10718             :     Real64 OutdoorDryBulb;  // Outdoor dry-bulb temperature at condenser (C)
   10719             :     Real64 OutdoorWetBulb;  // Outdoor wet-bulb temperature at condenser (C)
   10720             :     Real64 OutdoorHumRat;   // Outdoor humidity ratio at condenser (kg/kg)
   10721             :     Real64 OutdoorPressure; // Outdoor barometric pressure at condenser (Pa)
   10722             : 
   10723     1553952 :     auto &CurrentEndTime = state.dataDXCoils->CalcVRFCoolingCoilCurrentEndTime;
   10724             :     int Mode;                 // Performance mode for Multimode DX coil; Always 1 for other coil types
   10725             :     Real64 OutletAirTemp;     // Supply air temperature (average value if constant fan, full output if cycling fan)
   10726             :     Real64 OutletAirHumRat;   // Supply air humidity ratio (average value if constant fan, full output if cycling fan)
   10727             :     Real64 OutletAirEnthalpy; // Supply air enthalpy (average value if constant fan, full output if cycling fan)
   10728             :     Real64 ADiff;             // Used for exponential
   10729             : 
   10730             :     // If Performance mode not present, then set to 1.  Used only by Multimode/Multispeed DX coil (otherwise mode = 1)
   10731     1553952 :     if (present(PerfMode)) {
   10732           0 :         Mode = PerfMode;
   10733             :     } else {
   10734     1553952 :         Mode = 1;
   10735             :     }
   10736             : 
   10737             :     // If AirFlowRatio not present, then set to 1. Used only by DX coils with different air flow
   10738             :     // during cooling and when no cooling is required (constant fan, fan speed changes)
   10739     1553952 :     if (present(OnOffAirFlowRatio)) {
   10740     1553911 :         AirFlowRatio = OnOffAirFlowRatio;
   10741             :     } else {
   10742          41 :         AirFlowRatio = 1.0;
   10743             :     }
   10744             : 
   10745     1553952 :     auto &DXCT = state.dataHVACGlobal->DXCT;
   10746     1553952 :     auto &OnOffFanPartLoadFraction = state.dataHVACGlobal->OnOffFanPartLoadFraction;
   10747             : 
   10748     1553952 :     MaxIter = 30;
   10749     1553952 :     RF = 0.4;
   10750     1553952 :     Counter = 0;
   10751     1553952 :     Tolerance = 0.01;
   10752     1553952 :     CondInletTemp = 0.0;
   10753     1553952 :     CondInletHumRat = 0.0;
   10754     1553952 :     AirMassFlow = state.dataDXCoils->DXCoil(DXCoilNum).InletAirMassFlowRate;
   10755     1553952 :     InletAirDryBulbTemp = state.dataDXCoils->DXCoil(DXCoilNum).InletAirTemp;
   10756     1553952 :     InletAirEnthalpy = state.dataDXCoils->DXCoil(DXCoilNum).InletAirEnthalpy;
   10757     1553952 :     InletAirHumRat = state.dataDXCoils->DXCoil(DXCoilNum).InletAirHumRat;
   10758             :     //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   10759             :     // InletAirPressure    = DXCoil(DXCoilNum)%InletAirPressure
   10760     1553952 :     state.dataHeatBal->HeatReclaimDXCoil(DXCoilNum).AvailCapacity = 0.0;
   10761     1553952 :     state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction = 0.0;
   10762     1553952 :     state.dataDXCoils->DXCoil(DXCoilNum).PartLoadRatio = 0.0;
   10763     1553952 :     state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterPower = 0.0;
   10764             : 
   10765     1553952 :     if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(Mode) != 0) {
   10766     1553952 :         OutdoorDryBulb = state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(Mode)).Temp;
   10767     1553952 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(Mode) == DataHeatBalance::RefrigCondenserType::Water) {
   10768      156173 :             OutdoorHumRat = state.dataEnvrn->OutHumRat;
   10769      156173 :             OutdoorPressure = state.dataEnvrn->OutBaroPress;
   10770      156173 :             OutdoorWetBulb = state.dataEnvrn->OutWetBulbTemp;
   10771             :         } else {
   10772     1397779 :             OutdoorPressure = state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(Mode)).Press;
   10773             :             // If node is not connected to anything, pressure = default, use weather data
   10774     1397779 :             if (OutdoorPressure == state.dataLoopNodes->DefaultNodeValues.Press) {
   10775           0 :                 OutdoorDryBulb = state.dataEnvrn->OutDryBulbTemp;
   10776           0 :                 OutdoorHumRat = state.dataEnvrn->OutHumRat;
   10777           0 :                 OutdoorPressure = state.dataEnvrn->OutBaroPress;
   10778           0 :                 OutdoorWetBulb = state.dataEnvrn->OutWetBulbTemp;
   10779             :             } else {
   10780     1397779 :                 OutdoorHumRat = state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(Mode)).HumRat;
   10781             :                 // this should use Node%WetBulbTemp or a PSYC function, not OAWB
   10782     1397779 :                 OutdoorWetBulb = state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(Mode)).OutAirWetBulb;
   10783             :             }
   10784             :         }
   10785             :     } else {
   10786           0 :         OutdoorDryBulb = state.dataEnvrn->OutDryBulbTemp;
   10787           0 :         OutdoorHumRat = state.dataEnvrn->OutHumRat;
   10788           0 :         OutdoorPressure = state.dataEnvrn->OutBaroPress;
   10789           0 :         OutdoorWetBulb = state.dataEnvrn->OutWetBulbTemp;
   10790             :     }
   10791             : 
   10792     1553952 :     if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(Mode) == DataHeatBalance::RefrigCondenserType::Evap) {
   10793           0 :         RhoAir = PsyRhoAirFnPbTdbW(state, OutdoorPressure, OutdoorDryBulb, OutdoorHumRat);
   10794           0 :         CondAirMassFlow = RhoAir * state.dataDXCoils->DXCoil(DXCoilNum).EvapCondAirFlow(Mode);
   10795             :         // (Outdoor wet-bulb temp from DataEnvironment) + (1.0-EvapCondEffectiveness) * (drybulb - wetbulb)
   10796           0 :         CondInletTemp = OutdoorWetBulb + (OutdoorDryBulb - OutdoorWetBulb) * (1.0 - state.dataDXCoils->DXCoil(DXCoilNum).EvapCondEffect(Mode));
   10797           0 :         CondInletHumRat = PsyWFnTdbTwbPb(state, CondInletTemp, OutdoorWetBulb, OutdoorPressure);
   10798           0 :         CompAmbTemp = OutdoorDryBulb;
   10799             :     } else {                            // for air or water-cooled, inlet temp is stored in OutdoorDryBulb temp
   10800     1553952 :         CondInletTemp = OutdoorDryBulb; // Outdoor dry-bulb temp or water inlet temp
   10801     1553952 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(Mode) == DataHeatBalance::RefrigCondenserType::Water) {
   10802      156173 :             CompAmbTemp = state.dataEnvrn->OutDryBulbTemp; // for crankcase heater use actual outdoor temp for water-cooled
   10803             :         } else {
   10804     1397779 :             CompAmbTemp = OutdoorDryBulb;
   10805             :         }
   10806             :     }
   10807             : 
   10808             :     // Initialize crankcase heater, operates below OAT defined in input deck for HP DX cooling coil
   10809             :     // If used in a heat pump, the value of MaxOAT in the heating coil overrides that in the cooling coil (in GetInput)
   10810     1553952 :     if (CompAmbTemp < state.dataDXCoils->DXCoil(DXCoilNum).MaxOATCrankcaseHeater) {
   10811       90820 :         CrankcaseHeatingPower = state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterCapacity;
   10812             :     } else {
   10813     1463132 :         CrankcaseHeatingPower = 0.0;
   10814             :     }
   10815             : 
   10816             :     // calculate end time of current time step to determine if error messages should be printed
   10817     1553952 :     CurrentEndTime = state.dataGlobal->CurrentTime + SysTimeElapsed;
   10818             : 
   10819             :     //   Print warning messages only when valid and only for the first ocurrance. Let summary provide statistics.
   10820             :     //   Wait for next time step to print warnings. If simulation iterates, print out
   10821             :     //   the warning for the last iteration only. Must wait for next time step to accomplish this.
   10822             :     //   If a warning occurs and the simulation down shifts, the warning is not valid.
   10823     1553952 :     if (state.dataDXCoils->DXCoil(DXCoilNum).PrintLowAmbMessage) { // .AND. &
   10824           0 :         if (CurrentEndTime > state.dataDXCoils->DXCoil(DXCoilNum).CurrentEndTimeLast &&
   10825           0 :             TimeStepSys >= state.dataDXCoils->DXCoil(DXCoilNum).TimeStepSysLast) {
   10826           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).LowAmbErrIndex == 0) {
   10827           0 :                 ShowWarningMessage(state, state.dataDXCoils->DXCoil(DXCoilNum).LowAmbBuffer1);
   10828           0 :                 ShowContinueError(state, state.dataDXCoils->DXCoil(DXCoilNum).LowAmbBuffer2);
   10829           0 :                 ShowContinueError(state, "... Operation at low inlet temperatures may require special performance curves.");
   10830             :             }
   10831           0 :             ShowRecurringWarningErrorAtEnd(state,
   10832           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + " \"" + state.dataDXCoils->DXCoil(DXCoilNum).Name +
   10833             :                                                "\" - Low condenser inlet temperature error continues...",
   10834           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).LowAmbErrIndex,
   10835           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).LowTempLast,
   10836           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).LowTempLast,
   10837             :                                            _,
   10838             :                                            "[C]",
   10839             :                                            "[C]");
   10840             :         }
   10841             :     }
   10842             : 
   10843     1553952 :     if (state.dataDXCoils->DXCoil(DXCoilNum).PrintHighAmbMessage) { // .AND. &
   10844           0 :         if (CurrentEndTime > state.dataDXCoils->DXCoil(DXCoilNum).CurrentEndTimeLast &&
   10845           0 :             TimeStepSys >= state.dataDXCoils->DXCoil(DXCoilNum).TimeStepSysLast) {
   10846           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).HighAmbErrIndex == 0) {
   10847           0 :                 ShowWarningMessage(state, state.dataDXCoils->DXCoil(DXCoilNum).HighAmbBuffer1);
   10848           0 :                 ShowContinueError(state, state.dataDXCoils->DXCoil(DXCoilNum).HighAmbBuffer2);
   10849           0 :                 ShowContinueError(state, "... Operation at high inlet temperatures may require special performance curves.");
   10850             :             }
   10851           0 :             ShowRecurringWarningErrorAtEnd(state,
   10852           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + " \"" + state.dataDXCoils->DXCoil(DXCoilNum).Name +
   10853             :                                                "\" - High condenser inlet temperature error continues...",
   10854           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).HighAmbErrIndex,
   10855           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).HighTempLast,
   10856           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).HighTempLast,
   10857             :                                            _,
   10858             :                                            "[C]",
   10859             :                                            "[C]");
   10860             :         }
   10861             :     }
   10862             : 
   10863     1553952 :     if (state.dataDXCoils->DXCoil(DXCoilNum).PrintLowOutTempMessage) {
   10864           0 :         if (CurrentEndTime > state.dataDXCoils->DXCoil(DXCoilNum).CurrentEndTimeLast &&
   10865           0 :             TimeStepSys >= state.dataDXCoils->DXCoil(DXCoilNum).TimeStepSysLast) {
   10866           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).LowOutletTempIndex == 0) {
   10867           0 :                 ShowWarningMessage(state, state.dataDXCoils->DXCoil(DXCoilNum).LowOutTempBuffer1);
   10868           0 :                 ShowContinueError(state, state.dataDXCoils->DXCoil(DXCoilNum).LowOutTempBuffer2);
   10869           0 :                 ShowContinueError(state, "... Possible reasons for low outlet air dry-bulb temperatures are: This DX coil");
   10870           0 :                 ShowContinueError(state,
   10871           0 :                                   format("   1) may have a low inlet air dry-bulb temperature. Inlet air temperature = {:.3T} C.",
   10872           0 :                                          state.dataDXCoils->DXCoil(DXCoilNum).FullLoadInletAirTempLast));
   10873           0 :                 ShowContinueError(state, "   2) may have a low air flow rate per watt of cooling capacity. Check inputs.");
   10874           0 :                 ShowContinueError(state,
   10875             :                                   "   3) is used as part of a HX assisted cooling coil which uses a high sensible effectiveness. Check inputs.");
   10876             :             }
   10877           0 :             ShowRecurringWarningErrorAtEnd(state,
   10878           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + " \"" + state.dataDXCoils->DXCoil(DXCoilNum).Name +
   10879             :                                                "\" - Full load outlet temperature indicates a possibility of frost/freeze error continues. "
   10880             :                                                "Outlet air temperature statistics follow:",
   10881           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).LowOutletTempIndex,
   10882           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).FullLoadOutAirTempLast,
   10883           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).FullLoadOutAirTempLast);
   10884             :         }
   10885             :     }
   10886             : 
   10887             :     // save last system time step and last end time of current time step (used to determine if warning is valid)
   10888     1553952 :     state.dataDXCoils->DXCoil(DXCoilNum).TimeStepSysLast = TimeStepSys;
   10889     1553952 :     state.dataDXCoils->DXCoil(DXCoilNum).CurrentEndTimeLast = CurrentEndTime;
   10890     1553952 :     state.dataDXCoils->DXCoil(DXCoilNum).PrintLowAmbMessage = false;
   10891     1553952 :     state.dataDXCoils->DXCoil(DXCoilNum).PrintLowOutTempMessage = false;
   10892             : 
   10893     1553952 :     if ((AirMassFlow > 0.0) && (GetCurrentScheduleValue(state, state.dataDXCoils->DXCoil(DXCoilNum).SchedPtr) > 0.0) && (PartLoadRatio > 0.0) &&
   10894             :         (CompressorOp == CompressorOperation::On)) { // for cycling fan, reset mass flow to full on rate
   10895      855137 :         if (FanOpMode == CycFanCycCoil) {
   10896      241185 :             AirMassFlow /= PartLoadRatio;
   10897      613952 :         } else if (FanOpMode == ContFanCycCoil) {
   10898      613952 :             AirMassFlow *= AirFlowRatio;
   10899             :         } else {
   10900           0 :             AirMassFlow = state.dataDXCoils->DXCoil(DXCoilNum).RatedAirMassFlowRate(Mode);
   10901             :         }
   10902             : 
   10903             :         // Check for valid air volume flow per rated total cooling capacity (200 - 500 cfm/ton)
   10904             : 
   10905             :         // for some reason there are diff's when using coil inlet air pressure
   10906             :         // these lines (more to follow) are commented out for the time being
   10907             : 
   10908      855137 :         InletAirWetBulbC = PsyTwbFnTdbWPb(state, InletAirDryBulbTemp, InletAirHumRat, OutdoorPressure);
   10909      855137 :         AirVolumeFlowRate = AirMassFlow / PsyRhoAirFnPbTdbW(state, OutdoorPressure, InletAirDryBulbTemp, InletAirHumRat);
   10910      855137 :         VolFlowperRatedTotCap = AirVolumeFlowRate / state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode);
   10911             : 
   10912      855137 :         if (state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode) <= 0.0) {
   10913           0 :             ShowFatalError(state,
   10914           0 :                            state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + " \"" + state.dataDXCoils->DXCoil(DXCoilNum).Name +
   10915             :                                "\" - Rated total cooling capacity is zero or less.");
   10916             :         }
   10917             : 
   10918      915786 :         if (!FirstHVACIteration && !state.dataGlobal->WarmupFlag &&
   10919      121298 :             ((VolFlowperRatedTotCap < state.dataHVACGlobal->MinOperVolFlowPerRatedTotCap(DXCT)) ||
   10920       60649 :              (VolFlowperRatedTotCap > state.dataHVACGlobal->MaxCoolVolFlowPerRatedTotCap(DXCT)))) {
   10921           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).ErrIndex1 == 0) {
   10922           0 :                 ShowWarningMessage(
   10923             :                     state,
   10924           0 :                     format("{} \"{}\" - Air volume flow rate per watt of rated total cooling capacity is out of range at {:.3R} m3/s/W.",
   10925           0 :                            state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
   10926           0 :                            state.dataDXCoils->DXCoil(DXCoilNum).Name,
   10927           0 :                            VolFlowperRatedTotCap));
   10928           0 :                 ShowContinueErrorTimeStamp(state, "");
   10929           0 :                 ShowContinueError(state,
   10930           0 :                                   format("...Expected range for VolumeFlowPerRatedTotalCapacity=[{:.3R}--{:.3R}]",
   10931           0 :                                          state.dataHVACGlobal->MinOperVolFlowPerRatedTotCap(DXCT),
   10932           0 :                                          state.dataHVACGlobal->MaxCoolVolFlowPerRatedTotCap(DXCT)));
   10933           0 :                 ShowContinueError(state, "...Possible causes include inconsistent air flow rates in system components,");
   10934           0 :                 ShowContinueError(state, "...or mixing manual inputs with autosize inputs. Also check the following values and calculations.");
   10935           0 :                 ShowContinueError(state, "...Volume Flow Rate per Rated Total Capacity = Volume Flow Rate / Rated Total Capacity");
   10936           0 :                 ShowContinueError(state, "...Volume Flow Rate = Air Mass Flow Rate / Air Density");
   10937           0 :                 ShowContinueError(state, "...Data used for calculations:");
   10938           0 :                 ShowContinueError(state, format("...Rated Total Capacity = {:.2R} W.", state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode)));
   10939           0 :                 ShowContinueError(state, "...Volume Flow Rate = Air Mass Flow Rate / Air Density");
   10940           0 :                 ShowContinueError(state, format("...Volume Flow Rate   = {:.8R} m3/s.", AirVolumeFlowRate));
   10941           0 :                 ShowContinueError(state, format("...Air Mass Flow Rate = {:.8R} kg/s.", AirMassFlow));
   10942           0 :                 ShowContinueError(
   10943             :                     state,
   10944           0 :                     format("...Air Density        = {:.8R} kg/m3.", PsyRhoAirFnPbTdbW(state, OutdoorPressure, InletAirDryBulbTemp, InletAirHumRat)));
   10945           0 :                 ShowContinueError(state, "...Data used for air density calculation:");
   10946           0 :                 ShowContinueError(state, format("...Outdoor Air Pressure     = {:.3R} Pa.", OutdoorPressure));
   10947           0 :                 ShowContinueError(state, format("...Inlet Air Dry-Bulb Temp  = {:.3R} C.", InletAirDryBulbTemp));
   10948           0 :                 ShowContinueError(state, format("...Inlet Air Humidity Ratio = {:.8R} kgWater/kgDryAir.", InletAirHumRat));
   10949             :             }
   10950           0 :             ShowRecurringWarningErrorAtEnd(
   10951             :                 state,
   10952           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + " \"" + state.dataDXCoils->DXCoil(DXCoilNum).Name +
   10953             :                     "\" - Air volume flow rate per watt of rated total cooling capacity is out of range error continues...",
   10954           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).ErrIndex1,
   10955             :                 VolFlowperRatedTotCap,
   10956             :                 VolFlowperRatedTotCap);
   10957             :         }
   10958             :         //    Adjust coil bypass factor for actual air flow rate. Use relation CBF = exp(-NTU) where
   10959             :         //    NTU = A0/(m*cp). Relationship models the cooling coil as a heat exchanger with Cmin/Cmax = 0.
   10960             : 
   10961      855137 :         RatedCBF = state.dataDXCoils->DXCoil(DXCoilNum).RatedCBF(Mode);
   10962      855137 :         if (RatedCBF > 0.0) {
   10963      855137 :             A0 = -std::log(RatedCBF) * state.dataDXCoils->DXCoil(DXCoilNum).RatedAirMassFlowRate(Mode);
   10964             :         } else {
   10965           0 :             A0 = 0.0;
   10966             :         }
   10967      855137 :         ADiff = -A0 / AirMassFlow;
   10968      855137 :         if (ADiff >= DataPrecisionGlobals::EXP_LowerLimit) {
   10969      855137 :             CBF = std::exp(ADiff);
   10970             :         } else {
   10971           0 :             CBF = 0.0;
   10972             :         }
   10973             : 
   10974             :         // check boundary for low ambient temperature and post warnings to individual DX coil buffers to print at end of time step
   10975      855137 :         if (OutdoorDryBulb < state.dataDXCoils->DXCoil(DXCoilNum).MinOATCompressor && !state.dataGlobal->WarmupFlag) {
   10976           0 :             state.dataDXCoils->DXCoil(DXCoilNum).PrintLowAmbMessage = true;
   10977           0 :             state.dataDXCoils->DXCoil(DXCoilNum).LowTempLast = OutdoorDryBulb;
   10978           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).LowAmbErrIndex == 0) {
   10979           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).LowAmbBuffer1 =
   10980           0 :                     format("{} \"{}\" - Condenser inlet temperature below {:.2R} C. Condenser inlet temperature = {:.2R}",
   10981           0 :                            state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
   10982           0 :                            state.dataDXCoils->DXCoil(DXCoilNum).Name,
   10983           0 :                            state.dataDXCoils->DXCoil(DXCoilNum).MinOATCompressor,
   10984           0 :                            OutdoorDryBulb);
   10985           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).LowAmbBuffer2 = " ... Occurrence info = " + state.dataEnvrn->EnvironmentName + ", " +
   10986           0 :                                                                      state.dataEnvrn->CurMnDy + ' ' + CreateSysTimeIntervalString(state);
   10987             :             }
   10988             :         }
   10989             : 
   10990             :         // check boundary for high ambient temperature and post warnings to individual DX coil buffers to print at end of time step
   10991      855137 :         if (OutdoorDryBulb > state.dataDXCoils->DXCoil(DXCoilNum).MaxOATCompressor && !state.dataGlobal->WarmupFlag) {
   10992           0 :             state.dataDXCoils->DXCoil(DXCoilNum).PrintHighAmbMessage = true;
   10993           0 :             state.dataDXCoils->DXCoil(DXCoilNum).HighTempLast = OutdoorDryBulb;
   10994           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).HighAmbErrIndex == 0) {
   10995           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).HighAmbBuffer1 =
   10996           0 :                     format("{} \"{}\" - Condenser inlet temperature above {:.2R} C. Condenser temperature = {:.2R}",
   10997           0 :                            state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
   10998           0 :                            state.dataDXCoils->DXCoil(DXCoilNum).Name,
   10999           0 :                            state.dataDXCoils->DXCoil(DXCoilNum).MaxOATCompressor,
   11000           0 :                            OutdoorDryBulb);
   11001           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).HighAmbBuffer2 = " ... Occurrence info = " + state.dataEnvrn->EnvironmentName + ", " +
   11002           0 :                                                                       state.dataEnvrn->CurMnDy + ' ' + CreateSysTimeIntervalString(state);
   11003             :             }
   11004             :         }
   11005             : 
   11006             :         //  Get total capacity modifying factor (function of temperature) for off-rated conditions
   11007             :         //  InletAirHumRat may be modified in this ADP/BF loop, use temporary varible for calculations
   11008      855137 :         InletAirHumRatTemp = InletAirHumRat;
   11009             :         // No need to differentiate between curve types, single-independent curve will just use first variable
   11010             :         // (as long as the first independent variable is the same for both curve types)
   11011      855137 :     Label50:;
   11012      855137 :         TotCapTempModFac = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(Mode), InletAirWetBulbC, CondInletTemp);
   11013             : 
   11014             :         //  Warn user if curve output goes negative
   11015      855137 :         if (TotCapTempModFac < 0.0) {
   11016           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).CCapFTempErrorIndex == 0) {
   11017           0 :                 ShowWarningMessage(state,
   11018           0 :                                    state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + " \"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\":");
   11019           0 :                 ShowContinueError(
   11020           0 :                     state, format(" Total Cooling Capacity Modifier curve (function of temperature) output is negative ({:.3T}).", TotCapTempModFac));
   11021           0 :                 ShowContinueError(
   11022             :                     state,
   11023           0 :                     format(" Negative value occurs using a condenser inlet temperature of {:.1T} and an inlet air wet-bulb temperature of {:.1T}.",
   11024             :                            CondInletTemp,
   11025           0 :                            InletAirWetBulbC));
   11026           0 :                 if (Mode > 1) {
   11027           0 :                     ShowContinueError(state, format(" Negative output results from stage {} compressor operation.", Mode));
   11028             :                 }
   11029           0 :                 ShowContinueErrorTimeStamp(state, " Resetting curve output to zero and continuing simulation.");
   11030             :             }
   11031           0 :             ShowRecurringWarningErrorAtEnd(
   11032             :                 state,
   11033           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + " \"" + state.dataDXCoils->DXCoil(DXCoilNum).Name +
   11034             :                     "\": Total Cooling Capacity Modifier curve (function of temperature) output is negative warning continues...",
   11035           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).CCapFTempErrorIndex,
   11036             :                 TotCapTempModFac,
   11037             :                 TotCapTempModFac);
   11038           0 :             TotCapTempModFac = 0.0;
   11039             :         }
   11040             : 
   11041             :         //  Get total capacity modifying factor (function of mass flow) for off-rated conditions
   11042      855137 :         AirMassFlowRatio = AirMassFlow / state.dataDXCoils->DXCoil(DXCoilNum).RatedAirMassFlowRate(Mode);
   11043      855137 :         TotCapFlowModFac = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).CCapFFlow(Mode), AirMassFlowRatio);
   11044             : 
   11045             :         //  Warn user if curve output goes negative
   11046      855137 :         if (TotCapFlowModFac < 0.0) {
   11047           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).CCapFFlowErrorIndex == 0) {
   11048           0 :                 ShowWarningMessage(state,
   11049           0 :                                    state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + " \"" + state.dataDXCoils->DXCoil(DXCoilNum).Name + "\":");
   11050           0 :                 ShowContinueError(
   11051             :                     state,
   11052           0 :                     format(" Total Cooling Capacity Modifier curve (function of flow fraction) output is negative ({:.3T}).", TotCapFlowModFac));
   11053           0 :                 ShowContinueError(state, format(" Negative value occurs using an air flow fraction of {:.3T}.", AirMassFlowRatio));
   11054           0 :                 ShowContinueErrorTimeStamp(state, " Resetting curve output to zero and continuing simulation.");
   11055           0 :                 if (Mode > 1) {
   11056           0 :                     ShowContinueError(state, format(" Negative output results from stage {} compressor operation.", Mode));
   11057             :                 }
   11058             :             }
   11059           0 :             ShowRecurringWarningErrorAtEnd(
   11060             :                 state,
   11061           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + " \"" + state.dataDXCoils->DXCoil(DXCoilNum).Name +
   11062             :                     "\": Total Cooling Capacity Modifier curve (function of flow fraction) output is negative warning continues...",
   11063           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).CCapFFlowErrorIndex,
   11064             :                 TotCapFlowModFac,
   11065             :                 TotCapFlowModFac);
   11066           0 :             TotCapFlowModFac = 0.0;
   11067             :         }
   11068             : 
   11069      855137 :         if (present(MaxCoolCap)) {
   11070      855096 :             TotCap = min(MaxCoolCap, state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode) * TotCapFlowModFac * TotCapTempModFac);
   11071             :         } else {
   11072          41 :             TotCap = state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode) * TotCapFlowModFac * TotCapTempModFac;
   11073             :         }
   11074             : 
   11075      855137 :         TotCap *= PartLoadRatio;
   11076             : 
   11077             :         // Calculate apparatus dew point conditions using TotCap and CBF
   11078      855137 :         hDelta = TotCap / AirMassFlow;
   11079             :         // there is an issue here with using CBF to calculate the ADP enthalpy.
   11080             :         // at low loads the bypass factor increases significantly.
   11081      855137 :         hADP = InletAirEnthalpy - hDelta / (1.0 - CBF);
   11082      855137 :         tADP = PsyTsatFnHPb(state, hADP, OutdoorPressure, RoutineName);
   11083             :         //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   11084             :         //  tADP = PsyTsatFnHPb(hADP,InletAirPressure)
   11085      855137 :         wADP = min(InletAirHumRat, PsyWFnTdbH(state, tADP, hADP, RoutineName));
   11086      855137 :         hTinwADP = PsyHFnTdbW(InletAirDryBulbTemp, wADP);
   11087      855137 :         if ((InletAirEnthalpy - hADP) > 1.e-10) {
   11088      782327 :             SHR = min((hTinwADP - hADP) / (InletAirEnthalpy - hADP), 1.0);
   11089             :         } else {
   11090       72810 :             SHR = 1.0;
   11091             :         }
   11092             :         // Check for dry evaporator conditions (win < wadp)
   11093      855137 :         if (wADP > InletAirHumRatTemp || (Counter >= 1 && Counter < MaxIter)) {
   11094           0 :             if (InletAirHumRatTemp == 0.0) InletAirHumRatTemp = 0.00001;
   11095           0 :             werror = (InletAirHumRatTemp - wADP) / InletAirHumRatTemp;
   11096             :             // Increase InletAirHumRatTemp at constant InletAirTemp to find coil dry-out point. Then use the
   11097             :             // capacity at the dry-out point to determine exiting conditions from coil. This is required
   11098             :             // since the TotCapTempModFac doesn't work properly with dry-coil conditions.
   11099           0 :             InletAirHumRatTemp = RF * wADP + (1.0 - RF) * InletAirHumRatTemp;
   11100           0 :             InletAirWetBulbC = PsyTwbFnTdbWPb(state, InletAirDryBulbTemp, InletAirHumRatTemp, OutdoorPressure);
   11101             :             //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   11102             :             //     InletAirWetBulbC = PsyTwbFnTdbWPb(InletAirDryBulbTemp,InletAirHumRatTemp,InletAirPressure)
   11103           0 :             ++Counter;
   11104           0 :             if (std::abs(werror) > Tolerance) goto Label50; // Recalculate with modified inlet conditions
   11105             :         }
   11106             : 
   11107      855137 :         if (state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(Mode) > 0 && CompCycRatio < 1.0) {
   11108           0 :             PLF = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(Mode), CompCycRatio); // Calculate part-load factor
   11109             :         } else {
   11110      855137 :             PLF = 1.0;
   11111             :         }
   11112             : 
   11113      855137 :         if (PLF < 0.7) {
   11114           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).ErrIndex2 == 0) {
   11115           0 :                 ShowWarningMessage(state,
   11116           0 :                                    format("The PLF curve value for the DX cooling coil {} ={:.3R} for part-load ratio ={:.3R}",
   11117           0 :                                           state.dataDXCoils->DXCoil(DXCoilNum).Name,
   11118             :                                           PLF,
   11119           0 :                                           PartLoadRatio));
   11120           0 :                 ShowContinueErrorTimeStamp(state, "PLF curve values must be >= 0.7. PLF has been reset to 0.7 and simulation is continuing.");
   11121           0 :                 ShowContinueError(state, "Check the IO reference manual for PLF curve guidance [Coil:Cooling:DX:SingleSpeed].");
   11122             :             }
   11123           0 :             ShowRecurringWarningErrorAtEnd(state,
   11124           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).Name + ", DX cooling coil PLF curve < 0.7 warning continues...",
   11125           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).ErrIndex2,
   11126             :                                            PLF,
   11127             :                                            PLF);
   11128           0 :             PLF = 0.7;
   11129             :         }
   11130             : 
   11131      855137 :         state.dataDXCoils->DXCoil(DXCoilNum).PartLoadRatio = PartLoadRatio;
   11132      855137 :         state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction = CompCycRatio / PLF;
   11133      855137 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction > 1.0 &&
   11134           0 :             std::abs(state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction - 1.0) > 0.001) {
   11135           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).ErrIndex3 == 0) {
   11136           0 :                 ShowWarningMessage(state,
   11137           0 :                                    format("The runtime fraction for DX cooling coil {} exceeded 1.0. [{:.4R}].",
   11138           0 :                                           state.dataDXCoils->DXCoil(DXCoilNum).Name,
   11139           0 :                                           state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction));
   11140           0 :                 ShowContinueError(state, "Runtime fraction reset to 1 and the simulation will continue.");
   11141           0 :                 ShowContinueError(state, "Check the IO reference manual for PLF curve guidance [Coil:Cooling:DX:SingleSpeed].");
   11142           0 :                 ShowContinueErrorTimeStamp(state, "");
   11143             :             }
   11144           0 :             ShowRecurringWarningErrorAtEnd(state,
   11145           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).Name +
   11146             :                                                ", DX cooling coil runtime fraction > 1.0 warning continues...",
   11147           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).ErrIndex3,
   11148           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction,
   11149           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction);
   11150           0 :             state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction = 1.0; // Reset coil runtime fraction to 1.0
   11151      855137 :         } else if (state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction > 1.0) {
   11152           0 :             state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction = 1.0; // Reset coil runtime fraction to 1.0
   11153             :         }
   11154             : 
   11155             :         // If cycling fan, send coil part-load fraction to on/off fan via HVACDataGlobals
   11156      855137 :         if (FanOpMode == CycFanCycCoil) OnOffFanPartLoadFraction = PLF;
   11157             : 
   11158             :         //  Calculate full load output conditions
   11159             :         //            if ( SHR > 1.0 || Counter > 0 ) SHR = 1.0;
   11160      855137 :         if (SHR > 1.0) SHR = 1.0;
   11161      855137 :         FullLoadOutAirEnth = InletAirEnthalpy - TotCap / AirMassFlow;
   11162      855137 :         hTinwout = InletAirEnthalpy - (1.0 - SHR) * hDelta;
   11163      855137 :         if (SHR < 1.0) {
   11164      561616 :             FullLoadOutAirHumRat = PsyWFnTdbH(state, InletAirDryBulbTemp, hTinwout);
   11165             :         } else {
   11166      293521 :             FullLoadOutAirHumRat = InletAirHumRat;
   11167             :         }
   11168      855137 :         FullLoadOutAirTemp = PsyTdbFnHW(FullLoadOutAirEnth, FullLoadOutAirHumRat);
   11169             : 
   11170             :         // Check for saturation error and modify temperature at constant enthalpy
   11171      855137 :         if (FullLoadOutAirTemp < PsyTsatFnHPb(state, FullLoadOutAirEnth, OutdoorPressure)) {
   11172         658 :             FullLoadOutAirTemp = PsyTsatFnHPb(state, FullLoadOutAirEnth, OutdoorPressure);
   11173             :             //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   11174             :             //   IF(FullLoadOutAirTemp .LT. PsyTsatFnHPb(FullLoadOutAirEnth,InletAirPressure)) THEN
   11175             :             //    FullLoadOutAirTemp = PsyTsatFnHPb(FullLoadOutAirEnth,InletAirPressure)
   11176         658 :             FullLoadOutAirHumRat = PsyWFnTdbH(state, FullLoadOutAirTemp, FullLoadOutAirEnth);
   11177             :         }
   11178             : 
   11179             :         // Store actual outlet conditions when DX coil is ON for use in heat recovery module
   11180      855137 :         state.dataDXCoils->DXCoilFullLoadOutAirTemp(DXCoilNum) = FullLoadOutAirTemp;
   11181      855137 :         state.dataDXCoils->DXCoilFullLoadOutAirHumRat(DXCoilNum) = FullLoadOutAirHumRat;
   11182             : 
   11183             :         // Add warning message for cold cooling coil (FullLoadOutAirTemp < 2 C)
   11184      855137 :         if (FullLoadOutAirTemp < 2.0 && !FirstHVACIteration && !state.dataGlobal->WarmupFlag) {
   11185           0 :             state.dataDXCoils->DXCoil(DXCoilNum).PrintLowOutTempMessage = true;
   11186           0 :             state.dataDXCoils->DXCoil(DXCoilNum).FullLoadOutAirTempLast = FullLoadOutAirTemp;
   11187           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).LowOutletTempIndex == 0) {
   11188           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).FullLoadInletAirTempLast = InletAirDryBulbTemp;
   11189           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).LowOutTempBuffer1 =
   11190           0 :                     format("{} \"{}\" - Full load outlet air dry-bulb temperature < 2C. This indicates the "
   11191             :                            "possibility of coil frost/freeze. Outlet temperature = {:.2R} C.",
   11192           0 :                            state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
   11193           0 :                            state.dataDXCoils->DXCoil(DXCoilNum).Name,
   11194           0 :                            FullLoadOutAirTemp);
   11195           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).LowOutTempBuffer2 = " ...Occurrence info = " + state.dataEnvrn->EnvironmentName + ", " +
   11196           0 :                                                                          state.dataEnvrn->CurMnDy + ' ' + CreateSysTimeIntervalString(state);
   11197             :             }
   11198             :         }
   11199             : 
   11200             :         //  If constant fan with cycling compressor, call function to determine "effective SHR"
   11201             :         //  which includes the part-load degradation on latent capacity
   11202      855137 :         if (FanOpMode == ContFanCycCoil && CompCycRatio < 1.0) {
   11203      479428 :             QLatRated = state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode) *
   11204      239714 :                         (1.0 - state.dataDXCoils->DXCoil(DXCoilNum).RatedSHR(Mode)); // always the same number
   11205      239714 :             QLatActual = TotCap * (1.0 - SHR);
   11206      239714 :             SHRUnadjusted = SHR;
   11207      479428 :             SHR = CalcEffectiveSHR(state,
   11208             :                                    DXCoilNum,
   11209             :                                    SHR,
   11210      239714 :                                    state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction,
   11211             :                                    QLatRated,
   11212             :                                    QLatActual,
   11213             :                                    InletAirDryBulbTemp,
   11214             :                                    InletAirWetBulbC,
   11215             :                                    Mode);
   11216             : 
   11217             :             //  Calculate full load output conditions
   11218             :             //                if ( SHR > 1.0 || Counter > 0 ) SHR = 1.0;
   11219      239714 :             if (SHR > 1.0) SHR = 1.0;
   11220      239714 :             FullLoadOutAirEnth = InletAirEnthalpy - TotCap / AirMassFlow;
   11221      239714 :             hTinwout = InletAirEnthalpy - (1.0 - SHR) * hDelta;
   11222      239714 :             if (SHR < 1.0) {
   11223      171672 :                 FullLoadOutAirHumRat = PsyWFnTdbH(state, InletAirDryBulbTemp, hTinwout);
   11224             :             } else {
   11225       68042 :                 FullLoadOutAirHumRat = InletAirHumRat;
   11226             :             }
   11227      239714 :             FullLoadOutAirTemp = PsyTdbFnHW(FullLoadOutAirEnth, FullLoadOutAirHumRat);
   11228             :         }
   11229             : 
   11230             :         //  Calculate actual outlet conditions for the input part load ratio
   11231             :         //  Actual outlet conditions are "average" for time step when compressor cycles
   11232             : 
   11233      855137 :         if (FanOpMode == ContFanCycCoil && CompCycRatio < 1.0) {
   11234             :             // Continuous fan, cycling compressor
   11235             :             // hmmm ... this seems wrong. PLR * AirFlowRatio = 1. So we get FullLoadOutAirEnth all this time. This is OK since above TotCap *=
   11236             :             // PLR.
   11237      239714 :             OutletAirEnthalpy = ((PartLoadRatio * AirFlowRatio) * FullLoadOutAirEnth + (1.0 - (PartLoadRatio * AirFlowRatio)) * InletAirEnthalpy);
   11238      239714 :             OutletAirHumRat = ((PartLoadRatio * AirFlowRatio) * FullLoadOutAirHumRat + (1.0 - (PartLoadRatio * AirFlowRatio)) * InletAirHumRat);
   11239      239714 :             OutletAirTemp = PsyTdbFnHW(OutletAirEnthalpy, OutletAirHumRat);
   11240             :         } else {
   11241             :             // Default to cycling fan, cycling compressor
   11242      615423 :             OutletAirEnthalpy = FullLoadOutAirEnth;
   11243      615423 :             OutletAirHumRat = FullLoadOutAirHumRat;
   11244      615423 :             OutletAirTemp = FullLoadOutAirTemp;
   11245             :         }
   11246             : 
   11247             :         // Check for saturation error and modify temperature at constant enthalpy
   11248      855137 :         if (OutletAirTemp < PsyTsatFnHPb(state, OutletAirEnthalpy, OutdoorPressure, RoutineName)) {
   11249         595 :             OutletAirTemp = PsyTsatFnHPb(state, OutletAirEnthalpy, OutdoorPressure);
   11250             :             //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   11251             :             //   IF(OutletAirTemp .LT. PsyTsatFnHPb(OutletAirEnthalpy,InletAirPressure)) THEN
   11252             :             //    OutletAirTemp = PsyTsatFnHPb(OutletAirEnthalpy,InletAirPressure)
   11253         595 :             OutletAirHumRat = PsyWFnTdbH(state, OutletAirTemp, OutletAirEnthalpy);
   11254             :         }
   11255             : 
   11256             :         // Reset AirMassFlow to inlet node air mass flow for final total, sensible and latent calculations
   11257             :         // since AirMassFlow might have been modified above (in this subroutine):
   11258             :         //     IF (FanOpMode .EQ. CycFanCycCoil) AirMassFlow = AirMassFlow / PartLoadRatio
   11259             :         // For multimode coil, this should be full flow including bypassed fraction
   11260      855137 :         AirMassFlow = state.dataDXCoils->DXCoil(DXCoilNum).InletAirMassFlowRate;
   11261             : 
   11262             :         // Coil total/sensible/latent cooling rates
   11263     2565411 :         CalcComponentSensibleLatentOutput(AirMassFlow,
   11264             :                                           InletAirDryBulbTemp,
   11265             :                                           InletAirHumRat,
   11266             :                                           OutletAirTemp,
   11267             :                                           OutletAirHumRat,
   11268      855137 :                                           state.dataDXCoils->DXCoil(DXCoilNum).SensCoolingEnergyRate,
   11269      855137 :                                           state.dataDXCoils->DXCoil(DXCoilNum).LatCoolingEnergyRate,
   11270      855137 :                                           state.dataDXCoils->DXCoil(DXCoilNum).TotalCoolingEnergyRate);
   11271             : 
   11272      855137 :         state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp = OutletAirTemp;
   11273      855137 :         state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat = OutletAirHumRat;
   11274      855137 :         state.dataDXCoils->DXCoil(DXCoilNum).OutletAirEnthalpy = OutletAirEnthalpy;
   11275             : 
   11276             :     } else {
   11277             : 
   11278             :         // DX coil is off; just pass through conditions
   11279      698815 :         state.dataDXCoils->DXCoil(DXCoilNum).OutletAirEnthalpy = state.dataDXCoils->DXCoil(DXCoilNum).InletAirEnthalpy;
   11280      698815 :         state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat = state.dataDXCoils->DXCoil(DXCoilNum).InletAirHumRat;
   11281      698815 :         state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp = state.dataDXCoils->DXCoil(DXCoilNum).InletAirTemp;
   11282             : 
   11283      698815 :         state.dataDXCoils->DXCoil(DXCoilNum).ElecCoolingPower = 0.0;
   11284      698815 :         state.dataDXCoils->DXCoil(DXCoilNum).TotalCoolingEnergyRate = 0.0;
   11285      698815 :         state.dataDXCoils->DXCoil(DXCoilNum).SensCoolingEnergyRate = 0.0;
   11286      698815 :         state.dataDXCoils->DXCoil(DXCoilNum).LatCoolingEnergyRate = 0.0;
   11287      698815 :         state.dataDXCoils->DXCoil(DXCoilNum).EvapCondPumpElecPower = 0.0;
   11288      698815 :         state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterConsumpRate = 0.0;
   11289             : 
   11290             :         // Reset globals when DX coil is OFF for use in heat recovery module
   11291      698815 :         state.dataDXCoils->DXCoilFullLoadOutAirTemp(DXCoilNum) = 0.0;
   11292      698815 :         state.dataDXCoils->DXCoilFullLoadOutAirHumRat(DXCoilNum) = 0.0;
   11293             : 
   11294             :     } // end of on/off if - else
   11295             : 
   11296             :     // set water system demand request (if needed)
   11297     1553952 :     if (state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterSupplyMode == EvapWaterSupply::FromTank) {
   11298           0 :         state.dataWaterData->WaterStorage(state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterSupTankID)
   11299           0 :             .VdotRequestDemand(state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterTankDemandARRID) =
   11300           0 :             state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterConsumpRate;
   11301             :     }
   11302             : 
   11303     1553952 :     state.dataDXCoils->DXCoilOutletTemp(DXCoilNum) = state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp;
   11304     1553952 :     state.dataDXCoils->DXCoilOutletHumRat(DXCoilNum) = state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat;
   11305     1553952 :     state.dataDXCoils->DXCoilPartLoadRatio(DXCoilNum) = state.dataDXCoils->DXCoil(DXCoilNum).PartLoadRatio;
   11306     1553952 :     state.dataDXCoils->DXCoilFanOpMode(DXCoilNum) = FanOpMode;
   11307     1553952 :     state.dataDXCoils->DXCoil(DXCoilNum).CondInletTemp = CondInletTemp;
   11308     1553952 :     state.dataDXCoils->DXCoilTotalCooling(DXCoilNum) = state.dataDXCoils->DXCoil(DXCoilNum).TotalCoolingEnergyRate;
   11309     1553952 :     state.dataDXCoils->DXCoilCoolInletAirWBTemp(DXCoilNum) = PsyTwbFnTdbWPb(state, InletAirDryBulbTemp, InletAirHumRat, OutdoorPressure);
   11310             : 
   11311             :     // set outlet node conditions
   11312     1553952 :     int airOutletNode = state.dataDXCoils->DXCoil(DXCoilNum).AirOutNode;
   11313     1553952 :     state.dataLoopNodes->Node(airOutletNode).Temp = state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp;
   11314     1553952 :     state.dataLoopNodes->Node(airOutletNode).HumRat = state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat;
   11315     1553952 : }
   11316             : 
   11317     8964565 : void CalcDXHeatingCoil(EnergyPlusData &state,
   11318             :                        int const DXCoilNum,                      // the number of the DX heating coil to be simulated
   11319             :                        Real64 const PartLoadRatio,               // sensible cooling load / full load sensible cooling capacity
   11320             :                        int const FanOpMode,                      // Allows parent object to control fan mode
   11321             :                        Optional<Real64 const> OnOffAirFlowRatio, // ratio of compressor on airflow to compressor off airflow
   11322             :                        Optional<Real64 const> MaxHeatCap         // maximum allowed heating capacity
   11323             : )
   11324             : {
   11325             : 
   11326             :     // SUBROUTINE INFORMATION:
   11327             :     //       AUTHOR         Richard Raustad
   11328             :     //       DATE WRITTEN   October 2001
   11329             :     //       MODIFIED       Raustad/Shirey Mar 2004
   11330             :     //                      Kenneth Tang 2004 (Sensitivity of TotCapTempModFac & EIRTempModFac  to indoor dry bulb temp)
   11331             :     //                      Feb 2005 M. J. Witte, GARD Analytics, Inc.
   11332             :     //                        Add new coil type COIL:DX:MultiMode:CoolingEmpirical:
   11333             : 
   11334             :     // PURPOSE OF THIS SUBROUTINE:
   11335             :     // Calculates the air-side heating performance and electrical heating energy
   11336             :     // use of a direct-expansion, air-cooled heat pump unit.
   11337             : 
   11338             :     // METHODOLOGY EMPLOYED:
   11339             :     // This routine simulates the performance of air-cooled DX heating equipment.
   11340             :     // The routine requires the user to enter the total heating capacity
   11341             :     // and COP for the unit at ARI 210/240 rating conditions (21.11C [70F] dry-bulb,
   11342             :     // 15.55C [60F] wet-bulb air entering the heating coil, 8.33C [47F] dry-bulb,
   11343             :     // 6.11C [43F] wet-bulb air entering the outdoor condenser. Since different
   11344             :     // manufacturer's rate their equipment at different air flow rates, the supply
   11345             :     // air flow rate corresponding to the rated capacities and rated COP must also
   11346             :     // be entered (should be between 300 cfm/ton and 450 cfm/ton). The rated information
   11347             :     // entered by the user should NOT include the thermal or electrical impacts of the
   11348             :     // supply air fan, as this is addressed by another module.
   11349             : 
   11350             :     // With the rated performance data entered by the user, the model employs some of the
   11351             :     // DOE-2.1E curve fits to adjust the capacity and efficiency of the unit as a function
   11352             :     // of outdoor air temperatures and supply air flow rate (actual vs rated flow). The
   11353             :     // model does NOT employ the exact same methodology to calculate performance as DOE-2,
   11354             :     // although some of the DOE-2 curve fits are employed by this model.
   11355             : 
   11356             :     // REFERENCES:
   11357             :     // Winkelmann, F.C., Birdsall, B.E., Buhl W.F., Ellington, K.L., Erdem, A.E. 1993.
   11358             :     // DOE-2 Supplement Version 2.1E.  Energy and Environment Division, Larwence Berkely
   11359             :     // Laboratory.
   11360             :     // Henderson, H.I. Jr., Y.J. Huang and Danny Parker. 1999. Residential Equipment Part
   11361             :     // Load Curves for Use in DOE-2.  Environmental Energy Technologies Division, Ernest
   11362             :     // Orlando Lawrence Berkeley National Laboratory.
   11363             : 
   11364             :     // Using/Aliasing
   11365             :     using Curve::CurveValue;
   11366             : 
   11367             :     // SUBROUTINE PARAMETER DEFINITIONS:
   11368             :     static constexpr std::string_view RoutineNameFullLoad("CalcDXHeatingCoil:fullload");
   11369             : 
   11370             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   11371             :     Real64 AirMassFlow;           // dry air mass flow rate through coil [kg/s]
   11372             :     Real64 AirMassFlowRatio;      // Ratio of actual air mass flow to rated air mass flow
   11373             :     Real64 AirVolumeFlowRate;     // Air volume flow rate across the cooling coil [m3/s]
   11374             :     Real64 VolFlowperRatedTotCap; // Air volume flow rate divided by rated total cooling capacity [m3/s-W]
   11375             :     Real64 TotCap;                // gross total cooling capacity at off-rated conditions [W]
   11376             :     Real64 TotCapAdj;             // adjusted total cooling capacity at off-rated conditions [W]
   11377             :     Real64 TotCapTempModFac;      // Total capacity modifier (function of entering drybulb, outside drybulb) depending
   11378             :     // on the type of curve
   11379             :     Real64 TotCapFlowModFac;    // Total capacity modifier (function of actual supply air flow vs rated flow)
   11380             :     Real64 InletAirDryBulbTemp; // inlet air dry bulb temperature [C]
   11381             :     Real64 InletAirWetBulbC;    // wetbulb temperature of inlet air [C]
   11382             :     Real64 InletAirEnthalpy;    // inlet air enthalpy [J/kg]
   11383             :     Real64 InletAirHumRat;      // inlet air humidity ratio [kg/kg]
   11384             :     //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   11385             :     // REAL(r64)     :: InletAirPressure            ! inlet air pressure [Pa]
   11386             :     Real64 FullLoadOutAirEnth;   // outlet full load enthalpy [J/kg]
   11387             :     Real64 FullLoadOutAirHumRat; // outlet humidity ratio at full load
   11388             :     Real64 FullLoadOutAirTemp;   // outlet air temperature at full load [C]
   11389             :     Real64 FullLoadOutAirRH;     // outlet air relative humidity at full load
   11390     8964565 :     Real64 EIRTempModFac(0.0);   // EIR modifier (function of entering drybulb, outside drybulb) depending on the
   11391             :     // type of curve
   11392             :     Real64 DefrostEIRTempModFac;      // EIR modifier for defrost (function of entering wetbulb, outside drybulb)
   11393             :     Real64 EIRFlowModFac;             // EIR modifier (function of actual supply air flow vs rated flow)
   11394             :     Real64 EIR;                       // EIR at part load and off rated conditions
   11395             :     Real64 PLF;                       // Part load factor, accounts for thermal lag at compressor startup
   11396             :     Real64 PLRHeating;                // PartLoadRatio in heating
   11397             :     Real64 OutdoorCoilT;              // Outdoor coil temperature (C)
   11398             :     Real64 OutdoorCoildw;             // Outdoor coil delta w assuming coil temp of OutdoorCoilT (kg/kg)
   11399             :     Real64 FractionalDefrostTime;     // Fraction of time step system is in defrost
   11400             :     Real64 HeatingCapacityMultiplier; // Multiplier for heating capacity when system is in defrost
   11401             :     Real64 InputPowerMultiplier;      // Multiplier for power when system is in defrost
   11402             :     Real64 LoadDueToDefrost;          // Additional load due to defrost
   11403             :     Real64 CrankcaseHeatingPower;     // power due to crankcase heater
   11404             :     Real64 OutdoorDryBulb;            // Outdoor dry-bulb temperature at condenser (C)
   11405             :     Real64 OutdoorWetBulb;            // Outdoor wet-bulb temperature at condenser (C)
   11406             :     Real64 OutdoorHumRat;             // Outdoor humidity ratio at condenser (kg/kg)
   11407             :     Real64 OutdoorPressure;           // Outdoor barometric pressure at condenser (Pa)
   11408     8964565 :     constexpr int Mode(1);            // Performance mode for MultiMode DX coil; Always 1 for other coil types
   11409             :     Real64 AirFlowRatio;              // Ratio of compressor on airflow to average timestep airflow
   11410             :     Real64 OutletAirTemp;             // Supply air temperature (average value if constant fan, full output if cycling fan)
   11411             :     Real64 OutletAirHumRat;           // Supply air humidity ratio (average value if constant fan, full output if cycling fan)
   11412             :     Real64 OutletAirEnthalpy;         // Supply air enthalpy (average value if constant fan, full output if cycling fan)
   11413     8964565 :     Real64 CompAmbTemp(0.0);          // Ambient temperature at compressor
   11414             : 
   11415     8964565 :     if (present(OnOffAirFlowRatio)) {
   11416     8964524 :         AirFlowRatio = OnOffAirFlowRatio;
   11417             :     } else {
   11418          41 :         AirFlowRatio = 1.0;
   11419             :     }
   11420             : 
   11421     8964565 :     auto &DXCT = state.dataHVACGlobal->DXCT;
   11422             : 
   11423             :     // Get condenser outdoor node info from DX Heating Coil
   11424     8964565 :     if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(1) != 0) {
   11425     2282953 :         OutdoorDryBulb = state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(1)).Temp;
   11426     2282953 :         CompAmbTemp = OutdoorDryBulb;
   11427     2282953 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(Mode) == DataHeatBalance::RefrigCondenserType::Water) {
   11428      156173 :             OutdoorHumRat = state.dataEnvrn->OutHumRat;
   11429      156173 :             OutdoorPressure = state.dataEnvrn->OutBaroPress;
   11430      156173 :             OutdoorWetBulb = state.dataEnvrn->OutWetBulbTemp;
   11431      156173 :             CompAmbTemp = state.dataEnvrn->OutDryBulbTemp;
   11432             :         } else {
   11433     2126780 :             OutdoorPressure = state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(1)).Press;
   11434             :             // If node is not connected to anything, pressure = default, use weather data
   11435     2126780 :             if (OutdoorPressure == state.dataLoopNodes->DefaultNodeValues.Press) {
   11436           0 :                 OutdoorDryBulb = state.dataEnvrn->OutDryBulbTemp;
   11437           0 :                 OutdoorHumRat = state.dataEnvrn->OutHumRat;
   11438           0 :                 OutdoorPressure = state.dataEnvrn->OutBaroPress;
   11439           0 :                 OutdoorWetBulb = state.dataEnvrn->OutWetBulbTemp;
   11440             :             } else {
   11441     2126780 :                 OutdoorHumRat = state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(1)).HumRat;
   11442             :                 // this should use Node%WetBulbTemp or a PSYC function, not OAWB
   11443     2126780 :                 OutdoorWetBulb = state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(1)).OutAirWetBulb;
   11444             :             }
   11445     2126780 :             if (state.dataDXCoils->DXCoil(DXCoilNum).IsSecondaryDXCoilInZone) {
   11446           0 :                 auto &secZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(state.dataDXCoils->DXCoil(DXCoilNum).SecZonePtr);
   11447           0 :                 OutdoorDryBulb = secZoneHB.ZT;
   11448           0 :                 OutdoorHumRat = secZoneHB.ZoneAirHumRat;
   11449           0 :                 OutdoorWetBulb = state.dataDXCoils->DXCoil(DXCoilNum).EvapInletWetBulb;
   11450           0 :                 OutdoorPressure = state.dataEnvrn->OutBaroPress;
   11451           0 :                 CompAmbTemp = OutdoorDryBulb;
   11452             :             }
   11453             :         }
   11454     6681612 :     } else if (state.dataDXCoils->DXCoil(DXCoilNum).IsSecondaryDXCoilInZone) {
   11455       83893 :         auto &secZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(state.dataDXCoils->DXCoil(DXCoilNum).SecZonePtr);
   11456       83893 :         OutdoorDryBulb = secZoneHB.ZT;
   11457       83893 :         OutdoorHumRat = secZoneHB.ZoneAirHumRat;
   11458       83893 :         OutdoorWetBulb = state.dataDXCoils->DXCoil(DXCoilNum).EvapInletWetBulb;
   11459       83893 :         OutdoorPressure = state.dataEnvrn->OutBaroPress;
   11460       83893 :         CompAmbTemp = OutdoorDryBulb;
   11461             :     } else {
   11462     6597719 :         OutdoorDryBulb = state.dataEnvrn->OutDryBulbTemp;
   11463     6597719 :         OutdoorHumRat = state.dataEnvrn->OutHumRat;
   11464     6597719 :         OutdoorPressure = state.dataEnvrn->OutBaroPress;
   11465     6597719 :         OutdoorWetBulb = state.dataEnvrn->OutWetBulbTemp;
   11466     6597719 :         CompAmbTemp = OutdoorDryBulb;
   11467             :     }
   11468             : 
   11469     8964565 :     AirMassFlow = state.dataDXCoils->DXCoil(DXCoilNum).InletAirMassFlowRate;
   11470     8964565 :     InletAirDryBulbTemp = state.dataDXCoils->DXCoil(DXCoilNum).InletAirTemp;
   11471     8964565 :     InletAirEnthalpy = state.dataDXCoils->DXCoil(DXCoilNum).InletAirEnthalpy;
   11472     8964565 :     InletAirHumRat = state.dataDXCoils->DXCoil(DXCoilNum).InletAirHumRat;
   11473             :     //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   11474             :     // InletAirPressure = DXCoil(DXCoilNum)%InletAirPressure
   11475             :     // InletAirWetBulbC = PsyTwbFnTdbWPb(InletAirDryBulbTemp,InletAirHumRat,InletAirPressure)
   11476     8964565 :     InletAirWetBulbC = PsyTwbFnTdbWPb(state, InletAirDryBulbTemp, InletAirHumRat, OutdoorPressure);
   11477     8964565 :     PLRHeating = 0.0;
   11478     8964565 :     state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction = 0.0;
   11479             :     // Initialize crankcase heater, operates below OAT defined in input deck for HP DX heating coil
   11480     8964565 :     if (CompAmbTemp < state.dataDXCoils->DXCoil(DXCoilNum).MaxOATCrankcaseHeater) {
   11481     1887073 :         CrankcaseHeatingPower = state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterCapacity;
   11482             :     } else {
   11483     7077492 :         CrankcaseHeatingPower = 0.0;
   11484             :     }
   11485             : 
   11486    10145508 :     if ((AirMassFlow > 0.0) && (GetCurrentScheduleValue(state, state.dataDXCoils->DXCoil(DXCoilNum).SchedPtr) > 0.0) && (PartLoadRatio > 0.0) &&
   11487     1180943 :         OutdoorDryBulb > state.dataDXCoils->DXCoil(DXCoilNum).MinOATCompressor) {
   11488             :         // for cycling fan, reset mass flow to full on rate
   11489      577898 :         if (FanOpMode == CycFanCycCoil) AirMassFlow /= PartLoadRatio;
   11490      577898 :         if (FanOpMode == ContFanCycCoil) AirMassFlow *= AirFlowRatio;
   11491             :         // Check for valid air volume flow per rated total cooling capacity (200 - 600 cfm/ton)
   11492      577898 :         AirVolumeFlowRate = AirMassFlow / PsyRhoAirFnPbTdbW(state, OutdoorPressure, InletAirDryBulbTemp, InletAirHumRat);
   11493             :         //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   11494             :         //  AirVolumeFlowRate = AirMassFlow/PsyRhoAirFnPbTdbW(InletAirPressure,InletAirDryBulbTemp, InletAirHumRat)
   11495      577898 :         VolFlowperRatedTotCap = AirVolumeFlowRate / state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode);
   11496             : 
   11497     1155796 :         if ((VolFlowperRatedTotCap < state.dataHVACGlobal->MinOperVolFlowPerRatedTotCap(DXCT)) ||
   11498      577898 :             (VolFlowperRatedTotCap > state.dataHVACGlobal->MaxHeatVolFlowPerRatedTotCap(DXCT))) {
   11499           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).ErrIndex1 == 0) {
   11500           0 :                 ShowWarningMessage(
   11501             :                     state,
   11502           0 :                     format("{} \"{}\" - Air volume flow rate per watt of rated total heating capacity is out of range at {:.3R} m3/s/W.",
   11503           0 :                            state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
   11504           0 :                            state.dataDXCoils->DXCoil(DXCoilNum).Name,
   11505           0 :                            VolFlowperRatedTotCap));
   11506           0 :                 ShowContinueErrorTimeStamp(state, "");
   11507           0 :                 ShowContinueError(state,
   11508           0 :                                   format("Expected range for VolumeFlowPerRatedTotalCapacity=[{:.3R}--{:.3R}]",
   11509           0 :                                          state.dataHVACGlobal->MinOperVolFlowPerRatedTotCap(DXCT),
   11510           0 :                                          state.dataHVACGlobal->MaxHeatVolFlowPerRatedTotCap(DXCT)));
   11511           0 :                 ShowContinueError(state, "Possible causes include inconsistent air flow rates in system components or");
   11512           0 :                 ShowContinueError(state, "inconsistent supply air fan operation modes in coil and unitary system objects.");
   11513             :             }
   11514           0 :             ShowRecurringWarningErrorAtEnd(
   11515             :                 state,
   11516           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + " \"" + state.dataDXCoils->DXCoil(DXCoilNum).Name +
   11517             :                     "\" - Air volume flow rate per watt of rated total heating capacity is out of range error continues...",
   11518           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).ErrIndex1,
   11519             :                 VolFlowperRatedTotCap,
   11520             :                 VolFlowperRatedTotCap);
   11521             :         }
   11522             : 
   11523             :         // Get total capacity modifying factor (function of temperature) for off-rated conditions
   11524             :         // Model was extended to accept bi-quadratic curves. This allows sensitivity of the heating capacity
   11525             :         // to the entering dry-bulb temperature as well as the outside dry-bulb temperature. User is
   11526             :         // advised to use the bi-quaratic curve if sufficient manufacturer data is available.
   11527      577898 :         if (state.dataCurveManager->PerfCurve(state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(Mode)).numDims == 2) {
   11528       56682 :             switch (state.dataDXCoils->DXCoil(DXCoilNum).HeatingPerformanceOATType) {
   11529           1 :             case DryBulbIndicator: {
   11530           1 :                 TotCapTempModFac = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(Mode), InletAirDryBulbTemp, OutdoorDryBulb);
   11531           1 :             } break;
   11532       56681 :             case WetBulbIndicator: {
   11533       56681 :                 TotCapTempModFac = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(Mode), InletAirDryBulbTemp, OutdoorWetBulb);
   11534       56681 :             } break;
   11535           0 :             default: {
   11536           0 :                 TotCapTempModFac = 1.0;
   11537           0 :             } break;
   11538             :             }
   11539             :         } else {
   11540      521216 :             switch (state.dataDXCoils->DXCoil(DXCoilNum).HeatingPerformanceOATType) {
   11541      312190 :             case DryBulbIndicator: {
   11542      600560 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num != CoilVRF_Heating &&
   11543      288370 :                     state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num != CoilVRF_FluidTCtrl_Heating) {
   11544      288370 :                     TotCapTempModFac = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(Mode), OutdoorDryBulb);
   11545             :                 } else {
   11546       23820 :                     TotCapTempModFac = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(Mode), InletAirDryBulbTemp);
   11547             :                 }
   11548      312190 :             } break;
   11549      209026 :             case WetBulbIndicator: {
   11550      209026 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num != CoilVRF_Heating &&
   11551           0 :                     state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num != CoilVRF_FluidTCtrl_Heating) {
   11552           0 :                     TotCapTempModFac = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(Mode), OutdoorWetBulb);
   11553             :                 } else {
   11554      209026 :                     TotCapTempModFac = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(Mode), InletAirDryBulbTemp);
   11555             :                 }
   11556      209026 :             } break;
   11557           0 :             default: {
   11558           0 :                 TotCapTempModFac = 1.0;
   11559           0 :             } break;
   11560             :             }
   11561             :         }
   11562             : 
   11563      577898 :         if (TotCapTempModFac < 0.0) {
   11564           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).CAPFTErrIndex == 0) {
   11565           0 :                 ShowWarningMessage(state,
   11566           0 :                                    format("The TotCapTempModFac curve value for DX heating coil {} ={:.2R}",
   11567           0 :                                           state.dataDXCoils->DXCoil(DXCoilNum).Name,
   11568           0 :                                           TotCapTempModFac));
   11569           0 :                 ShowContinueError(state,
   11570             :                                   "TotCapTempModFac curve value must be > 0. TotCapTempModFac curve value has been reset to 0.0 and "
   11571             :                                   "simulation is continuing.");
   11572           0 :                 ShowContinueError(state,
   11573           0 :                                   "Check the IO reference manual for TotCapTempModFac curve guidance [ " +
   11574           0 :                                       state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + " ].");
   11575           0 :                 ShowContinueErrorTimeStamp(state, "");
   11576             :             }
   11577           0 :             ShowRecurringWarningErrorAtEnd(state,
   11578             :                                            "DX heating coil TotCapTempModFac curve value < 0 warning continues... ",
   11579           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).CAPFTErrIndex,
   11580             :                                            TotCapTempModFac,
   11581             :                                            TotCapTempModFac);
   11582           0 :             TotCapTempModFac = 0.0;
   11583             :         }
   11584             : 
   11585             :         //  Get total capacity modifying factor (function of mass flow) for off-rated conditions
   11586      577898 :         AirMassFlowRatio = AirMassFlow / state.dataDXCoils->DXCoil(DXCoilNum).RatedAirMassFlowRate(Mode);
   11587      577898 :         TotCapFlowModFac = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).CCapFFlow(Mode), AirMassFlowRatio);
   11588             : 
   11589             :         // Calculate total heating capacity for off-rated conditions
   11590      577898 :         TotCap = state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode) * TotCapFlowModFac * TotCapTempModFac;
   11591             : 
   11592             :         // Calculating adjustment factors for defrost
   11593             :         // Calculate delta w through outdoor coil by assuming a coil temp of 0.82*DBT-9.7(F) per DOE2.1E
   11594      577898 :         OutdoorCoilT = 0.82 * OutdoorDryBulb - 8.589;
   11595      577898 :         OutdoorCoildw = max(1.0e-6, (OutdoorHumRat - PsyWFnTdpPb(state, OutdoorCoilT, OutdoorPressure)));
   11596             : 
   11597             :         // Initializing defrost adjustment factors
   11598      577898 :         LoadDueToDefrost = 0.0;
   11599      577898 :         HeatingCapacityMultiplier = 1.0;
   11600      577898 :         FractionalDefrostTime = 0.0;
   11601      577898 :         InputPowerMultiplier = 1.0;
   11602             : 
   11603             :         // Check outdoor temperature to determine of defrost is active
   11604      666122 :         if (OutdoorDryBulb <= state.dataDXCoils->DXCoil(DXCoilNum).MaxOATDefrost &&
   11605       88224 :             state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(Mode) != DataHeatBalance::RefrigCondenserType::Water) {
   11606             :             // Calculate defrost adjustment factors depending on defrost control type
   11607       88224 :             if (state.dataDXCoils->DXCoil(DXCoilNum).DefrostControl == StandardRatings::HPdefrostControl::Timed) {
   11608       87681 :                 FractionalDefrostTime = state.dataDXCoils->DXCoil(DXCoilNum).DefrostTime;
   11609       87681 :                 if (FractionalDefrostTime > 0.0) {
   11610       87681 :                     HeatingCapacityMultiplier = 0.909 - 107.33 * OutdoorCoildw;
   11611       87681 :                     InputPowerMultiplier = 0.90 - 36.45 * OutdoorCoildw;
   11612             :                 }
   11613             :             } else { // else defrost control is on-demand
   11614         543 :                 FractionalDefrostTime = 1.0 / (1.0 + 0.01446 / OutdoorCoildw);
   11615         543 :                 HeatingCapacityMultiplier = 0.875 * (1.0 - FractionalDefrostTime);
   11616         543 :                 InputPowerMultiplier = 0.954 * (1.0 - FractionalDefrostTime);
   11617             :             }
   11618             : 
   11619       88224 :             if (FractionalDefrostTime > 0.0) {
   11620             :                 // Calculate defrost adjustment factors depending on defrost control strategy
   11621       88224 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).DefrostStrategy == StandardRatings::DefrostStrat::ReverseCycle) {
   11622        1086 :                     LoadDueToDefrost = (0.01 * FractionalDefrostTime) * (7.222 - OutdoorDryBulb) *
   11623         543 :                                        (state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode) / 1.01667);
   11624        2172 :                     DefrostEIRTempModFac = CurveValue(
   11625        1629 :                         state, state.dataDXCoils->DXCoil(DXCoilNum).DefrostEIRFT, max(15.555, InletAirWetBulbC), max(15.555, OutdoorDryBulb));
   11626         543 :                     state.dataDXCoils->DXCoil(DXCoilNum).DefrostPower =
   11627         543 :                         DefrostEIRTempModFac * (state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode) / 1.01667) * FractionalDefrostTime;
   11628             :                 } else { // Defrost strategy is resistive
   11629       87681 :                     state.dataDXCoils->DXCoil(DXCoilNum).DefrostPower = state.dataDXCoils->DXCoil(DXCoilNum).DefrostCapacity * FractionalDefrostTime;
   11630             :                 }
   11631             :             } else { // Defrost is not active because (FractionalDefrostTime .EQ. 0.0)
   11632           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).DefrostPower = 0.0;
   11633             :             }
   11634             :         }
   11635             : 
   11636             :         // Modify total heating capacity based on defrost heating capacity multiplier
   11637             :         // MaxHeatCap passed from parent object VRF Condenser and is used to limit capacity of TU's to that available from condenser
   11638      577898 :         if (present(MaxHeatCap)) {
   11639      289486 :             TotCapAdj = min(MaxHeatCap, TotCap * HeatingCapacityMultiplier);
   11640      289486 :             TotCap = min(MaxHeatCap, TotCap);
   11641             :         } else {
   11642      288412 :             TotCapAdj = TotCap * HeatingCapacityMultiplier;
   11643             :         }
   11644             : 
   11645             :         // Calculate full load outlet conditions
   11646      577898 :         FullLoadOutAirEnth = InletAirEnthalpy + TotCapAdj / AirMassFlow;
   11647      577898 :         FullLoadOutAirHumRat = InletAirHumRat;
   11648      577898 :         FullLoadOutAirTemp = PsyTdbFnHW(FullLoadOutAirEnth, FullLoadOutAirHumRat);
   11649      577898 :         FullLoadOutAirRH = PsyRhFnTdbWPb(state, FullLoadOutAirTemp, FullLoadOutAirHumRat, OutdoorPressure, RoutineNameFullLoad);
   11650             :         //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   11651             :         //  FullLoadOutAirRH = PsyRhFnTdbWPb(FullLoadOutAirTemp,FullLoadOutAirHumRat,InletAirPressure)
   11652      577898 :         if (FullLoadOutAirRH > 1.0) { // Limit to saturated conditions at FullLoadOutAirEnth
   11653           0 :             FullLoadOutAirTemp = PsyTsatFnHPb(state, FullLoadOutAirEnth, OutdoorPressure);
   11654             :             //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   11655             :             //    FullLoadOutAirTemp = PsyTsatFnHPb(FullLoadOutAirEnth,InletAirPressure)
   11656           0 :             FullLoadOutAirHumRat = PsyWFnTdbH(state, FullLoadOutAirTemp, FullLoadOutAirEnth);
   11657             :         }
   11658             : 
   11659             :         // Calculate actual outlet conditions for the input part load ratio
   11660             :         // Actual outlet conditions are "average" for time step
   11661      577898 :         if (FanOpMode == ContFanCycCoil) {
   11662             :             // continuous fan, cycling compressor
   11663      334395 :             OutletAirEnthalpy = ((PartLoadRatio * AirFlowRatio) * FullLoadOutAirEnth + (1.0 - (PartLoadRatio * AirFlowRatio)) * InletAirEnthalpy);
   11664      334395 :             OutletAirHumRat = (PartLoadRatio * FullLoadOutAirHumRat + (1.0 - PartLoadRatio) * InletAirHumRat);
   11665      334395 :             OutletAirTemp = PsyTdbFnHW(OutletAirEnthalpy, OutletAirHumRat);
   11666             :         } else {
   11667             :             // default to cycling fan, cycling compressor
   11668      243503 :             OutletAirEnthalpy = FullLoadOutAirEnth;
   11669      243503 :             OutletAirHumRat = FullLoadOutAirHumRat;
   11670      243503 :             OutletAirTemp = FullLoadOutAirTemp;
   11671             :         }
   11672             :         // Calculate electricity consumed. First, get EIR modifying factors for off-rated conditions
   11673             :         // Model was extended to accept bi-quadratic curves. This allows sensitivity of the EIR
   11674             :         // to the entering dry-bulb temperature as well as the outside dry-bulb temperature. User is
   11675             :         // advised to use the bi-quaratic curve if sufficient manufacturer data is available.
   11676      866269 :         if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num != CoilVRF_Heating &&
   11677      288371 :             state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num != CoilVRF_FluidTCtrl_Heating) {
   11678      288371 :             if (state.dataCurveManager->PerfCurve(state.dataDXCoils->DXCoil(DXCoilNum).EIRFTemp(Mode)).numDims == 1) {
   11679      288370 :                 EIRTempModFac = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).EIRFTemp(Mode), OutdoorDryBulb);
   11680             :             } else {
   11681           1 :                 EIRTempModFac = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).EIRFTemp(Mode), InletAirDryBulbTemp, OutdoorDryBulb);
   11682             :             }
   11683      288371 :             EIRFlowModFac = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).EIRFFlow(Mode), AirMassFlowRatio);
   11684             :         } else {
   11685      289527 :             EIRTempModFac = 1.0;
   11686      289527 :             EIRFlowModFac = 1.0;
   11687             :         }
   11688             : 
   11689      577898 :         if (EIRTempModFac < 0.0) {
   11690           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).EIRFTErrIndex == 0) {
   11691           0 :                 ShowWarningMessage(
   11692             :                     state,
   11693           0 :                     format("The EIRTempModFac curve value for DX heating coil {} ={:.2R}", state.dataDXCoils->DXCoil(DXCoilNum).Name, EIRTempModFac));
   11694           0 :                 ShowContinueError(
   11695             :                     state, "EIRTempModFac curve value must be > 0.  EIRTempModFac curve value has been reset to 0.0 and simulation is continuing.");
   11696           0 :                 ShowContinueError(state,
   11697           0 :                                   "Check the IO reference manual for EIRTempModFac curve guidance [ " +
   11698           0 :                                       state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + " ].");
   11699           0 :                 ShowContinueErrorTimeStamp(state, "");
   11700             :             }
   11701           0 :             ShowRecurringWarningErrorAtEnd(state,
   11702             :                                            "DX heating coil EIRTempModFac curve value < 0.0 warning continues... ",
   11703           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).EIRFTErrIndex,
   11704             :                                            EIRTempModFac,
   11705             :                                            EIRTempModFac);
   11706           0 :             EIRTempModFac = 0.0;
   11707             :         }
   11708             : 
   11709      577898 :         EIR = state.dataDXCoils->DXCoil(DXCoilNum).RatedEIR(Mode) * EIRTempModFac * EIRFlowModFac;
   11710             :         // Calculate modified PartLoadRatio due to defrost (reverse-cycle defrost only)
   11711      577898 :         if (TotCapAdj > 0.0) {
   11712      577832 :             PLRHeating = min(1.0, (PartLoadRatio + (LoadDueToDefrost * PartLoadRatio) / TotCapAdj));
   11713             :         } else {
   11714          66 :             PLRHeating = 0.0;
   11715             :         }
   11716      577898 :         if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num != CoilVRF_Heating) {
   11717      288371 :             PLF = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(Mode), PLRHeating); // Calculate part-load factor
   11718             :         } else {
   11719      289527 :             PLF = 1.0;
   11720             :         }
   11721             : 
   11722      577898 :         if (PLF < 0.7) {
   11723           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).PLRErrIndex == 0) {
   11724           0 :                 ShowWarningMessage(state,
   11725           0 :                                    format("The PLF curve value for DX heating coil {} ={:.2R} for part-load ratio ={:.2R}",
   11726           0 :                                           state.dataDXCoils->DXCoil(DXCoilNum).Name,
   11727             :                                           PLF,
   11728           0 :                                           PLRHeating));
   11729           0 :                 ShowContinueError(state, "PLF curve values must be >= 0.7. PLF has been reset to 0.7 and simulation is continuing.");
   11730           0 :                 ShowContinueError(state, "Check the IO reference manual for PLF curve guidance [Coil:Heating:DX:SingleSpeed].");
   11731           0 :                 ShowContinueErrorTimeStamp(state, "");
   11732             :             }
   11733           0 :             ShowRecurringWarningErrorAtEnd(
   11734           0 :                 state, "DX heating coil PLF curve < 0.7 warning continues... ", state.dataDXCoils->DXCoil(DXCoilNum).PLRErrIndex, PLF, PLF);
   11735           0 :             PLF = 0.7;
   11736             :         }
   11737             : 
   11738      577898 :         state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction = (PLRHeating / PLF);
   11739      577898 :         if (state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction > 1.0 &&
   11740           0 :             std::abs(state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction - 1.0) > 0.001) {
   11741           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).ErrIndex4 == 0) {
   11742           0 :                 ShowWarningMessage(state,
   11743           0 :                                    format("The runtime fraction for DX heating coil {} exceeded 1.0. [{:.4R}].",
   11744           0 :                                           state.dataDXCoils->DXCoil(DXCoilNum).Name,
   11745           0 :                                           state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction));
   11746           0 :                 ShowContinueError(state, "Runtime fraction is set to 1.0 and the simulation continues...");
   11747           0 :                 ShowContinueError(state, "Check the IO reference manual for PLF curve guidance [Coil:Heating:DX:SingleSpeed].");
   11748           0 :                 ShowContinueErrorTimeStamp(state, "");
   11749             :             }
   11750           0 :             ShowRecurringWarningErrorAtEnd(state,
   11751           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).Name +
   11752             :                                                ", DX heating coil runtime fraction > 1.0 warning continues...",
   11753           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).ErrIndex4,
   11754           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction,
   11755           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction);
   11756           0 :             state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction = 1.0; // Reset coil runtime fraction to 1.0
   11757      577898 :         } else if (state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction > 1.0) {
   11758           0 :             state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction = 1.0; // Reset coil runtime fraction to 1.0
   11759             :         }
   11760             :         // if cycling fan, send coil part-load fraction to on/off fan via HVACDataGlobals
   11761      577898 :         if (FanOpMode == CycFanCycCoil) state.dataHVACGlobal->OnOffFanPartLoadFraction = PLF;
   11762      577898 :         state.dataDXCoils->DXCoil(DXCoilNum).ElecHeatingPower =
   11763      577898 :             TotCap * EIR * state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction * InputPowerMultiplier;
   11764             : 
   11765             :         // Calculate crankcase heater power using the runtime fraction for this DX heating coil only if there is no companion DX coil.
   11766             :         // Else use the largest runtime fraction of this DX heating coil and the companion DX cooling coil.
   11767             : 
   11768      577898 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CompanionUpstreamDXCoil == 0) {
   11769      289550 :             state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterPower =
   11770      289550 :                 CrankcaseHeatingPower * (1.0 - state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction);
   11771             :         } else {
   11772      288348 :             state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterPower =
   11773      288348 :                 CrankcaseHeatingPower *
   11774      288348 :                 (1.0 - max(state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction,
   11775      288348 :                            state.dataDXCoils->DXCoil(state.dataDXCoils->DXCoil(DXCoilNum).CompanionUpstreamDXCoil).CoolingCoilRuntimeFraction));
   11776             :         }
   11777             : 
   11778      577898 :         AirMassFlow = state.dataDXCoils->DXCoil(DXCoilNum).InletAirMassFlowRate;
   11779      577898 :         state.dataDXCoils->DXCoil(DXCoilNum).TotalHeatingEnergyRate = AirMassFlow * (OutletAirEnthalpy - InletAirEnthalpy);
   11780             :         // Adjust defrost power to correct for DOE-2 bug where defrost power is constant regardless of compressor runtime fraction
   11781             :         // Defrosts happen based on compressor run time (frost buildup on outdoor coil), not total elapsed time.
   11782      577898 :         state.dataDXCoils->DXCoil(DXCoilNum).DefrostPower *= state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction;
   11783             : 
   11784      577898 :         state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp = OutletAirTemp;
   11785      577898 :         state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat = OutletAirHumRat;
   11786      577898 :         state.dataDXCoils->DXCoil(DXCoilNum).OutletAirEnthalpy = OutletAirEnthalpy;
   11787      577898 :         state.dataDXCoils->DXCoil(DXCoilNum).CompressorPartLoadRatio = PartLoadRatio;
   11788             : 
   11789             :     } else {
   11790             : 
   11791             :         // DX coil is off; just pass through conditions
   11792     8386667 :         state.dataDXCoils->DXCoil(DXCoilNum).OutletAirEnthalpy = state.dataDXCoils->DXCoil(DXCoilNum).InletAirEnthalpy;
   11793     8386667 :         state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat = state.dataDXCoils->DXCoil(DXCoilNum).InletAirHumRat;
   11794     8386667 :         state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp = state.dataDXCoils->DXCoil(DXCoilNum).InletAirTemp;
   11795             : 
   11796     8386667 :         state.dataDXCoils->DXCoil(DXCoilNum).ElecHeatingPower = 0.0;
   11797     8386667 :         state.dataDXCoils->DXCoil(DXCoilNum).TotalHeatingEnergyRate = 0.0;
   11798     8386667 :         state.dataDXCoils->DXCoil(DXCoilNum).DefrostPower = 0.0;
   11799             : 
   11800             :         // Calculate crankcase heater power using the runtime fraction for this DX heating coil (here DXHeatingCoilRTF=0) if
   11801             :         // there is no companion DX coil, or the runtime fraction of the companion DX cooling coil (here DXCoolingCoilRTF>=0).
   11802     8386667 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CompanionUpstreamDXCoil == 0) {
   11803     2348801 :             state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterPower = CrankcaseHeatingPower;
   11804             :         } else {
   11805     6037866 :             state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterPower =
   11806     6037866 :                 CrankcaseHeatingPower *
   11807     6037866 :                 (1.0 - state.dataDXCoils->DXCoil(state.dataDXCoils->DXCoil(DXCoilNum).CompanionUpstreamDXCoil).CoolingCoilRuntimeFraction);
   11808             :         }
   11809     8386667 :         state.dataDXCoils->DXCoil(DXCoilNum).CompressorPartLoadRatio = 0.0;
   11810             : 
   11811             :     } // end of on/off if - else
   11812             : 
   11813     8964565 :     state.dataDXCoils->DXCoilOutletTemp(DXCoilNum) = state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp;
   11814     8964565 :     state.dataDXCoils->DXCoilOutletHumRat(DXCoilNum) = state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat;
   11815     8964565 :     state.dataDXCoils->DXCoilFanOpMode(DXCoilNum) = FanOpMode;
   11816     8964565 :     state.dataDXCoils->DXCoilPartLoadRatio(DXCoilNum) = PLRHeating;
   11817     8964565 :     state.dataDXCoils->DXCoilTotalHeating(DXCoilNum) = state.dataDXCoils->DXCoil(DXCoilNum).TotalHeatingEnergyRate;
   11818     8964565 :     state.dataDXCoils->DXCoilHeatInletAirDBTemp(DXCoilNum) = InletAirDryBulbTemp;
   11819     8964565 :     state.dataDXCoils->DXCoilHeatInletAirWBTemp(DXCoilNum) = InletAirWetBulbC;
   11820             : 
   11821             :     // set outlet node conditions
   11822     8964565 :     int airOutletNode = state.dataDXCoils->DXCoil(DXCoilNum).AirOutNode;
   11823     8964565 :     state.dataLoopNodes->Node(airOutletNode).Temp = state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp;
   11824     8964565 :     state.dataLoopNodes->Node(airOutletNode).HumRat = state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat;
   11825             : 
   11826             :     // calc secondary coil if specified
   11827     8964565 :     if (state.dataDXCoils->DXCoil(DXCoilNum).IsSecondaryDXCoilInZone) {
   11828       83893 :         CalcSecondaryDXCoils(state, DXCoilNum);
   11829             :     }
   11830     8964565 : }
   11831             : 
   11832     4153909 : void CalcMultiSpeedDXCoil(EnergyPlusData &state,
   11833             :                           int const DXCoilNum,     // the number of the DX heating coil to be simulated
   11834             :                           Real64 const SpeedRatio, // = (CompressorSpeed - CompressorSpeedMin) / (CompressorSpeedMax - CompressorSpeedMin)
   11835             :                           Real64 const CycRatio,   // cycling part load ratio
   11836             :                           Optional_bool_const ForceOn)
   11837             : {
   11838             : 
   11839             :     // SUBROUTINE INFORMATION:
   11840             :     //       AUTHOR         Fred Buhl
   11841             :     //       DATE WRITTEN   September 2002
   11842             :     //       MODIFIED       Raustad/Shirey, Feb 2004
   11843             :     //                      Feb 2005 M. J. Witte, GARD Analytics, Inc.
   11844             :     //                        Add new coil type COIL:DX:MultiMode:CoolingEmpirical:
   11845             :     //                      April 2010, Chandan sharma, FSEC, added basin heater
   11846             : 
   11847             :     // PURPOSE OF THIS SUBROUTINE:
   11848             :     // Calculates the air-side performance and electrical energy use of a direct-
   11849             :     // expansion, air-cooled cooling unit with a 2 speed or variable speed compressor.
   11850             : 
   11851             :     // METHODOLOGY EMPLOYED:
   11852             :     // Uses the same methodology as the single speed DX unit model (SUBROUTINE CalcDoe2DXCoil).
   11853             :     // In addition it assumes that the unit performance is obtained by interpolating between
   11854             :     // the performance at high speed and that at low speed. If the output needed is below
   11855             :     // that produced at low speed, the compressor cycles between off and low speed.
   11856             : 
   11857             :     // Using/Aliasing
   11858             :     using Curve::CurveValue;
   11859             : 
   11860             :     // SUBROUTINE ARGUMENT DEFINITIONS:
   11861             :     // SpeedRatio varies between 1.0 (maximum speed) and 0.0 (minimum speed)
   11862             : 
   11863             :     // SUBROUTINE PARAMETER DEFINITIONS:
   11864             :     static constexpr std::string_view RoutineNameHighSpeedOutlet("CalcMultiSpeedDXCoil:highspeedoutlet");
   11865             :     static constexpr std::string_view RoutineNameLowSpeedOutlet("CalcMultiSpeedDXCoil:lowspeedoutlet");
   11866             :     static constexpr std::string_view RoutineNameNewDewPointConditions("CalcMultiSpeedDXCoil:newdewpointconditions");
   11867             : 
   11868             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   11869             :     Real64 AirMassFlow;         // dry air mass flow rate through coil [kg/s]
   11870             :     Real64 AirMassFlowRatio;    // Ratio of max air mass flow to rated air mass flow
   11871             :     Real64 InletAirWetBulbC;    // wetbulb temperature of inlet air [C]
   11872             :     Real64 InletAirDryBulbTemp; // inlet air dry bulb temperature [C]
   11873             :     Real64 InletAirEnthalpy;    // inlet air enthalpy [J/kg]
   11874             :     Real64 InletAirHumRat;      // inlet air humidity ratio [kg/kg]
   11875             :     //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   11876             :     // REAL(r64) :: InletAirPressure    ! inlet air pressure [Pa]
   11877             :     Real64 OutletAirDryBulbTemp;    // outlet air dry bulb temperature [C]
   11878             :     Real64 OutletAirEnthalpy;       // outlet air enthalpy [J/kg]
   11879             :     Real64 OutletAirHumRat;         // outlet air humidity ratio [kg/kg]
   11880             :     Real64 OutletAirDryBulbTempSat; // outlet air dry bulb temp at saturation at the outlet enthalpy [C]
   11881             :     Real64 LSOutletAirDryBulbTemp;  // low speed outlet air dry bulb temperature [C]
   11882             :     Real64 LSOutletAirEnthalpy;     // low speed outlet air enthalpy [J/kg]
   11883             :     Real64 LSOutletAirHumRat;       // low speed outlet air humidity ratio [kg/kg]
   11884             :     Real64 hDelta;                  // Change in air enthalpy across the cooling coil [J/kg]
   11885             :     Real64 hTinwout;                // Enthalpy at inlet dry-bulb and outlet humidity ratio [J/kg]
   11886             :     Real64 hADP;                    // Apparatus dew point enthalpy [J/kg]
   11887             :     Real64 tADP;                    // Apparatus dew point temperature [C]
   11888             :     Real64 wADP;                    // Apparatus dew point humidity ratio [kg/kg]
   11889             :     Real64 hTinwADP;                // Enthalpy at inlet dry-bulb and wADP [J/kg]
   11890             :     Real64 RatedCBFHS;              // coil bypass factor at rated conditions (high speed)
   11891             :     Real64 CBFHS;                   // coil bypass factor at max flow (high speed)
   11892             :     Real64 TotCapHS;                // total capacity at high speed [W]
   11893             :     Real64 SHRHS;                   // sensible heat ratio at high speed
   11894             :     Real64 TotCapLS;                // total capacity at low speed [W]
   11895             :     Real64 SHRLS;                   // sensible heat ratio at low speed
   11896             :     Real64 EIRTempModFacHS;         // EIR modifier (function of entering wetbulb, outside drybulb) (high speed)
   11897             :     Real64 EIRFlowModFacHS;         // EIR modifier (function of actual supply air flow vs rated flow) (high speed)
   11898             :     Real64 EIRHS;                   // EIR at off rated conditions (high speed)
   11899             :     Real64 EIRTempModFacLS;         // EIR modifier (function of entering wetbulb, outside drybulb) (low speed)
   11900             :     Real64 EIRLS;                   // EIR at off rated conditions (low speed)
   11901             :     Real64 TotCap;                  // total capacity at current speed [W]
   11902             :     Real64 SHR;                     // sensible heat ratio at current speed
   11903             :     Real64 EIR;                     // EIR at current speed
   11904             :     Real64 AirMassFlowNom;          // speed ratio weighted average of high and low speed air mass flow rates [kg/s]
   11905             :     Real64 CBFNom;                  // coil bypass factor corresponding to AirMassFlowNom and SpeedRatio
   11906             :     Real64 CBF;                     // CBFNom adjusted for actual air mass flow rate
   11907             :     Real64 PLF;                     // Part load factor, accounts for thermal lag at compressor startup, used in
   11908             :     // power calculation
   11909             :     Real64 CondInletTemp; // Condenser inlet temperature (C). Outdoor dry-bulb temp for air-cooled condenser.
   11910             :     // Outdoor Wetbulb +(1 - effectiveness)*(outdoor drybulb - outdoor wetbulb) for evap condenser.
   11911             :     Real64 CondInletHumRat; // Condenser inlet humidity ratio (kg/kg). Zero for air-cooled condenser.
   11912             :     // For evap condenser, its the humidity ratio of the air leaving the evap cooling pads.
   11913             :     Real64 RhoAir;                // Density of air [kg/m3]
   11914             :     Real64 RhoWater;              // Density of water [kg/m3]
   11915             :     Real64 CondAirMassFlow;       // Condenser air mass flow rate [kg/s]
   11916             :     Real64 EvapCondPumpElecPower; // Evaporative condenser electric pump power [W]
   11917     4153909 :     constexpr int Mode(1);        // Performance mode for MultiMode DX coil; Always 1 for other coil types
   11918             :     Real64 OutdoorDryBulb;        // Outdoor dry-bulb temperature at condenser (C)
   11919             :     Real64 OutdoorWetBulb;        // Outdoor wet-bulb temperature at condenser (C)
   11920             :     Real64 OutdoorHumRat;         // Outdoor humidity ratio at condenser (kg/kg)
   11921             :     Real64 OutdoorPressure;       // Outdoor barometric pressure at condenser (Pa)
   11922             :     bool LocalForceOn;
   11923             :     Real64 AirMassFlowRatio2; // Ratio of low speed air mass flow to rated air mass flow
   11924     4153909 :     Real64 CompAmbTemp(0.0);  // Ambient temperature at compressor
   11925             : 
   11926     4153909 :     if (present(ForceOn)) {
   11927       55355 :         LocalForceOn = true;
   11928             :     } else {
   11929     4098554 :         LocalForceOn = false;
   11930             :     }
   11931             : 
   11932     4153909 :     if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(Mode) != 0) {
   11933      351376 :         OutdoorPressure = state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(Mode)).Press;
   11934             :         // If node is not connected to anything, pressure = default, use weather data
   11935      351376 :         if (OutdoorPressure == state.dataLoopNodes->DefaultNodeValues.Press) {
   11936           0 :             OutdoorDryBulb = state.dataEnvrn->OutDryBulbTemp;
   11937           0 :             OutdoorHumRat = state.dataEnvrn->OutHumRat;
   11938           0 :             OutdoorPressure = state.dataEnvrn->OutBaroPress;
   11939           0 :             OutdoorWetBulb = state.dataEnvrn->OutWetBulbTemp;
   11940             :         } else {
   11941      351376 :             OutdoorDryBulb = state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(Mode)).Temp;
   11942      351376 :             OutdoorHumRat = state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(Mode)).HumRat;
   11943      351376 :             OutdoorWetBulb = PsyTwbFnTdbWPb(state, OutdoorDryBulb, OutdoorHumRat, OutdoorPressure);
   11944             :         }
   11945      351376 :         CompAmbTemp = OutdoorDryBulb;
   11946      351376 :         if (state.dataDXCoils->DXCoil(DXCoilNum).IsSecondaryDXCoilInZone) {
   11947           0 :             auto &secZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(state.dataDXCoils->DXCoil(DXCoilNum).SecZonePtr);
   11948           0 :             OutdoorDryBulb = secZoneHB.ZT;
   11949           0 :             OutdoorHumRat = secZoneHB.ZoneAirHumRat;
   11950           0 :             OutdoorWetBulb = state.dataDXCoils->DXCoil(DXCoilNum).EvapInletWetBulb;
   11951           0 :             OutdoorPressure = state.dataEnvrn->OutBaroPress;
   11952           0 :             CompAmbTemp = OutdoorDryBulb;
   11953             :         }
   11954     3802533 :     } else if (state.dataDXCoils->DXCoil(DXCoilNum).IsSecondaryDXCoilInZone) {
   11955           0 :         auto &secZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(state.dataDXCoils->DXCoil(DXCoilNum).SecZonePtr);
   11956           0 :         OutdoorDryBulb = secZoneHB.ZT;
   11957           0 :         OutdoorHumRat = secZoneHB.ZoneAirHumRat;
   11958           0 :         OutdoorWetBulb = state.dataDXCoils->DXCoil(DXCoilNum).EvapInletWetBulb;
   11959           0 :         OutdoorPressure = state.dataEnvrn->OutBaroPress;
   11960           0 :         CompAmbTemp = OutdoorDryBulb;
   11961             :     } else {
   11962     3802533 :         OutdoorDryBulb = state.dataEnvrn->OutDryBulbTemp;
   11963     3802533 :         OutdoorHumRat = state.dataEnvrn->OutHumRat;
   11964     3802533 :         OutdoorPressure = state.dataEnvrn->OutBaroPress;
   11965     3802533 :         OutdoorWetBulb = state.dataEnvrn->OutWetBulbTemp;
   11966     3802533 :         CompAmbTemp = OutdoorDryBulb;
   11967             :     }
   11968             : 
   11969     4153909 :     AirMassFlow = state.dataDXCoils->DXCoil(DXCoilNum).InletAirMassFlowRate;
   11970     4153909 :     AirMassFlowRatio = state.dataDXCoils->DXCoil(DXCoilNum).InletAirMassFlowRateMax / state.dataDXCoils->DXCoil(DXCoilNum).RatedAirMassFlowRate(Mode);
   11971     4153909 :     state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction = 0.0;
   11972     4153909 :     InletAirDryBulbTemp = state.dataDXCoils->DXCoil(DXCoilNum).InletAirTemp;
   11973     4153909 :     InletAirEnthalpy = state.dataDXCoils->DXCoil(DXCoilNum).InletAirEnthalpy;
   11974     4153909 :     InletAirHumRat = state.dataDXCoils->DXCoil(DXCoilNum).InletAirHumRat;
   11975     4153909 :     AirMassFlowRatio2 = 1.0; // DXCoil(DXCoilNum)%RatedAirMassFlowRate2 / DXCoil(DXCoilNum)%RatedAirMassFlowRate(Mode)
   11976             :     //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   11977             :     // InletAirPressure = DXCoil(DXCoilNum)%InletAirPressure
   11978             :     // InletAirWetBulbC = PsyTwbFnTdbWPb(InletAirDryBulbTemp,InletAirHumRat,InletAirPressure)
   11979     4153909 :     InletAirWetBulbC = PsyTwbFnTdbWPb(state, InletAirDryBulbTemp, InletAirHumRat, OutdoorPressure);
   11980     4153909 :     if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(Mode) == DataHeatBalance::RefrigCondenserType::Air) {
   11981     4129464 :         CondInletTemp = OutdoorDryBulb; // Outdoor dry-bulb temp
   11982       24445 :     } else if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(Mode) == DataHeatBalance::RefrigCondenserType::Evap) {
   11983             :         // Outdoor wet-bulb temp from DataEnvironment + (1.0-EvapCondEffectiveness) * (drybulb - wetbulb)
   11984       24445 :         CondInletTemp = OutdoorWetBulb + (OutdoorDryBulb - OutdoorWetBulb) * (1.0 - state.dataDXCoils->DXCoil(DXCoilNum).EvapCondEffect(Mode));
   11985       24445 :         CondInletHumRat = PsyWFnTdbTwbPb(state, CondInletTemp, OutdoorWetBulb, OutdoorPressure);
   11986             :     }
   11987             : 
   11988    12105163 :     if ((AirMassFlow > 0.0 && CompAmbTemp >= state.dataDXCoils->DXCoil(DXCoilNum).MinOATCompressor) &&
   11989    11214612 :         ((GetCurrentScheduleValue(state, state.dataDXCoils->DXCoil(DXCoilNum).SchedPtr) > 0.0) || (LocalForceOn)) &&
   11990     1756511 :         (SpeedRatio > 0.0 || CycRatio > 0.0)) {
   11991             : 
   11992     3069783 :         RhoAir = PsyRhoAirFnPbTdbW(state, OutdoorPressure, OutdoorDryBulb, OutdoorHumRat);
   11993     3069783 :         if (SpeedRatio > 0.0) {
   11994             :             // Adjust high speed coil bypass factor for actual maximum air flow rate.
   11995     2207089 :             RatedCBFHS = state.dataDXCoils->DXCoil(DXCoilNum).RatedCBF(Mode);
   11996     4414178 :             CBFHS = AdjustCBF(RatedCBFHS,
   11997     2207089 :                               state.dataDXCoils->DXCoil(DXCoilNum).RatedAirMassFlowRate(Mode),
   11998     2207089 :                               state.dataDXCoils->DXCoil(DXCoilNum).InletAirMassFlowRateMax);
   11999             :             // get high speed total capacity and SHR at current conditions
   12000    11035445 :             CalcTotCapSHR(state,
   12001             :                           InletAirDryBulbTemp,
   12002             :                           InletAirHumRat,
   12003             :                           InletAirEnthalpy,
   12004             :                           InletAirWetBulbC,
   12005             :                           AirMassFlowRatio,
   12006     2207089 :                           state.dataDXCoils->DXCoil(DXCoilNum).InletAirMassFlowRateMax,
   12007     2207089 :                           state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode),
   12008             :                           CBFHS,
   12009     2207089 :                           state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(Mode),
   12010     2207089 :                           state.dataDXCoils->DXCoil(DXCoilNum).CCapFFlow(Mode),
   12011             :                           TotCapHS,
   12012             :                           SHRHS,
   12013             :                           CondInletTemp,
   12014             :                           OutdoorPressure,
   12015     2207089 :                           state.dataDXCoils->DXCoil(DXCoilNum).capModFacTotal);
   12016             :             //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   12017             :             //                       CondInletTemp, Node(DXCoil(DXCoilNum)%AirInNode)%Press)
   12018             :             // get the high speed SHR from user specified SHR modifier curves
   12019     2207089 :             if (state.dataDXCoils->DXCoil(DXCoilNum).UserSHRCurveExists) {
   12020       10986 :                 SHRHS = CalcSHRUserDefinedCurves(state,
   12021             :                                                  InletAirDryBulbTemp,
   12022             :                                                  InletAirWetBulbC,
   12023             :                                                  AirMassFlowRatio,
   12024        3662 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).SHRFTemp(Mode),
   12025        3662 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).SHRFFlow(Mode),
   12026        3662 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).RatedSHR(Mode));
   12027             :             }
   12028             :             // get low speed total capacity and SHR at current conditions
   12029    13242534 :             CalcTotCapSHR(state,
   12030             :                           InletAirDryBulbTemp,
   12031             :                           InletAirHumRat,
   12032             :                           InletAirEnthalpy,
   12033             :                           InletAirWetBulbC,
   12034             :                           1.0,
   12035     2207089 :                           state.dataDXCoils->DXCoil(DXCoilNum).RatedAirMassFlowRate2,
   12036     2207089 :                           state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap2,
   12037     2207089 :                           state.dataDXCoils->DXCoil(DXCoilNum).RatedCBF2,
   12038     2207089 :                           state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp2,
   12039     2207089 :                           state.dataDXCoils->DXCoil(DXCoilNum).CCapFFlow(Mode),
   12040             :                           TotCapLS,
   12041             :                           SHRLS,
   12042             :                           CondInletTemp,
   12043             :                           OutdoorPressure,
   12044     2207089 :                           state.dataDXCoils->DXCoil(DXCoilNum).capModFacTotal);
   12045             :             //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   12046             :             //                       Node(DXCoil(DXCoilNum)%AirInNode)%Press)
   12047             :             // get the low speed SHR from user specified SHR modifier curves
   12048     2207089 :             if (state.dataDXCoils->DXCoil(DXCoilNum).UserSHRCurveExists) {
   12049       10986 :                 SHRLS = CalcSHRUserDefinedCurves(state,
   12050             :                                                  InletAirDryBulbTemp,
   12051             :                                                  InletAirWetBulbC,
   12052             :                                                  AirMassFlowRatio2,
   12053        3662 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).SHRFTemp2,
   12054        3662 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).SHRFFlow2,
   12055        3662 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).RatedSHR2);
   12056             :             }
   12057             :             // get high speed EIR at current conditions
   12058     2207089 :             EIRTempModFacHS = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).EIRFTemp(Mode), InletAirWetBulbC, CondInletTemp);
   12059     2207089 :             EIRFlowModFacHS = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).EIRFFlow(Mode), AirMassFlowRatio);
   12060     2207089 :             EIRHS = state.dataDXCoils->DXCoil(DXCoilNum).RatedEIR(Mode) * EIRFlowModFacHS * EIRTempModFacHS;
   12061             :             // get low speed EIR at current conditions
   12062             :             //    EIRTempModFacLS = CurveValue(state, DXCoil(DXCoilNum)%EIRFTemp(Mode),InletAirWetBulbC,CondInletTemp)
   12063             :             //    CR7307 changed EIRTempModFacLS calculation to that shown below.
   12064     2207089 :             EIRTempModFacLS = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).EIRFTemp2, InletAirWetBulbC, CondInletTemp);
   12065     2207089 :             EIRLS = state.dataDXCoils->DXCoil(DXCoilNum).RatedEIR2 * EIRTempModFacLS;
   12066             : 
   12067             :             // get current total capacity, SHR, EIR
   12068     2207089 :             if (SpeedRatio >= 1.0) {
   12069      705890 :                 TotCap = TotCapHS;
   12070      705890 :                 SHR = SHRHS;
   12071      705890 :                 EIR = EIRHS;
   12072      705890 :                 CBFNom = CBFHS;
   12073      705890 :                 AirMassFlowNom = state.dataDXCoils->DXCoil(DXCoilNum).InletAirMassFlowRateMax;
   12074      705890 :                 CondAirMassFlow = RhoAir * state.dataDXCoils->DXCoil(DXCoilNum).EvapCondAirFlow(Mode);
   12075      705890 :                 EvapCondPumpElecPower = state.dataDXCoils->DXCoil(DXCoilNum).EvapCondPumpElecNomPower(Mode);
   12076             :             } else {
   12077     1501199 :                 TotCap = SpeedRatio * TotCapHS + (1.0 - SpeedRatio) * TotCapLS;
   12078     1501199 :                 EIR = SpeedRatio * EIRHS + (1.0 - SpeedRatio) * EIRLS;
   12079     1501199 :                 CBFNom = SpeedRatio * CBFHS + (1.0 - SpeedRatio) * state.dataDXCoils->DXCoil(DXCoilNum).RatedCBF2;
   12080     3002398 :                 AirMassFlowNom = SpeedRatio * state.dataDXCoils->DXCoil(DXCoilNum).InletAirMassFlowRateMax +
   12081     1501199 :                                  (1.0 - SpeedRatio) * state.dataDXCoils->DXCoil(DXCoilNum).RatedAirMassFlowRate2;
   12082     3002398 :                 CondAirMassFlow = RhoAir * (SpeedRatio * state.dataDXCoils->DXCoil(DXCoilNum).EvapCondAirFlow(Mode) +
   12083     1501199 :                                             (1.0 - SpeedRatio) * state.dataDXCoils->DXCoil(DXCoilNum).EvapCondAirFlow2);
   12084     3002398 :                 EvapCondPumpElecPower = SpeedRatio * state.dataDXCoils->DXCoil(DXCoilNum).EvapCondPumpElecNomPower(Mode) +
   12085     1501199 :                                         (1.0 - SpeedRatio) * state.dataDXCoils->DXCoil(DXCoilNum).EvapCondPumpElecNomPower2;
   12086             :             }
   12087     2207089 :             hDelta = TotCap / AirMassFlow;
   12088     2207089 :             if (state.dataDXCoils->DXCoil(DXCoilNum).UserSHRCurveExists) {
   12089        3662 :                 if (SpeedRatio >= 1.0) {
   12090        2939 :                     SHR = SHRHS;
   12091             :                 } else {
   12092         723 :                     SHR = min(SpeedRatio * SHRHS + (1.0 - SpeedRatio) * SHRLS, 1.0);
   12093             :                 }
   12094        3662 :                 OutletAirEnthalpy = InletAirEnthalpy - hDelta;
   12095        3662 :                 if (SHR < 1.0) {
   12096        3662 :                     hTinwout = InletAirEnthalpy - (1.0 - SHR) * hDelta;
   12097        3662 :                     OutletAirHumRat = PsyWFnTdbH(state, InletAirDryBulbTemp, hTinwout);
   12098        3662 :                     if (OutletAirHumRat <= 0.0) {
   12099           0 :                         OutletAirHumRat = min(DryCoilOutletHumRatioMin, InletAirHumRat);
   12100             :                     }
   12101             :                 } else {
   12102           0 :                     SHR = 1.0;
   12103           0 :                     OutletAirHumRat = InletAirHumRat;
   12104             :                 }
   12105        3662 :                 OutletAirDryBulbTemp = PsyTdbFnHW(OutletAirEnthalpy, OutletAirHumRat);
   12106        3662 :                 OutletAirDryBulbTempSat = PsyTdpFnWPb(state, OutletAirHumRat, OutdoorPressure, RoutineNameHighSpeedOutlet);
   12107        3662 :                 if (OutletAirDryBulbTempSat > OutletAirDryBulbTemp) {
   12108        3635 :                     OutletAirDryBulbTemp = OutletAirDryBulbTempSat;
   12109        3635 :                     OutletAirHumRat = PsyWFnTdbH(state, OutletAirDryBulbTemp, OutletAirEnthalpy, RoutineNameHighSpeedOutlet);
   12110             :                 }
   12111             : 
   12112             :             } else {
   12113             :                 // Adjust CBF for off-nominal flow
   12114     2203427 :                 CBF = AdjustCBF(CBFNom, AirMassFlowNom, AirMassFlow);
   12115             :                 // Calculate new apparatus dew point conditions
   12116     2203427 :                 hADP = InletAirEnthalpy - hDelta / (1.0 - CBF);
   12117     2203427 :                 tADP = PsyTsatFnHPb(state, hADP, OutdoorPressure);
   12118             :                 //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   12119             :                 //    tADP = PsyTsatFnHPb(hADP,InletAirPressure)
   12120     2203427 :                 wADP = PsyWFnTdbH(state, tADP, hADP);
   12121     2203427 :                 hTinwADP = PsyHFnTdbW(InletAirDryBulbTemp, wADP);
   12122             :                 // get corresponding SHR
   12123     2203427 :                 if ((InletAirEnthalpy - hADP) > 1.e-10) {
   12124     2203427 :                     SHR = min((hTinwADP - hADP) / (InletAirEnthalpy - hADP), 1.0);
   12125             :                 } else {
   12126           0 :                     SHR = 1.0;
   12127             :                 }
   12128             : 
   12129             :                 // cr8918    SHR = MIN((hTinwADP-hADP)/(InletAirEnthalpy-hADP),1.0d0)
   12130     2203427 :                 OutletAirEnthalpy = InletAirEnthalpy - hDelta;
   12131             :                 // get outlet conditions
   12132     2203427 :                 hTinwout = InletAirEnthalpy - (1.0 - SHR) * hDelta;
   12133     2203427 :                 OutletAirHumRat = PsyWFnTdbH(state, InletAirDryBulbTemp, hTinwout);
   12134             : 
   12135     2203427 :                 OutletAirDryBulbTemp = PsyTdbFnHW(OutletAirEnthalpy, OutletAirHumRat);
   12136     2203427 :                 OutletAirDryBulbTempSat = PsyTsatFnHPb(state, OutletAirEnthalpy, OutdoorPressure);
   12137     2203427 :                 if (OutletAirDryBulbTemp < OutletAirDryBulbTempSat) { // Limit to saturated conditions at OutletAirEnthalpy
   12138      382139 :                     OutletAirDryBulbTemp = OutletAirDryBulbTempSat;
   12139      382139 :                     OutletAirHumRat = PsyWFnTdbH(state, OutletAirDryBulbTemp, OutletAirEnthalpy);
   12140             :                 }
   12141             :             }
   12142             :             // Coil total/sensible/latent cooling rates and electrical power
   12143     6621267 :             CalcComponentSensibleLatentOutput(AirMassFlow,
   12144             :                                               InletAirDryBulbTemp,
   12145             :                                               InletAirHumRat,
   12146             :                                               OutletAirDryBulbTemp,
   12147             :                                               OutletAirHumRat,
   12148     2207089 :                                               state.dataDXCoils->DXCoil(DXCoilNum).SensCoolingEnergyRate,
   12149     2207089 :                                               state.dataDXCoils->DXCoil(DXCoilNum).LatCoolingEnergyRate,
   12150     2207089 :                                               state.dataDXCoils->DXCoil(DXCoilNum).TotalCoolingEnergyRate);
   12151     2207089 :             state.dataDXCoils->DXCoil(DXCoilNum).ElecCoolingPower = TotCap * EIR;
   12152             :             //   Calculation for heat reclaim needs to be corrected to use compressor power (not including condenser fan power)
   12153     2207089 :             state.dataHeatBal->HeatReclaimDXCoil(DXCoilNum).AvailCapacity =
   12154     2207089 :                 state.dataDXCoils->DXCoil(DXCoilNum).TotalCoolingEnergyRate + state.dataDXCoils->DXCoil(DXCoilNum).ElecCoolingPower;
   12155     2207089 :             state.dataDXCoils->DXCoil(DXCoilNum).PartLoadRatio = 1.0;
   12156     2207089 :             state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction = 1.0;
   12157             : 
   12158     2207089 :             state.dataDXCoils->DXCoil(DXCoilNum).OutletAirEnthalpy = OutletAirEnthalpy;
   12159     2207089 :             state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat = OutletAirHumRat;
   12160     2207089 :             state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp = OutletAirDryBulbTemp;
   12161             : 
   12162      862694 :         } else if (CycRatio > 0.0) {
   12163             : 
   12164      862694 :             if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(Mode) == DataHeatBalance::RefrigCondenserType::Evap) {
   12165             :                 // Outdoor wet-bulb temp from DataEnvironment + (1.0-EvapCondEffectiveness) * (drybulb - wetbulb)
   12166        6319 :                 CondInletTemp = OutdoorWetBulb + (OutdoorDryBulb - OutdoorWetBulb) * (1.0 - state.dataDXCoils->DXCoil(DXCoilNum).EvapCondEffect2);
   12167        6319 :                 CondInletHumRat = PsyWFnTdbTwbPb(state, CondInletTemp, OutdoorWetBulb, OutdoorPressure);
   12168             :             }
   12169             : 
   12170             :             // Adjust low speed coil bypass factor for actual flow rate.
   12171             :             // CBF = AdjustCBF(DXCoil(DXCoilNum)%RatedCBF2,DXCoil(DXCoilNum)%RatedAirMassFlowRate2,AirMassFlow)
   12172             :             // get low speed total capacity and SHR at current conditions
   12173     5176164 :             CalcTotCapSHR(state,
   12174             :                           InletAirDryBulbTemp,
   12175             :                           InletAirHumRat,
   12176             :                           InletAirEnthalpy,
   12177             :                           InletAirWetBulbC,
   12178             :                           1.0,
   12179      862694 :                           state.dataDXCoils->DXCoil(DXCoilNum).RatedAirMassFlowRate2,
   12180      862694 :                           state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap2,
   12181      862694 :                           state.dataDXCoils->DXCoil(DXCoilNum).RatedCBF2,
   12182      862694 :                           state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp2,
   12183      862694 :                           state.dataDXCoils->DXCoil(DXCoilNum).CCapFFlow(Mode),
   12184             :                           TotCapLS,
   12185             :                           SHRLS,
   12186             :                           CondInletTemp,
   12187             :                           OutdoorPressure,
   12188      862694 :                           state.dataDXCoils->DXCoil(DXCoilNum).capModFacTotal);
   12189             :             // get the low speed SHR from user specified SHR modifier curves
   12190      862694 :             if (state.dataDXCoils->DXCoil(DXCoilNum).UserSHRCurveExists) {
   12191        5658 :                 SHRLS = CalcSHRUserDefinedCurves(state,
   12192             :                                                  InletAirDryBulbTemp,
   12193             :                                                  InletAirWetBulbC,
   12194             :                                                  1.0,
   12195        1886 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).SHRFTemp2,
   12196        1886 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).SHRFFlow2,
   12197        1886 :                                                  state.dataDXCoils->DXCoil(DXCoilNum).RatedSHR2);
   12198             :             }
   12199             :             //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   12200             :             //                       Node(DXCoil(DXCoilNum)%AirInNode)%Press)
   12201      862694 :             hDelta = TotCapLS / AirMassFlow;
   12202      862694 :             if (state.dataDXCoils->DXCoil(DXCoilNum).UserSHRCurveExists) {
   12203        1886 :                 SHR = SHRLS;
   12204        1886 :                 LSOutletAirEnthalpy = InletAirEnthalpy - hDelta;
   12205        1886 :                 if (SHR < 1.0) {
   12206        1886 :                     hTinwout = InletAirEnthalpy - (1.0 - SHR) * hDelta;
   12207        1886 :                     LSOutletAirHumRat = PsyWFnTdbH(state, InletAirDryBulbTemp, hTinwout);
   12208        1886 :                     if (LSOutletAirHumRat <= 0.0) {
   12209           0 :                         LSOutletAirHumRat = min(DryCoilOutletHumRatioMin, InletAirHumRat);
   12210             :                     }
   12211             :                 } else {
   12212           0 :                     SHR = 1.0;
   12213           0 :                     LSOutletAirHumRat = InletAirHumRat;
   12214             :                 }
   12215        1886 :                 LSOutletAirDryBulbTemp = PsyTdbFnHW(LSOutletAirEnthalpy, LSOutletAirHumRat);
   12216        1886 :                 OutletAirDryBulbTempSat = PsyTdpFnWPb(state, LSOutletAirHumRat, OutdoorPressure, RoutineNameLowSpeedOutlet);
   12217        1886 :                 if (OutletAirDryBulbTempSat > LSOutletAirDryBulbTemp) {
   12218           1 :                     LSOutletAirDryBulbTemp = OutletAirDryBulbTempSat;
   12219           1 :                     LSOutletAirHumRat = PsyWFnTdbH(state, LSOutletAirDryBulbTemp, LSOutletAirEnthalpy, RoutineNameLowSpeedOutlet);
   12220             :                 }
   12221             : 
   12222             :             } else {
   12223             :                 // Adjust CBF for off-nominal flow
   12224     1721616 :                 CBF = AdjustCBF(
   12225     1721616 :                     state.dataDXCoils->DXCoil(DXCoilNum).RatedCBF2, state.dataDXCoils->DXCoil(DXCoilNum).RatedAirMassFlowRate2, AirMassFlow);
   12226             :                 // Calculate new apparatus dew point conditions
   12227      860808 :                 hADP = InletAirEnthalpy - hDelta / (1.0 - CBF);
   12228      860808 :                 tADP = PsyTsatFnHPb(state, hADP, OutdoorPressure, RoutineNameNewDewPointConditions);
   12229             :                 //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   12230             :                 //    tADP = PsyTsatFnHPb(hADP,InletAirPressure)
   12231      860808 :                 wADP = PsyWFnTdbH(state, tADP, hADP, RoutineNameNewDewPointConditions);
   12232      860808 :                 hTinwADP = PsyHFnTdbW(InletAirDryBulbTemp, wADP);
   12233             :                 // get corresponding SHR
   12234      860808 :                 if ((InletAirEnthalpy - hADP) > 1.e-10) {
   12235      860808 :                     SHR = min((hTinwADP - hADP) / (InletAirEnthalpy - hADP), 1.0);
   12236             :                 } else {
   12237           0 :                     SHR = 1.0;
   12238             :                 }
   12239             :                 // cr8918    SHR = MIN((hTinwADP-hADP)/(InletAirEnthalpy-hADP),1.0d0)
   12240             :                 // get low speed outlet conditions
   12241      860808 :                 LSOutletAirEnthalpy = InletAirEnthalpy - hDelta;
   12242      860808 :                 hTinwout = InletAirEnthalpy - (1.0 - SHR) * hDelta;
   12243      860808 :                 LSOutletAirHumRat = PsyWFnTdbH(state, InletAirDryBulbTemp, hTinwout);
   12244      860808 :                 LSOutletAirDryBulbTemp = PsyTdbFnHW(LSOutletAirEnthalpy, LSOutletAirHumRat);
   12245      860808 :                 OutletAirDryBulbTempSat = PsyTsatFnHPb(state, LSOutletAirEnthalpy, OutdoorPressure, RoutineNameLowSpeedOutlet);
   12246      860808 :                 if (LSOutletAirDryBulbTemp < OutletAirDryBulbTempSat) { // Limit to saturated conditions at OutletAirEnthalpy
   12247       83000 :                     LSOutletAirDryBulbTemp = OutletAirDryBulbTempSat;
   12248       83000 :                     LSOutletAirHumRat = PsyWFnTdbH(state, LSOutletAirDryBulbTemp, LSOutletAirEnthalpy, RoutineNameLowSpeedOutlet);
   12249             :                 }
   12250             :             }
   12251             :             // outlet conditions are average of inlet and low speed weighted by CycRatio
   12252      862694 :             OutletAirEnthalpy = CycRatio * LSOutletAirEnthalpy + (1.0 - CycRatio) * InletAirEnthalpy;
   12253      862694 :             OutletAirHumRat = CycRatio * LSOutletAirHumRat + (1.0 - CycRatio) * InletAirHumRat;
   12254      862694 :             OutletAirDryBulbTemp = PsyTdbFnHW(OutletAirEnthalpy, OutletAirHumRat);
   12255             :             // get low speed EIR at current conditions
   12256             :             //    EIRTempModFacLS = CurveValue(state, DXCoil(DXCoilNum)%EIRFTemp(Mode),InletAirWetBulbC,CondInletTemp)
   12257             :             //    CR7307 changed EIRTempModFacLS calculation to that shown below.
   12258      862694 :             EIRTempModFacLS = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).EIRFTemp2, InletAirWetBulbC, CondInletTemp);
   12259      862694 :             EIRLS = state.dataDXCoils->DXCoil(DXCoilNum).RatedEIR2 * EIRTempModFacLS;
   12260             :             // get the part load factor that will account for cycling losses
   12261      862694 :             PLF = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(Mode), CycRatio);
   12262      862694 :             if (PLF < 0.7) {
   12263           0 :                 PLF = 0.7;
   12264             :             }
   12265             :             // calculate the run time fraction
   12266      862694 :             state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction = CycRatio / PLF;
   12267      862694 :             state.dataDXCoils->DXCoil(DXCoilNum).PartLoadRatio = CycRatio;
   12268      862694 :             if (state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction > 1.0) {
   12269           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction = 1.0; // Reset coil runtime fraction to 1.0
   12270             :             }
   12271             :             // get the eletrical power consumption
   12272      862694 :             state.dataDXCoils->DXCoil(DXCoilNum).ElecCoolingPower =
   12273      862694 :                 TotCapLS * EIRLS * state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction;
   12274             : 
   12275             :             // Coil total/sensible/latent cooling rates and electrical power
   12276     2588082 :             CalcComponentSensibleLatentOutput(AirMassFlow,
   12277             :                                               InletAirDryBulbTemp,
   12278             :                                               InletAirHumRat,
   12279             :                                               OutletAirDryBulbTemp,
   12280             :                                               OutletAirHumRat,
   12281      862694 :                                               state.dataDXCoils->DXCoil(DXCoilNum).SensCoolingEnergyRate,
   12282      862694 :                                               state.dataDXCoils->DXCoil(DXCoilNum).LatCoolingEnergyRate,
   12283      862694 :                                               state.dataDXCoils->DXCoil(DXCoilNum).TotalCoolingEnergyRate);
   12284      862694 :             state.dataHeatBal->HeatReclaimDXCoil(DXCoilNum).AvailCapacity =
   12285      862694 :                 state.dataDXCoils->DXCoil(DXCoilNum).TotalCoolingEnergyRate + state.dataDXCoils->DXCoil(DXCoilNum).ElecCoolingPower;
   12286      862694 :             state.dataDXCoils->DXCoil(DXCoilNum).OutletAirEnthalpy = OutletAirEnthalpy;
   12287      862694 :             state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat = OutletAirHumRat;
   12288      862694 :             state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp = OutletAirDryBulbTemp;
   12289      862694 :             CondAirMassFlow =
   12290      862694 :                 RhoAir * state.dataDXCoils->DXCoil(DXCoilNum).EvapCondAirFlow2 * state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction;
   12291      862694 :             EvapCondPumpElecPower =
   12292      862694 :                 state.dataDXCoils->DXCoil(DXCoilNum).EvapCondPumpElecNomPower2 * state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction;
   12293             :         }
   12294             : 
   12295     3069783 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(Mode) == DataHeatBalance::RefrigCondenserType::Evap) {
   12296             :             //******************
   12297             :             //             WATER CONSUMPTION IN m3 OF WATER FOR DIRECT
   12298             :             //             H2O [m3/s] = Delta W[kgWater/kgDryAir]*Mass Flow Air[kgDryAir/s]
   12299             :             //                                /RhoWater [kgWater/m3]
   12300             :             //******************
   12301       19877 :             RhoWater = RhoH2O(OutdoorDryBulb);
   12302       19877 :             state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterConsumpRate = (CondInletHumRat - OutdoorHumRat) * CondAirMassFlow / RhoWater;
   12303       19877 :             state.dataDXCoils->DXCoil(DXCoilNum).EvapCondPumpElecPower = EvapCondPumpElecPower;
   12304             :             // set water system demand request (if needed)
   12305       19877 :             if (state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterSupplyMode == EvapWaterSupply::FromTank) {
   12306             : 
   12307           0 :                 state.dataWaterData->WaterStorage(state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterSupTankID)
   12308           0 :                     .VdotRequestDemand(state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterTankDemandARRID) =
   12309           0 :                     state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterConsumpRate;
   12310             :             }
   12311             : 
   12312             :             // Calculate basin heater power
   12313       79508 :             CalcBasinHeaterPower(state,
   12314       19877 :                                  state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterPowerFTempDiff,
   12315       19877 :                                  state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterSchedulePtr,
   12316       19877 :                                  state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterSetPointTemp,
   12317       19877 :                                  state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterPower);
   12318       19877 :             state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterPower *= (1.0 - state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction);
   12319             :         }
   12320             : 
   12321             :     } else {
   12322             : 
   12323             :         // DX coil is off; just pass through conditions
   12324     1084126 :         state.dataDXCoils->DXCoil(DXCoilNum).OutletAirEnthalpy = state.dataDXCoils->DXCoil(DXCoilNum).InletAirEnthalpy;
   12325     1084126 :         state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat = state.dataDXCoils->DXCoil(DXCoilNum).InletAirHumRat;
   12326     1084126 :         state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp = state.dataDXCoils->DXCoil(DXCoilNum).InletAirTemp;
   12327             : 
   12328     1084126 :         state.dataDXCoils->DXCoil(DXCoilNum).ElecCoolingPower = 0.0;
   12329     1084126 :         state.dataDXCoils->DXCoil(DXCoilNum).TotalCoolingEnergyRate = 0.0;
   12330     1084126 :         state.dataDXCoils->DXCoil(DXCoilNum).SensCoolingEnergyRate = 0.0;
   12331     1084126 :         state.dataDXCoils->DXCoil(DXCoilNum).LatCoolingEnergyRate = 0.0;
   12332     1084126 :         state.dataDXCoils->DXCoil(DXCoilNum).EvapCondPumpElecPower = 0.0;
   12333     1084126 :         state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterConsumpRate = 0.0;
   12334             : 
   12335             :         // Calculate basin heater power
   12336     1084126 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(Mode) == DataHeatBalance::RefrigCondenserType::Evap) {
   12337       18272 :             CalcBasinHeaterPower(state,
   12338        4568 :                                  state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterPowerFTempDiff,
   12339        4568 :                                  state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterSchedulePtr,
   12340        4568 :                                  state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterSetPointTemp,
   12341        4568 :                                  state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterPower);
   12342             :         }
   12343             :     }
   12344             : 
   12345     4153909 :     state.dataDXCoils->DXCoilOutletTemp(DXCoilNum) = state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp;
   12346     4153909 :     state.dataDXCoils->DXCoilOutletHumRat(DXCoilNum) = state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat;
   12347     4153909 :     state.dataDXCoils->DXCoil(DXCoilNum).CondInletTemp = CondInletTemp; // Save condenser inlet temp in the data structure
   12348             : 
   12349             :     // set outlet node conditions
   12350     4153909 :     int airOutletNode = state.dataDXCoils->DXCoil(DXCoilNum).AirOutNode;
   12351     4153909 :     state.dataLoopNodes->Node(airOutletNode).Temp = state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp;
   12352     4153909 :     state.dataLoopNodes->Node(airOutletNode).HumRat = state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat;
   12353             : 
   12354             :     // calc secondary coil if specified
   12355     4153909 :     if (state.dataDXCoils->DXCoil(DXCoilNum).IsSecondaryDXCoilInZone) {
   12356           0 :         CalcSecondaryDXCoils(state, DXCoilNum);
   12357             :     }
   12358     4153909 : }
   12359             : 
   12360      131261 : void CalcBasinHeaterPowerForMultiModeDXCoil(EnergyPlusData &state,
   12361             :                                             int const DXCoilNum,  // Index of coil being simulated
   12362             :                                             int const DehumidMode // Dehumidification mode (0=normal, 1=enhanced)
   12363             : )
   12364             : {
   12365             : 
   12366             :     // SUBROUTINE INFORMATION:
   12367             :     //       AUTHOR         Chandan Sharma, FSEC
   12368             :     //       DATE WRITTEN   May 2010
   12369             : 
   12370             :     // PURPOSE OF THIS SUBROUTINE:
   12371             :     // To calculate the basin heater power for multi mode DX cooling coil
   12372             : 
   12373             :     // METHODOLOGY EMPLOYED:
   12374             :     // The methodology employed is as follows:
   12375             :     // 1) If the number of capacity stages is equal to 1 and the CondenserType for stage 1
   12376             :     //    is EvapCooled, then the basin heater power is calculated for (1-runtimefractionstage1) of DX coil
   12377             :     // 2) If the number of capacity stages is greater than 1, then
   12378             :     //    a) If the CondenserType for stage 1 is EvapCooled, then the basin heater power is calculated for
   12379             :     //       (1-runtimefractionofstage1) of DX coil
   12380             :     //    b) Elseif the CondenserType for stage 2 is EvapCooled, then the basin heater power is calculated for
   12381             :     //       (1-runtimefractionofstage2) of DX coil
   12382             : 
   12383             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   12384             :     int PerfMode; // Performance mode for MultiMode DX coil; Always 1 for other coil types
   12385             :     // 1-2=normal mode: 1=stage 1 only, 2=stage 1&2
   12386             :     // 3-4=enhanced dehumidification mode: 3=stage 1 only, 4=stage 1&2
   12387             : 
   12388      131261 :     if (state.dataDXCoils->DXCoil(DXCoilNum).NumCapacityStages == 1) {
   12389       11412 :         state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterPower *= (1.0 - state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction);
   12390             :     } else {
   12391      119849 :         PerfMode = DehumidMode * 2 + 1;
   12392      119849 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(PerfMode) == DataHeatBalance::RefrigCondenserType::Evap) {
   12393           0 :             state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterPower *= (1.0 - state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction);
   12394      119849 :         } else if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(PerfMode + 1) == DataHeatBalance::RefrigCondenserType::Evap) {
   12395           0 :             CalcBasinHeaterPower(state,
   12396           0 :                                  state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterPowerFTempDiff,
   12397           0 :                                  state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterSchedulePtr,
   12398           0 :                                  state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterSetPointTemp,
   12399           0 :                                  state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterPower);
   12400           0 :             state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterPower *= (1.0 - state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilStg2RuntimeFrac);
   12401             :         }
   12402             :     }
   12403      131261 : }
   12404             : 
   12405    53814841 : Real64 AdjustCBF(Real64 const CBFNom,             // nominal coil bypass factor
   12406             :                  Real64 const AirMassFlowRateNom, // nominal air mass flow rate [kg/s]
   12407             :                  Real64 const AirMassFlowRate     // actual air mass flow rate [kg/s]
   12408             : )
   12409             : {
   12410             : 
   12411             :     // FUNCTION INFORMATION:
   12412             :     //       AUTHOR         Fred Buhl using Don Shirey's code
   12413             :     //       DATE WRITTEN   September 2002
   12414             : 
   12415             :     // PURPOSE OF THIS FUNCTION:
   12416             :     //    Adjust coil bypass factor for actual air flow rate.
   12417             : 
   12418             :     // METHODOLOGY EMPLOYED:
   12419             :     // Uses relation CBF = exp(-NTU) whereNTU = A0/(m*cp). Relationship models the cooling coil
   12420             :     // as a heat exchanger with Cmin/Cmax = 0.
   12421             : 
   12422             :     // Return value
   12423             :     Real64 CBFAdj; // the result - the adjusted coil bypass factor
   12424             : 
   12425             :     // FUNCTION LOCAL VARIABLE DECLARATIONS:
   12426             :     Real64 A0;    // intermediate variable
   12427             :     Real64 ADiff; // intermediate variable
   12428             : 
   12429    53814841 :     if (CBFNom > 0.0) {
   12430    53814841 :         A0 = -std::log(CBFNom) * AirMassFlowRateNom;
   12431             :     } else {
   12432           0 :         A0 = 0.0;
   12433             :     }
   12434    53814841 :     ADiff = -A0 / AirMassFlowRate;
   12435    53814841 :     if (ADiff >= DataPrecisionGlobals::EXP_LowerLimit) {
   12436    53788356 :         CBFAdj = std::exp(ADiff);
   12437             :     } else {
   12438       26485 :         CBFAdj = 1.0e-6;
   12439             :     }
   12440             : 
   12441    53814841 :     return CBFAdj;
   12442             : }
   12443             : 
   12444       25618 : Real64 CalcCBF(EnergyPlusData &state,
   12445             :                std::string const &UnitType,
   12446             :                std::string const &UnitName,
   12447             :                Real64 const InletAirTemp,   // inlet air temperature [C]
   12448             :                Real64 const InletAirHumRat, // inlet air humidity ratio [kg water / kg dry air]
   12449             :                Real64 const TotCap,         // total cooling  capacity [Watts]
   12450             :                Real64 const AirVolFlowRate, // the air volume flow rate at the given capacity [m3/s]
   12451             :                Real64 const SHR,            // sensible heat ratio at the given capacity and flow rate
   12452             :                bool const PrintFlag         // flag used to print warnings if desired
   12453             : )
   12454             : {
   12455             : 
   12456             :     // FUNCTION INFORMATION:
   12457             :     //       AUTHOR         Fred Buhl using Don Shirey's code
   12458             :     //       DATE WRITTEN   September 2002
   12459             : 
   12460             :     // PURPOSE OF THIS FUNCTION:
   12461             :     // Calculate the coil bypass factor for a coil given the total capacity at the entering conditions,
   12462             :     // air mass flow rate at the entering conditions, and the sensible heat ratio (SHR) at the
   12463             :     // entering conditions. Standard barometric pressure is used for this model parameter.
   12464             : 
   12465             :     // METHODOLOGY EMPLOYED:
   12466             :     // calculate SlopeRated (deltahumrat/deltaT) using rated unit information provided by
   12467             :     // user. Then hunt along saturation curve of psychrometric chart until the slope of the line
   12468             :     // between the saturation point and rated inlet air humidity ratio and T is the same as SlopeRated.
   12469             :     // When the slopes are equal, then we have located the apparatus dewpoint of the coil at rated
   12470             :     // conditions. From this information, coil bypass factor is calculated.
   12471             : 
   12472             :     // Using/Aliasing
   12473             : 
   12474             :     // Return value
   12475       25618 :     Real64 CBF(0.0); // the result - the coil bypass factor
   12476             : 
   12477             :     // FUNCTION PARAMETER DEFINITIONS:
   12478             :     static constexpr std::string_view RoutineName("CalcCBF");
   12479       25618 :     constexpr Real64 SmallDifferenceTest(0.00000001);
   12480             : 
   12481             :     // FUNCTION LOCAL VARIABLE DECLARATIONS:
   12482             :     Real64 InletAirEnthalpy;                // Enthalpy of inlet air to evaporator at given conditions [J/kg]
   12483       25618 :     Real64 DeltaH(0.0);                     // Enthalpy drop across evaporator at given conditions [J/kg]
   12484       25618 :     Real64 DeltaT(0.0);                     // Temperature drop across evaporator at given conditions [C]
   12485       25618 :     Real64 DeltaHumRat(0.0);                // Humidity ratio drop across evaporator at given conditions [kg/kg]
   12486       25618 :     Real64 OutletAirTemp(InletAirTemp);     // Outlet dry-bulb temperature from evaporator at given conditions [C]
   12487       25618 :     Real64 OutletAirTempSat(InletAirTemp);  // Saturation dry-bulb temperature from evaporator at outlet air enthalpy [C]
   12488             :     Real64 OutletAirEnthalpy;               // Enthalpy of outlet air at given conditions [J/kg]
   12489       25618 :     Real64 OutletAirHumRat(InletAirHumRat); // Outlet humidity ratio from evaporator at given conditions [kg/kg]
   12490             :     Real64 OutletAirRH;                     // relative humidity of the outlet air
   12491             :     Real64 Error;                           // Error term used in given coil bypass factor (CBF) calculations
   12492             :     Real64 ErrorLast;                       // Error term, from previous iteration
   12493             :     int Iter;                               // Iteration loop counter in CBF calculations
   12494       25618 :     int IterMax(50);                        // Maximum number of iterations in CBF calculations
   12495             :     Real64 ADPTemp;                         // Apparatus dewpoint temperature used in CBF calculations [C]
   12496             :     Real64 ADPHumRat;                       // Apparatus dewpoint humidity used in CBF calculations [kg/kg]
   12497             :     Real64 ADPEnthalpy;                     // Air enthalpy at apparatus dew point [J/kg]
   12498             :     Real64 DeltaADPTemp;                    // Change in Apparatus Dew Point used in CBF calculations [C]
   12499       25618 :     Real64 SlopeAtConds(0.0);               // Slope (DeltaHumRat/DeltaT) at given conditions
   12500       25618 :     Real64 Slope(0.0);                      // Calculated Slope used while hunting for Tadp
   12501             :     Real64 Tolerance;                       // Convergence tolerance for CBF calculations
   12502             :     Real64 HTinHumRatOut;                   // Air enthalpy at inlet air temp and outlet air humidity ratio [J/kg]
   12503             :     Real64 AirMassFlowRate;                 // the standard air mass flow rate at the given capacity [kg/s]
   12504             :     Real64 adjustedSHR;                     // SHR calculated using adjusted outlet air properties []
   12505       25618 :     bool CBFErrors(false);                  // Set to true if errors in CBF calculation, fatal at end of routine
   12506             : 
   12507       25618 :     auto &DXCT = state.dataHVACGlobal->DXCT;
   12508             : 
   12509       25618 :     AirMassFlowRate = AirVolFlowRate * PsyRhoAirFnPbTdbW(state, DataEnvironment::StdPressureSeaLevel, InletAirTemp, InletAirHumRat, RoutineName);
   12510       25618 :     DeltaH = TotCap / AirMassFlowRate;
   12511       25618 :     InletAirEnthalpy = PsyHFnTdbW(InletAirTemp, InletAirHumRat);
   12512       25618 :     HTinHumRatOut = InletAirEnthalpy - (1.0 - SHR) * DeltaH;
   12513       25618 :     OutletAirHumRat = PsyWFnTdbH(state, InletAirTemp, HTinHumRatOut);
   12514       25618 :     DeltaHumRat = InletAirHumRat - OutletAirHumRat;
   12515       25618 :     OutletAirEnthalpy = InletAirEnthalpy - DeltaH;
   12516       25618 :     OutletAirTemp = PsyTdbFnHW(OutletAirEnthalpy, OutletAirHumRat);
   12517             :     //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   12518             :     //  Pressure will have to be pass into this subroutine to fix this one
   12519       25618 :     OutletAirRH = PsyRhFnTdbWPb(state, OutletAirTemp, OutletAirHumRat, DataEnvironment::StdPressureSeaLevel, RoutineName);
   12520       25618 :     if (OutletAirRH >= 1.0 && PrintFlag) {
   12521           5 :         ShowWarningError(state, "For object = " + UnitType + ", name = \"" + UnitName + "\"");
   12522           5 :         ShowContinueError(state, "Calculated outlet air relative humidity greater than 1. The combination of");
   12523           5 :         ShowContinueError(state, "rated air volume flow rate, total cooling capacity and sensible heat ratio yields coil exiting");
   12524           5 :         ShowContinueError(state, "air conditions above the saturation curve. Possible fixes are to reduce the rated total cooling");
   12525           5 :         ShowContinueError(state, "capacity, increase the rated air volume flow rate, or reduce the rated sensible heat ratio for this coil.");
   12526           5 :         ShowContinueError(state, "If autosizing, it is recommended that all three of these values be autosized.");
   12527           5 :         ShowContinueError(state, "...Inputs used for calculating cooling coil bypass factor.");
   12528           5 :         ShowContinueError(state, format("...Inlet Air Temperature     = {:.2R} C", InletAirTemp));
   12529           5 :         ShowContinueError(state, format("...Outlet Air Temperature    = {:.2R} C", OutletAirTemp));
   12530           5 :         ShowContinueError(state, format("...Inlet Air Humidity Ratio  = {:.6R} kgWater/kgDryAir", InletAirHumRat));
   12531           5 :         ShowContinueError(state, format("...Outlet Air Humidity Ratio = {:.6R} kgWater/kgDryAir", OutletAirHumRat));
   12532           5 :         ShowContinueError(state, format("...Total Cooling Capacity used in calculation = {:.2R} W", TotCap));
   12533           5 :         ShowContinueError(state, format("...Air Mass Flow Rate used in calculation     = {:.6R} kg/s", AirMassFlowRate));
   12534           5 :         ShowContinueError(state, format("...Air Volume Flow Rate used in calculation   = {:.6R} m3/s", AirVolFlowRate));
   12535           5 :         if (TotCap > 0.0) {
   12536          10 :             if (((state.dataHVACGlobal->MinRatedVolFlowPerRatedTotCap(DXCT) - AirVolFlowRate / TotCap) > SmallDifferenceTest) ||
   12537           5 :                 ((AirVolFlowRate / TotCap - state.dataHVACGlobal->MaxRatedVolFlowPerRatedTotCap(DXCT)) > SmallDifferenceTest)) {
   12538           0 :                 ShowContinueError(state,
   12539           0 :                                   format("...Air Volume Flow Rate per Watt of Rated Cooling Capacity is also out of bounds at = {:.7R} m3/s/W",
   12540           0 :                                          AirVolFlowRate / TotCap));
   12541             :             }
   12542             :         }
   12543           5 :         ShowContinueErrorTimeStamp(state, "");
   12544           5 :         OutletAirTempSat = PsyTsatFnHPb(state, OutletAirEnthalpy, DataEnvironment::StdPressureSeaLevel, RoutineName);
   12545           5 :         if (OutletAirTemp < OutletAirTempSat) { // Limit to saturated conditions at OutletAirEnthalpy
   12546           5 :             OutletAirTemp = OutletAirTempSat + 0.005;
   12547           5 :             OutletAirHumRat = PsyWFnTdbH(state, OutletAirTemp, OutletAirEnthalpy, RoutineName);
   12548           5 :             DeltaHumRat = InletAirHumRat - OutletAirHumRat;
   12549           5 :             HTinHumRatOut = PsyHFnTdbW(InletAirTemp, OutletAirHumRat);
   12550           5 :             adjustedSHR = (HTinHumRatOut - OutletAirEnthalpy) / DeltaH;
   12551           5 :             ShowContinueError(state, "CalcCBF: SHR adjusted to achieve valid outlet air properties and the simulation continues.");
   12552           5 :             ShowContinueError(state, format("CalcCBF: initial SHR = {:.5R}", SHR));
   12553           5 :             ShowContinueError(state, format("CalcCBF: adjusted SHR = {:.5R}", adjustedSHR));
   12554             :         }
   12555             :     }
   12556       25618 :     DeltaT = InletAirTemp - OutletAirTemp;
   12557       25618 :     if (DeltaT <= 0.0) {
   12558           0 :         ShowSevereError(state, "For object = " + UnitType + ", name = \"" + UnitName + "\"");
   12559           0 :         ShowContinueError(state, "Calculated coil delta T is less than or equal to 0. The combination of");
   12560           0 :         ShowContinueError(state, "rated air volume flow rate, total cooling capacity and sensible heat ratio yields coil exiting");
   12561           0 :         ShowContinueError(state, "air conditions that are not reasonable. Possible fixes are to adjust the rated total cooling");
   12562           0 :         ShowContinueError(state, "capacity, rated air volume flow rate, or rated sensible heat ratio for this coil.");
   12563           0 :         ShowContinueError(state, "If autosizing, it is recommended that all three of these values be autosized.");
   12564           0 :         ShowContinueError(state, "...Inputs used for calculating cooling coil bypass factor.");
   12565           0 :         ShowContinueError(state, format("...Inlet Air Temperature     = {:.2R} C", InletAirTemp));
   12566           0 :         ShowContinueError(state, format("...Outlet Air Temperature    = {:.2R} C", OutletAirTemp));
   12567           0 :         ShowContinueError(state, format("...Inlet Air Humidity Ratio  = {:.6R} kgWater/kgDryAir", InletAirHumRat));
   12568           0 :         ShowContinueError(state, format("...Outlet Air Humidity Ratio = {:.6R} kgWater/kgDryAir", OutletAirHumRat));
   12569           0 :         ShowContinueError(state, format("...Total Cooling Capacity used in calculation = {:.2R} W", TotCap));
   12570           0 :         ShowContinueError(state, format("...Air Mass Flow Rate used in calculation     = {:.6R} kg/s", AirMassFlowRate));
   12571           0 :         ShowContinueError(state, format("...Air Volume Flow Rate used in calculation   = {:.6R} m3/s", AirVolFlowRate));
   12572           0 :         if (TotCap > 0.0) {
   12573           0 :             if (((state.dataHVACGlobal->MinRatedVolFlowPerRatedTotCap(DXCT) - AirVolFlowRate / TotCap) > SmallDifferenceTest) ||
   12574           0 :                 ((AirVolFlowRate / TotCap - state.dataHVACGlobal->MaxRatedVolFlowPerRatedTotCap(DXCT)) > SmallDifferenceTest)) {
   12575           0 :                 ShowContinueError(state,
   12576           0 :                                   format("...Air Volume Flow Rate per Watt of Rated Cooling Capacity is also out of bounds at = {:.7R} m3/s/W",
   12577           0 :                                          AirVolFlowRate / TotCap));
   12578             :             }
   12579             :         }
   12580           0 :         ShowContinueErrorTimeStamp(state, "");
   12581           0 :         ShowFatalError(state, "Check and revise the input data for this coil before rerunning the simulation.");
   12582             :     }
   12583             :     // Calculate slope at given conditions
   12584       25618 :     if (DeltaT > 0.0) SlopeAtConds = DeltaHumRat / DeltaT;
   12585             : 
   12586             :     //  IF (SlopeAtConds .le. .0000001d0 .or. OutletAirHumRat .le. 0.0d0) THEN
   12587       25618 :     if (SlopeAtConds < 0.0 || OutletAirHumRat <= 0.0) {
   12588             :         //   Invalid conditions, slope can't be less than zero (SHR > 1) or
   12589             :         //   outlet air humidity ratio can't be less than zero.
   12590           0 :         ShowSevereError(state, UnitType + " \"" + UnitName + "\"");
   12591           0 :         ShowContinueError(state, "...Invalid slope or outlet air condition when calculating cooling coil bypass factor.");
   12592           0 :         ShowContinueError(state, format("...Slope = {:.8R}", SlopeAtConds));
   12593           0 :         ShowContinueError(state, format("...Inlet Air Temperature     = {:.2R} C", InletAirTemp));
   12594           0 :         ShowContinueError(state, format("...Outlet Air Temperature    = {:.2R} C", OutletAirTemp));
   12595           0 :         ShowContinueError(state, format("...Inlet Air Humidity Ratio  = {:.6R} kgWater/kgDryAir", InletAirHumRat));
   12596           0 :         ShowContinueError(state, format("...Outlet Air Humidity Ratio = {:.6R} kgWater/kgDryAir", OutletAirHumRat));
   12597           0 :         ShowContinueError(state, format("...Total Cooling Capacity used in calculation = {:.2R} W", TotCap));
   12598           0 :         ShowContinueError(state, format("...Air Mass Flow Rate used in calculation     = {:.6R} kg/s", AirMassFlowRate));
   12599           0 :         ShowContinueError(state, format("...Air Volume Flow Rate used in calculation   = {:.6R} m3/s", AirVolFlowRate));
   12600           0 :         if (TotCap > 0.0) {
   12601           0 :             if (((state.dataHVACGlobal->MinRatedVolFlowPerRatedTotCap(DXCT) - AirVolFlowRate / TotCap) > SmallDifferenceTest) ||
   12602           0 :                 ((AirVolFlowRate / TotCap - state.dataHVACGlobal->MaxRatedVolFlowPerRatedTotCap(DXCT)) > SmallDifferenceTest)) {
   12603           0 :                 ShowContinueError(state,
   12604           0 :                                   format("...Air Volume Flow Rate per Watt of Rated Cooling Capacity is also out of bounds at = {:.7R} m3/s/W",
   12605           0 :                                          AirVolFlowRate / TotCap));
   12606             :             }
   12607             :         }
   12608           0 :         ShowContinueErrorTimeStamp(state, "");
   12609           0 :         CBFErrors = true;
   12610           0 :         CBF = 0.0; //? Added: Is this what should be returned
   12611             :     } else {
   12612             : 
   12613             :         //   First guess for Tadp is outlet air dew point
   12614             :         //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   12615             :         //  Pressure will have to be pass into this subroutine to fix this one
   12616       25618 :         ADPTemp = PsyTdpFnWPb(state, OutletAirHumRat, DataEnvironment::StdPressureSeaLevel);
   12617             : 
   12618       25618 :         Tolerance = 1.0; // initial conditions for iteration
   12619       25618 :         ErrorLast = 100.0;
   12620       25618 :         Iter = 0;
   12621       25618 :         DeltaADPTemp = 5.0;
   12622      667718 :         while ((Iter <= IterMax) && (Tolerance > 0.001)) {
   12623             :             //     Do for IterMax iterations or until the error gets below .1%
   12624      321050 :             if (Iter > 0) ADPTemp += DeltaADPTemp;
   12625      321050 :             ++Iter;
   12626             : 
   12627             :             //     Find new slope using guessed Tadp
   12628             : 
   12629             :             //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   12630             :             //  Pressure will have to be pass into this subroutine to fix this one
   12631      321050 :             ADPHumRat = min(OutletAirHumRat, PsyWFnTdpPb(state, ADPTemp, DataEnvironment::StdPressureSeaLevel));
   12632      321050 :             Slope = (InletAirHumRat - ADPHumRat) / max(0.001, (InletAirTemp - ADPTemp));
   12633             : 
   12634             :             //     check for convergence (slopes are equal to within error tolerance)
   12635             : 
   12636      321050 :             Error = (Slope - SlopeAtConds) / SlopeAtConds;
   12637      321050 :             if ((Error > 0.0) && (ErrorLast < 0.0)) {
   12638      103587 :                 DeltaADPTemp = -DeltaADPTemp / 2.0;
   12639      217463 :             } else if ((Error < 0.0) && (ErrorLast > 0.0)) {
   12640      117333 :                 DeltaADPTemp = -DeltaADPTemp / 2.0;
   12641      100130 :             } else if (std::abs(Error) > std::abs(ErrorLast)) {
   12642         553 :                 DeltaADPTemp = -DeltaADPTemp / 2.0;
   12643             :             }
   12644      321050 :             ErrorLast = Error;
   12645             : 
   12646      321050 :             Tolerance = std::abs(Error);
   12647             :         }
   12648             : 
   12649             :         //   Calculate Bypass Factor from Enthalpies
   12650             : 
   12651       25618 :         InletAirEnthalpy = PsyHFnTdbW(InletAirTemp, InletAirHumRat);
   12652       25618 :         OutletAirEnthalpy = PsyHFnTdbW(OutletAirTemp, OutletAirHumRat);
   12653       25618 :         ADPEnthalpy = PsyHFnTdbW(ADPTemp, ADPHumRat);
   12654       25618 :         CBF = min(1.0, (OutletAirEnthalpy - ADPEnthalpy) / (InletAirEnthalpy - ADPEnthalpy));
   12655       25618 :         if (Iter > IterMax && PrintFlag) {
   12656           0 :             ShowSevereError(state, UnitType + " \"" + UnitName + "\" -- coil bypass factor calculation did not converge after max iterations.");
   12657           0 :             ShowContinueError(state, format("The RatedSHR of [{:.3R}], entered by the user or autosized (see *.eio file),", SHR));
   12658           0 :             ShowContinueError(state, "may be causing this. The line defined by the coil rated inlet air conditions");
   12659           0 :             ShowContinueError(state, "(26.7C drybulb and 19.4C wetbulb) and the RatedSHR (i.e., slope of the line) must intersect");
   12660           0 :             ShowContinueError(state, "the saturation curve of the psychrometric chart. If the RatedSHR is too low, then this");
   12661           0 :             ShowContinueError(state, "intersection may not occur and the coil bypass factor calculation will not converge.");
   12662           0 :             ShowContinueError(state, "If autosizing the SHR, recheck the design supply air humidity ratio and design supply air");
   12663           0 :             ShowContinueError(state, "temperature values in the Sizing:System and Sizing:Zone objects. In general, the temperatures");
   12664           0 :             ShowContinueError(state, "and humidity ratios specified in these two objects should be the same for each system");
   12665           0 :             ShowContinueError(state, "and the zones that it serves.");
   12666           0 :             ShowContinueErrorTimeStamp(state, "");
   12667           0 :             CBFErrors = true; // Didn't converge within MaxIter iterations
   12668             :         }
   12669       25618 :         if (CBF < 0.0 && PrintFlag) {
   12670           0 :             ShowSevereError(state, UnitType + " \"" + UnitName + "\" -- negative coil bypass factor calculated.");
   12671           0 :             ShowContinueErrorTimeStamp(state, "");
   12672           0 :             CBFErrors = true; // Negative CBF not valid
   12673             :         }
   12674             :     }
   12675             : 
   12676             :     // Show fatal error for specific coil that caused a CBF error
   12677       25618 :     if (CBFErrors) {
   12678           0 :         ShowFatalError(state, UnitType + " \"" + UnitName + "\" Errors found in calculating coil bypass factors");
   12679             :     }
   12680             : 
   12681       25618 :     return CBF;
   12682             : }
   12683             : 
   12684         822 : Real64 ValidateADP(EnergyPlusData &state,
   12685             :                    std::string const &UnitType,      // component name
   12686             :                    std::string const &UnitName,      // component type
   12687             :                    Real64 const RatedInletAirTemp,   // coil inlet air temperature [C]
   12688             :                    Real64 const RatedInletAirHumRat, // coil inlet air humidity ratio [kg/kg]
   12689             :                    Real64 const TotCap,              // coil total capacity [W]
   12690             :                    Real64 const AirVolFlowRate,      // coil air volume flow rate [m3/s]
   12691             :                    Real64 const InitialSHR,          // coil sensible heat ratio []
   12692             :                    std::string const &CallingRoutine // function name calling this routine
   12693             : )
   12694             : {
   12695             : 
   12696             :     // FUNCTION INFORMATION:
   12697             :     //    AUTHOR         Richard Raustad, FSEC
   12698             :     //    DATE WRITTEN   December 2015
   12699             : 
   12700             :     // PURPOSE OF THIS FUNCTION:
   12701             :     //    Validates that the calcualted bypass factor represents valid SHR based on total capacity and air mass flow rate.
   12702             : 
   12703             :     // METHODOLOGY EMPLOYED:
   12704             :     //    With model parameters autosized by the user, the SHR is selected based on an empirical model.
   12705             :     //    This can sometimes lead to an SHR that does not cross the saturation curve, or one that crosses excessively where
   12706             :     //    the coil outlet air conditions exceed the saturation curve (i.e., RH > 1).
   12707             :     //    This function checks to see if the ADP based on coil delta T and calculated bypass factor and the ADP based
   12708             :     //    on coil delta W and calculated bypass factor land on the saturation curve at the same place within a tolerance.
   12709             :     //    The result is passed back to the sizing routine as the new value for SHR.
   12710             :     //    If the SHR is not autosized, this routine will still adjust the design SHR appropriately, however, the hard-sized SHR will not
   12711             :     //    change.
   12712             : 
   12713             :     // Return value
   12714         822 :     Real64 SHR(0.0); // the result - the adjusted design SHR
   12715             : 
   12716             :     // FUNCTION LOCAL VARIABLE DECLARATIONS:
   12717         822 :     Real64 CBF_calculated(0.0);    // coil bypass factor based on TotCap, AirFlow, SHR, and BaroPress
   12718         822 :     Real64 InletAirEnthalpy(0.0);  // Enthalpy of inlet air to evaporator at given conditions [J/kg]
   12719         822 :     Real64 DeltaH(0.0);            // Enthalpy drop across evaporator at given conditions [J/kg]
   12720         822 :     Real64 HTinHumRatOut(0.0);     // Air enthalpy at inlet air temp and outlet air humidity ratio [J/kg]
   12721         822 :     Real64 DeltaHumRat(0.0);       // Humidity ratio drop across evaporator at given conditions [kg/kg]
   12722         822 :     Real64 OutletAirTemp(0.0);     // Outlet dry-bulb temperature from evaporator at given conditions [C]
   12723         822 :     Real64 OutletAirEnthalpy(0.0); // Enthalpy of outlet air at given conditions [J/kg]
   12724         822 :     Real64 OutletAirHumRat(0.0);   // Outlet humidity ratio from evaporator at given conditions [kg/kg]
   12725         822 :     Real64 OutletAirRH(0.0);       // relative humidity of the outlet air
   12726         822 :     Real64 CalcADPTemp(0.0);       // actual ADP temperature based on bypass factor [C]
   12727         822 :     Real64 CalcADPHumRat(0.0);     // actual ADP humidity ratio based on bypass factor [kg/kg]
   12728         822 :     Real64 CalcADPTempFnHR(0.0);   // actual ADP temperature as a function of humidity ratio based on bypass factor [C]
   12729         822 :     Real64 ADPerror(0.0);          // difference between ADP function of temperature and humidity ratio [deltaC]
   12730         822 :     Real64 AirMassFlow(0.0);       // air mass flow rate based on standard barometric pressure [kg/s]
   12731         822 :     bool bStillValidating(true);   // while loop flag
   12732         822 :     bool bNoReporting(false);      // don't report specific warnings in calcCBF while iterating on result
   12733         822 :     bool bReversePerturb(false);   // identifies when SHR is being lowered based on outlet air RH
   12734             : 
   12735         822 :     SHR = InitialSHR;
   12736         822 :     AirMassFlow =
   12737         822 :         AirVolFlowRate * PsyRhoAirFnPbTdbW(state, DataEnvironment::StdPressureSeaLevel, RatedInletAirTemp, RatedInletAirHumRat, CallingRoutine);
   12738       49196 :     while (bStillValidating) {
   12739       24187 :         CBF_calculated = max(0.0, CalcCBF(state, UnitType, UnitName, RatedInletAirTemp, RatedInletAirHumRat, TotCap, AirMassFlow, SHR, bNoReporting));
   12740       24187 :         DeltaH = TotCap / AirMassFlow;
   12741       24187 :         InletAirEnthalpy = PsyHFnTdbW(RatedInletAirTemp, RatedInletAirHumRat);
   12742       24187 :         HTinHumRatOut = InletAirEnthalpy - (1.0 - SHR) * DeltaH;
   12743       24187 :         OutletAirHumRat = PsyWFnTdbH(state, RatedInletAirTemp, HTinHumRatOut, CallingRoutine);
   12744       24187 :         DeltaHumRat = RatedInletAirHumRat - OutletAirHumRat;
   12745       24187 :         OutletAirEnthalpy = InletAirEnthalpy - DeltaH;
   12746       24187 :         OutletAirTemp = PsyTdbFnHW(OutletAirEnthalpy, OutletAirHumRat);
   12747       24187 :         OutletAirRH = PsyRhFnTdbWPb(state, OutletAirTemp, OutletAirHumRat, DataEnvironment::StdPressureSeaLevel, CallingRoutine);
   12748       24187 :         if (CBF_calculated < 1) {
   12749       24187 :             CalcADPTemp = RatedInletAirTemp - ((RatedInletAirTemp - OutletAirTemp) / (1 - CBF_calculated));
   12750       24187 :             CalcADPHumRat = RatedInletAirHumRat - ((DeltaHumRat) / (1 - CBF_calculated));
   12751       24187 :             CalcADPTempFnHR = PsyTdpFnWPb(state, CalcADPHumRat, DataEnvironment::StdPressureSeaLevel, CallingRoutine);
   12752       24187 :             ADPerror = CalcADPTemp - CalcADPTempFnHR;
   12753             :         } else {
   12754           0 :             ADPerror = 0; // might be able to check for RH >= 1 and reduce SHR, need defect file for that since can't create one
   12755             :         }
   12756             : 
   12757       24187 :         if (std::abs(ADPerror) > 0.012) {
   12758       24187 :             if (OutletAirRH >= 1.0) { // if RH > 1, reduce SHR until it crosses the saturation curve
   12759         592 :                 SHR -= 0.001;
   12760         592 :                 bReversePerturb = true;
   12761         592 :                 if (SHR < 0.5)
   12762           0 :                     bStillValidating = false; // have to stop somewhere, this is lower than the lower limit of SHR empirical model (see
   12763             :                                               // Autosizing/CoolingSHRSizing)
   12764             :             } else {
   12765       23595 :                 if (bReversePerturb) {
   12766         588 :                     bStillValidating = false; // stop iterating once SHR causes ADP to cross back under saturation curve, take what you get
   12767             :                 } else {
   12768       23007 :                     SHR += 0.001; // increase SHR slowly until ADP temps are resolved
   12769             :                 }
   12770             :             }
   12771       24187 :             if (SHR > 0.8)
   12772         234 :                 bStillValidating = false; // have to stop somewhere, this is the upper limit of SHR empirical model (see Autosizing/CoolingSHRSizing)
   12773             :         } else {
   12774           0 :             bStillValidating = false; // ADP temps are close enough. Normal input files hit this on first pass
   12775             :         }
   12776             :     }
   12777             : 
   12778         822 :     return SHR;
   12779             : }
   12780             : 
   12781     8498106 : Real64 CalcEffectiveSHR(EnergyPlusData &state,
   12782             :                         int const DXCoilNum,              // Index number for cooling coil
   12783             :                         Real64 const SHRss,               // Steady-state sensible heat ratio
   12784             :                         Real64 const RTF,                 // Compressor run-time fraction
   12785             :                         Real64 const QLatRated,           // Rated latent capacity
   12786             :                         Real64 const QLatActual,          // Actual latent capacity
   12787             :                         Real64 const EnteringDB,          // Entering air dry-bulb temperature
   12788             :                         Real64 const EnteringWB,          // Entering air wet-bulb temperature
   12789             :                         Optional_int_const Mode,          // Performance mode for MultiMode DX coil; Always 1 for other coil types
   12790             :                         Optional<Real64 const> HeatingRTF // Used to recalculate Toff for cycling fan systems
   12791             : )
   12792             : {
   12793             : 
   12794             :     // FUNCTION INFORMATION:
   12795             :     //    AUTHOR         Richard Raustad, FSEC
   12796             :     //    DATE WRITTEN   September 2003
   12797             :     //                   Feb 2005 M. J. Witte, GARD Analytics, Inc.
   12798             :     //                    Add new coil type COIL:DX:MultiMode:CoolingEmpirical:
   12799             :     //                   Nov 2008 R. Raustad, FSEC
   12800             :     //                    Modified to allow latent degradation with cycling fan
   12801             : 
   12802             :     // PURPOSE OF THIS FUNCTION:
   12803             :     //    Adjust sensible heat ratio to account for degradation of DX coil latent
   12804             :     //    capacity at part-load (cycling) conditions.
   12805             : 
   12806             :     // METHODOLOGY EMPLOYED:
   12807             :     //    With model parameters entered by the user, the part-load latent performance
   12808             :     //    of a DX cooling coil is determined for a constant air flow system with
   12809             :     //    a cooling coil that cycles on/off. The model calculates the time
   12810             :     //    required for condensate to begin falling from the cooling coil.
   12811             :     //    Runtimes greater than this are integrated to a "part-load" latent
   12812             :     //    capacity which is used to determine the "part-load" sensible heat ratio.
   12813             :     //    See reference below for additional details (linear decay model, Eq. 8b).
   12814             :     // REFERENCES:
   12815             :     //   "A Model to Predict the Latent Capacity of Air Conditioners and
   12816             :     //    Heat Pumps at Part-Load Conditions with Constant Fan Operation"
   12817             :     //    1996 ASHRAE Transactions, Volume 102, Part 1, Pp. 266 - 274,
   12818             :     //    Hugh I. Henderson, Jr., P.E., Kannan Rengarajan, P.E.
   12819             : 
   12820             :     // Return value
   12821             :     Real64 SHReff; // Effective sensible heat ratio, includes degradation due to cycling effects
   12822             : 
   12823             :     // FUNCTION LOCAL VARIABLE DECLARATIONS:
   12824             :     Real64 Twet; // Nominal time for condensate to begin leaving the coil's condensate drain line
   12825             :     //   at the current operating conditions (sec)
   12826             :     Real64 Gamma; // Initial moisture evaporation rate divided by steady-state AC latent capacity
   12827             :     //   at the current operating conditions
   12828             :     Real64 Twet_Rated;  // Twet at rated conditions (coil air flow rate and air temperatures), sec
   12829             :     Real64 Gamma_Rated; // Gamma at rated conditions (coil air flow rate and air temperatures)
   12830             :     Real64 Twet_max;    // Maximum allowed value for Twet
   12831             :     Real64 Nmax;        // Maximum ON/OFF cycles per hour for the compressor (cycles/hr)
   12832             :     Real64 Tcl;         // Time constant for latent capacity to reach steady state after startup (sec)
   12833             :     Real64 Ton;         // Coil on time (sec)
   12834             :     Real64 Toff;        // Coil off time (sec)
   12835             :     Real64 Toffa;       // Actual coil off time (sec). Equations valid for Toff <= (2.0 * Twet/Gamma)
   12836             :     Real64 aa;          // Intermediate variable
   12837             :     Real64 To1;         // Intermediate variable (first guess at To). To = time to the start of moisture removal
   12838             :     Real64 To2;         // Intermediate variable (second guess at To). To = time to the start of moisture removal
   12839             :     Real64 Error;       // Error for iteration (DO) loop
   12840             :     Real64 LHRmult;     // Latent Heat Ratio (LHR) multiplier. The effective latent heat ratio LHR = (1-SHRss)*LHRmult
   12841             :     Real64 Ton_heating;
   12842             :     Real64 Toff_heating;
   12843             : 
   12844     8498106 :     if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num != CoilDX_MultiSpeedCooling) {
   12845     8216936 :         Twet_Rated = state.dataDXCoils->DXCoil(DXCoilNum).Twet_Rated(Mode);
   12846     8216936 :         Gamma_Rated = state.dataDXCoils->DXCoil(DXCoilNum).Gamma_Rated(Mode);
   12847     8216936 :         Nmax = state.dataDXCoils->DXCoil(DXCoilNum).MaxONOFFCyclesperHour(Mode);
   12848     8216936 :         Tcl = state.dataDXCoils->DXCoil(DXCoilNum).LatentCapacityTimeConstant(Mode);
   12849             :     } else {
   12850      281170 :         Twet_Rated = state.dataDXCoils->DXCoil(DXCoilNum).MSTwet_Rated(Mode);
   12851      281170 :         Gamma_Rated = state.dataDXCoils->DXCoil(DXCoilNum).MSGamma_Rated(Mode);
   12852      281170 :         Nmax = state.dataDXCoils->DXCoil(DXCoilNum).MSMaxONOFFCyclesperHour(Mode);
   12853      281170 :         Tcl = state.dataDXCoils->DXCoil(DXCoilNum).MSLatentCapacityTimeConstant(Mode);
   12854             :     }
   12855             : 
   12856             :     //  No moisture evaporation (latent degradation) occurs for runtime fraction of 1.0
   12857             :     //  All latent degradation model parameters cause divide by 0.0 if not greater than 0.0
   12858             :     //  Latent degradation model parameters initialize to 0.0 meaning no evaporation model used.
   12859     8498106 :     if (RTF >= 1.0 || Twet_Rated <= 0.0 || Gamma_Rated <= 0.0 || Nmax <= 0.0 || Tcl <= 0.0) {
   12860     7305045 :         SHReff = SHRss;
   12861     7305045 :         return SHReff;
   12862             :     }
   12863             : 
   12864     1193061 :     Twet_max = 9999.0; // high limit for Twet
   12865             : 
   12866             :     //  Calculate the model parameters at the actual operating conditions
   12867     1193061 :     Twet = min(Twet_Rated * QLatRated / (QLatActual + 1.e-10), Twet_max);
   12868     1193061 :     Gamma = Gamma_Rated * QLatRated * (EnteringDB - EnteringWB) / ((26.7 - 19.4) * QLatActual + 1.e-10);
   12869             : 
   12870             :     //  Calculate the compressor on and off times using a converntional thermostat curve
   12871     1193061 :     Ton = 3600.0 / (4.0 * Nmax * (1.0 - RTF)); // duration of cooling coil on-cycle (sec)
   12872     1193061 :     Toff = 3600.0 / (4.0 * Nmax * RTF);        // duration of cooling coil off-cycle (sec)
   12873             : 
   12874             :     //  Cap Toff to meet the equation restriction
   12875     1193061 :     if (Gamma > 0.0) {
   12876     1193061 :         Toffa = min(Toff, 2.0 * Twet / Gamma);
   12877             :     } else {
   12878           0 :         Toffa = Toff;
   12879             :     }
   12880             : 
   12881             :     //  Need to include the reheat coil operation to account for actual fan run time. E+ uses a
   12882             :     //  separate heating coil for heating and reheat (to separate the heating and reheat loads)
   12883             :     //  and real world applications would use a single heating coil for both purposes, the actual
   12884             :     //  fan operation is based on HeatingPLR + ReheatPLR. For cycling fan RH control, latent
   12885             :     //  degradation only occurs when a heating load exists, in this case the reheat load is
   12886             :     //  equal to and oposite in magnitude to the cooling coil sensible output but the reheat
   12887             :     //  coil is not always active. This additional fan run time has not been accounted for at this time.
   12888             :     //  Recalculate Toff for cycling fan systems when heating is active
   12889     1193061 :     if (present(HeatingRTF)) {
   12890           0 :         if (HeatingRTF < 1.0 && HeatingRTF > RTF) {
   12891           0 :             Ton_heating = 3600.0 / (4.0 * Nmax * (1.0 - HeatingRTF));
   12892           0 :             Toff_heating = 3600.0 / (4.0 * Nmax * HeatingRTF);
   12893             :             //    add additional heating coil operation during cooling coil off cycle (due to cycling rate difference of coils)
   12894           0 :             Ton_heating += max(0.0, min(Ton_heating, (Ton + Toffa) - (Ton_heating + Toff_heating)));
   12895           0 :             Toffa = min(Toffa, Ton_heating - Ton);
   12896             :         }
   12897             :     }
   12898             : 
   12899             :     //  Use sucessive substitution to solve for To
   12900     1193061 :     aa = (Gamma * Toffa) - (0.25 / Twet) * pow_2(Gamma) * pow_2(Toffa);
   12901     1193061 :     To1 = aa + Tcl;
   12902     1193061 :     Error = 1.0;
   12903     6801655 :     while (Error > 0.001) {
   12904     2804297 :         To2 = aa - Tcl * (std::exp(-To1 / Tcl) - 1.0);
   12905     2804297 :         Error = std::abs((To2 - To1) / To1);
   12906     2804297 :         To1 = To2;
   12907             :     }
   12908             : 
   12909             :     //  Adjust Sensible Heat Ratio (SHR) using Latent Heat Ratio (LHR) multiplier
   12910             :     //  Floating underflow errors occur when -Ton/Tcl is a large negative number.
   12911             :     //  Cap lower limit at -700 to avoid the underflow errors.
   12912     1193061 :     aa = std::exp(max(-700.0, -Ton / Tcl));
   12913             :     //  Calculate latent heat ratio multiplier
   12914     1193061 :     LHRmult = max(((Ton - To2) / (Ton + Tcl * (aa - 1.0))), 0.0);
   12915             : 
   12916             :     //  Calculate part-load or "effective" sensible heat ratio
   12917     1193061 :     SHReff = 1.0 - (1.0 - SHRss) * LHRmult;
   12918             : 
   12919     1193061 :     if (SHReff < SHRss) SHReff = SHRss; // Effective SHR can be less than the steady-state SHR
   12920     1193061 :     if (SHReff > 1.0) SHReff = 1.0;     // Effective sensible heat ratio can't be greater than 1.0
   12921             : 
   12922     1193061 :     return SHReff;
   12923             : }
   12924             : 
   12925     9212801 : void CalcTotCapSHR(EnergyPlusData &state,
   12926             :                    Real64 const InletDryBulb,     // inlet air dry bulb temperature [C]
   12927             :                    Real64 const InletHumRat,      // inlet air humidity ratio [kg water / kg dry air]
   12928             :                    Real64 const InletEnthalpy,    // inlet air specific enthalpy [J/kg]
   12929             :                    Real64 const InletWetBulb,     // inlet air wet bulb temperature [C]
   12930             :                    Real64 const AirMassFlowRatio, // Ratio of actual air mass flow to nominal air mass flow
   12931             :                    Real64 const AirMassFlow,      // actual mass flow for capacity and SHR calculation
   12932             :                    Real64 const TotCapNom,        // nominal total capacity [W]
   12933             :                    Real64 const CBF,              // coil bypass factor
   12934             :                    int const CCapFTemp,           // capacity modifier curve index, function of entering wetbulb
   12935             :                    int const CCapFFlow,           // capacity modifier curve, function of actual flow vs rated flow
   12936             :                    Real64 &TotCap,                // total capacity at the given conditions [W]
   12937             :                    Real64 &SHR,                   // sensible heat ratio at the given conditions
   12938             :                    Real64 const CondInletTemp,    // Condenser inlet temperature [C]
   12939             :                    Real64 const Pressure,         // air pressure [Pa]
   12940             :                    Real64 &TotCapModFac           // capacity modification factor, func of temp and func of flow
   12941             : )
   12942             : {
   12943             : 
   12944             :     // SUBROUTINE INFORMATION:
   12945             :     //       AUTHOR         Fred Buhl using Don Shirey's code
   12946             :     //       DATE WRITTEN   September 2002
   12947             : 
   12948             :     // PURPOSE OF THIS SUBROUTINE:
   12949             :     // Calculates total capacity and sensible heat ratio of a DX coil at the specified conditions
   12950             : 
   12951             :     // METHODOLOGY EMPLOYED:
   12952             :     // With the rated performance data entered by the user, the model employs some of the
   12953             :     // DOE-2.1E curve fits to adjust the capacity and SHR of the unit as a function
   12954             :     // of entering air temperatures and supply air flow rate (actual vs rated flow). The model
   12955             :     // does NOT employ the exact same methodology to calculate performance as DOE-2, although
   12956             :     // some of the DOE-2 curve fits are employed by this model.
   12957             : 
   12958             :     // The model checks for coil dryout conditions, and adjusts the calculated performance
   12959             :     // appropriately.
   12960             : 
   12961             :     // REFERENCES:
   12962             :     // ASHRAE HVAC 2 Toolkit page 4-81.
   12963             :     // Henderson, H.I. Jr., K. Rengarajan and D.B. Shirey, III. 1992.The impact of comfort
   12964             :     // control on air conditioner energy use in humid climates. ASHRAE Transactions 98(2):
   12965             :     // 104-113.
   12966             :     // Henderson, H.I. Jr., Danny Parker and Y.J. Huang. 2000.Improving DOE-2's RESYS routine:
   12967             :     // User Defined Functions to Provide More Accurate Part Load Energy Use and Humidity
   12968             :     // Predictions. Proceedings of ACEEE Conference.
   12969             : 
   12970             :     // Using/Aliasing
   12971             :     using Curve::CurveValue;
   12972             : 
   12973             :     // Locals
   12974             :     // SUBROUTINE ARGUMENT DEFINITIONS:
   12975             :     // and outside drybulb
   12976             : 
   12977             :     // SUBROUTINE PARAMETER DEFINITIONS:
   12978     9212801 :     constexpr int MaxIter(30);               // Maximum number of iterations for dry evaporator calculations
   12979     9212801 :     constexpr Real64 RF(0.4);                // Relaxation factor for dry evaporator iterations
   12980     9212801 :     constexpr Real64 Tolerance(0.01);        // Error tolerance for dry evaporator iterations
   12981     9212801 :     constexpr Real64 MinHumRatCalc(0.00001); // Error tolerance for dry evaporator iterations
   12982             : 
   12983             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   12984             :     Real64 InletWetBulbCalc; // calculated inlet wetbulb temperature used for finding dry coil point [C]
   12985             :     Real64 InletHumRatCalc;  // calculated inlet humidity ratio used for finding dry coil point [kg water / kg dry air]
   12986             :     Real64 TotCapTempModFac; // Total capacity modifier (function of entering wetbulb, outside drybulb)
   12987             :     Real64 TotCapFlowModFac; // Total capacity modifier (function of actual supply air flow vs nominal flow)
   12988             :     Real64 hDelta;           // Change in air enthalpy across the cooling coil [J/kg]
   12989             :     Real64 hADP;             // Apparatus dew point enthalpy [J/kg]
   12990             :     Real64 tADP;             // Apparatus dew point temperature [C]
   12991             :     Real64 wADP;             // Apparatus dew point humidity ratio [kg/kg]
   12992             :     Real64 hTinwADP;         // Enthalpy at inlet dry-bulb and wADP [J/kg]
   12993             :     Real64 SHRCalc;          // temporary calculated value of SHR
   12994             :     Real64 TotCapCalc;       // temporary calculated value of total capacity [W]
   12995             :     int Counter;             // Counter for dry evaporator iterations
   12996             :     Real64 werror;           // Deviation of humidity ratio in dry evaporator iteration loop
   12997             : 
   12998             :     //  MaxIter = 30
   12999             :     //  RF = 0.4d0
   13000     9212801 :     Counter = 0;
   13001             :     //  Tolerance = 0.01d0
   13002     9212801 :     werror = 0.0;
   13003             : 
   13004     9212801 :     InletWetBulbCalc = InletWetBulb;
   13005     9212801 :     InletHumRatCalc = InletHumRat;
   13006             : 
   13007     9212801 :     if (AirMassFlow <= 0.00001) {
   13008          61 :         TotCap = 0.0;
   13009          61 :         SHR = 0.0;
   13010          61 :         return;
   13011             :     }
   13012             : 
   13013             :     //  DO WHILE (ABS(werror) .gt. Tolerance .OR. Counter == 0)
   13014             :     //   Get capacity modifying factor (function of inlet wetbulb & outside drybulb) for off-rated conditions
   13015             :     while (true) {
   13016    19750444 :         TotCapTempModFac = CurveValue(state, CCapFTemp, InletWetBulbCalc, CondInletTemp);
   13017             :         //   Get capacity modifying factor (function of mass flow) for off-rated conditions
   13018    14481592 :         TotCapFlowModFac = CurveValue(state, CCapFFlow, AirMassFlowRatio);
   13019             :         //   Get total capacity
   13020    14481592 :         TotCapCalc = TotCapNom * TotCapFlowModFac * TotCapTempModFac;
   13021             : 
   13022             :         //   Calculate apparatus dew point conditions using TotCap and CBF
   13023    14481592 :         hDelta = TotCapCalc / AirMassFlow;
   13024    14481592 :         hADP = InletEnthalpy - hDelta / (1.0 - CBF);
   13025    14481592 :         tADP = PsyTsatFnHPb(state, hADP, Pressure);
   13026    14481592 :         wADP = PsyWFnTdbH(state, tADP, hADP);
   13027    14481592 :         hTinwADP = PsyHFnTdbW(InletDryBulb, wADP);
   13028    14481592 :         if ((InletEnthalpy - hADP) > 1.e-10) {
   13029    14481592 :             SHRCalc = min((hTinwADP - hADP) / (InletEnthalpy - hADP), 1.0);
   13030             :         } else {
   13031           0 :             SHRCalc = 1.0;
   13032             :         }
   13033             :         //   Check for dry evaporator conditions (win < wadp)
   13034    14481592 :         if (wADP > InletHumRatCalc || (Counter >= 1 && Counter < MaxIter)) {
   13035     6907893 :             if (InletHumRatCalc == 0.0) InletHumRatCalc = MinHumRatCalc;
   13036             :             //      InletHumRatCalc=MAX(InletHumRatCalc,MinHumRatCalc)  ! proposed.
   13037             : 
   13038     6907893 :             werror = (InletHumRatCalc - wADP) / InletHumRatCalc;
   13039             :             //     Increase InletHumRatCalc at constant inlet air temp to find coil dry-out point. Then use the
   13040             :             //     capacity at the dry-out point to determine exiting conditions from coil. This is required
   13041             :             //     since the TotCapTempModFac doesn't work properly with dry-coil conditions.
   13042     6907893 :             InletHumRatCalc = RF * wADP + (1.0 - RF) * InletHumRatCalc;
   13043     6907893 :             InletWetBulbCalc = PsyTwbFnTdbWPb(state, InletDryBulb, InletHumRatCalc, Pressure);
   13044     6907893 :             ++Counter;
   13045     6907893 :             if (std::abs(werror) > Tolerance) continue; // Recalculate with modified inlet conditions
   13046     1639041 :             break;                                      // conditions are satisfied
   13047             :         } else {
   13048             :             break; // conditions are satisfied
   13049             :         }
   13050             :     }
   13051             : 
   13052             :     // END DO
   13053             : 
   13054             :     //  Calculate full load output conditions
   13055     9212740 :     if (SHRCalc > 1.0 || Counter > 0) SHRCalc = 1.0;
   13056             : 
   13057     9212740 :     SHR = SHRCalc;
   13058     9212740 :     TotCap = TotCapCalc;
   13059     9212740 :     TotCapModFac = TotCapTempModFac * TotCapFlowModFac;
   13060             : }
   13061             : 
   13062     6761048 : void CalcMultiSpeedDXCoilCooling(EnergyPlusData &state,
   13063             :                                  int const DXCoilNum,     // the number of the DX heating coil to be simulated
   13064             :                                  Real64 const SpeedRatio, // = (CompressorSpeed - CompressorSpeedMin) / (CompressorSpeedMax - CompressorSpeedMin)
   13065             :                                  Real64 const CycRatio,   // cycling part load ratio
   13066             :                                  int const SpeedNum,      // Speed number
   13067             :                                  int const FanOpMode,     // Sets fan control to CycFanCycCoil or ContFanCycCoil
   13068             :                                  CompressorOperation const CompressorOp, // Compressor on/off; 1=on, 0=off
   13069             :                                  int const SingleMode                    // Single mode operation Yes/No; 1=Yes, 0=No
   13070             : )
   13071             : {
   13072             : 
   13073             :     // SUBROUTINE INFORMATION:
   13074             :     //       AUTHOR         Lixing Gu, FSEC
   13075             :     //       DATE WRITTEN   June 2007
   13076             :     //       MODIFIED       April 2010, Chandan sharma, FSEC, added basin heater
   13077             :     //       RE-ENGINEERED  Revised based on CalcMultiSpeedDXCoil
   13078             : 
   13079             :     // PURPOSE OF THIS SUBROUTINE:
   13080             :     // Calculates the air-side performance and electrical energy use of a direct-
   13081             :     // expansion, air-cooled cooling unit with a multispeed compressor.
   13082             : 
   13083             :     // METHODOLOGY EMPLOYED:
   13084             :     // Uses the same methodology as the single speed DX unit model (SUBROUTINE CalcDoe2DXCoil).
   13085             :     // In addition it assumes that the unit performance is obtained by interpolating between
   13086             :     // the performance at high speed and that at low speed. If the output needed is below
   13087             :     // that produced at low speed, the compressor cycles between off and low speed.
   13088             : 
   13089             :     // Using/Aliasing
   13090             :     using Curve::CurveValue;
   13091     6761048 :     auto &MSHPMassFlowRateHigh = state.dataHVACGlobal->MSHPMassFlowRateHigh;
   13092     6761048 :     auto &MSHPMassFlowRateLow = state.dataHVACGlobal->MSHPMassFlowRateLow;
   13093     6761048 :     auto &MSHPWasteHeat = state.dataHVACGlobal->MSHPWasteHeat;
   13094             : 
   13095             :     // Locals
   13096             :     // SUBROUTINE ARGUMENT DEFINITIONS:
   13097             :     // SpeedRatio varies between 1.0 (maximum speed) and 0.0 (minimum speed)
   13098             : 
   13099             :     // SUBROUTINE PARAMETER DEFINITIONS:
   13100             :     static constexpr std::string_view RoutineName("CalcMultiSpeedDXCoilCooling");
   13101             :     static constexpr std::string_view RoutineNameHighSpeedAlt("CalcMultiSpeedDXCoilCooling highspeed");
   13102             : 
   13103             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   13104             :     Real64 AirMassFlow;         // dry air mass flow rate through coil [kg/s]
   13105             :     Real64 InletAirWetBulbC;    // wetbulb temperature of inlet air [C]
   13106             :     Real64 InletAirDryBulbTemp; // inlet air dry bulb temperature [C]
   13107             :     Real64 InletAirEnthalpy;    // inlet air enthalpy [J/kg]
   13108             :     Real64 InletAirHumRat;      // inlet air humidity ratio [kg/kg]
   13109             :     //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   13110             :     // REAL(r64)   :: InletAirPressure    ! inlet air pressure [Pa]
   13111             :     Real64 OutletAirDryBulbTemp;    // outlet air dry bulb temperature [C]
   13112             :     Real64 OutletAirEnthalpy;       // outlet air enthalpy [J/kg]
   13113             :     Real64 OutletAirHumRat;         // outlet air humidity ratio [kg/kg]
   13114             :     Real64 OutletAirDryBulbTempSat; // outlet air dry bulb temp at saturation at the outlet enthalpy [C]
   13115             :     Real64 LSOutletAirDryBulbTemp;  // low speed outlet air dry bulb temperature [C]
   13116             :     Real64 LSOutletAirEnthalpy;     // low speed outlet air enthalpy [J/kg]
   13117             :     Real64 LSOutletAirHumRat;       // low speed outlet air humidity ratio [kg/kg]
   13118             :     Real64 HSOutletAirDryBulbTemp;  // hihg speed outlet air dry bulb temperature [C]
   13119             :     Real64 HSOutletAirEnthalpy;     // high speed outlet air enthalpy [J/kg]
   13120             :     Real64 HSOutletAirHumRat;       // high speed outlet air humidity ratio [kg/kg]
   13121             :     Real64 hDelta;                  // Change in air enthalpy across the cooling coil [J/kg]
   13122             :     Real64 hTinwout;                // Enthalpy at inlet dry-bulb and outlet humidity ratio [J/kg]
   13123             :     Real64 hADP;                    // Apparatus dew point enthalpy [J/kg]
   13124             :     Real64 tADP;                    // Apparatus dew point temperature [C]
   13125             :     Real64 wADP;                    // Apparatus dew point humidity ratio [kg/kg]
   13126             :     Real64 hTinwADP;                // Enthalpy at inlet dry-bulb and wADP [J/kg]
   13127             :     Real64 RatedCBFHS;              // coil bypass factor at rated conditions (high speed)
   13128             :     Real64 CBFHS;                   // coil bypass factor at max flow (high speed)
   13129             :     Real64 RatedCBFLS;              // coil bypass factor at rated conditions (low speed)
   13130             :     Real64 CBFLS;                   // coil bypass factor at max flow (low speed)
   13131             :     Real64 TotCapHS;                // total capacity at high speed [W]
   13132             :     Real64 SHRHS;                   // sensible heat ratio at high speed
   13133             :     Real64 TotCapLS;                // total capacity at low speed [W]
   13134             :     Real64 SHRLS;                   // sensible heat ratio at low speed
   13135             :     Real64 EIRTempModFacHS;         // EIR modifier (function of entering wetbulb, outside drybulb) (high speed)
   13136             :     Real64 EIRFlowModFacHS;         // EIR modifier (function of actual supply air flow vs rated flow) (high speed)
   13137             :     Real64 EIRHS;                   // EIR at off rated conditions (high speed)
   13138             :     Real64 EIRTempModFacLS;         // EIR modifier (function of entering wetbulb, outside drybulb) (low speed)
   13139             :     Real64 EIRFlowModFacLS;         // EIR modifier (function of actual supply air flow vs rated flow) (low speed)
   13140             :     Real64 EIRLS;                   // EIR at off rated conditions (low speed)
   13141             :     Real64 SHR;                     // sensible heat ratio at current speed
   13142             :     Real64 EIR;                     // EIR at current speed
   13143             :     Real64 CBF;                     // CBFNom adjusted for actual air mass flow rate
   13144             :     Real64 PLF;                     // Part load factor, accounts for thermal lag at compressor startup, used in
   13145             :     // power calculation
   13146             :     Real64 CondInletTemp; // Condenser inlet temperature (C). Outdoor dry-bulb temp for air-cooled condenser.
   13147             :     // Outdoor Wetbulb +(1 - effectiveness)*(outdoor drybulb - outdoor wetbulb) for evap condenser.
   13148             :     Real64 CondInletHumRat; // Condenser inlet humidity ratio (kg/kg). Zero for air-cooled condenser.
   13149             :     // For evap condenser, its the humidity ratio of the air leaving the evap cooling pads.
   13150             :     Real64 RhoAir;                // Density of air [kg/m3]
   13151             :     Real64 RhoWater;              // Density of water [kg/m3]
   13152             :     Real64 CondAirMassFlow;       // Condenser air mass flow rate [kg/s]
   13153             :     Real64 EvapCondPumpElecPower; // Evaporative condenser electric pump power [W]
   13154     6761048 :     constexpr int DXMode(1);      // Performance mode for MultiMode DX coil; Always 1 for other coil types
   13155             :     Real64 OutdoorDryBulb;        // Outdoor dry-bulb temperature at condenser (C)
   13156             :     Real64 OutdoorWetBulb;        // Outdoor wet-bulb temperature at condenser (C)
   13157             :     Real64 OutdoorHumRat;         // Outdoor humidity ratio at condenser (kg/kg)
   13158             :     Real64 OutdoorPressure;       // Outdoor barometric pressure at condenser (Pa)
   13159             :     int SpeedNumHS;               // High speed number
   13160             :     int SpeedNumLS;               // Low speed number
   13161             :     Real64 SHRUnadjusted;         // Temp SHR
   13162             :     Real64 QLatRated;             // Qlatent at rated conditions of indoor(TDB,TWB)=(26.7C,19.4C)
   13163             :     Real64 QLatActual;            // Qlatent at actual operating conditions
   13164             :     Real64 AirMassFlowRatioLS;    // airflow ratio at low speed
   13165             :     Real64 AirMassFlowRatioHS;    // airflow ratio at high speed
   13166             :     Real64 WasteHeatLS;           // Waste heat at low speed
   13167             :     Real64 WasteHeatHS;           // Waste heat at high speed
   13168             :     Real64 LSElecCoolingPower;    // low speed power [W]
   13169             :     Real64 HSElecCoolingPower;    // high speed power [W]
   13170             :     Real64 CrankcaseHeatingPower; // Power due to crank case heater
   13171             :     Real64 AirVolumeFlowRate;     // Air volume flow rate across the heating coil
   13172             :     Real64 VolFlowperRatedTotCap; // Air volume flow rate divided by rated total heating capacity
   13173             : 
   13174     6761048 :     auto &DXCT = state.dataHVACGlobal->DXCT;
   13175             : 
   13176     6761048 :     if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(DXMode) != 0) {
   13177     4674615 :         OutdoorPressure = state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(DXMode)).Press;
   13178             :         // If node is not connected to anything, pressure = default, use weather data
   13179     4674615 :         if (OutdoorPressure == state.dataLoopNodes->DefaultNodeValues.Press) {
   13180           0 :             OutdoorDryBulb = state.dataEnvrn->OutDryBulbTemp;
   13181           0 :             OutdoorHumRat = state.dataEnvrn->OutHumRat;
   13182           0 :             OutdoorPressure = state.dataEnvrn->OutBaroPress;
   13183           0 :             OutdoorWetBulb = state.dataEnvrn->OutWetBulbTemp;
   13184             :         } else {
   13185     4674615 :             OutdoorDryBulb = state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(DXMode)).Temp;
   13186     4674615 :             OutdoorHumRat = state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(DXMode)).HumRat;
   13187     4674615 :             OutdoorWetBulb = PsyTwbFnTdbWPb(state, OutdoorDryBulb, OutdoorHumRat, OutdoorPressure, RoutineName);
   13188             :         }
   13189     4674615 :         if (state.dataDXCoils->DXCoil(DXCoilNum).IsSecondaryDXCoilInZone) {
   13190           0 :             auto &secZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(state.dataDXCoils->DXCoil(DXCoilNum).SecZonePtr);
   13191           0 :             OutdoorDryBulb = secZoneHB.ZT;
   13192           0 :             OutdoorHumRat = secZoneHB.ZoneAirHumRat;
   13193           0 :             OutdoorWetBulb = state.dataDXCoils->DXCoil(DXCoilNum).EvapInletWetBulb;
   13194           0 :             OutdoorPressure = state.dataEnvrn->OutBaroPress;
   13195             :         }
   13196     2086433 :     } else if (state.dataDXCoils->DXCoil(DXCoilNum).IsSecondaryDXCoilInZone) {
   13197           0 :         auto &secZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(state.dataDXCoils->DXCoil(DXCoilNum).SecZonePtr);
   13198           0 :         OutdoorDryBulb = secZoneHB.ZT;
   13199           0 :         OutdoorHumRat = secZoneHB.ZoneAirHumRat;
   13200           0 :         OutdoorWetBulb = state.dataDXCoils->DXCoil(DXCoilNum).EvapInletWetBulb;
   13201           0 :         OutdoorPressure = state.dataEnvrn->OutBaroPress;
   13202             :     } else {
   13203     2086433 :         OutdoorDryBulb = state.dataEnvrn->OutDryBulbTemp;
   13204     2086433 :         OutdoorHumRat = state.dataEnvrn->OutHumRat;
   13205     2086433 :         OutdoorPressure = state.dataEnvrn->OutBaroPress;
   13206     2086433 :         OutdoorWetBulb = state.dataEnvrn->OutWetBulbTemp;
   13207             :     }
   13208             : 
   13209     6761048 :     if (SpeedNum > 1) {
   13210     1843820 :         SpeedNumLS = SpeedNum - 1;
   13211     1843820 :         SpeedNumHS = SpeedNum;
   13212     1843820 :         if (SpeedNum > state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds) {
   13213           0 :             SpeedNumLS = state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds - 1;
   13214           0 :             SpeedNumHS = state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds;
   13215             :         }
   13216             :     } else {
   13217     4917228 :         SpeedNumLS = 1;
   13218     4917228 :         SpeedNumHS = 1;
   13219             :     }
   13220             : 
   13221     6761048 :     MSHPWasteHeat = 0.0;
   13222     6761048 :     AirMassFlow = state.dataDXCoils->DXCoil(DXCoilNum).InletAirMassFlowRate;
   13223     6761048 :     AirMassFlowRatioLS = MSHPMassFlowRateLow / state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirMassFlowRate(SpeedNumLS);
   13224     6761048 :     AirMassFlowRatioHS = MSHPMassFlowRateHigh / state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirMassFlowRate(SpeedNumHS);
   13225     6761048 :     if ((AirMassFlow > 0.0) && (CycRatio > 0.0) && (MSHPMassFlowRateHigh == 0.0)) {
   13226           0 :         ShowSevereError(state,
   13227           0 :                         "CalcMultiSpeedDXCoilCooling: " + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + " \"" +
   13228           0 :                             state.dataDXCoils->DXCoil(DXCoilNum).Name + " Developer error - inconsistent airflow rates.");
   13229           0 :         if (MSHPMassFlowRateLow == 0.0 && SpeedNum > 1) {
   13230           0 :             ShowContinueError(state,
   13231             :                               "When AirMassFlow > 0.0 and CycRatio > 0.0 and SpeedNum > 1, then MSHPMassFlowRateLow and MSHPMassFlowRateHigh "
   13232             :                               "must also be > 0.0");
   13233           0 :             ShowContinueErrorTimeStamp(state, "");
   13234           0 :             ShowContinueError(state,
   13235           0 :                               format("AirMassFlow={:.3R},CycRatio={:.3R},SpeedNum={:.0R}, MSHPMassFlowRateLow={:.3R}, MSHPMassFlowRateHigh={:.3R}",
   13236             :                                      AirMassFlow,
   13237           0 :                                      double(SpeedNum),
   13238             :                                      CycRatio,
   13239             :                                      MSHPMassFlowRateLow,
   13240           0 :                                      MSHPMassFlowRateHigh));
   13241           0 :             ShowFatalError(state, "Preceding condition(s) causes termination.");
   13242             :         } else {
   13243           0 :             ShowContinueError(state, "When AirMassFlow > 0.0 and CycRatio > 0.0, then MSHPMassFlowRateHigh must also be > 0.0");
   13244           0 :             ShowContinueErrorTimeStamp(state, "");
   13245           0 :             ShowContinueError(state,
   13246           0 :                               format("AirMassFlow={:.3R},CycRatio={:.3R}, MSHPMassFlowRateHigh={:.3R}", AirMassFlow, CycRatio, MSHPMassFlowRateHigh));
   13247           0 :             ShowFatalError(state, "Preceding condition(s) causes termination.");
   13248             :         }
   13249     6761048 :     } else if (CycRatio > 1.0 || SpeedRatio > 1.0) {
   13250           0 :         ShowSevereError(state,
   13251           0 :                         "CalcMultiSpeedDXCoilCooling: " + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + " \"" +
   13252           0 :                             state.dataDXCoils->DXCoil(DXCoilNum).Name + " Developer error - inconsistent speed ratios.");
   13253           0 :         ShowContinueError(state, "CycRatio and SpeedRatio must be between 0.0 and 1.0");
   13254           0 :         ShowContinueErrorTimeStamp(state, "");
   13255           0 :         ShowContinueError(state, format("CycRatio={:.1R}, SpeedRatio = {:.1R}", CycRatio, SpeedRatio));
   13256           0 :         ShowFatalError(state, "Preceding condition(s) causes termination.");
   13257             :     }
   13258             : 
   13259     6761048 :     state.dataDXCoils->DXCoil(DXCoilNum).PartLoadRatio = 0.0;
   13260     6761048 :     state.dataHeatBal->HeatReclaimDXCoil(DXCoilNum).AvailCapacity = 0.0;
   13261     6761048 :     state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction = 0.0;
   13262     6761048 :     InletAirDryBulbTemp = state.dataDXCoils->DXCoil(DXCoilNum).InletAirTemp;
   13263     6761048 :     InletAirEnthalpy = state.dataDXCoils->DXCoil(DXCoilNum).InletAirEnthalpy;
   13264     6761048 :     InletAirHumRat = state.dataDXCoils->DXCoil(DXCoilNum).InletAirHumRat;
   13265             :     //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   13266             :     // InletAirPressure = DXCoil(DXCoilNum)%InletAirPressure
   13267             :     // InletAirWetBulbC = PsyTwbFnTdbWPb(InletAirDryBulbTemp,InletAirHumRat,InletAirPressure)
   13268     6761048 :     InletAirWetBulbC = PsyTwbFnTdbWPb(state, InletAirDryBulbTemp, InletAirHumRat, OutdoorPressure, RoutineName);
   13269     6761048 :     if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(DXMode) == DataHeatBalance::RefrigCondenserType::Air) {
   13270     6761048 :         CondInletTemp = OutdoorDryBulb; // Outdoor dry-bulb temp
   13271           0 :     } else if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(DXMode) == DataHeatBalance::RefrigCondenserType::Evap) {
   13272             :         // Outdoor wet-bulb temp from DataEnvironment + (1.0-EvapCondEffectiveness) * (drybulb - wetbulb)
   13273           0 :         CondInletTemp =
   13274           0 :             OutdoorWetBulb + (OutdoorDryBulb - OutdoorWetBulb) * (1.0 - state.dataDXCoils->DXCoil(DXCoilNum).MSEvapCondEffect(SpeedNumHS));
   13275           0 :         CondInletHumRat = PsyWFnTdbTwbPb(state, CondInletTemp, OutdoorWetBulb, OutdoorPressure, RoutineName);
   13276             :     }
   13277     6761048 :     if (OutdoorDryBulb < state.dataDXCoils->DXCoil(DXCoilNum).MaxOATCrankcaseHeater) {
   13278     2782409 :         CrankcaseHeatingPower = state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterCapacity;
   13279             :     } else {
   13280     3978639 :         CrankcaseHeatingPower = 0.0;
   13281             :     }
   13282             : 
   13283    24090698 :     if ((AirMassFlow > 0.0 && CondInletTemp >= state.dataDXCoils->DXCoil(DXCoilNum).MinOATCompressor) &&
   13284    10358586 :         (GetCurrentScheduleValue(state, state.dataDXCoils->DXCoil(DXCoilNum).SchedPtr) > 0.0) &&
   13285    13137975 :         ((SpeedRatio > 0.0 && SingleMode == 0) || CycRatio > 0.0) && (CompressorOp == CompressorOperation::On)) {
   13286             : 
   13287     2631991 :         RhoAir = PsyRhoAirFnPbTdbW(state, OutdoorPressure, OutdoorDryBulb, OutdoorHumRat, RoutineName);
   13288     2631991 :         if (SpeedNum > 1 && SingleMode == 0) {
   13289             : 
   13290             :             // Check for valid air volume flow per rated total cooling capacity (200 - 500 cfm/ton) at low speed
   13291     1303938 :             AirVolumeFlowRate = MSHPMassFlowRateLow / PsyRhoAirFnPbTdbW(state, OutdoorPressure, InletAirDryBulbTemp, InletAirHumRat, RoutineName);
   13292             :             //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   13293             :             //  AirVolumeFlowRate = AirMassFlow/PsyRhoAirFnPbTdbW(InletAirPressure,InletAirDryBulbTemp, InletAirHumRat)
   13294     1303938 :             VolFlowperRatedTotCap = AirVolumeFlowRate / state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(SpeedNumLS);
   13295     2607876 :             if ((VolFlowperRatedTotCap < state.dataHVACGlobal->MinOperVolFlowPerRatedTotCap(DXCT)) ||
   13296     1303938 :                 (VolFlowperRatedTotCap > state.dataHVACGlobal->MaxCoolVolFlowPerRatedTotCap(DXCT))) {
   13297      741368 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).MSErrIndex(SpeedNumLS) == 0) {
   13298          96 :                     ShowWarningMessage(
   13299             :                         state,
   13300         128 :                         format("{} \"{}\" - Air volume flow rate per watt of rated total cooling capacity is out of range at speed {}.",
   13301          32 :                                state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
   13302          32 :                                state.dataDXCoils->DXCoil(DXCoilNum).Name,
   13303          32 :                                SpeedNumLS));
   13304          32 :                     ShowContinueErrorTimeStamp(state, "");
   13305          96 :                     ShowContinueError(state,
   13306         128 :                                       format("Expected range for VolumeFlowPerRatedTotalCapacity=[{:.3R}--{:.3R}] Current value is {:.3R} m3/s/W",
   13307          32 :                                              state.dataHVACGlobal->MinOperVolFlowPerRatedTotCap(DXCT),
   13308          32 :                                              state.dataHVACGlobal->MaxCoolVolFlowPerRatedTotCap(DXCT),
   13309          32 :                                              VolFlowperRatedTotCap));
   13310          32 :                     ShowContinueError(state, "Possible causes include inconsistent air flow rates in system components or");
   13311          32 :                     ShowContinueError(state, "inconsistent supply air fan operation modes in coil and unitary system objects.");
   13312             :                 }
   13313     2965472 :                 ShowRecurringWarningErrorAtEnd(state,
   13314     2965472 :                                                format("{} \"{}\" - Air volume flow rate per watt of rated total cooling capacity is out of range "
   13315             :                                                       "at speed {} error continues...",
   13316      741368 :                                                       state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
   13317      741368 :                                                       state.dataDXCoils->DXCoil(DXCoilNum).Name,
   13318      741368 :                                                       SpeedNumLS),
   13319      741368 :                                                state.dataDXCoils->DXCoil(DXCoilNum).MSErrIndex(SpeedNumLS),
   13320             :                                                VolFlowperRatedTotCap,
   13321             :                                                VolFlowperRatedTotCap);
   13322             :             }
   13323             : 
   13324             :             // Check for valid air volume flow per rated total cooling capacity (200 - 500 cfm/ton) at high speed
   13325     1303938 :             AirVolumeFlowRate = MSHPMassFlowRateHigh / PsyRhoAirFnPbTdbW(state, OutdoorPressure, InletAirDryBulbTemp, InletAirHumRat, RoutineName);
   13326             :             //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   13327             :             //  AirVolumeFlowRate = AirMassFlow/PsyRhoAirFnPbTdbW(InletAirPressure,InletAirDryBulbTemp, InletAirHumRat)
   13328     1303938 :             VolFlowperRatedTotCap = AirVolumeFlowRate / state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(SpeedNumHS);
   13329     2607876 :             if ((VolFlowperRatedTotCap < state.dataHVACGlobal->MinOperVolFlowPerRatedTotCap(DXCT)) ||
   13330     1303938 :                 (VolFlowperRatedTotCap > state.dataHVACGlobal->MaxCoolVolFlowPerRatedTotCap(DXCT))) {
   13331      373993 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).MSErrIndex(SpeedNumHS) == 0) {
   13332          48 :                     ShowWarningMessage(
   13333             :                         state,
   13334          64 :                         format("{} \"{}\" - Air volume flow rate per watt of rated total cooling capacity is out of range at speed {}.",
   13335          16 :                                state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
   13336          16 :                                state.dataDXCoils->DXCoil(DXCoilNum).Name,
   13337          16 :                                SpeedNumHS));
   13338          16 :                     ShowContinueErrorTimeStamp(state, "");
   13339          48 :                     ShowContinueError(state,
   13340          64 :                                       format("Expected range for VolumeFlowPerRatedTotalCapacity=[{:.3R}--{:.3R}] Current value is {:.3R} m3/s/W",
   13341          16 :                                              state.dataHVACGlobal->MinOperVolFlowPerRatedTotCap(DXCT),
   13342          16 :                                              state.dataHVACGlobal->MaxCoolVolFlowPerRatedTotCap(DXCT),
   13343          16 :                                              VolFlowperRatedTotCap));
   13344          16 :                     ShowContinueError(state, "Possible causes include inconsistent air flow rates in system components or");
   13345          16 :                     ShowContinueError(state, "inconsistent supply air fan operation modes in coil and unitary system objects.");
   13346             :                 }
   13347     1495972 :                 ShowRecurringWarningErrorAtEnd(state,
   13348     1495972 :                                                format("{} \"{}\" - Air volume flow rate per watt of rated total cooling capacity is out of range "
   13349             :                                                       "at speed {} error continues...",
   13350      373993 :                                                       state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
   13351      373993 :                                                       state.dataDXCoils->DXCoil(DXCoilNum).Name,
   13352      373993 :                                                       SpeedNumHS),
   13353      373993 :                                                state.dataDXCoils->DXCoil(DXCoilNum).MSErrIndex(SpeedNumHS),
   13354             :                                                VolFlowperRatedTotCap,
   13355             :                                                VolFlowperRatedTotCap);
   13356             :             }
   13357             : 
   13358             :             // Adjust high speed coil bypass factor for actual maximum air flow rate.
   13359     1303938 :             RatedCBFHS = state.dataDXCoils->DXCoil(DXCoilNum).MSRatedCBF(SpeedNumHS);
   13360     1303938 :             CBFHS = AdjustCBF(RatedCBFHS, state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirMassFlowRate(SpeedNumHS), MSHPMassFlowRateHigh);
   13361     1303938 :             RatedCBFLS = state.dataDXCoils->DXCoil(DXCoilNum).MSRatedCBF(SpeedNumLS);
   13362     1303938 :             CBFLS = AdjustCBF(RatedCBFLS, state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirMassFlowRate(SpeedNumLS), MSHPMassFlowRateLow);
   13363             :             // get low speed total capacity and SHR at current conditions
   13364     5215752 :             CalcTotCapSHR(state,
   13365             :                           InletAirDryBulbTemp,
   13366             :                           InletAirHumRat,
   13367             :                           InletAirEnthalpy,
   13368             :                           InletAirWetBulbC,
   13369             :                           AirMassFlowRatioLS,
   13370             :                           MSHPMassFlowRateLow,
   13371     1303938 :                           state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(SpeedNumLS),
   13372             :                           CBFLS,
   13373     1303938 :                           state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFTemp(SpeedNumLS),
   13374     1303938 :                           state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFFlow(SpeedNumLS),
   13375             :                           TotCapLS,
   13376             :                           SHRLS,
   13377             :                           CondInletTemp,
   13378             :                           OutdoorPressure,
   13379     1303938 :                           state.dataDXCoils->DXCoil(DXCoilNum).capModFacTotal);
   13380             :             // get low speed outlet conditions
   13381     1303938 :             hDelta = TotCapLS / MSHPMassFlowRateLow;
   13382             :             // Calculate new apparatus dew point conditions
   13383     1303938 :             hADP = InletAirEnthalpy - hDelta / (1.0 - CBFLS);
   13384     1303938 :             tADP = PsyTsatFnHPb(state, hADP, OutdoorPressure, RoutineNameHighSpeedAlt);
   13385             :             //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   13386             :             //  tADP = PsyTsatFnHPb(hADP,InletAirPressure)
   13387     1303938 :             wADP = PsyWFnTdbH(state, tADP, hADP, RoutineName);
   13388     1303938 :             hTinwADP = PsyHFnTdbW(InletAirDryBulbTemp, wADP);
   13389             :             // get corresponding SHR
   13390     1303938 :             if ((InletAirEnthalpy - hADP) > 1.e-10) {
   13391     1303938 :                 SHRLS = min((hTinwADP - hADP) / (InletAirEnthalpy - hADP), 1.0);
   13392             :             } else {
   13393           0 :                 SHRLS = 1.0;
   13394             :             }
   13395             :             // cr8918    SHRLS = MIN((hTinwADP-hADP)/(InletAirEnthalpy-hADP),1.0d0)
   13396             :             // get low speed outlet conditions
   13397     1303938 :             LSOutletAirEnthalpy = InletAirEnthalpy - hDelta;
   13398     1303938 :             hTinwout = InletAirEnthalpy - (1.0 - SHRLS) * hDelta;
   13399     1303938 :             LSOutletAirHumRat = PsyWFnTdbH(state, InletAirDryBulbTemp, hTinwout, RoutineName);
   13400     1303938 :             LSOutletAirDryBulbTemp = PsyTdbFnHW(LSOutletAirEnthalpy, LSOutletAirHumRat);
   13401     1303938 :             OutletAirDryBulbTempSat = PsyTsatFnHPb(state, LSOutletAirEnthalpy, OutdoorPressure, RoutineName);
   13402     1303938 :             if (LSOutletAirDryBulbTemp < OutletAirDryBulbTempSat) { // Limit to saturated conditions at OutletAirEnthalpy
   13403           0 :                 LSOutletAirDryBulbTemp = OutletAirDryBulbTempSat;
   13404           0 :                 LSOutletAirHumRat = PsyWFnTdbH(state, LSOutletAirDryBulbTemp, LSOutletAirEnthalpy, RoutineName);
   13405             :             }
   13406             : 
   13407             :             // get high speed total capacity and SHR at current conditions
   13408             : 
   13409     5215752 :             CalcTotCapSHR(state,
   13410             :                           InletAirDryBulbTemp,
   13411             :                           InletAirHumRat,
   13412             :                           InletAirEnthalpy,
   13413             :                           InletAirWetBulbC,
   13414             :                           AirMassFlowRatioHS,
   13415             :                           MSHPMassFlowRateHigh,
   13416     1303938 :                           state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(SpeedNumHS),
   13417             :                           CBFHS,
   13418     1303938 :                           state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFTemp(SpeedNumHS),
   13419     1303938 :                           state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFFlow(SpeedNumHS),
   13420             :                           TotCapHS,
   13421             :                           SHRHS,
   13422             :                           CondInletTemp,
   13423             :                           OutdoorPressure,
   13424     1303938 :                           state.dataDXCoils->DXCoil(DXCoilNum).capModFacTotal);
   13425     1303938 :             hDelta = TotCapHS / MSHPMassFlowRateHigh;
   13426             :             // Calculate new apparatus dew point conditions
   13427     1303938 :             hADP = InletAirEnthalpy - hDelta / (1.0 - CBFHS);
   13428     1303938 :             tADP = PsyTsatFnHPb(state, hADP, OutdoorPressure, RoutineName);
   13429             :             //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   13430             :             //  tADP = PsyTsatFnHPb(hADP,InletAirPressure)
   13431     1303938 :             wADP = PsyWFnTdbH(state, tADP, hADP, RoutineName);
   13432     1303938 :             hTinwADP = PsyHFnTdbW(InletAirDryBulbTemp, wADP);
   13433             :             // get corresponding SHR
   13434     1303938 :             if ((InletAirEnthalpy - hADP) > 1.e-10) {
   13435     1303938 :                 SHRHS = min((hTinwADP - hADP) / (InletAirEnthalpy - hADP), 1.0);
   13436             :             } else {
   13437           0 :                 SHRHS = 1.0;
   13438             :             }
   13439             :             // cr8918    SHRHS = MIN((hTinwADP-hADP)/(InletAirEnthalpy-hADP),1.0d0)
   13440             :             // get the part load factor that will account for cycling losses
   13441     1303938 :             PLF = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).MSPLFFPLR(SpeedNumHS), SpeedRatio);
   13442     1303938 :             if (PLF < 0.7) {
   13443           0 :                 PLF = 0.7;
   13444             :             }
   13445             :             // calculate the run time fraction
   13446     1303938 :             state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction = SpeedRatio / PLF;
   13447     1303938 :             state.dataDXCoils->DXCoil(DXCoilNum).PartLoadRatio = SpeedRatio;
   13448             : 
   13449     1303938 :             if (state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction > 1.0) {
   13450           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction = 1.0; // Reset coil runtime fraction to 1.0
   13451             :             }
   13452             : 
   13453             :             // get high speed outlet conditions
   13454     1303938 :             HSOutletAirEnthalpy = InletAirEnthalpy - hDelta;
   13455     1303938 :             hTinwout = InletAirEnthalpy - (1.0 - SHRHS) * hDelta;
   13456     1303938 :             HSOutletAirHumRat = PsyWFnTdbH(state, InletAirDryBulbTemp, hTinwout, RoutineName);
   13457     1303938 :             HSOutletAirDryBulbTemp = PsyTdbFnHW(HSOutletAirEnthalpy, HSOutletAirHumRat);
   13458     1303938 :             OutletAirDryBulbTempSat = PsyTsatFnHPb(state, HSOutletAirEnthalpy, OutdoorPressure, RoutineName);
   13459     1303938 :             if (HSOutletAirDryBulbTemp < OutletAirDryBulbTempSat) { // Limit to saturated conditions at OutletAirEnthalpy
   13460           4 :                 HSOutletAirDryBulbTemp = OutletAirDryBulbTempSat;
   13461           4 :                 HSOutletAirHumRat = PsyWFnTdbH(state, HSOutletAirDryBulbTemp, HSOutletAirEnthalpy, RoutineName);
   13462             :             }
   13463             : 
   13464             :             //  If constant fan with cycling compressor, call function to determine "effective SHR"
   13465             :             //  which includes the part-load degradation on latent capacity
   13466     1303938 :             if (state.dataDXCoils->DXCoil(DXCoilNum).LatentImpact && FanOpMode == ContFanCycCoil && SpeedRatio > 0.0) {
   13467           0 :                 QLatRated = state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(SpeedNumHS) *
   13468           0 :                             (1.0 - state.dataDXCoils->DXCoil(DXCoilNum).MSRatedSHR(SpeedNumHS));
   13469           0 :                 QLatActual = TotCapHS * (1.0 - SHRHS);
   13470           0 :                 SHRUnadjusted = SHRHS;
   13471           0 :                 SHR = CalcEffectiveSHR(state,
   13472             :                                        DXCoilNum,
   13473             :                                        SHRHS,
   13474           0 :                                        state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction,
   13475             :                                        QLatRated,
   13476             :                                        QLatActual,
   13477             :                                        InletAirDryBulbTemp,
   13478             :                                        InletAirWetBulbC,
   13479             :                                        SpeedNumHS);
   13480             :                 // Calculate full load output conditions
   13481           0 :                 if (SHR > 1.0) SHR = 1.0;
   13482           0 :                 hTinwout = InletAirEnthalpy - (1.0 - SHR) * hDelta;
   13483           0 :                 if (SHR < 1.0) {
   13484           0 :                     HSOutletAirHumRat = PsyWFnTdbH(state, InletAirDryBulbTemp, hTinwout, RoutineName);
   13485             :                 } else {
   13486           0 :                     HSOutletAirHumRat = InletAirHumRat;
   13487             :                 }
   13488           0 :                 HSOutletAirDryBulbTemp = PsyTdbFnHW(HSOutletAirEnthalpy, HSOutletAirHumRat);
   13489             :             }
   13490             : 
   13491             :             // get high speed EIR at current conditions
   13492     1303938 :             EIRTempModFacHS = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).MSEIRFTemp(SpeedNumHS), InletAirWetBulbC, CondInletTemp);
   13493     1303938 :             EIRFlowModFacHS = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).MSEIRFFlow(SpeedNumHS), AirMassFlowRatioHS);
   13494     1303938 :             EIRHS = 1.0 / state.dataDXCoils->DXCoil(DXCoilNum).MSRatedCOP(SpeedNumHS) * EIRFlowModFacHS * EIRTempModFacHS;
   13495             :             // get low speed EIR at current conditions
   13496     1303938 :             EIRTempModFacLS = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).MSEIRFTemp(SpeedNumLS), InletAirWetBulbC, CondInletTemp);
   13497     1303938 :             EIRFlowModFacLS = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).MSEIRFFlow(SpeedNumLS), AirMassFlowRatioLS);
   13498     1303938 :             EIRLS = 1.0 / state.dataDXCoils->DXCoil(DXCoilNum).MSRatedCOP(SpeedNumLS) * EIRTempModFacLS * EIRFlowModFacLS;
   13499             : 
   13500             :             // get current total capacity, SHR, EIR
   13501     1303938 :             if (SpeedRatio >= 1.0) {
   13502      810413 :                 SHR = SHRHS;
   13503      810413 :                 EIR = EIRHS;
   13504      810413 :                 CondAirMassFlow = RhoAir * state.dataDXCoils->DXCoil(DXCoilNum).MSEvapCondAirFlow(SpeedNumHS);
   13505      810413 :                 EvapCondPumpElecPower = state.dataDXCoils->DXCoil(DXCoilNum).MSEvapCondPumpElecNomPower(SpeedNumHS);
   13506             :             } else {
   13507      493525 :                 EIR = SpeedRatio * EIRHS + (1.0 - SpeedRatio) * EIRLS;
   13508      493525 :                 SHR = SpeedRatio * SHRHS + (1.0 - SpeedRatio) * SHRLS;
   13509      987050 :                 CondAirMassFlow = RhoAir * (SpeedRatio * state.dataDXCoils->DXCoil(DXCoilNum).MSEvapCondAirFlow(SpeedNumHS) +
   13510      493525 :                                             (1.0 - SpeedRatio) * state.dataDXCoils->DXCoil(DXCoilNum).MSEvapCondAirFlow(SpeedNumLS));
   13511      987050 :                 EvapCondPumpElecPower = SpeedRatio * state.dataDXCoils->DXCoil(DXCoilNum).MSEvapCondPumpElecNomPower(SpeedNumHS) +
   13512      493525 :                                         (1.0 - SpeedRatio) * state.dataDXCoils->DXCoil(DXCoilNum).MSEvapCondPumpElecNomPower(SpeedNumLS);
   13513             :             }
   13514             : 
   13515             :             // Outlet calculation
   13516     1303938 :             Real64 SensibleOutputLS(0.0); // low speed sensible output rate
   13517     1303938 :             Real64 LatentOutputLS(0.0);   // low speed latent output rate
   13518     1303938 :             Real64 TotalOutputLS(0.0);    // low speed total output rate
   13519     1303938 :             Real64 SensibleOutputHS(0.0); // high speed sensible output rate
   13520     1303938 :             Real64 LatentOutputHS(0.0);   // high speed latent output rate
   13521     1303938 :             Real64 TotalOutputHS(0.0);    // high speed total output rate
   13522     1303938 :             CalcComponentSensibleLatentOutput(MSHPMassFlowRateLow,
   13523             :                                               InletAirDryBulbTemp,
   13524             :                                               InletAirHumRat,
   13525             :                                               LSOutletAirDryBulbTemp,
   13526             :                                               LSOutletAirHumRat,
   13527             :                                               SensibleOutputLS,
   13528             :                                               LatentOutputLS,
   13529             :                                               TotalOutputLS);
   13530     1303938 :             CalcComponentSensibleLatentOutput(MSHPMassFlowRateHigh,
   13531             :                                               InletAirDryBulbTemp,
   13532             :                                               InletAirHumRat,
   13533             :                                               HSOutletAirDryBulbTemp,
   13534             :                                               HSOutletAirHumRat,
   13535             :                                               SensibleOutputHS,
   13536             :                                               LatentOutputHS,
   13537             :                                               TotalOutputHS);
   13538     1303938 :             state.dataDXCoils->DXCoil(DXCoilNum).TotalCoolingEnergyRate = TotalOutputHS * SpeedRatio + TotalOutputLS * (1.0 - SpeedRatio);
   13539     1303938 :             state.dataDXCoils->DXCoil(DXCoilNum).SensCoolingEnergyRate = SensibleOutputHS * SpeedRatio + SensibleOutputLS * (1.0 - SpeedRatio);
   13540     1303938 :             state.dataDXCoils->DXCoil(DXCoilNum).LatCoolingEnergyRate = LatentOutputHS * SpeedRatio + LatentOutputLS * (1.0 - SpeedRatio);
   13541             :             // Average outlet enthalpy
   13542     2607876 :             OutletAirEnthalpy = InletAirEnthalpy - state.dataDXCoils->DXCoil(DXCoilNum).TotalCoolingEnergyRate /
   13543     1303938 :                                                        state.dataDXCoils->DXCoil(DXCoilNum).InletAirMassFlowRate;
   13544             : 
   13545     1303938 :             if (FanOpMode == CycFanCycCoil) state.dataHVACGlobal->OnOffFanPartLoadFraction = 1.0;
   13546             :             // Update outlet conditions
   13547     1303938 :             if (SpeedRatio == 0.0 && FanOpMode == CycFanCycCoil) {
   13548       12755 :                 OutletAirEnthalpy = LSOutletAirEnthalpy;
   13549       12755 :                 OutletAirHumRat = LSOutletAirHumRat;
   13550       12755 :                 OutletAirDryBulbTemp = LSOutletAirDryBulbTemp;
   13551     1291183 :             } else if (SpeedRatio >= 1.0 && FanOpMode == CycFanCycCoil) {
   13552      395211 :                 OutletAirEnthalpy = HSOutletAirEnthalpy;
   13553      395211 :                 OutletAirHumRat = HSOutletAirHumRat;
   13554      395211 :                 OutletAirDryBulbTemp = HSOutletAirDryBulbTemp;
   13555             :             } else {
   13556      895972 :                 OutletAirHumRat =
   13557      895972 :                     ((HSOutletAirHumRat * SpeedRatio * MSHPMassFlowRateHigh) + (LSOutletAirHumRat * (1.0 - SpeedRatio) * MSHPMassFlowRateLow)) /
   13558      895972 :                     state.dataDXCoils->DXCoil(DXCoilNum).InletAirMassFlowRate;
   13559      895972 :                 OutletAirDryBulbTemp = PsyTdbFnHW(OutletAirEnthalpy, OutletAirHumRat);
   13560      895972 :                 if (OutletAirDryBulbTemp < OutletAirDryBulbTempSat) { // Limit to saturated conditions at OutletAirEnthalpy
   13561       19055 :                     OutletAirDryBulbTemp = OutletAirDryBulbTempSat;
   13562       19055 :                     OutletAirHumRat = PsyWFnTdbH(state, OutletAirDryBulbTemp, OutletAirEnthalpy, RoutineName);
   13563       57165 :                     CalcComponentSensibleLatentOutput(AirMassFlow,
   13564             :                                                       InletAirDryBulbTemp,
   13565             :                                                       InletAirHumRat,
   13566             :                                                       OutletAirDryBulbTemp,
   13567             :                                                       OutletAirHumRat,
   13568       19055 :                                                       state.dataDXCoils->DXCoil(DXCoilNum).SensCoolingEnergyRate,
   13569       19055 :                                                       state.dataDXCoils->DXCoil(DXCoilNum).LatCoolingEnergyRate,
   13570       19055 :                                                       state.dataDXCoils->DXCoil(DXCoilNum).TotalCoolingEnergyRate);
   13571             :                 }
   13572             :             }
   13573             : 
   13574     1303938 :             LSElecCoolingPower = TotCapLS * EIRLS;
   13575     1303938 :             HSElecCoolingPower = TotCapHS * EIRHS;
   13576             : 
   13577             :             // Power calculation
   13578     1303938 :             if (!state.dataDXCoils->DXCoil(DXCoilNum).PLRImpact) {
   13579     1303938 :                 state.dataDXCoils->DXCoil(DXCoilNum).ElecCoolingPower = SpeedRatio * HSElecCoolingPower + (1.0 - SpeedRatio) * LSElecCoolingPower;
   13580             :             } else {
   13581           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).ElecCoolingPower =
   13582           0 :                     state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction * HSElecCoolingPower +
   13583           0 :                     (1.0 - state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction) * LSElecCoolingPower;
   13584             :             }
   13585             :             // Now reset runtime fraction to 1.0 (because LS is running the full timestep)
   13586     1303938 :             state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction = 1.0;
   13587             : 
   13588             :             //   Calculation for heat reclaim needs to be corrected to use compressor power (not including condenser fan power)
   13589     1303938 :             state.dataHeatBal->HeatReclaimDXCoil(DXCoilNum).AvailCapacity =
   13590     1303938 :                 state.dataDXCoils->DXCoil(DXCoilNum).TotalCoolingEnergyRate + state.dataDXCoils->DXCoil(DXCoilNum).ElecCoolingPower;
   13591             : 
   13592             :             // Waste heat calculation
   13593             :             // TODO: waste heat not considered even if defined in Cooling:DX:MultiSpeed, N16, \field Speed 1 Rated Waste Heat Fraction of
   13594             :             // Power Input
   13595     1303938 :             if (state.dataDXCoils->DXCoil(DXCoilNum).FuelTypeNum != DataGlobalConstants::ResourceType::Electricity) {
   13596      319078 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).MSWasteHeat(SpeedNumLS) == 0) {
   13597           0 :                     WasteHeatLS = state.dataDXCoils->DXCoil(DXCoilNum).MSWasteHeatFrac(SpeedNumLS);
   13598             :                 } else {
   13599      319078 :                     WasteHeatLS =
   13600      638156 :                         CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).MSWasteHeat(SpeedNumLS), OutdoorDryBulb, InletAirDryBulbTemp) *
   13601      319078 :                         state.dataDXCoils->DXCoil(DXCoilNum).MSWasteHeatFrac(SpeedNumLS);
   13602             :                 }
   13603      319078 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).MSWasteHeat(SpeedNumHS) == 0) {
   13604           0 :                     WasteHeatHS = state.dataDXCoils->DXCoil(DXCoilNum).MSWasteHeatFrac(SpeedNumHS);
   13605             :                 } else {
   13606      319078 :                     WasteHeatHS =
   13607      638156 :                         CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).MSWasteHeat(SpeedNumHS), OutdoorDryBulb, InletAirDryBulbTemp) *
   13608      319078 :                         state.dataDXCoils->DXCoil(DXCoilNum).MSWasteHeatFrac(SpeedNumHS);
   13609             :                 }
   13610      319078 :                 state.dataDXCoils->DXCoil(DXCoilNum).MSFuelWasteHeat =
   13611      319078 :                     (SpeedRatio * WasteHeatHS + (1.0 - SpeedRatio) * WasteHeatLS) * state.dataDXCoils->DXCoil(DXCoilNum).ElecCoolingPower;
   13612      319078 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).MSHPHeatRecActive) {
   13613           0 :                     MSHPWasteHeat = state.dataDXCoils->DXCoil(DXCoilNum).MSFuelWasteHeat;
   13614             :                 }
   13615             :             }
   13616             : 
   13617             :             // Energy use for other fuel types
   13618     1303938 :             if (state.dataDXCoils->DXCoil(DXCoilNum).FuelTypeNum != DataGlobalConstants::ResourceType::Electricity) {
   13619      319078 :                 state.dataDXCoils->DXCoil(DXCoilNum).FuelUsed = state.dataDXCoils->DXCoil(DXCoilNum).ElecCoolingPower;
   13620      319078 :                 state.dataDXCoils->DXCoil(DXCoilNum).ElecCoolingPower = 0.0;
   13621             :             }
   13622             : 
   13623     1303938 :             state.dataDXCoils->DXCoil(DXCoilNum).OutletAirEnthalpy = OutletAirEnthalpy;
   13624     1303938 :             state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat = OutletAirHumRat;
   13625     1303938 :             state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp = OutletAirDryBulbTemp;
   13626     1303938 :             state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterPower = 0.0;
   13627             : 
   13628     1328053 :         } else if (CycRatio > 0.0) {
   13629             : 
   13630     1328053 :             if (FanOpMode == CycFanCycCoil) AirMassFlow /= CycRatio;
   13631     1328053 :             if (FanOpMode == ContFanCycCoil) AirMassFlow = MSHPMassFlowRateHigh;
   13632             : 
   13633             :             // Check for valid air volume flow per rated total cooling capacity (200 - 500 cfm/ton) at low speed
   13634     1328053 :             AirVolumeFlowRate = MSHPMassFlowRateHigh / PsyRhoAirFnPbTdbW(state, OutdoorPressure, InletAirDryBulbTemp, InletAirHumRat, RoutineName);
   13635             :             //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   13636             :             //  AirVolumeFlowRate = AirMassFlow/PsyRhoAirFnPbTdbW(InletAirPressure,InletAirDryBulbTemp, InletAirHumRat)
   13637     1328053 :             VolFlowperRatedTotCap = AirVolumeFlowRate / state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(SpeedNum);
   13638     2656106 :             if ((VolFlowperRatedTotCap < state.dataHVACGlobal->MinOperVolFlowPerRatedTotCap(DXCT)) ||
   13639     1328053 :                 (VolFlowperRatedTotCap > state.dataHVACGlobal->MaxCoolVolFlowPerRatedTotCap(DXCT))) {
   13640      769524 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).MSErrIndex(SpeedNum) == 0) {
   13641           3 :                     ShowWarningMessage(
   13642             :                         state,
   13643           4 :                         format("{} \"{}\" - Air volume flow rate per watt of rated total cooling capacity is out of range at speed {}.",
   13644           1 :                                state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
   13645           1 :                                state.dataDXCoils->DXCoil(DXCoilNum).Name,
   13646           1 :                                SpeedNum));
   13647           1 :                     ShowContinueErrorTimeStamp(state, "");
   13648           3 :                     ShowContinueError(state,
   13649           4 :                                       format("Expected range for VolumeFlowPerRatedTotalCapacity=[{:.3R}--{:.3R}] Current value is {:.3R} m3/s/W",
   13650           1 :                                              state.dataHVACGlobal->MinOperVolFlowPerRatedTotCap(DXCT),
   13651           1 :                                              state.dataHVACGlobal->MaxCoolVolFlowPerRatedTotCap(DXCT),
   13652           1 :                                              VolFlowperRatedTotCap));
   13653           1 :                     ShowContinueError(state, "Possible causes include inconsistent air flow rates in system components or");
   13654           1 :                     ShowContinueError(state, "inconsistent supply air fan operation modes in coil and unitary system objects.");
   13655             :                 }
   13656     3078096 :                 ShowRecurringWarningErrorAtEnd(state,
   13657     3078096 :                                                format("{} \"{}\" - Air volume flow rate per watt of rated total cooling capacity is out of range "
   13658             :                                                       "at speed {} error continues...",
   13659      769524 :                                                       state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
   13660      769524 :                                                       state.dataDXCoils->DXCoil(DXCoilNum).Name,
   13661      769524 :                                                       SpeedNumHS),
   13662      769524 :                                                state.dataDXCoils->DXCoil(DXCoilNum).MSErrIndex(SpeedNumHS),
   13663             :                                                VolFlowperRatedTotCap,
   13664             :                                                VolFlowperRatedTotCap);
   13665             :             }
   13666             : 
   13667     1328053 :             if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(SpeedNum) == DataHeatBalance::RefrigCondenserType::Evap) {
   13668             :                 // Outdoor wet-bulb temp from DataEnvironment + (1.0-EvapCondEffectiveness) * (drybulb - wetbulb)
   13669           0 :                 CondInletTemp =
   13670           0 :                     OutdoorWetBulb + (OutdoorDryBulb - OutdoorWetBulb) * (1.0 - state.dataDXCoils->DXCoil(DXCoilNum).MSEvapCondEffect(SpeedNum));
   13671           0 :                 CondInletHumRat = PsyWFnTdbTwbPb(state, CondInletTemp, OutdoorWetBulb, OutdoorPressure, RoutineName);
   13672             :             }
   13673             : 
   13674     1328053 :             RatedCBFLS = state.dataDXCoils->DXCoil(DXCoilNum).MSRatedCBF(SpeedNum);
   13675     1328053 :             CBFLS = AdjustCBF(RatedCBFLS, state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirMassFlowRate(SpeedNum), MSHPMassFlowRateHigh);
   13676             : 
   13677             :             // Adjust low speed coil bypass factor for actual flow rate.
   13678             :             // CBF = AdjustCBF(DXCoil(DXCoilNum)%RatedCBF2,DXCoil(DXCoilNum)%RatedAirMassFlowRate2,AirMassFlow)
   13679             :             // get low speed total capacity and SHR at current conditions
   13680     5312212 :             CalcTotCapSHR(state,
   13681             :                           InletAirDryBulbTemp,
   13682             :                           InletAirHumRat,
   13683             :                           InletAirEnthalpy,
   13684             :                           InletAirWetBulbC,
   13685             :                           AirMassFlowRatioLS,
   13686             :                           MSHPMassFlowRateHigh,
   13687     1328053 :                           state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(SpeedNum),
   13688             :                           CBFLS,
   13689     1328053 :                           state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFTemp(SpeedNum),
   13690     1328053 :                           state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFFlow(SpeedNum),
   13691             :                           TotCapLS,
   13692             :                           SHRLS,
   13693             :                           CondInletTemp,
   13694             :                           OutdoorPressure,
   13695     1328053 :                           state.dataDXCoils->DXCoil(DXCoilNum).capModFacTotal);
   13696             :             //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   13697             :             //  Node(DXCoil(DXCoilNum)%AirInNode)%Press)
   13698     1328053 :             hDelta = TotCapLS / AirMassFlow;
   13699             :             // Adjust CBF for off-nominal flow
   13700     2656106 :             CBF = AdjustCBF(state.dataDXCoils->DXCoil(DXCoilNum).MSRatedCBF(SpeedNum),
   13701     1328053 :                             state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirMassFlowRate(SpeedNum),
   13702             :                             AirMassFlow);
   13703             :             // Calculate new apparatus dew point conditions
   13704     1328053 :             hADP = InletAirEnthalpy - hDelta / (1.0 - CBF);
   13705     1328053 :             tADP = PsyTsatFnHPb(state, hADP, OutdoorPressure, RoutineName);
   13706             :             //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   13707             :             //  tADP = PsyTsatFnHPb(hADP,InletAirPressure)
   13708     1328053 :             wADP = PsyWFnTdbH(state, tADP, hADP, RoutineName);
   13709     1328053 :             hTinwADP = PsyHFnTdbW(InletAirDryBulbTemp, wADP);
   13710             :             // get corresponding SHR
   13711     1328053 :             if ((InletAirEnthalpy - hADP) > 1.e-10) {
   13712     1328053 :                 SHR = min((hTinwADP - hADP) / (InletAirEnthalpy - hADP), 1.0);
   13713             :             } else {
   13714           0 :                 SHR = 1.0;
   13715             :             }
   13716             :             // cr8918    SHR = MIN((hTinwADP-hADP)/(InletAirEnthalpy-hADP),1.0d0)
   13717             : 
   13718             :             // get the part load factor that will account for cycling losses
   13719     1328053 :             PLF = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).MSPLFFPLR(SpeedNum), CycRatio);
   13720     1328053 :             if (FanOpMode == CycFanCycCoil && CycRatio == 1.0 && PLF != 1.0) {
   13721           0 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).PLFErrIndex == 0) {
   13722           0 :                     ShowWarningMessage(state,
   13723           0 :                                        format("The PLF curve value for DX cooling coil {} ={:.2R} for part-load ratio = 1",
   13724           0 :                                               state.dataDXCoils->DXCoil(DXCoilNum).Name,
   13725           0 :                                               PLF));
   13726           0 :                     ShowContinueError(state, "PLF curve value must be = 1.0 and has been reset to 1.0. Simulation is continuing.");
   13727           0 :                     ShowContinueErrorTimeStamp(state, "");
   13728             :                 }
   13729           0 :                 ShowRecurringWarningErrorAtEnd(state,
   13730           0 :                                                state.dataDXCoils->DXCoil(DXCoilNum).Name +
   13731             :                                                    "\": DX cooling coil PLF curve value <> 1.0 warning continues...",
   13732           0 :                                                state.dataDXCoils->DXCoil(DXCoilNum).PLFErrIndex,
   13733             :                                                PLF,
   13734             :                                                PLF);
   13735           0 :                 PLF = 1.0;
   13736             :             }
   13737             : 
   13738     1328053 :             if (PLF < 0.7) {
   13739           0 :                 PLF = 0.7;
   13740             :             }
   13741             :             // calculate the run time fraction
   13742     1328053 :             state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction = CycRatio / PLF;
   13743     1328053 :             state.dataDXCoils->DXCoil(DXCoilNum).PartLoadRatio = CycRatio;
   13744             : 
   13745     1328053 :             if (state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction > 1.0) {
   13746           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction = 1.0; // Reset coil runtime fraction to 1.0
   13747             :             }
   13748             : 
   13749             :             // get low speed outlet conditions
   13750     1328053 :             LSOutletAirEnthalpy = InletAirEnthalpy - hDelta;
   13751     1328053 :             hTinwout = InletAirEnthalpy - (1.0 - SHR) * hDelta;
   13752     1328053 :             LSOutletAirHumRat = PsyWFnTdbH(state, InletAirDryBulbTemp, hTinwout, RoutineName);
   13753     1328053 :             LSOutletAirDryBulbTemp = PsyTdbFnHW(LSOutletAirEnthalpy, LSOutletAirHumRat);
   13754     1328053 :             OutletAirDryBulbTempSat = PsyTsatFnHPb(state, LSOutletAirEnthalpy, OutdoorPressure, RoutineName);
   13755     1328053 :             if (LSOutletAirDryBulbTemp < OutletAirDryBulbTempSat) { // Limit to saturated conditions at OutletAirEnthalpy
   13756           0 :                 LSOutletAirDryBulbTemp = OutletAirDryBulbTempSat;
   13757           0 :                 LSOutletAirHumRat = PsyWFnTdbH(state, LSOutletAirDryBulbTemp, LSOutletAirEnthalpy, RoutineName);
   13758             :             }
   13759             : 
   13760             :             //  If constant fan with cycling compressor, call function to determine "effective SHR"
   13761             :             //  which includes the part-load degradation on latent capacity
   13762     1328053 :             if (FanOpMode == ContFanCycCoil) {
   13763      281170 :                 QLatRated =
   13764      281170 :                     state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(SpeedNum) * (1.0 - state.dataDXCoils->DXCoil(DXCoilNum).MSRatedSHR(SpeedNum));
   13765      281170 :                 QLatActual = TotCapLS * (1.0 - SHR);
   13766      281170 :                 SHRUnadjusted = SHR;
   13767      562340 :                 SHR = CalcEffectiveSHR(state,
   13768             :                                        DXCoilNum,
   13769             :                                        SHR,
   13770      281170 :                                        state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction,
   13771             :                                        QLatRated,
   13772             :                                        QLatActual,
   13773             :                                        InletAirDryBulbTemp,
   13774             :                                        InletAirWetBulbC,
   13775             :                                        SpeedNum);
   13776             :                 // Calculate full load output conditions
   13777      281170 :                 if (SHR > 1.0) SHR = 1.0;
   13778      281170 :                 hTinwout = InletAirEnthalpy - (1.0 - SHR) * hDelta;
   13779      281170 :                 if (SHR < 1.0) {
   13780      186284 :                     LSOutletAirHumRat = PsyWFnTdbH(state, InletAirDryBulbTemp, hTinwout, RoutineName);
   13781             :                 } else {
   13782       94886 :                     LSOutletAirHumRat = InletAirHumRat;
   13783             :                 }
   13784      281170 :                 LSOutletAirDryBulbTemp = PsyTdbFnHW(LSOutletAirEnthalpy, LSOutletAirHumRat);
   13785             :             }
   13786             : 
   13787     1328053 :             if (FanOpMode == CycFanCycCoil) state.dataHVACGlobal->OnOffFanPartLoadFraction = PLF;
   13788     1328053 :             if (FanOpMode == ContFanCycCoil) {
   13789             :                 // outlet conditions are average of inlet and low speed weighted by CycRatio
   13790             :                 // Continuous fan, cycling compressor
   13791             :                 Real64 CycAirFlowRatio =
   13792      281170 :                     CycRatio * AirMassFlow /
   13793      281170 :                     state.dataDXCoils->DXCoil(DXCoilNum).InletAirMassFlowRate; // ratio of compressor on airflow to average timestep airflow
   13794      281170 :                 OutletAirEnthalpy = CycAirFlowRatio * LSOutletAirEnthalpy + (1.0 - CycAirFlowRatio) * InletAirEnthalpy;
   13795      281170 :                 OutletAirHumRat = CycAirFlowRatio * LSOutletAirHumRat + (1.0 - CycAirFlowRatio) * InletAirHumRat;
   13796      281170 :                 OutletAirDryBulbTemp = PsyTdbFnHW(OutletAirEnthalpy, OutletAirHumRat);
   13797             :             } else {
   13798     1046883 :                 OutletAirHumRat = LSOutletAirHumRat;
   13799     1046883 :                 OutletAirDryBulbTemp = LSOutletAirDryBulbTemp;
   13800     1046883 :                 OutletAirEnthalpy = LSOutletAirEnthalpy;
   13801             :             }
   13802             : 
   13803             :             // get low speed EIR at current conditions
   13804     1328053 :             EIRTempModFacLS = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).MSEIRFTemp(SpeedNum), InletAirWetBulbC, CondInletTemp);
   13805     1328053 :             EIRFlowModFacLS = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).MSEIRFFlow(SpeedNum), AirMassFlowRatioLS);
   13806     1328053 :             EIRLS = 1.0 / state.dataDXCoils->DXCoil(DXCoilNum).MSRatedCOP(SpeedNum) * EIRTempModFacLS * EIRFlowModFacLS;
   13807             : 
   13808             :             // get the eletrical power consumption
   13809     1328053 :             state.dataDXCoils->DXCoil(DXCoilNum).ElecCoolingPower =
   13810     1328053 :                 TotCapLS * EIRLS * state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction;
   13811             :             // calculate cooling output power
   13812             :             //    AirMassFlow = DXCoil(DXCoilNum)%InletAirMassFlowRate
   13813     3984159 :             CalcComponentSensibleLatentOutput(AirMassFlow,
   13814             :                                               InletAirDryBulbTemp,
   13815             :                                               InletAirHumRat,
   13816             :                                               LSOutletAirDryBulbTemp,
   13817             :                                               LSOutletAirHumRat,
   13818     1328053 :                                               state.dataDXCoils->DXCoil(DXCoilNum).SensCoolingEnergyRate,
   13819     1328053 :                                               state.dataDXCoils->DXCoil(DXCoilNum).LatCoolingEnergyRate,
   13820     1328053 :                                               state.dataDXCoils->DXCoil(DXCoilNum).TotalCoolingEnergyRate);
   13821     1328053 :             state.dataDXCoils->DXCoil(DXCoilNum).TotalCoolingEnergyRate = state.dataDXCoils->DXCoil(DXCoilNum).TotalCoolingEnergyRate * CycRatio;
   13822     1328053 :             state.dataDXCoils->DXCoil(DXCoilNum).SensCoolingEnergyRate = state.dataDXCoils->DXCoil(DXCoilNum).SensCoolingEnergyRate * CycRatio;
   13823     1328053 :             state.dataDXCoils->DXCoil(DXCoilNum).LatCoolingEnergyRate = state.dataDXCoils->DXCoil(DXCoilNum).LatCoolingEnergyRate * CycRatio;
   13824             : 
   13825             :             //   Calculation for heat reclaim needs to be corrected to use compressor power (not including condenser fan power)
   13826     1328053 :             state.dataHeatBal->HeatReclaimDXCoil(DXCoilNum).AvailCapacity =
   13827     1328053 :                 state.dataDXCoils->DXCoil(DXCoilNum).TotalCoolingEnergyRate + state.dataDXCoils->DXCoil(DXCoilNum).ElecCoolingPower;
   13828     1328053 :             state.dataDXCoils->DXCoil(DXCoilNum).OutletAirEnthalpy = OutletAirEnthalpy;
   13829     1328053 :             state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat = OutletAirHumRat;
   13830     1328053 :             state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp = OutletAirDryBulbTemp;
   13831     2656106 :             CondAirMassFlow = RhoAir * state.dataDXCoils->DXCoil(DXCoilNum).MSEvapCondAirFlow(SpeedNum) *
   13832     1328053 :                               state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction;
   13833     2656106 :             EvapCondPumpElecPower = state.dataDXCoils->DXCoil(DXCoilNum).MSEvapCondPumpElecNomPower(SpeedNum) *
   13834     1328053 :                                     state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction;
   13835             : 
   13836             :             // Waste heat
   13837     1328053 :             if (state.dataDXCoils->DXCoil(DXCoilNum).MSHPHeatRecActive) {
   13838           0 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).MSWasteHeat(SpeedNum) == 0) {
   13839           0 :                     state.dataDXCoils->DXCoil(DXCoilNum).MSFuelWasteHeat =
   13840           0 :                         state.dataDXCoils->DXCoil(DXCoilNum).MSWasteHeatFrac(SpeedNum) * state.dataDXCoils->DXCoil(DXCoilNum).ElecCoolingPower;
   13841             :                 } else {
   13842           0 :                     state.dataDXCoils->DXCoil(DXCoilNum).MSFuelWasteHeat =
   13843           0 :                         CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).MSWasteHeat(SpeedNum), OutdoorDryBulb, InletAirDryBulbTemp) *
   13844           0 :                         state.dataDXCoils->DXCoil(DXCoilNum).MSWasteHeatFrac(SpeedNum) * state.dataDXCoils->DXCoil(DXCoilNum).ElecCoolingPower;
   13845             :                 }
   13846           0 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).MSHPHeatRecActive) {
   13847           0 :                     MSHPWasteHeat = state.dataDXCoils->DXCoil(DXCoilNum).MSFuelWasteHeat;
   13848             :                 }
   13849             :             }
   13850             :             // Energy use for other fuel types
   13851     1328053 :             if (state.dataDXCoils->DXCoil(DXCoilNum).FuelTypeNum != DataGlobalConstants::ResourceType::Electricity) {
   13852      100052 :                 state.dataDXCoils->DXCoil(DXCoilNum).FuelUsed = state.dataDXCoils->DXCoil(DXCoilNum).ElecCoolingPower;
   13853      100052 :                 state.dataDXCoils->DXCoil(DXCoilNum).ElecCoolingPower = 0.0;
   13854             :             }
   13855             : 
   13856     1328053 :             if (state.dataDXCoils->DXCoil(DXCoilNum).CompanionUpstreamDXCoil == 0) {
   13857     1328053 :                 state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterPower =
   13858     1328053 :                     CrankcaseHeatingPower * (1.0 - state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction);
   13859             :             } else {
   13860           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterPower =
   13861           0 :                     CrankcaseHeatingPower *
   13862           0 :                     (1.0 - max(state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction,
   13863           0 :                                state.dataDXCoils->DXCoil(state.dataDXCoils->DXCoil(DXCoilNum).CompanionUpstreamDXCoil).HeatingCoilRuntimeFraction));
   13864             :             }
   13865             :         }
   13866             : 
   13867     2631991 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(DXMode) == DataHeatBalance::RefrigCondenserType::Evap) {
   13868             :             //******************
   13869             :             //             WATER CONSUMPTION IN m3 OF WATER FOR DIRECT
   13870             :             //             H2O [m3/s] = Delta W[kgWater/kgDryAir]*Mass Flow Air[kgDryAir/s]
   13871             :             //                                /RhoWater [kgWater/m3]
   13872             :             //******************
   13873           0 :             RhoWater = RhoH2O(OutdoorDryBulb);
   13874           0 :             state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterConsumpRate = (CondInletHumRat - OutdoorHumRat) * CondAirMassFlow / RhoWater;
   13875           0 :             state.dataDXCoils->DXCoil(DXCoilNum).EvapCondPumpElecPower = EvapCondPumpElecPower;
   13876             :             // set water system demand request (if needed)
   13877           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterSupplyMode == EvapWaterSupply::FromTank) {
   13878           0 :                 state.dataWaterData->WaterStorage(state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterSupTankID)
   13879           0 :                     .VdotRequestDemand(state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterTankDemandARRID) =
   13880           0 :                     state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterConsumpRate;
   13881             :             }
   13882             : 
   13883             :             // Calculate basin heater power
   13884           0 :             CalcBasinHeaterPower(state,
   13885           0 :                                  state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterPowerFTempDiff,
   13886           0 :                                  state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterSchedulePtr,
   13887           0 :                                  state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterSetPointTemp,
   13888           0 :                                  state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterPower);
   13889           0 :             state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterPower *= (1.0 - state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction);
   13890             :         }
   13891             : 
   13892             :     } else {
   13893             : 
   13894             :         // DX coil is off; just pass through conditions
   13895     4129057 :         state.dataDXCoils->DXCoil(DXCoilNum).OutletAirEnthalpy = state.dataDXCoils->DXCoil(DXCoilNum).InletAirEnthalpy;
   13896     4129057 :         state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat = state.dataDXCoils->DXCoil(DXCoilNum).InletAirHumRat;
   13897     4129057 :         state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp = state.dataDXCoils->DXCoil(DXCoilNum).InletAirTemp;
   13898             : 
   13899     4129057 :         state.dataDXCoils->DXCoil(DXCoilNum).FuelUsed = 0.0;
   13900     4129057 :         state.dataDXCoils->DXCoil(DXCoilNum).ElecCoolingPower = 0.0;
   13901     4129057 :         state.dataDXCoils->DXCoil(DXCoilNum).TotalCoolingEnergyRate = 0.0;
   13902     4129057 :         state.dataDXCoils->DXCoil(DXCoilNum).SensCoolingEnergyRate = 0.0;
   13903     4129057 :         state.dataDXCoils->DXCoil(DXCoilNum).LatCoolingEnergyRate = 0.0;
   13904     4129057 :         state.dataDXCoils->DXCoil(DXCoilNum).EvapCondPumpElecPower = 0.0;
   13905     4129057 :         state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterConsumpRate = 0.0;
   13906             : 
   13907     4129057 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CompanionUpstreamDXCoil == 0) {
   13908     4129057 :             state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterPower = CrankcaseHeatingPower;
   13909             :         } else {
   13910           0 :             state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterPower =
   13911           0 :                 CrankcaseHeatingPower *
   13912           0 :                 (1.0 - state.dataDXCoils->DXCoil(state.dataDXCoils->DXCoil(DXCoilNum).CompanionUpstreamDXCoil).HeatingCoilRuntimeFraction);
   13913             :         }
   13914             : 
   13915             :         // Calculate basin heater power
   13916     4129057 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(DXMode) == DataHeatBalance::RefrigCondenserType::Evap) {
   13917           0 :             CalcBasinHeaterPower(state,
   13918           0 :                                  state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterPowerFTempDiff,
   13919           0 :                                  state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterSchedulePtr,
   13920           0 :                                  state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterSetPointTemp,
   13921           0 :                                  state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterPower);
   13922             :         }
   13923             :     }
   13924             : 
   13925     6761048 :     state.dataDXCoils->DXCoilOutletTemp(DXCoilNum) = state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp;
   13926     6761048 :     state.dataDXCoils->DXCoilOutletHumRat(DXCoilNum) = state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat;
   13927     6761048 :     state.dataDXCoils->DXCoilPartLoadRatio(DXCoilNum) = state.dataDXCoils->DXCoil(DXCoilNum).PartLoadRatio;
   13928     6761048 :     state.dataDXCoils->DXCoilFanOpMode(DXCoilNum) = FanOpMode;
   13929     6761048 :     state.dataDXCoils->DXCoil(DXCoilNum).CondInletTemp = CondInletTemp; // Save condenser inlet temp in the data structure
   13930             : 
   13931             :     // set outlet node conditions
   13932     6761048 :     int airOutletNode = state.dataDXCoils->DXCoil(DXCoilNum).AirOutNode;
   13933     6761048 :     state.dataLoopNodes->Node(airOutletNode).Temp = state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp;
   13934     6761048 :     state.dataLoopNodes->Node(airOutletNode).HumRat = state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat;
   13935             : 
   13936             :     // calc secondary coil if specified
   13937     6761048 :     if (state.dataDXCoils->DXCoil(DXCoilNum).IsSecondaryDXCoilInZone) {
   13938           0 :         CalcSecondaryDXCoils(state, DXCoilNum);
   13939             :     }
   13940     6761048 : }
   13941             : 
   13942     4644740 : void CalcMultiSpeedDXCoilHeating(EnergyPlusData &state,
   13943             :                                  int const DXCoilNum,     // the number of the DX heating coil to be simulated
   13944             :                                  Real64 const SpeedRatio, // = (CompressorSpeed - CompressorSpeedMin) / (CompressorSpeedMax - CompressorSpeedMin)
   13945             :                                  Real64 const CycRatio,   // cycling part load ratio
   13946             :                                  int const SpeedNum,      // Speed number
   13947             :                                  int const FanOpMode,     // Fan operation mode
   13948             :                                  int const SingleMode     // Single mode operation Yes/No; 1=Yes, 0=No
   13949             : )
   13950             : {
   13951             : 
   13952             :     // SUBROUTINE INFORMATION:
   13953             :     //       AUTHOR         Lixing Gu, FSEC
   13954             :     //       DATE WRITTEN   June 2007
   13955             :     //       RE-ENGINEERED  Revised based on CalcDXHeatingCoil
   13956             : 
   13957             :     // PURPOSE OF THIS SUBROUTINE:
   13958             :     // Calculates the air-side performance and electrical energy use of a direct-
   13959             :     // expansion, air-cooled cooling unit with a multispeed compressor.
   13960             : 
   13961             :     // METHODOLOGY EMPLOYED:
   13962             :     // Uses the same methodology as the single speed DX heating unit model (SUBROUTINE CalcDXHeatingCoil).
   13963             :     // In addition it assumes that the unit performance is obtained by interpolating between
   13964             :     // the performance at high speed and that at low speed. If the output needed is below
   13965             :     // that produced at low speed, the compressor cycles between off and low speed.
   13966             : 
   13967             :     // Using/Aliasing
   13968             :     using Curve::CurveValue;
   13969     4644740 :     auto &MSHPMassFlowRateHigh = state.dataHVACGlobal->MSHPMassFlowRateHigh;
   13970     4644740 :     auto &MSHPMassFlowRateLow = state.dataHVACGlobal->MSHPMassFlowRateLow;
   13971     4644740 :     auto &MSHPWasteHeat = state.dataHVACGlobal->MSHPWasteHeat;
   13972             : 
   13973             :     // SUBROUTINE ARGUMENT DEFINITIONS:
   13974             :     // SpeedRatio varies between 1.0 (maximum speed) and 0.0 (minimum speed)
   13975             : 
   13976             :     // SUBROUTINE PARAMETER DEFINITIONS:
   13977             :     static constexpr std::string_view RoutineName("CalcMultiSpeedDXCoilHeating");
   13978             :     static constexpr std::string_view RoutineNameAverageLoad("CalcMultiSpeedDXCoilHeating:Averageload");
   13979             :     static constexpr std::string_view RoutineNameFullLoad("CalcMultiSpeedDXCoilHeating:fullload");
   13980             : 
   13981             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   13982             :     Real64 AirMassFlow;         // dry air mass flow rate through coil [kg/s]
   13983             :     Real64 InletAirWetBulbC;    // wetbulb temperature of inlet air [C]
   13984             :     Real64 InletAirDryBulbTemp; // inlet air dry bulb temperature [C]
   13985             :     Real64 InletAirEnthalpy;    // inlet air enthalpy [J/kg]
   13986             :     Real64 InletAirHumRat;      // inlet air humidity ratio [kg/kg]
   13987             :     Real64 OutletAirEnthalpy;   // outlet air enthalpy [J/kg]
   13988             :     Real64 OutletAirHumRat;     // outlet air humidity ratio [kg/kg]
   13989             :     Real64 TotCapHS;            // total capacity at high speed [W]
   13990             :     Real64 TotCapLS;            // total capacity at low speed [W]
   13991             :     Real64 TotCapHSAdj;         // total adjusted capacity at high speed [W]
   13992             :     Real64 TotCapLSAdj;         // total adjusted capacity at low speed [W]
   13993             :     Real64 EIRHS;               // EIR at off rated conditions (high speed)
   13994             :     Real64 EIRLS;               // EIR at off rated conditions (low speed)
   13995             :     Real64 TotCap;              // total capacity at current speed [W]
   13996             :     Real64 TotCapAdj;           // total adjusted capacity at current speed [W]
   13997             :     Real64 EIR;                 // EIR at current speed
   13998             :     Real64 PLF;                 // Part load factor, accounts for thermal lag at compressor startup, used in
   13999             :     // power calculation
   14000             :     Real64 OutdoorDryBulb;            // Outdoor dry-bulb temperature at condenser (C)
   14001             :     Real64 OutdoorHumRat;             // Outdoor humidity ratio at condenser (kg/kg)
   14002             :     Real64 OutdoorPressure;           // Outdoor barometric pressure at condenser (Pa)
   14003             :     int SpeedNumHS;                   // High speed number
   14004             :     int SpeedNumLS;                   // Low speed number
   14005             :     Real64 AirMassFlowRatioLS;        // airflow ratio at low speed
   14006             :     Real64 AirMassFlowRatioHS;        // airflow ratio at high speed
   14007             :     Real64 AirFlowRatio;              // Airflow ratio
   14008             :     Real64 PLRHeating;                // Part load ratio in heating
   14009             :     Real64 CrankcaseHeatingPower;     // Power due to crank case heater
   14010             :     Real64 AirVolumeFlowRate;         // Air volume flow rate across the heating coil
   14011             :     Real64 VolFlowperRatedTotCap;     // Air volume flow rate divided by rated total heating capacity
   14012     4644740 :     Real64 TotCapTempModFac(0.0);     // Total capacity modifier as a function ot temperature
   14013             :     Real64 TotCapFlowModFac;          // Total capacity modifier as a function of flow ratio
   14014             :     Real64 OutdoorCoilT;              // Outdoor coil temperature
   14015             :     Real64 OutdoorCoildw;             // Outdoor coil delta w assuming coil temperature of OutdoorCoilT
   14016             :     Real64 LoadDueToDefrost;          // Additonal load due to defrost
   14017             :     Real64 LoadDueToDefrostLS;        // Additonal load due to defrost at low speed
   14018             :     Real64 LoadDueToDefrostHS;        // Additonal load due to defrost at high speed
   14019             :     Real64 HeatingCapacityMultiplier; // Multiplier for heating capacity when system is in defrost
   14020             :     Real64 FractionalDefrostTime;     // Fraction of time step when system is in defrost
   14021             :     Real64 InputPowerMultiplier;      // Multiplier for poer when system is in defrost
   14022             :     Real64 DefrostEIRTempModFac;      // EIR modifier for defrost
   14023             :     Real64 FullLoadOutAirEnth;        // Outlet full load enthalpy
   14024             :     Real64 FullLoadOutAirHumRat;      // Outlet humidity ratio at full load
   14025             :     Real64 FullLoadOutAirTemp;        // Outlet temperature at full load
   14026             :     Real64 FullLoadOutAirRH;          // Outler relative humidity at full load
   14027             :     Real64 OutletAirTemp;             // Supply ari temperature
   14028     4644740 :     Real64 EIRTempModFac(0.0);        // EIR modifier as a function of temperature
   14029             :     Real64 EIRFlowModFac;             // EIR modifier as a function of airflow ratio
   14030             :     Real64 WasteHeatLS;               // Waste heat at low speed
   14031             :     Real64 WasteHeatHS;               // Waste heat at high speed
   14032             :     Real64 LSFullLoadOutAirEnth;      // Outlet full load enthalpy at low speed
   14033             :     Real64 HSFullLoadOutAirEnth;      // Outlet full load enthalpy at high speed
   14034             :     Real64 LSElecHeatingPower;        // Full load power at low speed
   14035             :     Real64 HSElecHeatingPower;        // Full load power at high speed
   14036             :     Real64 DefrostPowerLS;            // Defrost power at low speed [W]
   14037             :     Real64 DefrostPowerHS;            // Defrost power at high speed [W]
   14038             : 
   14039             :     // Autodesk:Uninit Initialize variables used uninitialized
   14040     4644740 :     FullLoadOutAirEnth = 0.0; // Autodesk:Uninit Force default initialization
   14041             : 
   14042     4644740 :     auto &DXCT = state.dataHVACGlobal->DXCT;
   14043             : 
   14044     4644740 :     if (SpeedNum > 1) {
   14045     1259819 :         SpeedNumLS = SpeedNum - 1;
   14046     1259819 :         SpeedNumHS = SpeedNum;
   14047     1259819 :         if (SpeedNum > state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds) {
   14048           0 :             SpeedNumLS = state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds - 1;
   14049           0 :             SpeedNumHS = state.dataDXCoils->DXCoil(DXCoilNum).NumOfSpeeds;
   14050             :         }
   14051             :     } else {
   14052     3384921 :         SpeedNumLS = 1;
   14053     3384921 :         SpeedNumHS = 1;
   14054             :     }
   14055             : 
   14056     4644740 :     AirMassFlow = state.dataDXCoils->DXCoil(DXCoilNum).InletAirMassFlowRate;
   14057     4644740 :     AirMassFlowRatioLS = MSHPMassFlowRateLow / state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirMassFlowRate(SpeedNumLS);
   14058     4644740 :     AirMassFlowRatioHS = MSHPMassFlowRateHigh / state.dataDXCoils->DXCoil(DXCoilNum).MSRatedAirMassFlowRate(SpeedNumHS);
   14059     4644740 :     if ((AirMassFlow > 0.0) && (CycRatio > 0.0) && (MSHPMassFlowRateHigh == 0.0)) {
   14060           0 :         ShowSevereError(state,
   14061           0 :                         "CalcMultiSpeedDXCoilHeating: " + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + " \"" +
   14062           0 :                             state.dataDXCoils->DXCoil(DXCoilNum).Name + " Developer error - inconsistent airflow rates.");
   14063           0 :         if (MSHPMassFlowRateLow == 0.0 && SpeedNum > 1) {
   14064           0 :             ShowContinueError(state,
   14065             :                               "When AirMassFlow > 0.0 and CycRatio > 0.0 and SpeedNum > 1, then MSHPMassFlowRateLow and MSHPMassFlowRateHigh "
   14066             :                               "must also be > 0.0");
   14067           0 :             ShowContinueErrorTimeStamp(state, "");
   14068           0 :             ShowContinueError(state,
   14069           0 :                               format("AirMassFlow={:.3R},CycRatio={:.3R},SpeedNum={:.0R}, MSHPMassFlowRateLow={:.3R}, MSHPMassFlowRateHigh={:.3R}",
   14070             :                                      AirMassFlow,
   14071           0 :                                      double(SpeedNum),
   14072             :                                      CycRatio,
   14073             :                                      MSHPMassFlowRateLow,
   14074           0 :                                      MSHPMassFlowRateHigh));
   14075           0 :             ShowFatalError(state, "Preceding condition(s) causes termination.");
   14076             :         } else {
   14077           0 :             ShowContinueError(state, "When AirMassFlow > 0.0 and CycRatio > 0.0, then MSHPMassFlowRateHigh must also be > 0.0");
   14078           0 :             ShowContinueErrorTimeStamp(state, "");
   14079           0 :             ShowContinueError(state,
   14080           0 :                               format("AirMassFlow={:.3R},CycRatio={:.3R}, MSHPMassFlowRateHigh={:.3R}", AirMassFlow, CycRatio, MSHPMassFlowRateHigh));
   14081           0 :             ShowFatalError(state, "Preceding condition(s) causes termination.");
   14082             :         }
   14083     4644740 :     } else if (CycRatio > 1.0 || SpeedRatio > 1.0) {
   14084           0 :         ShowSevereError(state,
   14085           0 :                         "CalcMultiSpeedDXCoilHeating: " + state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + " \"" +
   14086           0 :                             state.dataDXCoils->DXCoil(DXCoilNum).Name + " Developer error - inconsistent speed ratios.");
   14087           0 :         ShowContinueError(state, "CycRatio and SpeedRatio must be between 0.0 and 1.0");
   14088           0 :         ShowContinueErrorTimeStamp(state, "");
   14089           0 :         ShowContinueError(state, format("CycRatio={:.1R}, SpeedRatio = {:.1R}", CycRatio, SpeedRatio));
   14090           0 :         ShowFatalError(state, "Preceding condition(s) causes termination.");
   14091             :     }
   14092             : 
   14093     4644740 :     AirFlowRatio = 1.0;
   14094     4644740 :     if (state.dataDXCoils->DXCoil(DXCoilNum).CompanionUpstreamDXCoil == 0) MSHPWasteHeat = 0.0;
   14095             : 
   14096             :     // Get condenser outdoor node info from DX Heating Coil
   14097     4644740 :     if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(1) != 0) {
   14098     3944655 :         OutdoorPressure = state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(1)).Press;
   14099             :         // If node is not connected to anything, pressure = default, use weather data
   14100     3944655 :         if (OutdoorPressure == state.dataLoopNodes->DefaultNodeValues.Press) {
   14101           0 :             OutdoorDryBulb = state.dataEnvrn->OutDryBulbTemp;
   14102           0 :             OutdoorHumRat = state.dataEnvrn->OutHumRat;
   14103           0 :             OutdoorPressure = state.dataEnvrn->OutBaroPress;
   14104             :         } else {
   14105     3944655 :             OutdoorDryBulb = state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(1)).Temp;
   14106     3944655 :             OutdoorHumRat = state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(1)).HumRat;
   14107             :         }
   14108     3944655 :         if (state.dataDXCoils->DXCoil(DXCoilNum).IsSecondaryDXCoilInZone) {
   14109           0 :             auto &secZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(state.dataDXCoils->DXCoil(DXCoilNum).SecZonePtr);
   14110           0 :             OutdoorDryBulb = secZoneHB.ZT;
   14111           0 :             OutdoorHumRat = secZoneHB.ZoneAirHumRat;
   14112             :             // OutdoorWetBulb = DXCoil( DXCoilNum ).EvapInletWetBulb;
   14113           0 :             OutdoorPressure = state.dataEnvrn->OutBaroPress;
   14114             :         }
   14115      700085 :     } else if (state.dataDXCoils->DXCoil(DXCoilNum).IsSecondaryDXCoilInZone) {
   14116           0 :         auto &secZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(state.dataDXCoils->DXCoil(DXCoilNum).SecZonePtr);
   14117           0 :         OutdoorDryBulb = secZoneHB.ZT;
   14118           0 :         OutdoorHumRat = secZoneHB.ZoneAirHumRat;
   14119             :         // OutdoorWetBulb = DXCoil( DXCoilNum ).EvapInletWetBulb;
   14120           0 :         OutdoorPressure = state.dataEnvrn->OutBaroPress;
   14121             :     } else {
   14122      700085 :         OutdoorDryBulb = state.dataEnvrn->OutDryBulbTemp;
   14123      700085 :         OutdoorHumRat = state.dataEnvrn->OutHumRat;
   14124      700085 :         OutdoorPressure = state.dataEnvrn->OutBaroPress;
   14125             :     }
   14126             : 
   14127     4644740 :     InletAirDryBulbTemp = state.dataDXCoils->DXCoil(DXCoilNum).InletAirTemp;
   14128     4644740 :     InletAirEnthalpy = state.dataDXCoils->DXCoil(DXCoilNum).InletAirEnthalpy;
   14129     4644740 :     InletAirHumRat = state.dataDXCoils->DXCoil(DXCoilNum).InletAirHumRat;
   14130             :     //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   14131             :     // InletAirPressure = DXCoil(DXCoilNum)%InletAirPressure
   14132             :     // InletAirWetBulbC = PsyTwbFnTdbWPb(InletAirDryBulbTemp,InletAirHumRat,InletAirPressure)
   14133     4644740 :     InletAirWetBulbC = PsyTwbFnTdbWPb(state, InletAirDryBulbTemp, InletAirHumRat, OutdoorPressure, RoutineName);
   14134     4644740 :     PLRHeating = 0.0;
   14135     4644740 :     state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction = 0.0;
   14136             :     // Initialize crankcase heater, operates below OAT defined in input deck for HP DX heating coil
   14137     4644740 :     if (OutdoorDryBulb < state.dataDXCoils->DXCoil(DXCoilNum).MaxOATCrankcaseHeater) {
   14138     1491164 :         CrankcaseHeatingPower = state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterCapacity;
   14139             :     } else {
   14140     3153576 :         CrankcaseHeatingPower = 0.0;
   14141             :     }
   14142     4644740 :     state.dataDXCoils->DXCoil(DXCoilNum).PartLoadRatio = 0.0;
   14143     4644740 :     state.dataHeatBal->HeatReclaimDXCoil(DXCoilNum).AvailCapacity = 0.0;
   14144             : 
   14145    16336902 :     if ((AirMassFlow > 0.0) && (GetCurrentScheduleValue(state, state.dataDXCoils->DXCoil(DXCoilNum).SchedPtr) > 0.0) &&
   14146    11322026 :         ((CycRatio > 0.0) || (SpeedRatio > 0.0 && SingleMode == 0)) && OutdoorDryBulb > state.dataDXCoils->DXCoil(DXCoilNum).MinOATCompressor) {
   14147             : 
   14148      372549 :         if (SpeedNum > 1 && SingleMode == 0) {
   14149             : 
   14150             :             // Check for valid air volume flow per rated total cooling capacity (200 - 600 cfm/ton) at low speed
   14151      302465 :             AirVolumeFlowRate = MSHPMassFlowRateLow / PsyRhoAirFnPbTdbW(state, OutdoorPressure, InletAirDryBulbTemp, InletAirHumRat, RoutineName);
   14152             :             //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   14153             :             //  AirVolumeFlowRate = AirMassFlow/PsyRhoAirFnPbTdbW(InletAirPressure,InletAirDryBulbTemp, InletAirHumRat)
   14154      302465 :             VolFlowperRatedTotCap = AirVolumeFlowRate / state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(SpeedNumLS);
   14155      604930 :             if ((VolFlowperRatedTotCap < state.dataHVACGlobal->MinOperVolFlowPerRatedTotCap(DXCT)) ||
   14156      302465 :                 (VolFlowperRatedTotCap > state.dataHVACGlobal->MaxHeatVolFlowPerRatedTotCap(DXCT))) {
   14157      281075 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).MSErrIndex(SpeedNumLS) == 0) {
   14158          12 :                     ShowWarningMessage(
   14159             :                         state,
   14160          16 :                         format("{} \"{}\" - Air volume flow rate per watt of rated total heating capacity is out of range at speed {}.",
   14161           4 :                                state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
   14162           4 :                                state.dataDXCoils->DXCoil(DXCoilNum).Name,
   14163           4 :                                SpeedNumLS));
   14164           4 :                     ShowContinueErrorTimeStamp(state, "");
   14165          12 :                     ShowContinueError(state,
   14166          16 :                                       format("Expected range for VolumeFlowPerRatedTotalCapacity=[{:.3R}--{:.3R}] Current value is {:.3R} m3/s/W",
   14167           4 :                                              state.dataHVACGlobal->MinOperVolFlowPerRatedTotCap(DXCT),
   14168           4 :                                              state.dataHVACGlobal->MaxHeatVolFlowPerRatedTotCap(DXCT),
   14169           4 :                                              VolFlowperRatedTotCap));
   14170           4 :                     ShowContinueError(state, "Possible causes include inconsistent air flow rates in system components or");
   14171           4 :                     ShowContinueError(state, "inconsistent supply air fan operation modes in coil and unitary system objects.");
   14172             :                 }
   14173     1124300 :                 ShowRecurringWarningErrorAtEnd(state,
   14174     1124300 :                                                format("{} \"{}\" - Air volume flow rate per watt of rated total heating capacity is out of range "
   14175             :                                                       "at speed {} error continues...",
   14176      281075 :                                                       state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
   14177      281075 :                                                       state.dataDXCoils->DXCoil(DXCoilNum).Name,
   14178      281075 :                                                       SpeedNumLS),
   14179      281075 :                                                state.dataDXCoils->DXCoil(DXCoilNum).MSErrIndex(SpeedNumLS),
   14180             :                                                VolFlowperRatedTotCap,
   14181             :                                                VolFlowperRatedTotCap);
   14182             :             }
   14183             : 
   14184             :             // Check for valid air volume flow per rated total cooling capacity (200 - 600 cfm/ton) at high speed
   14185      302465 :             AirVolumeFlowRate = MSHPMassFlowRateHigh / PsyRhoAirFnPbTdbW(state, OutdoorPressure, InletAirDryBulbTemp, InletAirHumRat, RoutineName);
   14186             :             //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   14187             :             //  AirVolumeFlowRate = AirMassFlow/PsyRhoAirFnPbTdbW(InletAirPressure,InletAirDryBulbTemp, InletAirHumRat)
   14188      302465 :             VolFlowperRatedTotCap = AirVolumeFlowRate / state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(SpeedNumHS);
   14189      604930 :             if ((VolFlowperRatedTotCap < state.dataHVACGlobal->MinOperVolFlowPerRatedTotCap(DXCT)) ||
   14190      302465 :                 (VolFlowperRatedTotCap > state.dataHVACGlobal->MaxHeatVolFlowPerRatedTotCap(DXCT))) {
   14191      281006 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).MSErrIndex(SpeedNumHS) == 0) {
   14192           6 :                     ShowWarningMessage(
   14193             :                         state,
   14194           8 :                         format("{} \"{}\" - Air volume flow rate per watt of rated total heating capacity is out of range at speed {}.",
   14195           2 :                                state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
   14196           2 :                                state.dataDXCoils->DXCoil(DXCoilNum).Name,
   14197           2 :                                SpeedNumHS));
   14198           2 :                     ShowContinueErrorTimeStamp(state, "");
   14199           6 :                     ShowContinueError(state,
   14200           8 :                                       format("Expected range for VolumeFlowPerRatedTotalCapacity=[{:.3R}--{:.3R}] Current value is {:.3R} m3/s/W",
   14201           2 :                                              state.dataHVACGlobal->MinOperVolFlowPerRatedTotCap(DXCT),
   14202           2 :                                              state.dataHVACGlobal->MaxHeatVolFlowPerRatedTotCap(DXCT),
   14203           2 :                                              VolFlowperRatedTotCap));
   14204           2 :                     ShowContinueError(state, "Possible causes include inconsistent air flow rates in system components or");
   14205           2 :                     ShowContinueError(state, "inconsistent supply air fan operation modes in coil and unitary system objects.");
   14206             :                 }
   14207     1124024 :                 ShowRecurringWarningErrorAtEnd(state,
   14208     1124024 :                                                format("{} \"{}\" - Air volume flow rate per watt of rated total heating capacity is out of range "
   14209             :                                                       "at speed {} error continues...",
   14210      281006 :                                                       state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
   14211      281006 :                                                       state.dataDXCoils->DXCoil(DXCoilNum).Name,
   14212      281006 :                                                       SpeedNumHS),
   14213      281006 :                                                state.dataDXCoils->DXCoil(DXCoilNum).MSErrIndex(SpeedNumHS),
   14214             :                                                VolFlowperRatedTotCap,
   14215             :                                                VolFlowperRatedTotCap);
   14216             :             }
   14217             : 
   14218             :             // Get total capacity modifying factor (function of temperature) for off-rated conditions
   14219             :             // Model was extended to accept bi-quadratic curves. This allows sensitivity of the heating capacity
   14220             :             // to the entering dry-bulb temperature as well as the outside dry-bulb temperature. User is
   14221             :             // advised to use the bi-quaratic curve if sufficient manufacturer data is available.
   14222             :             // Low speed
   14223      302465 :             if (state.dataCurveManager->PerfCurve(state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFTemp(SpeedNumLS)).numDims == 1) {
   14224           0 :                 TotCapTempModFac = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFTemp(SpeedNumLS), OutdoorDryBulb);
   14225             :             } else {
   14226      302465 :                 TotCapTempModFac =
   14227      604930 :                     CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFTemp(SpeedNumLS), InletAirDryBulbTemp, OutdoorDryBulb);
   14228             :             }
   14229             :             //  Get total capacity modifying factor (function of mass flow) for off-rated conditions
   14230      302465 :             TotCapFlowModFac = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFFlow(SpeedNumLS), AirMassFlowRatioLS);
   14231             :             // Calculate total heating capacity for off-rated conditions
   14232      302465 :             TotCapLS = state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(SpeedNumLS) * TotCapFlowModFac * TotCapTempModFac;
   14233             :             // High speed
   14234      302465 :             if (state.dataCurveManager->PerfCurve(state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFTemp(SpeedNumHS)).numDims == 1) {
   14235           0 :                 TotCapTempModFac = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFTemp(SpeedNumHS), OutdoorDryBulb);
   14236             :             } else {
   14237      302465 :                 TotCapTempModFac =
   14238      604930 :                     CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFTemp(SpeedNumHS), InletAirDryBulbTemp, OutdoorDryBulb);
   14239             :             }
   14240             :             //  Get total capacity modifying factor (function of mass flow) for off-rated conditions
   14241      302465 :             TotCapFlowModFac = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFFlow(SpeedNumHS), AirMassFlowRatioHS);
   14242             :             // Calculate total heating capacity for off-rated conditions
   14243      302465 :             TotCapHS = state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(SpeedNumHS) * TotCapFlowModFac * TotCapTempModFac;
   14244             :             // Calculate electricity consumed. First, get EIR modifying factors for off-rated conditions
   14245             :             // Model was extended to accept bi-quadratic curves. This allows sensitivity of the EIR
   14246             :             // to the entering dry-bulb temperature as well as the outside dry-bulb temperature. User is
   14247             :             // advised to use the bi-quaratic curve if sufficient manufacturer data is available.
   14248             :             // Low Speed
   14249      302465 :             if (state.dataCurveManager->PerfCurve(state.dataDXCoils->DXCoil(DXCoilNum).MSEIRFTemp(SpeedNumLS)).numDims == 1) {
   14250           0 :                 EIRTempModFac = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).MSEIRFTemp(SpeedNumLS), OutdoorDryBulb);
   14251             :             } else {
   14252      302465 :                 EIRTempModFac = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).MSEIRFTemp(SpeedNumLS), InletAirDryBulbTemp, OutdoorDryBulb);
   14253             :             }
   14254      302465 :             EIRFlowModFac = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).MSEIRFFlow(SpeedNumLS), AirMassFlowRatioLS);
   14255      302465 :             EIRLS = 1.0 / state.dataDXCoils->DXCoil(DXCoilNum).MSRatedCOP(SpeedNumLS) * EIRTempModFac * EIRFlowModFac;
   14256             :             // High Speed
   14257      302465 :             if (state.dataCurveManager->PerfCurve(state.dataDXCoils->DXCoil(DXCoilNum).MSEIRFTemp(SpeedNumHS)).numDims == 1) {
   14258           0 :                 EIRTempModFac = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).MSEIRFTemp(SpeedNumHS), OutdoorDryBulb);
   14259             :             } else {
   14260      302465 :                 EIRTempModFac = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).MSEIRFTemp(SpeedNumHS), InletAirDryBulbTemp, OutdoorDryBulb);
   14261             :             }
   14262      302465 :             EIRFlowModFac = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).MSEIRFFlow(SpeedNumHS), AirMassFlowRatioHS);
   14263      302465 :             EIRHS = 1.0 / state.dataDXCoils->DXCoil(DXCoilNum).MSRatedCOP(SpeedNumHS) * EIRTempModFac * EIRFlowModFac;
   14264             : 
   14265             :             // Calculating adjustment factors for defrost
   14266             :             // Calculate delta w through outdoor coil by assuming a coil temp of 0.82*DBT-9.7(F) per DOE2.1E
   14267      302465 :             OutdoorCoilT = 0.82 * OutdoorDryBulb - 8.589;
   14268      302465 :             OutdoorCoildw = max(1.0e-6, (OutdoorHumRat - PsyWFnTdpPb(state, OutdoorCoilT, OutdoorPressure, RoutineName)));
   14269             : 
   14270             :             // Initializing defrost adjustment factors
   14271      302465 :             LoadDueToDefrostLS = 0.0;
   14272      302465 :             LoadDueToDefrostHS = 0.0;
   14273      302465 :             HeatingCapacityMultiplier = 1.0;
   14274      302465 :             FractionalDefrostTime = 0.0;
   14275      302465 :             InputPowerMultiplier = 1.0;
   14276      302465 :             DefrostPowerLS = 0.0;
   14277      302465 :             DefrostPowerHS = 0.0;
   14278             : 
   14279             :             // Check outdoor temperature to determine of defrost is active
   14280      302465 :             if (OutdoorDryBulb <= state.dataDXCoils->DXCoil(DXCoilNum).MaxOATDefrost) {
   14281             :                 // Calculate defrost adjustment factors depending on defrost control type
   14282      301258 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).DefrostControl == StandardRatings::HPdefrostControl::Timed) {
   14283      301258 :                     FractionalDefrostTime = state.dataDXCoils->DXCoil(DXCoilNum).DefrostTime;
   14284      301258 :                     if (FractionalDefrostTime > 0.0) {
   14285      301258 :                         HeatingCapacityMultiplier = 0.909 - 107.33 * OutdoorCoildw;
   14286      301258 :                         InputPowerMultiplier = 0.90 - 36.45 * OutdoorCoildw;
   14287             :                     }
   14288             :                 } else { // else defrost control is on-demand
   14289           0 :                     FractionalDefrostTime = 1.0 / (1.0 + 0.01446 / OutdoorCoildw);
   14290           0 :                     HeatingCapacityMultiplier = 0.875 * (1.0 - FractionalDefrostTime);
   14291           0 :                     InputPowerMultiplier = 0.954 * (1.0 - FractionalDefrostTime);
   14292             :                 }
   14293             : 
   14294      301258 :                 if (FractionalDefrostTime > 0.0) {
   14295             :                     // Calculate defrost adjustment factors depending on defrost control strategy
   14296      602516 :                     if (state.dataDXCoils->DXCoil(DXCoilNum).DefrostStrategy == StandardRatings::DefrostStrat::ReverseCycle &&
   14297      301258 :                         state.dataDXCoils->DXCoil(DXCoilNum).DefrostControl == StandardRatings::HPdefrostControl::OnDemand) {
   14298           0 :                         DefrostEIRTempModFac = CurveValue(
   14299           0 :                             state, state.dataDXCoils->DXCoil(DXCoilNum).DefrostEIRFT, max(15.555, InletAirWetBulbC), max(15.555, OutdoorDryBulb));
   14300           0 :                         LoadDueToDefrostLS = (0.01 * FractionalDefrostTime) * (7.222 - OutdoorDryBulb) *
   14301           0 :                                              (state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(SpeedNumLS) / 1.01667);
   14302           0 :                         DefrostPowerLS =
   14303           0 :                             DefrostEIRTempModFac * (state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(SpeedNumLS) / 1.01667) * FractionalDefrostTime;
   14304           0 :                         LoadDueToDefrostHS = (0.01 * FractionalDefrostTime) * (7.222 - OutdoorDryBulb) *
   14305           0 :                                              (state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(SpeedNumHS) / 1.01667);
   14306           0 :                         DefrostPowerHS =
   14307           0 :                             DefrostEIRTempModFac * (state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(SpeedNumHS) / 1.01667) * FractionalDefrostTime;
   14308             :                     } else { // Defrost strategy is resistive
   14309      301258 :                         state.dataDXCoils->DXCoil(DXCoilNum).DefrostPower =
   14310      301258 :                             state.dataDXCoils->DXCoil(DXCoilNum).DefrostCapacity * FractionalDefrostTime;
   14311             :                     }
   14312             :                 } else { // Defrost is not active because (OutDryBulbTemp .GT. DXCoil(DXCoilNum)%MaxOATDefrost)
   14313           0 :                     state.dataDXCoils->DXCoil(DXCoilNum).DefrostPower = 0.0;
   14314             :                 }
   14315             :             }
   14316             : 
   14317      302465 :             TotCapLSAdj = TotCapLS * HeatingCapacityMultiplier;
   14318      302465 :             TotCapHSAdj = TotCapHS * HeatingCapacityMultiplier;
   14319             : 
   14320             :             // Calculate modified PartLoadRatio due to defrost (reverse-cycle defrost only)
   14321      302465 :             PLRHeating = min(1.0, (SpeedRatio + LoadDueToDefrostHS / TotCapHSAdj));
   14322      302465 :             PLF = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).MSPLFFPLR(SpeedNumHS), PLRHeating); // Calculate part-load factor
   14323             : 
   14324      302465 :             if (PLF < 0.7) {
   14325           0 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).PLRErrIndex == 0) {
   14326           0 :                     ShowWarningMessage(
   14327             :                         state,
   14328           0 :                         format("The PLF curve value at high speed for DX multispeed heating coil {} ={:.2R} for part-load ratio ={:.2R}",
   14329           0 :                                state.dataDXCoils->DXCoil(DXCoilNum).Name,
   14330             :                                PLF,
   14331           0 :                                PLRHeating));
   14332           0 :                     ShowContinueError(state, "PLF curve values must be >= 0.7. PLF has been reset to 0.7 and simulation is continuing.");
   14333           0 :                     ShowContinueError(state, "Check the IO reference manual for PLF curve guidance [Coil:Heating:DX:MultiSpeed].");
   14334           0 :                     ShowContinueErrorTimeStamp(state, "");
   14335             :                 }
   14336           0 :                 ShowRecurringWarningErrorAtEnd(
   14337           0 :                     state, "DX heating coil PLF curve < 0.7 warning continues... ", state.dataDXCoils->DXCoil(DXCoilNum).PLRErrIndex, PLF, PLF);
   14338           0 :                 PLF = 0.7;
   14339             :             }
   14340             : 
   14341      302465 :             state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction = (PLRHeating / PLF);
   14342      302465 :             if (state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction > 1.0 &&
   14343           0 :                 std::abs(state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction - 1.0) > 0.001) {
   14344           0 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).ErrIndex4 == 0) {
   14345           0 :                     ShowWarningMessage(state,
   14346           0 :                                        format("The runtime fraction at high speed for DX multispeed heating coil {} exceeded 1.0. [{:.4R}].",
   14347           0 :                                               state.dataDXCoils->DXCoil(DXCoilNum).Name,
   14348           0 :                                               state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction));
   14349           0 :                     ShowContinueError(state, "Runtime fraction is set to 1.0 and the simulation continues...");
   14350           0 :                     ShowContinueError(state, "Check the IO reference manual for PLF curve guidance [Coil:Heating:DX:SingleSpeed].");
   14351           0 :                     ShowContinueErrorTimeStamp(state, "");
   14352             :                 }
   14353           0 :                 ShowRecurringWarningErrorAtEnd(state,
   14354           0 :                                                state.dataDXCoils->DXCoil(DXCoilNum).Name +
   14355             :                                                    ", DX heating coil runtime fraction > 1.0 warning continues...",
   14356           0 :                                                state.dataDXCoils->DXCoil(DXCoilNum).ErrIndex4,
   14357           0 :                                                state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction,
   14358           0 :                                                state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction);
   14359           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction = 1.0; // Reset coil runtime fraction to 1.0
   14360      302465 :             } else if (state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction > 1.0) {
   14361           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction = 1.0; // Reset coil runtime fraction to 1.0
   14362             :             }
   14363             : 
   14364             :             // Get full load output and power
   14365      302465 :             LSFullLoadOutAirEnth = InletAirEnthalpy + TotCapLSAdj / MSHPMassFlowRateLow;
   14366      302465 :             HSFullLoadOutAirEnth = InletAirEnthalpy + TotCapHSAdj / MSHPMassFlowRateHigh;
   14367      302465 :             LSElecHeatingPower = TotCapLS * EIRLS * InputPowerMultiplier;
   14368      302465 :             HSElecHeatingPower = TotCapHS * EIRHS * InputPowerMultiplier;
   14369      302465 :             OutletAirHumRat = InletAirHumRat;
   14370             : 
   14371             :             // if cycling fan, send coil part-load fraction to on/off fan via HVACDataGlobals
   14372      302465 :             if (FanOpMode == CycFanCycCoil) state.dataHVACGlobal->OnOffFanPartLoadFraction = 1.0;
   14373             : 
   14374             :             // Power calculation
   14375      302465 :             if (!state.dataDXCoils->DXCoil(DXCoilNum).PLRImpact) {
   14376      302465 :                 state.dataDXCoils->DXCoil(DXCoilNum).ElecHeatingPower = SpeedRatio * HSElecHeatingPower + (1.0 - SpeedRatio) * LSElecHeatingPower;
   14377             :             } else {
   14378           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).ElecHeatingPower =
   14379           0 :                     state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction * HSElecHeatingPower +
   14380           0 :                     (1.0 - state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction) * LSElecHeatingPower;
   14381             :             }
   14382             : 
   14383      302465 :             state.dataDXCoils->DXCoil(DXCoilNum).TotalHeatingEnergyRate =
   14384      604930 :                 MSHPMassFlowRateHigh * (HSFullLoadOutAirEnth - InletAirEnthalpy) * SpeedRatio +
   14385      302465 :                 MSHPMassFlowRateLow * (LSFullLoadOutAirEnth - InletAirEnthalpy) * (1.0 - SpeedRatio);
   14386      604930 :             OutletAirEnthalpy = InletAirEnthalpy + state.dataDXCoils->DXCoil(DXCoilNum).TotalHeatingEnergyRate /
   14387      302465 :                                                        state.dataDXCoils->DXCoil(DXCoilNum).InletAirMassFlowRate;
   14388      302465 :             OutletAirTemp = PsyTdbFnHW(OutletAirEnthalpy, OutletAirHumRat);
   14389      302465 :             FullLoadOutAirRH = PsyRhFnTdbWPb(state, OutletAirTemp, OutletAirHumRat, OutdoorPressure, RoutineNameAverageLoad);
   14390      302465 :             if (FullLoadOutAirRH > 1.0) { // Limit to saturated conditions at FullLoadOutAirEnth
   14391           0 :                 OutletAirTemp = PsyTsatFnHPb(state,
   14392             :                                              FullLoadOutAirEnth,
   14393             :                                              OutdoorPressure,
   14394             :                                              RoutineName); // Autodesk:Uninit FullLoadOutAirEnth was possibly uninitialized
   14395           0 :                 OutletAirHumRat = PsyWFnTdbH(
   14396             :                     state, OutletAirTemp, FullLoadOutAirEnth, RoutineName); // Autodesk:Uninit FullLoadOutAirEnth was possibly uninitialized
   14397             :             }
   14398             : 
   14399             :             // Waste heat calculation
   14400      302465 :             if (state.dataDXCoils->DXCoil(DXCoilNum).FuelTypeNum != DataGlobalConstants::ResourceType::Electricity) {
   14401           0 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).MSWasteHeat(SpeedNumLS) == 0) {
   14402           0 :                     WasteHeatLS = state.dataDXCoils->DXCoil(DXCoilNum).MSWasteHeatFrac(SpeedNumLS);
   14403             :                 } else {
   14404           0 :                     WasteHeatLS =
   14405           0 :                         CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).MSWasteHeat(SpeedNumLS), OutdoorDryBulb, InletAirDryBulbTemp) *
   14406           0 :                         state.dataDXCoils->DXCoil(DXCoilNum).MSWasteHeatFrac(SpeedNumLS);
   14407             :                 }
   14408           0 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).MSWasteHeat(SpeedNumHS) == 0) {
   14409           0 :                     WasteHeatHS = state.dataDXCoils->DXCoil(DXCoilNum).MSWasteHeatFrac(SpeedNumHS);
   14410             :                 } else {
   14411           0 :                     WasteHeatHS =
   14412           0 :                         CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).MSWasteHeat(SpeedNumHS), OutdoorDryBulb, InletAirDryBulbTemp) *
   14413           0 :                         state.dataDXCoils->DXCoil(DXCoilNum).MSWasteHeatFrac(SpeedNumHS);
   14414             :                 }
   14415           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).MSFuelWasteHeat =
   14416           0 :                     (SpeedRatio * WasteHeatHS + (1.0 - SpeedRatio) * WasteHeatLS) * state.dataDXCoils->DXCoil(DXCoilNum).ElecCoolingPower;
   14417           0 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).MSHPHeatRecActive) {
   14418           0 :                     MSHPWasteHeat = state.dataDXCoils->DXCoil(DXCoilNum).MSFuelWasteHeat;
   14419             :                 }
   14420             :             }
   14421      302465 :             if (state.dataDXCoils->DXCoil(DXCoilNum).FuelTypeNum != DataGlobalConstants::ResourceType::Electricity) {
   14422             : 
   14423           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).FuelUsed = state.dataDXCoils->DXCoil(DXCoilNum).ElecHeatingPower;
   14424           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).ElecHeatingPower = 0.0;
   14425             :             }
   14426             : 
   14427             :             // Adjust defrost power to correct for DOE-2 bug where defrost power is constant regardless of compressor runtime fraction
   14428             :             // Defrosts happen based on compressor run time (frost buildup on outdoor coil), not total elapsed time.
   14429      302465 :             if (state.dataDXCoils->DXCoil(DXCoilNum).DefrostStrategy == StandardRatings::DefrostStrat::ReverseCycle) {
   14430      302465 :                 if (!state.dataDXCoils->DXCoil(DXCoilNum).PLRImpact) {
   14431      302465 :                     state.dataDXCoils->DXCoil(DXCoilNum).DefrostPower = DefrostPowerHS * SpeedRatio + DefrostPowerLS * (1.0 - SpeedRatio);
   14432             :                 } else {
   14433           0 :                     state.dataDXCoils->DXCoil(DXCoilNum).DefrostPower =
   14434           0 :                         DefrostPowerHS * state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction +
   14435           0 :                         DefrostPowerLS * (1.0 - state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction);
   14436             :                 }
   14437             :             }
   14438      302465 :             state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp = OutletAirTemp;
   14439      302465 :             state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat = OutletAirHumRat;
   14440      302465 :             state.dataDXCoils->DXCoil(DXCoilNum).OutletAirEnthalpy = OutletAirEnthalpy;
   14441      302465 :             state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterPower = 0.0;
   14442             : 
   14443             :             // Stage 1
   14444       70084 :         } else if (CycRatio > 0.0 || (CycRatio > 0.0 && SingleMode == 1)) {
   14445             : 
   14446             :             // for cycling fan, reset mass flow to full on rate
   14447       70084 :             if (FanOpMode == CycFanCycCoil) AirMassFlow /= CycRatio;
   14448       70084 :             if (FanOpMode == ContFanCycCoil) AirMassFlow = MSHPMassFlowRateHigh;
   14449             :             // Check for valid air volume flow per rated total cooling capacity (200 - 600 cfm/ton)
   14450       70084 :             AirVolumeFlowRate = AirMassFlow / PsyRhoAirFnPbTdbW(state, OutdoorPressure, InletAirDryBulbTemp, InletAirHumRat, RoutineName);
   14451             :             //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   14452             :             //  AirVolumeFlowRate = AirMassFlow/PsyRhoAirFnPbTdbW(InletAirPressure,InletAirDryBulbTemp, InletAirHumRat)
   14453       70084 :             VolFlowperRatedTotCap = AirVolumeFlowRate / state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(SpeedNum);
   14454             : 
   14455      140168 :             if ((VolFlowperRatedTotCap < state.dataHVACGlobal->MinOperVolFlowPerRatedTotCap(DXCT)) ||
   14456       70084 :                 (VolFlowperRatedTotCap > state.dataHVACGlobal->MaxHeatVolFlowPerRatedTotCap(DXCT))) {
   14457       59380 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).ErrIndex1 == 0) {
   14458          12 :                     ShowWarningMessage(state,
   14459           8 :                                        state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + " \"" + state.dataDXCoils->DXCoil(DXCoilNum).Name +
   14460             :                                            "\" - Air volume flow rate per watt of rated total heating capacity is out of range at speed 1.");
   14461           4 :                     ShowContinueErrorTimeStamp(state, "");
   14462          12 :                     ShowContinueError(state,
   14463          16 :                                       format("Expected range for VolumeFlowPerRatedTotalCapacity=[{:.3R}--{:.3R}] Current value is {:.3R} m3/s/W",
   14464           4 :                                              state.dataHVACGlobal->MinOperVolFlowPerRatedTotCap(DXCT),
   14465           4 :                                              state.dataHVACGlobal->MaxHeatVolFlowPerRatedTotCap(DXCT),
   14466           4 :                                              VolFlowperRatedTotCap));
   14467           4 :                     ShowContinueError(state, "Possible causes include inconsistent air flow rates in system components or");
   14468           4 :                     ShowContinueError(state, "inconsistent supply air fan operation modes in coil and unitary system objects.");
   14469             :                 }
   14470      237520 :                 ShowRecurringWarningErrorAtEnd(
   14471             :                     state,
   14472      118760 :                     state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + " \"" + state.dataDXCoils->DXCoil(DXCoilNum).Name +
   14473             :                         "\" - Air volume flow rate per watt of rated total heating capacity is out of range error continues at speed 1...",
   14474       59380 :                     state.dataDXCoils->DXCoil(DXCoilNum).ErrIndex1,
   14475             :                     VolFlowperRatedTotCap,
   14476             :                     VolFlowperRatedTotCap);
   14477             :             }
   14478             : 
   14479             :             // Get total capacity modifying factor (function of temperature) for off-rated conditions
   14480             :             // Model was extended to accept bi-quadratic curves. This allows sensitivity of the heating capacity
   14481             :             // to the entering dry-bulb temperature as well as the outside dry-bulb temperature. User is
   14482             :             // advised to use the bi-quaratic curve if sufficient manufacturer data is available.
   14483       70084 :             if (state.dataCurveManager->PerfCurve(state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFTemp(SpeedNum)).numDims == 1) {
   14484           0 :                 TotCapTempModFac = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFTemp(SpeedNum), OutdoorDryBulb);
   14485             :             } else {
   14486       70084 :                 TotCapTempModFac = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFTemp(SpeedNum), InletAirDryBulbTemp, OutdoorDryBulb);
   14487             :             }
   14488             : 
   14489             :             //  Get total capacity modifying factor (function of mass flow) for off-rated conditions
   14490             :             //    AirMassFlowRatio = AirMassFlow/DXCoil(DXCoilNum)%MSRatedAirMassFlowRate(SpeedNumLS)
   14491             :             //    TotCapFlowModFac = CurveValue(state, DXCoil(DXCoilNum)%MSCCapFFlow(SpeedNumLS),AirMassFlowRatio)
   14492       70084 :             TotCapFlowModFac = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).MSCCapFFlow(SpeedNum), AirMassFlowRatioLS);
   14493             :             // Calculate total heating capacity for off-rated conditions
   14494       70084 :             TotCap = state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(SpeedNum) * TotCapFlowModFac * TotCapTempModFac;
   14495             : 
   14496             :             // Calculating adjustment factors for defrost
   14497             :             // Calculate delta w through outdoor coil by assuming a coil temp of 0.82*DBT-9.7(F) per DOE2.1E
   14498       70084 :             OutdoorCoilT = 0.82 * OutdoorDryBulb - 8.589;
   14499       70084 :             OutdoorCoildw = max(1.0e-6, (OutdoorHumRat - PsyWFnTdpPb(state, OutdoorCoilT, OutdoorPressure, RoutineName)));
   14500             : 
   14501             :             // Initializing defrost adjustment factors
   14502       70084 :             LoadDueToDefrost = 0.0;
   14503       70084 :             HeatingCapacityMultiplier = 1.0;
   14504       70084 :             FractionalDefrostTime = 0.0;
   14505       70084 :             InputPowerMultiplier = 1.0;
   14506             : 
   14507             :             // Check outdoor temperature to determine of defrost is active
   14508       70084 :             if (OutdoorDryBulb <= state.dataDXCoils->DXCoil(DXCoilNum).MaxOATDefrost) {
   14509             :                 // Calculate defrost adjustment factors depending on defrost control type
   14510       64227 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).DefrostControl == StandardRatings::HPdefrostControl::Timed) {
   14511       64227 :                     FractionalDefrostTime = state.dataDXCoils->DXCoil(DXCoilNum).DefrostTime;
   14512       64227 :                     if (FractionalDefrostTime > 0.0) {
   14513       64227 :                         HeatingCapacityMultiplier = 0.909 - 107.33 * OutdoorCoildw;
   14514       64227 :                         InputPowerMultiplier = 0.90 - 36.45 * OutdoorCoildw;
   14515             :                     }
   14516             :                 } else { // else defrost control is on-demand
   14517           0 :                     FractionalDefrostTime = 1.0 / (1.0 + 0.01446 / OutdoorCoildw);
   14518           0 :                     HeatingCapacityMultiplier = 0.875 * (1.0 - FractionalDefrostTime);
   14519           0 :                     InputPowerMultiplier = 0.954 * (1.0 - FractionalDefrostTime);
   14520             :                 }
   14521             : 
   14522       64227 :                 if (FractionalDefrostTime > 0.0) {
   14523             :                     // Calculate defrost adjustment factors depending on defrost control strategy
   14524      128454 :                     if (state.dataDXCoils->DXCoil(DXCoilNum).DefrostStrategy == StandardRatings::DefrostStrat::ReverseCycle &&
   14525       64227 :                         state.dataDXCoils->DXCoil(DXCoilNum).DefrostControl == StandardRatings::HPdefrostControl::OnDemand) {
   14526           0 :                         LoadDueToDefrost = (0.01 * FractionalDefrostTime) * (7.222 - OutdoorDryBulb) *
   14527           0 :                                            (state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(1) / 1.01667);
   14528           0 :                         DefrostEIRTempModFac = CurveValue(
   14529           0 :                             state, state.dataDXCoils->DXCoil(DXCoilNum).DefrostEIRFT, max(15.555, InletAirWetBulbC), max(15.555, OutdoorDryBulb));
   14530           0 :                         state.dataDXCoils->DXCoil(DXCoilNum).DefrostPower =
   14531           0 :                             DefrostEIRTempModFac * (state.dataDXCoils->DXCoil(DXCoilNum).MSRatedTotCap(1) / 1.01667) * FractionalDefrostTime;
   14532             :                     } else { // Defrost strategy is resistive
   14533       64227 :                         state.dataDXCoils->DXCoil(DXCoilNum).DefrostPower =
   14534       64227 :                             state.dataDXCoils->DXCoil(DXCoilNum).DefrostCapacity * FractionalDefrostTime;
   14535             :                     }
   14536             :                 } else { // Defrost is not active because (OutDryBulbTemp .GT. DXCoil(DXCoilNum)%MaxOATDefrost)
   14537           0 :                     state.dataDXCoils->DXCoil(DXCoilNum).DefrostPower = 0.0;
   14538             :                 }
   14539             :             }
   14540             : 
   14541             :             // Modify total heating capacity based on defrost heating capacity multiplier
   14542       70084 :             TotCapAdj = TotCap * HeatingCapacityMultiplier;
   14543             : 
   14544             :             // Calculate full load outlet conditions
   14545       70084 :             FullLoadOutAirEnth = InletAirEnthalpy + TotCapAdj / AirMassFlow;
   14546       70084 :             FullLoadOutAirHumRat = InletAirHumRat;
   14547       70084 :             FullLoadOutAirTemp = PsyTdbFnHW(FullLoadOutAirEnth, FullLoadOutAirHumRat);
   14548       70084 :             FullLoadOutAirRH = PsyRhFnTdbWPb(state, FullLoadOutAirTemp, FullLoadOutAirHumRat, OutdoorPressure, RoutineNameFullLoad);
   14549             :             //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   14550             :             //  FullLoadOutAirRH = PsyRhFnTdbWPb(FullLoadOutAirTemp,FullLoadOutAirHumRat,InletAirPressure)
   14551       70084 :             if (FullLoadOutAirRH > 1.0) { // Limit to saturated conditions at FullLoadOutAirEnth
   14552           0 :                 FullLoadOutAirTemp = PsyTsatFnHPb(state, FullLoadOutAirEnth, OutdoorPressure, RoutineName);
   14553             :                 //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   14554             :                 //  FullLoadOutAirTemp = PsyTsatFnHPb(FullLoadOutAirEnth,InletAirPressure)
   14555           0 :                 FullLoadOutAirHumRat = PsyWFnTdbH(state, FullLoadOutAirTemp, FullLoadOutAirEnth, RoutineName);
   14556             :             }
   14557             : 
   14558             :             // Set outlet conditions from the full load calculation
   14559       70084 :             OutletAirEnthalpy = FullLoadOutAirEnth;
   14560       70084 :             OutletAirHumRat = FullLoadOutAirHumRat;
   14561       70084 :             OutletAirTemp = FullLoadOutAirTemp;
   14562             :             // Calculate electricity consumed. First, get EIR modifying factors for off-rated conditions
   14563             :             // Model was extended to accept bi-quadratic curves. This allows sensitivity of the EIR
   14564             :             // to the entering dry-bulb temperature as well as the outside dry-bulb temperature. User is
   14565             :             // advised to use the bi-quadratic curve if sufficient manufacturer data is available.
   14566       70084 :             if (state.dataCurveManager->PerfCurve(state.dataDXCoils->DXCoil(DXCoilNum).MSEIRFTemp(1)).numDims == 1) {
   14567           0 :                 EIRTempModFac = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).MSEIRFTemp(1), OutdoorDryBulb);
   14568             :             } else {
   14569       70084 :                 EIRTempModFac = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).MSEIRFTemp(1), InletAirDryBulbTemp, OutdoorDryBulb);
   14570             :             }
   14571       70084 :             EIRFlowModFac = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).MSEIRFFlow(1), AirMassFlowRatioLS);
   14572       70084 :             EIR = 1.0 / state.dataDXCoils->DXCoil(DXCoilNum).MSRatedCOP(1) * EIRTempModFac * EIRFlowModFac;
   14573             :             // Calculate modified PartLoadRatio due to defrost (reverse-cycle defrost only)
   14574       70084 :             PLRHeating = min(1.0, (CycRatio + LoadDueToDefrost / TotCapAdj));
   14575       70084 :             PLF = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).MSPLFFPLR(1), PLRHeating); // Calculate part-load factor
   14576       70084 :             if (FanOpMode == CycFanCycCoil && CycRatio == 1.0 && PLF != 1.0) {
   14577           0 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).PLFErrIndex == 0) {
   14578           0 :                     ShowWarningMessage(state,
   14579           0 :                                        format("The PLF curve value for DX heating coil {} ={:.2R} for part-load ratio = 1",
   14580           0 :                                               state.dataDXCoils->DXCoil(DXCoilNum).Name,
   14581           0 :                                               PLF));
   14582           0 :                     ShowContinueError(state, "PLF curve value must be = 1.0 and has been reset to 1.0. Simulation is continuing.");
   14583           0 :                     ShowContinueErrorTimeStamp(state, "");
   14584             :                 }
   14585           0 :                 ShowRecurringWarningErrorAtEnd(state,
   14586           0 :                                                state.dataDXCoils->DXCoil(DXCoilNum).Name +
   14587             :                                                    "\": DX heating coil PLF curve value <> 1.0 warning continues...",
   14588           0 :                                                state.dataDXCoils->DXCoil(DXCoilNum).PLFErrIndex,
   14589             :                                                PLF,
   14590             :                                                PLF);
   14591           0 :                 PLF = 1.0;
   14592             :             }
   14593             : 
   14594       70084 :             if (PLF < 0.7) {
   14595           0 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).PLRErrIndex == 0) {
   14596           0 :                     ShowWarningMessage(state,
   14597           0 :                                        format("The PLF curve value for DX heating coil {} ={:.2R} for part-load ratio ={:.2R}",
   14598           0 :                                               state.dataDXCoils->DXCoil(DXCoilNum).Name,
   14599             :                                               PLF,
   14600           0 :                                               PLRHeating));
   14601           0 :                     ShowContinueError(state, "PLF curve values must be >= 0.7. PLF has been reset to 0.7 and simulation is continuing.");
   14602           0 :                     ShowContinueError(state, "Check the IO reference manual for PLF curve guidance [Coil:Heating:DX:SingleSpeed].");
   14603           0 :                     ShowContinueErrorTimeStamp(state, "");
   14604             :                 }
   14605           0 :                 ShowRecurringWarningErrorAtEnd(
   14606           0 :                     state, "DX heating coil PLF curve < 0.7 warning continues... ", state.dataDXCoils->DXCoil(DXCoilNum).PLRErrIndex, PLF, PLF);
   14607           0 :                 PLF = 0.7;
   14608             :             }
   14609             : 
   14610       70084 :             state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction = (PLRHeating / PLF);
   14611       70084 :             if (state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction > 1.0 &&
   14612           0 :                 std::abs(state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction - 1.0) > 0.001) {
   14613           0 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).ErrIndex4 == 0) {
   14614           0 :                     ShowWarningMessage(state,
   14615           0 :                                        format("The runtime fraction for DX heating coil {} exceeded 1.0. [{:.4R}].",
   14616           0 :                                               state.dataDXCoils->DXCoil(DXCoilNum).Name,
   14617           0 :                                               state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction));
   14618           0 :                     ShowContinueError(state, "Runtime fraction is set to 1.0 and the simulation continues...");
   14619           0 :                     ShowContinueError(state, "Check the IO reference manual for PLF curve guidance [Coil:Heating:DX:SingleSpeed].");
   14620           0 :                     ShowContinueErrorTimeStamp(state, "");
   14621             :                 }
   14622           0 :                 ShowRecurringWarningErrorAtEnd(state,
   14623           0 :                                                state.dataDXCoils->DXCoil(DXCoilNum).Name +
   14624             :                                                    ", DX heating coil runtime fraction > 1.0 warning continues...",
   14625           0 :                                                state.dataDXCoils->DXCoil(DXCoilNum).ErrIndex4,
   14626           0 :                                                state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction,
   14627           0 :                                                state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction);
   14628           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction = 1.0; // Reset coil runtime fraction to 1.0
   14629       70084 :             } else if (state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction > 1.0) {
   14630           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction = 1.0; // Reset coil runtime fraction to 1.0
   14631             :             }
   14632             :             // if cycling fan, send coil part-load fraction to on/off fan via HVACDataGlobals
   14633       70084 :             if (FanOpMode == CycFanCycCoil) state.dataHVACGlobal->OnOffFanPartLoadFraction = PLF;
   14634       70084 :             state.dataDXCoils->DXCoil(DXCoilNum).ElecHeatingPower =
   14635       70084 :                 TotCap * EIR * state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction * InputPowerMultiplier;
   14636             : 
   14637             :             // Calculate crankcase heater power using the runtime fraction for this DX heating coil only if there is no companion DX coil.
   14638             :             // Else use the largest runtime fraction of this DX heating coil and the companion DX cooling coil.
   14639             : 
   14640       70084 :             if (state.dataDXCoils->DXCoil(DXCoilNum).CompanionUpstreamDXCoil == 0) {
   14641           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterPower =
   14642           0 :                     CrankcaseHeatingPower * (1.0 - state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction);
   14643             :             } else {
   14644       70084 :                 state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterPower =
   14645       70084 :                     CrankcaseHeatingPower *
   14646       70084 :                     (1.0 - max(state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction,
   14647       70084 :                                state.dataDXCoils->DXCoil(state.dataDXCoils->DXCoil(DXCoilNum).CompanionUpstreamDXCoil).CoolingCoilRuntimeFraction));
   14648             :             }
   14649             : 
   14650       70084 :             state.dataDXCoils->DXCoil(DXCoilNum).TotalHeatingEnergyRate = AirMassFlow * (FullLoadOutAirEnth - InletAirEnthalpy) * CycRatio;
   14651       70084 :             if (FanOpMode == ContFanCycCoil) {
   14652        4510 :                 OutletAirEnthalpy = InletAirEnthalpy + state.dataDXCoils->DXCoil(DXCoilNum).TotalHeatingEnergyRate /
   14653        2255 :                                                            state.dataDXCoils->DXCoil(DXCoilNum).InletAirMassFlowRate;
   14654        2255 :                 OutletAirTemp = PsyTdbFnHW(OutletAirEnthalpy, OutletAirHumRat);
   14655             :             }
   14656      140168 :             if (state.dataDXCoils->DXCoil(DXCoilNum).MSHPHeatRecActive ||
   14657       70084 :                 state.dataDXCoils->DXCoil(DXCoilNum).FuelTypeNum != DataGlobalConstants::ResourceType::Electricity) {
   14658           0 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).MSWasteHeat(SpeedNum) == 0) {
   14659           0 :                     state.dataDXCoils->DXCoil(DXCoilNum).MSFuelWasteHeat =
   14660           0 :                         state.dataDXCoils->DXCoil(DXCoilNum).MSWasteHeatFrac(SpeedNum) * state.dataDXCoils->DXCoil(DXCoilNum).ElecHeatingPower;
   14661             :                 } else {
   14662           0 :                     state.dataDXCoils->DXCoil(DXCoilNum).MSFuelWasteHeat =
   14663           0 :                         CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).MSWasteHeat(SpeedNum), OutdoorDryBulb, InletAirDryBulbTemp) *
   14664           0 :                         state.dataDXCoils->DXCoil(DXCoilNum).MSWasteHeatFrac(SpeedNum) * state.dataDXCoils->DXCoil(DXCoilNum).ElecHeatingPower;
   14665             :                 }
   14666           0 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).MSHPHeatRecActive) {
   14667           0 :                     MSHPWasteHeat = state.dataDXCoils->DXCoil(DXCoilNum).MSFuelWasteHeat;
   14668             :                 }
   14669             :             }
   14670       70084 :             if (state.dataDXCoils->DXCoil(DXCoilNum).FuelTypeNum != DataGlobalConstants::ResourceType::Electricity) {
   14671             : 
   14672           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).FuelUsed = state.dataDXCoils->DXCoil(DXCoilNum).ElecHeatingPower;
   14673           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).ElecHeatingPower = 0.0;
   14674             :             }
   14675             :             // Adjust defrost power to correct for DOE-2 bug where defrost power is constant regardless of compressor runtime fraction
   14676             :             // Defrosts happen based on compressor run time (frost buildup on outdoor coil), not total elapsed time.
   14677       70084 :             state.dataDXCoils->DXCoil(DXCoilNum).DefrostPower *= state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction;
   14678             : 
   14679       70084 :             state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp = OutletAirTemp;
   14680       70084 :             state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat = OutletAirHumRat;
   14681       70084 :             state.dataDXCoils->DXCoil(DXCoilNum).OutletAirEnthalpy = OutletAirEnthalpy;
   14682             :         }
   14683             : 
   14684             :     } else {
   14685             : 
   14686             :         // DX coil is off; just pass through conditions
   14687     4272191 :         state.dataDXCoils->DXCoil(DXCoilNum).OutletAirEnthalpy = state.dataDXCoils->DXCoil(DXCoilNum).InletAirEnthalpy;
   14688     4272191 :         state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat = state.dataDXCoils->DXCoil(DXCoilNum).InletAirHumRat;
   14689     4272191 :         state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp = state.dataDXCoils->DXCoil(DXCoilNum).InletAirTemp;
   14690             : 
   14691     4272191 :         state.dataDXCoils->DXCoil(DXCoilNum).ElecHeatingPower = 0.0;
   14692     4272191 :         state.dataDXCoils->DXCoil(DXCoilNum).FuelUsed = 0.0;
   14693     4272191 :         state.dataDXCoils->DXCoil(DXCoilNum).TotalHeatingEnergyRate = 0.0;
   14694     4272191 :         state.dataDXCoils->DXCoil(DXCoilNum).DefrostPower = 0.0;
   14695             : 
   14696             :         // Calculate crankcase heater power using the runtime fraction for this DX heating coil (here DXHeatingCoilRTF=0) if
   14697             :         // there is no companion DX coil, or the runtime fraction of the companion DX cooling coil (here DXCoolingCoilRTF>=0).
   14698     4272191 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CompanionUpstreamDXCoil == 0) {
   14699      700085 :             state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterPower = CrankcaseHeatingPower;
   14700             :         } else {
   14701     3572106 :             state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterPower =
   14702     3572106 :                 CrankcaseHeatingPower *
   14703     3572106 :                 (1.0 - state.dataDXCoils->DXCoil(state.dataDXCoils->DXCoil(DXCoilNum).CompanionUpstreamDXCoil).CoolingCoilRuntimeFraction);
   14704             :         }
   14705             : 
   14706             :     } // end of on/off if - else
   14707             : 
   14708     4644740 :     state.dataDXCoils->DXCoilOutletTemp(DXCoilNum) = state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp;
   14709     4644740 :     state.dataDXCoils->DXCoilOutletHumRat(DXCoilNum) = state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat;
   14710     4644740 :     state.dataDXCoils->DXCoil(DXCoilNum).PartLoadRatio = PLRHeating;
   14711     4644740 :     state.dataDXCoils->DXCoilFanOpMode(DXCoilNum) = FanOpMode;
   14712     4644740 :     state.dataDXCoils->DXCoilPartLoadRatio(DXCoilNum) = PLRHeating;
   14713     4644740 :     state.dataDXCoils->DXCoil(DXCoilNum).MSSpeedNumLS = SpeedNumLS;
   14714     4644740 :     state.dataDXCoils->DXCoil(DXCoilNum).MSSpeedNumHS = SpeedNumHS;
   14715     4644740 :     state.dataDXCoils->DXCoil(DXCoilNum).MSSpeedRatio = SpeedRatio;
   14716     4644740 :     state.dataDXCoils->DXCoil(DXCoilNum).MSCycRatio = CycRatio;
   14717             : 
   14718             :     // set outlet node conditions
   14719     4644740 :     int airOutletNode = state.dataDXCoils->DXCoil(DXCoilNum).AirOutNode;
   14720     4644740 :     state.dataLoopNodes->Node(airOutletNode).Temp = state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp;
   14721     4644740 :     state.dataLoopNodes->Node(airOutletNode).HumRat = state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat;
   14722             : 
   14723             :     // calc secondary coil if specified
   14724     4644740 :     if (state.dataDXCoils->DXCoil(DXCoilNum).IsSecondaryDXCoilInZone) {
   14725           0 :         CalcSecondaryDXCoils(state, DXCoilNum);
   14726             :     }
   14727     4644740 : }
   14728             : 
   14729    65004606 : void UpdateDXCoil(EnergyPlusData &state, int const DXCoilNum) // number of the current fan coil unit being simulated
   14730             : {
   14731             : 
   14732             :     // SUBROUTINE INFORMATION:
   14733             :     //       AUTHOR         Fred Buhl
   14734             :     //       DATE WRITTEN   May 2000
   14735             : 
   14736             :     // PURPOSE OF THIS SUBROUTINE:
   14737             :     // This subroutine is for passing results to the outlet air node.
   14738             : 
   14739             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   14740             :     int AirOutletNode; // air outlet node number
   14741             :     int AirInletNode;  // air inlet node number
   14742             : 
   14743    65004606 :     AirOutletNode = state.dataDXCoils->DXCoil(DXCoilNum).AirOutNode;
   14744    65004606 :     AirInletNode = state.dataDXCoils->DXCoil(DXCoilNum).AirInNode;
   14745             :     // changed outputs
   14746    65004606 :     state.dataLoopNodes->Node(AirOutletNode).Enthalpy = state.dataDXCoils->DXCoil(DXCoilNum).OutletAirEnthalpy;
   14747    65004606 :     state.dataLoopNodes->Node(AirOutletNode).Temp = state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp;
   14748    65004606 :     state.dataLoopNodes->Node(AirOutletNode).HumRat = state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat;
   14749    65004606 :     state.dataLoopNodes->Node(AirOutletNode).MassFlowRate = state.dataDXCoils->DXCoil(DXCoilNum).InletAirMassFlowRate;
   14750             :     // pass through outputs
   14751    65004606 :     state.dataLoopNodes->Node(AirOutletNode).Quality = state.dataLoopNodes->Node(AirInletNode).Quality;
   14752    65004606 :     state.dataLoopNodes->Node(AirOutletNode).Press = state.dataLoopNodes->Node(AirInletNode).Press;
   14753    65004606 :     state.dataLoopNodes->Node(AirOutletNode).MassFlowRateMin = state.dataLoopNodes->Node(AirInletNode).MassFlowRateMin;
   14754    65004606 :     state.dataLoopNodes->Node(AirOutletNode).MassFlowRateMax = state.dataLoopNodes->Node(AirInletNode).MassFlowRateMax;
   14755    65004606 :     state.dataLoopNodes->Node(AirOutletNode).MassFlowRateMinAvail = state.dataLoopNodes->Node(AirInletNode).MassFlowRateMinAvail;
   14756    65004606 :     state.dataLoopNodes->Node(AirOutletNode).MassFlowRateMaxAvail = state.dataLoopNodes->Node(AirInletNode).MassFlowRateMaxAvail;
   14757             : 
   14758    65004606 :     if (state.dataContaminantBalance->Contaminant.CO2Simulation) {
   14759     1156448 :         state.dataLoopNodes->Node(AirOutletNode).CO2 = state.dataLoopNodes->Node(AirInletNode).CO2;
   14760             :     }
   14761    65004606 :     if (state.dataContaminantBalance->Contaminant.GenericContamSimulation) {
   14762      174226 :         state.dataLoopNodes->Node(AirOutletNode).GenContam = state.dataLoopNodes->Node(AirInletNode).GenContam;
   14763             :     }
   14764    65004606 : }
   14765             : 
   14766    65004606 : void ReportDXCoil(EnergyPlusData &state, int const DXCoilNum) // number of the current fan coil unit being simulated
   14767             : {
   14768             : 
   14769             :     // SUBROUTINE INFORMATION:
   14770             :     //       AUTHOR         Fred Buhl
   14771             :     //       DATE WRITTEN   May 2000
   14772             :     //       MODIFIED       Richard Raustad/Don Shirey Oct 2001, Feb 2004
   14773             :     //                      Feb 2005 M. J. Witte, GARD Analytics, Inc.
   14774             :     //                        Always update evap value to support new coil type COIL:DX:MultiMode:CoolingEmpirical:
   14775             :     //                      Lixing Gu. Jan. 5, 2007, pass information to the AirflowNetwork model
   14776             : 
   14777             :     // PURPOSE OF THIS SUBROUTINE:
   14778             :     // Fills some of the report variables for the DX coils
   14779             : 
   14780             :     // Using/Aliasing
   14781    65004606 :     auto &DXElecCoolingPower = state.dataHVACGlobal->DXElecCoolingPower;
   14782    65004606 :     auto &DXElecHeatingPower = state.dataHVACGlobal->DXElecHeatingPower;
   14783    65004606 :     auto &TimeStepSys = state.dataHVACGlobal->TimeStepSys;
   14784             :     using Psychrometrics::RhoH2O;
   14785             : 
   14786             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   14787             :     Real64 RhoWater;
   14788             :     Real64 Tavg;
   14789             :     Real64 SpecHumOut;
   14790             :     Real64 SpecHumIn;
   14791             :     Real64 ReportingConstant; // Number of seconds per HVAC system time step, to convert from W (J/s) to J
   14792             : 
   14793    65004606 :     if (state.dataDXCoils->DXCoil(DXCoilNum).reportCoilFinalSizes) {
   14794    16719017 :         if (!state.dataGlobal->WarmupFlag && !state.dataGlobal->DoingHVACSizingSimulations && !state.dataGlobal->DoingSizing) {
   14795         952 :             Real64 ratedSensCap(0.0);
   14796         952 :             ratedSensCap = state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(1) * state.dataDXCoils->DXCoil(DXCoilNum).RatedSHR(1);
   14797        4760 :             state.dataRptCoilSelection->coilSelectionReportObj->setCoilFinalSizes(state,
   14798         952 :                                                                                   state.dataDXCoils->DXCoil(DXCoilNum).Name,
   14799         952 :                                                                                   state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
   14800         952 :                                                                                   state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(1),
   14801             :                                                                                   ratedSensCap,
   14802         952 :                                                                                   state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(1),
   14803             :                                                                                   -999.0);
   14804         952 :             state.dataDXCoils->DXCoil(DXCoilNum).reportCoilFinalSizes = false;
   14805             :         }
   14806             :     }
   14807             : 
   14808    65004606 :     ReportingConstant = TimeStepSys * DataGlobalConstants::SecInHour;
   14809             : 
   14810    65004606 :     switch (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num) {
   14811     9620817 :     case CoilDX_HeatingEmpirical:
   14812             :     case CoilVRF_Heating:
   14813             :     case CoilVRF_FluidTCtrl_Heating: {
   14814     9620817 :         state.dataDXCoils->DXCoil(DXCoilNum).TotalHeatingEnergy = state.dataDXCoils->DXCoil(DXCoilNum).TotalHeatingEnergyRate * ReportingConstant;
   14815     9620817 :         state.dataDXCoils->DXCoil(DXCoilNum).ElecHeatingConsumption = state.dataDXCoils->DXCoil(DXCoilNum).ElecHeatingPower * ReportingConstant;
   14816     9620817 :         state.dataDXCoils->DXCoil(DXCoilNum).DefrostConsumption = state.dataDXCoils->DXCoil(DXCoilNum).DefrostPower * ReportingConstant;
   14817     9620817 :         state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterConsumption =
   14818     9620817 :             state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterPower * ReportingConstant;
   14819     9620817 :         DXElecHeatingPower = state.dataDXCoils->DXCoil(DXCoilNum).ElecHeatingPower + state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterPower;
   14820     9620817 :     } break;
   14821     4644734 :     case CoilDX_MultiSpeedHeating: {
   14822     4644734 :         state.dataDXCoils->DXCoil(DXCoilNum).TotalHeatingEnergy = state.dataDXCoils->DXCoil(DXCoilNum).TotalHeatingEnergyRate * ReportingConstant;
   14823     4644734 :         if (state.dataDXCoils->DXCoil(DXCoilNum).FuelTypeNum == DataGlobalConstants::ResourceType::Electricity) {
   14824     3995800 :             state.dataDXCoils->DXCoil(DXCoilNum).ElecHeatingConsumption = state.dataDXCoils->DXCoil(DXCoilNum).ElecHeatingPower * ReportingConstant;
   14825             :         } else {
   14826      648934 :             state.dataDXCoils->DXCoil(DXCoilNum).FuelConsumed = state.dataDXCoils->DXCoil(DXCoilNum).FuelUsed * ReportingConstant;
   14827             :         }
   14828     4644734 :         state.dataDXCoils->DXCoil(DXCoilNum).DefrostConsumption = state.dataDXCoils->DXCoil(DXCoilNum).DefrostPower * ReportingConstant;
   14829     4644734 :         state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterConsumption =
   14830     4644734 :             state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterPower * ReportingConstant;
   14831     4644734 :         DXElecHeatingPower = state.dataDXCoils->DXCoil(DXCoilNum).ElecHeatingPower + state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterPower;
   14832     4644734 :     } break;
   14833     6761046 :     case CoilDX_MultiSpeedCooling: {
   14834     6761046 :         state.dataDXCoils->DXCoil(DXCoilNum).TotalCoolingEnergy = state.dataDXCoils->DXCoil(DXCoilNum).TotalCoolingEnergyRate * ReportingConstant;
   14835     6761046 :         state.dataDXCoils->DXCoil(DXCoilNum).SensCoolingEnergy = state.dataDXCoils->DXCoil(DXCoilNum).SensCoolingEnergyRate * ReportingConstant;
   14836     6761046 :         state.dataDXCoils->DXCoil(DXCoilNum).LatCoolingEnergy =
   14837     6761046 :             state.dataDXCoils->DXCoil(DXCoilNum).TotalCoolingEnergy - state.dataDXCoils->DXCoil(DXCoilNum).SensCoolingEnergy;
   14838     6761046 :         state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterConsumption =
   14839     6761046 :             state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterPower * ReportingConstant;
   14840     6761046 :         DXElecCoolingPower = state.dataDXCoils->DXCoil(DXCoilNum).ElecCoolingPower;
   14841     6761046 :         state.dataDXCoils->DXCoil(DXCoilNum).EvapCondPumpElecConsumption =
   14842     6761046 :             state.dataDXCoils->DXCoil(DXCoilNum).EvapCondPumpElecPower * ReportingConstant;
   14843     6761046 :         state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterConsump = state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterConsumpRate * ReportingConstant;
   14844     6761046 :         if (state.dataDXCoils->DXCoil(DXCoilNum).FuelTypeNum == DataGlobalConstants::ResourceType::Electricity) {
   14845     5491354 :             state.dataDXCoils->DXCoil(DXCoilNum).ElecCoolingConsumption = state.dataDXCoils->DXCoil(DXCoilNum).ElecCoolingPower * ReportingConstant;
   14846             :         } else {
   14847     1269692 :             state.dataDXCoils->DXCoil(DXCoilNum).FuelConsumed = state.dataDXCoils->DXCoil(DXCoilNum).FuelUsed * ReportingConstant;
   14848             :         }
   14849     6761046 :         if (any_eq(state.dataDXCoils->DXCoil(DXCoilNum).CondenserType, DataHeatBalance::RefrigCondenserType::Evap)) {
   14850           0 :             state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterConsumption = state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterPower * ReportingConstant;
   14851             :         }
   14852     6761046 :     } break;
   14853     1023180 :     case CoilDX_HeatPumpWaterHeaterPumped:
   14854             :     case CoilDX_HeatPumpWaterHeaterWrapped: {
   14855             :         // water heating energy for HP water heater DX Coil condenser
   14856     1023180 :         state.dataDXCoils->DXCoil(DXCoilNum).TotalHeatingEnergy = state.dataDXCoils->DXCoil(DXCoilNum).TotalHeatingEnergyRate * ReportingConstant;
   14857             :         // water heating power for HP water heater
   14858     1023180 :         state.dataDXCoils->DXCoil(DXCoilNum).ElecWaterHeatingConsumption =
   14859     1023180 :             state.dataDXCoils->DXCoil(DXCoilNum).ElecWaterHeatingPower * ReportingConstant;
   14860             :         // other usual DX cooling coil outputs
   14861     1023180 :         state.dataDXCoils->DXCoil(DXCoilNum).TotalCoolingEnergy = state.dataDXCoils->DXCoil(DXCoilNum).TotalCoolingEnergyRate * ReportingConstant;
   14862     1023180 :         state.dataDXCoils->DXCoil(DXCoilNum).SensCoolingEnergy = state.dataDXCoils->DXCoil(DXCoilNum).SensCoolingEnergyRate * ReportingConstant;
   14863     1023180 :         state.dataDXCoils->DXCoil(DXCoilNum).LatCoolingEnergy =
   14864     1023180 :             state.dataDXCoils->DXCoil(DXCoilNum).TotalCoolingEnergy - state.dataDXCoils->DXCoil(DXCoilNum).SensCoolingEnergy;
   14865     1023180 :         state.dataDXCoils->DXCoil(DXCoilNum).ElecCoolingConsumption = state.dataDXCoils->DXCoil(DXCoilNum).ElecCoolingPower * ReportingConstant;
   14866     1023180 :         state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterConsumption =
   14867     1023180 :             state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterPower * ReportingConstant;
   14868             :         // DXElecCoolingPower global is only used for air-to-air cooling and heating coils
   14869     1023180 :         DXElecCoolingPower = 0.0;
   14870     1023180 :     } break;
   14871    42954829 :     default: {
   14872    42954829 :         state.dataDXCoils->DXCoil(DXCoilNum).TotalCoolingEnergy = state.dataDXCoils->DXCoil(DXCoilNum).TotalCoolingEnergyRate * ReportingConstant;
   14873    42954829 :         state.dataDXCoils->DXCoil(DXCoilNum).SensCoolingEnergy = state.dataDXCoils->DXCoil(DXCoilNum).SensCoolingEnergyRate * ReportingConstant;
   14874    42954829 :         state.dataDXCoils->DXCoil(DXCoilNum).LatCoolingEnergy =
   14875    42954829 :             state.dataDXCoils->DXCoil(DXCoilNum).TotalCoolingEnergy - state.dataDXCoils->DXCoil(DXCoilNum).SensCoolingEnergy;
   14876    42954829 :         state.dataDXCoils->DXCoil(DXCoilNum).ElecCoolingConsumption = state.dataDXCoils->DXCoil(DXCoilNum).ElecCoolingPower * ReportingConstant;
   14877    42954829 :         state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterConsumption =
   14878    42954829 :             state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterPower * ReportingConstant;
   14879    42954829 :         DXElecCoolingPower = state.dataDXCoils->DXCoil(DXCoilNum).ElecCoolingPower;
   14880    42954829 :         state.dataDXCoils->DXCoil(DXCoilNum).EvapCondPumpElecConsumption =
   14881    42954829 :             state.dataDXCoils->DXCoil(DXCoilNum).EvapCondPumpElecPower * ReportingConstant;
   14882    42954829 :         state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterConsump = state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterConsumpRate * ReportingConstant;
   14883    42954829 :         if (any_eq(state.dataDXCoils->DXCoil(DXCoilNum).CondenserType, DataHeatBalance::RefrigCondenserType::Evap)) {
   14884       66976 :             state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterConsumption = state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterPower * ReportingConstant;
   14885             :         }
   14886    42954829 :     } break;
   14887             :     }
   14888             : 
   14889    65004606 :     if (state.dataDXCoils->DXCoil(DXCoilNum).CondensateCollectMode == CondensateCollectAction::ToTank) {
   14890             :         // calculate and report condensation rates  (how much water extracted from the air stream)
   14891             :         // water flow of water in m3/s for water system interactions
   14892             :         //  put here to catch all types of DX coils
   14893           0 :         Tavg = (state.dataDXCoils->DXCoil(DXCoilNum).InletAirTemp - state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp) / 2.0;
   14894           0 :         RhoWater = RhoH2O(Tavg);
   14895             :         // CR9155 Remove specific humidity calculations
   14896           0 :         SpecHumIn = state.dataDXCoils->DXCoil(DXCoilNum).InletAirHumRat;
   14897           0 :         SpecHumOut = state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat;
   14898             :         //  mdot * del HumRat / rho water
   14899           0 :         state.dataDXCoils->DXCoil(DXCoilNum).CondensateVdot =
   14900           0 :             max(0.0, (state.dataDXCoils->DXCoil(DXCoilNum).InletAirMassFlowRate * (SpecHumIn - SpecHumOut) / RhoWater));
   14901           0 :         state.dataDXCoils->DXCoil(DXCoilNum).CondensateVol = state.dataDXCoils->DXCoil(DXCoilNum).CondensateVdot * ReportingConstant;
   14902             : 
   14903           0 :         state.dataWaterData->WaterStorage(state.dataDXCoils->DXCoil(DXCoilNum).CondensateTankID)
   14904           0 :             .VdotAvailSupply(state.dataDXCoils->DXCoil(DXCoilNum).CondensateTankSupplyARRID) = state.dataDXCoils->DXCoil(DXCoilNum).CondensateVdot;
   14905           0 :         state.dataWaterData->WaterStorage(state.dataDXCoils->DXCoil(DXCoilNum).CondensateTankID)
   14906           0 :             .TwaterSupply(state.dataDXCoils->DXCoil(DXCoilNum).CondensateTankSupplyARRID) = state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp;
   14907             :     }
   14908             : 
   14909    65004606 :     state.dataAirLoop->LoopDXCoilRTF =
   14910    65004606 :         max(state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction, state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction);
   14911    65004606 :     if (state.dataDXCoils->DXCoil(DXCoilNum).AirLoopNum > 0) {
   14912     8108987 :         state.dataAirLoop->AirLoopAFNInfo(state.dataDXCoils->DXCoil(DXCoilNum).AirLoopNum).AFNLoopDXCoilRTF =
   14913     8108987 :             max(state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction, state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction);
   14914             :     }
   14915    65004606 : }
   14916             : 
   14917          66 : void CalcTwoSpeedDXCoilStandardRating(EnergyPlusData &state, int const DXCoilNum)
   14918             : {
   14919             :     // SUBROUTINE INFORMATION:
   14920             :     //       AUTHOR         B. Griffith, (Derived from CalcDXCoilStandardRating by Bereket Nigusse & Chandan Sharma)
   14921             :     //       DATE WRITTEN   July 2012
   14922             : 
   14923             :     // PURPOSE OF THIS SUBROUTINE:
   14924             :     // Calculate the following
   14925             :     //                 (1) Standard Rated (net) Cooling Capacity
   14926             :     //                 (2) Energy Efficiency Ratio (EER),
   14927             :     //                 (3) Integrated Energy Efficiency Ratio (IEER)
   14928             : 
   14929             :     // REFERENCES:
   14930             :     // ANSI/AHRI Standard 340/360-2007, Performance Rating of Commercial and Industrial Unitary Air-Conditioning and
   14931             :     //  Heat Pump Equipment, Air-Conditioning, Heating, and Refrigeration Institute, Arlington VA.
   14932             : 
   14933             :     // Using/Aliasing
   14934             :     using Curve::CurveValue;
   14935             :     using namespace OutputReportPredefined;
   14936             : 
   14937             :     // SUBROUTINE PARAMETER DEFINITIONS:
   14938             :     // AHRI Standard 340/360-2007 Performance Rating of Commercial and Industrial Unitary Air-Conditioning and Heat Pump Equipment
   14939          66 :     Real64 constexpr CoolingCoilInletAirWetBulbTempRated(19.4); // 19.44C (67F)
   14940          66 :     Real64 constexpr CoolingCoilInletAirDryBulbTempRated(26.7);
   14941          66 :     Real64 constexpr OutdoorUnitInletAirDryBulbTempRated(35.0); // 35.00C (95F)
   14942          66 :     static Array1D<Real64> const OutdoorUnitInletAirDryBulbTempPLTestPoint(3, {27.5, 20.0, 18.3});
   14943          66 :     static Array1D<Real64> const NetCapacityFactorPLTestPoint(3, {0.75, 0.50, 0.25});
   14944          66 :     Real64 constexpr ConvFromSIToIP(3.412141633); // Conversion from SI to IP [3.412 Btu/hr-W]
   14945             : 
   14946          66 :     Real64 constexpr AirMassFlowRatioRated(1.0); // AHRI test is at the design flow rate
   14947             :     // and hence AirMassFlowRatio is 1.0
   14948             : 
   14949          66 :     Real64 constexpr DefaultFanPowerPerEvapAirFlowRate(773.3);      // 365 W/1000 scfm or 773.3 W/(m3/s). The AHRI standard
   14950          66 :     Real64 constexpr DefaultFanPowerPerEvapAirFlowRateSEER2(934.4); // 441 W/1000 scfm or 934.4 W/(m3/s). The AHRI standard
   14951             :     // specifies a nominal/default fan electric power consumption per rated air
   14952             :     // volume flow rate to account for indoor fan electric power consumption
   14953             :     // when the standard tests are conducted on units that do not have an
   14954             :     // indoor air circulating fan. Used if user doesn't enter a specific value.
   14955             : 
   14956             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   14957             :     static constexpr std::string_view RoutineName("CalcTwoSpeedDXCoilStandardRating");
   14958             : 
   14959          66 :     auto &NetCoolingCapRated = state.dataDXCoils->NetCoolingCapRated;
   14960          66 :     auto &EER = state.dataDXCoils->EER;
   14961          66 :     auto &IEER = state.dataDXCoils->IEER;
   14962          66 :     auto &TotCapTempModFac = state.dataDXCoils->TotCapTempModFac;
   14963          66 :     auto &TotCapFlowModFac = state.dataDXCoils->TotCapFlowModFac;
   14964          66 :     auto &EIRTempModFac = state.dataDXCoils->EIRTempModFac;
   14965          66 :     auto &EIRFlowModFac = state.dataDXCoils->EIRFlowModFac;
   14966          66 :     auto &TempDryBulb_Leaving_Apoint = state.dataDXCoils->TempDryBulb_Leaving_Apoint;
   14967             : 
   14968          66 :     constexpr Real64 AccuracyTolerance(0.2); // tolerance in AHRI 340/360 Table 6 note 1
   14969          66 :     constexpr int MaximumIterations(1000);
   14970             :     Real64 EIR;
   14971             :     Real64 TotalElecPowerRated;
   14972         118 :     Array1D<Real64> EER_TestPoint_SI(4);      // 1 = A, 2 = B, 3= C, 4= D
   14973         118 :     Array1D<Real64> EER_TestPoint_IP(4);      // 1 = A, 2 = B, 3= C, 4= D
   14974         118 :     Array1D<Real64> NetCapacity_TestPoint(4); // 1 = A, 2 = B, 3= C, 4= D
   14975         118 :     Array1D<Real64> NetPower_TestPoint(4);    // 1 = A, 2 = B, 3= C, 4= D
   14976         118 :     Array1D<Real64> SupAirMdot_TestPoint(4);  // 1 = A, 2 = B, 3= C, 4= D
   14977             : 
   14978             :     Real64 HighSpeedNetCoolingCap;
   14979             :     Real64 LowSpeedNetCoolingCap;
   14980             : 
   14981             :     Real64 PartLoadAirMassFlowRate;
   14982             :     Real64 AirMassFlowRatio;
   14983             :     int SolverFlag;
   14984             :     Real64 EIR_HighSpeed;
   14985             :     Real64 EIR_LowSpeed;
   14986             :     int FanInletNode;
   14987             :     int FanOutletNode;
   14988             :     int Iter;
   14989             :     Real64 ExternalStatic;
   14990             :     Real64 FanStaticPressureRise;
   14991          66 :     bool ErrorsFound(false);
   14992             :     Real64 FanHeatCorrection;
   14993             :     Real64 FanPowerCorrection;
   14994          66 :     Real64 FanPowerPerEvapAirFlowRate = 0.0;
   14995             :     Real64 FanPowerPerEvapAirFlowRateSEER2;
   14996             :     Real64 SpeedRatio;
   14997             :     Real64 CycRatio;
   14998             :     Real64 TargetNetCapacity;
   14999             :     Real64 SupplyAirHumRat;
   15000             :     Real64 SupplyAirRho;
   15001             :     Real64 SupplyAirVolFlowRate;
   15002             :     Real64 HighSpeedTotCoolingCap;
   15003             :     Real64 LowSpeedTotCoolingCap;
   15004             :     Real64 TotCoolingCap;
   15005             :     Real64 NetCoolingCap;
   15006             :     Real64 PLF;
   15007             :     Real64 RunTimeFraction;
   15008             :     Real64 LowerBoundMassFlowRate;
   15009             :     int PartLoadTestPoint;
   15010             :     int countStaticInputs;
   15011             :     int index;
   15012             : 
   15013             :     // Formats
   15014             :     static constexpr std::string_view Header(
   15015             :         "! <VAV DX Cooling Coil Standard Rating Information>, DX Coil Type, DX Coil Name, Fan Type, Fan Name, Standard Net Cooling Capacity "
   15016             :         "{{W}}, Standard Net Cooling Capacity {{Btu/h}}, IEER {{Btu/W-h}}, COP 100% Capacity {{W/W}}, COP 75% Capacity {{W/W}}, COP 50% Capacity "
   15017             :         "{{W/W}}, COP 25% Capacity {{W/W}}, EER 100% Capacity {{Btu/W-h}}, EER 75% Capacity {{Btu/W-h}}, EER 50% Capacity {{Btu/W-h}}, EER 25% "
   15018             :         "Capacity {{Btu/W-h}}, Supply Air Flow 100% {{kg/s}}, Supply Air Flow 75% {{kg/s}},Supply Air Flow 50% {{kg/s}},Supply Air Flow 25% "
   15019             :         "{{kg/s}}\n");
   15020             : 
   15021             :     static constexpr std::string_view Format_891{
   15022             :         " VAV DX Cooling Coil Standard Rating Information, "
   15023             :         "{},{},{},{},{:.2R},{:.2R},{:.2R},{:.2R},{:.2R},{:.2R},{:.2R},{:.2R},{:.2R},{:.2R},{:.2R},{:.4R},{:.4R},{:.4R},{:.4R},\n"};
   15024             : 
   15025             :     // Get fan index and name if not already available
   15026          66 :     if (state.dataDXCoils->DXCoil(DXCoilNum).SupplyFanIndex == -1)
   15027         198 :         GetFanIndexForTwoSpeedCoil(state,
   15028             :                                    DXCoilNum,
   15029          66 :                                    state.dataDXCoils->DXCoil(DXCoilNum).SupplyFanIndex,
   15030          66 :                                    state.dataDXCoils->DXCoil(DXCoilNum).SupplyFanName,
   15031          66 :                                    state.dataDXCoils->DXCoil(DXCoilNum).SupplyFan_TypeNum);
   15032          66 :     if (state.dataDXCoils->DXCoil(DXCoilNum).SupplyFanIndex == -1) { // didn't find VAV fan, do not rate this coil
   15033          14 :         state.dataDXCoils->DXCoil(DXCoilNum).RateWithInternalStaticAndFanObject = false;
   15034          42 :         ShowWarningError(state,
   15035          28 :                          "CalcTwoSpeedDXCoilStandardRating: Did not find an appropriate fan associated with DX coil named = \"" +
   15036          42 :                              state.dataDXCoils->DXCoil(DXCoilNum).Name + "\". Standard Ratings will not be calculated.");
   15037          14 :         return;
   15038             :     }
   15039             : 
   15040             :     // Calculate the Indoor fan electric power consumption.  The electric power consumption is estimated
   15041             :     // using either user supplied or AHRI default value for fan power per air volume flow rate
   15042          52 :     if (state.dataDXCoils->DXCoil(DXCoilNum).RateWithInternalStaticAndFanObject) {
   15043             : 
   15044          29 :         TotCapFlowModFac = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).CCapFFlow(1), AirMassFlowRatioRated);
   15045          58 :         TotCapTempModFac = CurveValue(
   15046          29 :             state, state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(1), CoolingCoilInletAirWetBulbTempRated, OutdoorUnitInletAirDryBulbTempRated);
   15047         145 :         for (Iter = 1; Iter <= 4; ++Iter) { // iterative solution in the event that net capacity is near a threshold for external static
   15048             :             // Obtain external static pressure from Table 5 in ANSI/AHRI Std. 340/360-2007
   15049         116 :             if (NetCoolingCapRated <= 21000.0) {
   15050          14 :                 ExternalStatic = 50.0;
   15051         102 :             } else if (21000.0 < NetCoolingCapRated && NetCoolingCapRated <= 30800.0) {
   15052           0 :                 ExternalStatic = 60.0;
   15053         102 :             } else if (30800.0 < NetCoolingCapRated && NetCoolingCapRated <= 39300.0) {
   15054           0 :                 ExternalStatic = 70.0;
   15055         102 :             } else if (39300.0 < NetCoolingCapRated && NetCoolingCapRated <= 61500.0) {
   15056          11 :                 ExternalStatic = 90.0;
   15057          91 :             } else if (61500.0 < NetCoolingCapRated && NetCoolingCapRated <= 82100.0) {
   15058           3 :                 ExternalStatic = 100.0;
   15059          88 :             } else if (82100.0 < NetCoolingCapRated && NetCoolingCapRated <= 103000.0) {
   15060           0 :                 ExternalStatic = 110.0;
   15061          88 :             } else if (103000.0 < NetCoolingCapRated && NetCoolingCapRated <= 117000.0) {
   15062           0 :                 ExternalStatic = 140.0;
   15063          88 :             } else if (117000.0 < NetCoolingCapRated && NetCoolingCapRated <= 147000.0) {
   15064          16 :                 ExternalStatic = 160.0;
   15065          72 :             } else if (147000.0 < NetCoolingCapRated) {
   15066          72 :                 ExternalStatic = 190.0;
   15067             :             }
   15068         116 :             FanStaticPressureRise = ExternalStatic + state.dataDXCoils->DXCoil(DXCoilNum).InternalStaticPressureDrop;
   15069         116 :             if (state.dataDXCoils->DXCoil(DXCoilNum).SupplyFan_TypeNum == DataHVACGlobals::FanType_SystemModelObject) {
   15070          16 :                 FanInletNode = state.dataHVACFan->fanObjs[state.dataDXCoils->DXCoil(DXCoilNum).SupplyFanIndex]->inletNodeNum;
   15071          16 :                 FanOutletNode = state.dataHVACFan->fanObjs[state.dataDXCoils->DXCoil(DXCoilNum).SupplyFanIndex]->outletNodeNum;
   15072             :             } else {
   15073         100 :                 FanInletNode = Fans::GetFanInletNode(state, "FAN:VARIABLEVOLUME", state.dataDXCoils->DXCoil(DXCoilNum).SupplyFanName, ErrorsFound);
   15074         100 :                 FanOutletNode = Fans::GetFanOutletNode(state, "FAN:VARIABLEVOLUME", state.dataDXCoils->DXCoil(DXCoilNum).SupplyFanName, ErrorsFound);
   15075             :             }
   15076             : 
   15077             :             // set node state variables in preparation for fan model.
   15078         116 :             state.dataLoopNodes->Node(FanInletNode).MassFlowRate = state.dataDXCoils->DXCoil(DXCoilNum).RatedAirMassFlowRate(1);
   15079         116 :             state.dataLoopNodes->Node(FanOutletNode).MassFlowRate = state.dataDXCoils->DXCoil(DXCoilNum).RatedAirMassFlowRate(1);
   15080         116 :             state.dataLoopNodes->Node(FanInletNode).Temp = CoolingCoilInletAirDryBulbTempRated;
   15081         116 :             state.dataLoopNodes->Node(FanInletNode).HumRat = PsyWFnTdbTwbPb(
   15082         116 :                 state, CoolingCoilInletAirDryBulbTempRated, CoolingCoilInletAirWetBulbTempRated, state.dataEnvrn->OutBaroPress, RoutineName);
   15083         116 :             state.dataLoopNodes->Node(FanInletNode).Enthalpy =
   15084         116 :                 PsyHFnTdbW(CoolingCoilInletAirDryBulbTempRated, state.dataLoopNodes->Node(FanInletNode).HumRat);
   15085         116 :             if (state.dataDXCoils->DXCoil(DXCoilNum).SupplyFan_TypeNum == DataHVACGlobals::FanType_SystemModelObject) {
   15086          16 :                 state.dataHVACFan->fanObjs[state.dataDXCoils->DXCoil(DXCoilNum).SupplyFanIndex]->simulate(
   15087             :                     state, _, true, false, FanStaticPressureRise);
   15088          16 :                 FanPowerCorrection = state.dataHVACFan->fanObjs[state.dataDXCoils->DXCoil(DXCoilNum).SupplyFanIndex]->fanPower();
   15089             :             } else {
   15090         300 :                 Fans::SimulateFanComponents(state,
   15091         100 :                                             state.dataDXCoils->DXCoil(DXCoilNum).SupplyFanName,
   15092             :                                             true,
   15093         100 :                                             state.dataDXCoils->DXCoil(DXCoilNum).SupplyFanIndex,
   15094             :                                             _,
   15095             :                                             true,
   15096             :                                             false,
   15097             :                                             FanStaticPressureRise);
   15098         100 :                 FanPowerCorrection = Fans::GetFanPower(state, state.dataDXCoils->DXCoil(DXCoilNum).SupplyFanIndex);
   15099             :             }
   15100             : 
   15101         232 :             FanHeatCorrection = state.dataLoopNodes->Node(FanInletNode).MassFlowRate *
   15102         116 :                                 (state.dataLoopNodes->Node(FanOutletNode).Enthalpy - state.dataLoopNodes->Node(FanInletNode).Enthalpy);
   15103             : 
   15104         116 :             NetCoolingCapRated = state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(1) * TotCapTempModFac * TotCapFlowModFac - FanHeatCorrection;
   15105             :         }
   15106             : 
   15107             :     } else {
   15108          23 :         FanPowerPerEvapAirFlowRate = DefaultFanPowerPerEvapAirFlowRate;
   15109          23 :         FanPowerPerEvapAirFlowRateSEER2 = DefaultFanPowerPerEvapAirFlowRateSEER2;
   15110          23 :         FanPowerCorrection = DefaultFanPowerPerEvapAirFlowRate * state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(1);
   15111          23 :         FanHeatCorrection = DefaultFanPowerPerEvapAirFlowRate * state.dataDXCoils->DXCoil(DXCoilNum).RatedAirVolFlowRate(1);
   15112          23 :         TotCapFlowModFac = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).CCapFFlow(1), AirMassFlowRatioRated);
   15113          46 :         TotCapTempModFac = CurveValue(
   15114          23 :             state, state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(1), CoolingCoilInletAirWetBulbTempRated, OutdoorUnitInletAirDryBulbTempRated);
   15115          23 :         NetCoolingCapRated = state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(1) * TotCapTempModFac * TotCapFlowModFac - FanHeatCorrection;
   15116             :     }
   15117             : 
   15118          52 :     SupAirMdot_TestPoint(1) = state.dataDXCoils->DXCoil(DXCoilNum).RatedAirMassFlowRate(1);
   15119             : 
   15120             :     // Calculate Energy Efficiency Ratio (EER) at (19.44C WB and 35.0C DB ), ANSI/AHRI Std. 340/360
   15121          52 :     EIRTempModFac =
   15122         104 :         CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).EIRFTemp(1), CoolingCoilInletAirWetBulbTempRated, OutdoorUnitInletAirDryBulbTempRated);
   15123          52 :     EIRFlowModFac = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).EIRFFlow(1), AirMassFlowRatioRated);
   15124          52 :     if (state.dataDXCoils->DXCoil(DXCoilNum).RatedCOP(1) > 0.0) {
   15125             :         // RatedCOP <= 0.0 is trapped in GetInput, but keep this as "safety"
   15126          52 :         EIR = EIRTempModFac * EIRFlowModFac / state.dataDXCoils->DXCoil(DXCoilNum).RatedCOP(1);
   15127             :     } else {
   15128           0 :         EIR = 0.0;
   15129             :     }
   15130          52 :     TotalElecPowerRated = EIR * (state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(1) * TotCapTempModFac * TotCapFlowModFac) + FanPowerCorrection;
   15131             : 
   15132          52 :     if (TotalElecPowerRated > 0.0) {
   15133          52 :         EER = NetCoolingCapRated / TotalElecPowerRated;
   15134             :     } else {
   15135           0 :         EER = 0.0;
   15136             :     }
   15137             : 
   15138             :     // IEER - A point 100 % net capacity
   15139          52 :     EER_TestPoint_SI(1) = EER;
   15140          52 :     EER_TestPoint_IP(1) = EER * ConvFromSIToIP;
   15141             : 
   15142             :     // find coil leaving drybulb at point A, with full rated air flow rate.
   15143             :     // init coil
   15144          52 :     state.dataDXCoils->DXCoil(DXCoilNum).InletAirMassFlowRate = state.dataDXCoils->DXCoil(DXCoilNum).RatedAirMassFlowRate(1);
   15145          52 :     state.dataDXCoils->DXCoil(DXCoilNum).InletAirMassFlowRateMax = state.dataDXCoils->DXCoil(DXCoilNum).RatedAirMassFlowRate(1);
   15146          52 :     state.dataDXCoils->DXCoil(DXCoilNum).InletAirTemp = 26.7;
   15147          52 :     state.dataDXCoils->DXCoil(DXCoilNum).InletAirHumRat = PsyWFnTdbTwbPb(state, 26.7, 19.4, state.dataEnvrn->OutBaroPress, RoutineName);
   15148          52 :     state.dataDXCoils->DXCoil(DXCoilNum).InletAirEnthalpy = PsyHFnTdbW(26.7, state.dataDXCoils->DXCoil(DXCoilNum).InletAirHumRat);
   15149             : 
   15150          52 :     Real64 const heldOutDryBulb = state.dataEnvrn->OutDryBulbTemp;
   15151          52 :     if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(1) != 0) {
   15152           8 :         state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(1)).Temp = OutdoorUnitInletAirDryBulbTempRated;
   15153             :     } else {
   15154          44 :         state.dataEnvrn->OutDryBulbTemp = OutdoorUnitInletAirDryBulbTempRated;
   15155             :     }
   15156          52 :     SpeedRatio = 1.0;
   15157          52 :     CycRatio = 1.0;
   15158          52 :     CalcMultiSpeedDXCoil(state, DXCoilNum, SpeedRatio, CycRatio, true);
   15159          52 :     TempDryBulb_Leaving_Apoint = state.dataDXCoils->DXCoilOutletTemp(DXCoilNum); // store result
   15160             : 
   15161             :     // IEER - part load test points ***************************************************
   15162         208 :     for (PartLoadTestPoint = 1; PartLoadTestPoint <= 3; ++PartLoadTestPoint) {
   15163             :         // determine minimum unloading capacity fraction at point B conditions.
   15164         156 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(1) != 0) {
   15165          24 :             state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(1)).Temp =
   15166          24 :                 OutdoorUnitInletAirDryBulbTempPLTestPoint(PartLoadTestPoint);
   15167             :         } else {
   15168         132 :             state.dataEnvrn->OutDryBulbTemp = OutdoorUnitInletAirDryBulbTempPLTestPoint(PartLoadTestPoint);
   15169             :         }
   15170             : 
   15171         156 :         TargetNetCapacity = NetCapacityFactorPLTestPoint(PartLoadTestPoint) * NetCoolingCapRated;
   15172             : 
   15173             :         // set up parameters for the solver here
   15174         156 :         Real64 const par3 = OutdoorUnitInletAirDryBulbTempPLTestPoint(PartLoadTestPoint);
   15175         156 :         Real64 par7 = FanPowerPerEvapAirFlowRate;
   15176         156 :         int fanInNode = 0;
   15177         156 :         int fanOutNode = 0;
   15178         156 :         Real64 externalStatic = 0.0;
   15179         156 :         int fanIndex = 0;
   15180         156 :         if (state.dataDXCoils->DXCoil(DXCoilNum).RateWithInternalStaticAndFanObject) {
   15181          87 :             par7 = 0.0;
   15182          87 :             fanInNode = FanInletNode;
   15183          87 :             fanOutNode = FanOutletNode;
   15184          87 :             externalStatic = ExternalStatic;
   15185          87 :             fanIndex = state.dataDXCoils->DXCoil(DXCoilNum).SupplyFanIndex;
   15186             :         }
   15187             : 
   15188         156 :         LowerBoundMassFlowRate = 0.01 * state.dataDXCoils->DXCoil(DXCoilNum).RatedAirMassFlowRate(1);
   15189             : 
   15190             :         // OK, so there are two variables here which are const at compile time.  The question is whether compile time data needs to be
   15191             :         // explicitly captured in the lambda capture block.
   15192             :         // For GCC it currently doesn't mind whether they are captured or not, no warnings.
   15193             :         // On Clang, if you list them, there is a compiler warning.
   15194             :         // On our version of MSVC, if you take them out, the compiler will fail.  On newer versions, I think it's OK.  Should be soon anyway.
   15195             :         // To avoid this, you could pragma away the Clang warning in this section, or tell Clang to hush via compiler flags.  However, to keep things
   15196             :         // really simple, I'm just going to use two local variables and capture them instead of the original data.
   15197             :         // I'm not sure if there are any more of these instances in the codebase.  If so I am going to tag all of them with CONST_LAMBDA_CAPTURE.
   15198         156 :         Real64 dbRated = CoolingCoilInletAirDryBulbTempRated;
   15199         156 :         Real64 wbRated = CoolingCoilInletAirWetBulbTempRated;
   15200             :         auto f =
   15201             :             [&state, DXCoilNum, TempDryBulb_Leaving_Apoint, TargetNetCapacity, par3, par7, fanInNode, fanOutNode, externalStatic, dbRated, wbRated](
   15202     1297243 :                 Real64 SupplyAirMassFlowRate) {
   15203             :                 static constexpr std::string_view RoutineName("CalcTwoSpeedDXCoilIEERResidual");
   15204      110606 :                 auto &coil = state.dataDXCoils->DXCoil(DXCoilNum);
   15205       55303 :                 Real64 AirMassFlowRatio = 0.0;
   15206       55303 :                 if (coil.RatedAirMassFlowRate(1) > 0.0) {
   15207       55303 :                     AirMassFlowRatio = SupplyAirMassFlowRate / coil.RatedAirMassFlowRate(1);
   15208             :                 }
   15209      110606 :                 Real64 SupplyAirHumRat = PsyWFnTdbTwbPb(state, dbRated, wbRated, state.dataEnvrn->OutBaroPress, RoutineName);
   15210      110606 :                 Real64 SupplyAirRho = PsyRhoAirFnPbTdbW(state, state.dataEnvrn->OutBaroPress, dbRated, SupplyAirHumRat, RoutineName);
   15211       55303 :                 Real64 SupplyAirVolFlowRate = SupplyAirMassFlowRate / SupplyAirRho;
   15212             : 
   15213             :                 Real64 FanHeatCorrection;
   15214       55303 :                 if (coil.RateWithInternalStaticAndFanObject) {
   15215             :                     // modify external static per AHRI 340/360, Table 6, note 1.
   15216       66042 :                     Real64 FanStaticPressureRise = coil.InternalStaticPressureDrop + (externalStatic * pow_2(AirMassFlowRatio));
   15217       66042 :                     auto &inletNode = state.dataLoopNodes->Node(fanInNode);
   15218       66042 :                     auto &outletNode = state.dataLoopNodes->Node(fanOutNode);
   15219       33021 :                     inletNode.MassFlowRate = SupplyAirMassFlowRate;
   15220       33021 :                     outletNode.MassFlowRate = SupplyAirMassFlowRate;
   15221       33021 :                     inletNode.Temp = dbRated;
   15222       66042 :                     inletNode.HumRat = PsyWFnTdbTwbPb(state, dbRated, wbRated, state.dataEnvrn->OutBaroPress, RoutineName);
   15223       66042 :                     inletNode.Enthalpy = PsyHFnTdbW(dbRated, inletNode.HumRat);
   15224       33021 :                     if (coil.SupplyFan_TypeNum == DataHVACGlobals::FanType_SystemModelObject) {
   15225        9200 :                         state.dataHVACFan->fanObjs[coil.SupplyFanIndex]->simulate(state, _, true, false, FanStaticPressureRise);
   15226             :                     } else {
   15227       56842 :                         Fans::SimulateFanComponents(state, coil.SupplyFanName, true, coil.SupplyFanIndex, _, true, false, FanStaticPressureRise);
   15228             :                     }
   15229       33021 :                     FanHeatCorrection = SupplyAirMassFlowRate * (outletNode.Enthalpy - inletNode.Enthalpy);
   15230             :                 } else {
   15231       22282 :                     FanHeatCorrection = par7 * SupplyAirVolFlowRate;
   15232             :                 }
   15233             : 
   15234      110606 :                 Real64 TotCapFlowModFac = Curve::CurveValue(state, coil.CCapFFlow(1), AirMassFlowRatio);
   15235      165909 :                 Real64 TotCapTempModFac = Curve::CurveValue(state, coil.CCapFTemp(1), wbRated, par3);
   15236       55303 :                 Real64 HighSpeedNetCoolingCap = coil.RatedTotCap(1) * TotCapTempModFac * TotCapFlowModFac - FanHeatCorrection;
   15237             : 
   15238             :                 // TotCapFlowModFac = CurveManager::CurveValue(state, coil.CCapFFlow(1), AirMassFlowRatio);
   15239      165909 :                 TotCapTempModFac = Curve::CurveValue(state, coil.CCapFTemp2, wbRated, par3);
   15240       55303 :                 Real64 LowSpeedNetCoolingCap = coil.RatedTotCap2 * TotCapTempModFac * TotCapFlowModFac - FanHeatCorrection;
   15241             : 
   15242             :                 Real64 SpeedRatio;
   15243             :                 Real64 CycRatio;
   15244       55303 :                 if (LowSpeedNetCoolingCap <= TargetNetCapacity) {
   15245       42188 :                     CycRatio = 1.0;
   15246       42188 :                     SpeedRatio = (TargetNetCapacity - LowSpeedNetCoolingCap) / (HighSpeedNetCoolingCap - LowSpeedNetCoolingCap);
   15247             :                 } else { // minimum unloading limit exceeded for no cycling
   15248       13115 :                     SpeedRatio = 0.0;
   15249       13115 :                     CycRatio = TargetNetCapacity / LowSpeedNetCoolingCap;
   15250             :                 }
   15251             : 
   15252       55303 :                 coil.InletAirMassFlowRate = SupplyAirMassFlowRate;
   15253      110606 :                 CalcMultiSpeedDXCoil(state, DXCoilNum, SpeedRatio, CycRatio, true);
   15254      110606 :                 Real64 OutletAirTemp = state.dataDXCoils->DXCoilOutletTemp(DXCoilNum);
   15255       55303 :                 return TempDryBulb_Leaving_Apoint - OutletAirTemp;
   15256         156 :             };
   15257         156 :         General::SolveRoot(state,
   15258             :                            AccuracyTolerance,
   15259             :                            MaximumIterations,
   15260             :                            SolverFlag,
   15261             :                            PartLoadAirMassFlowRate,
   15262             :                            f,
   15263             :                            LowerBoundMassFlowRate,
   15264         156 :                            state.dataDXCoils->DXCoil(DXCoilNum).RatedAirMassFlowRate(1));
   15265             : 
   15266         156 :         if (SolverFlag == -1) {
   15267             : 
   15268           0 :             ShowWarningError(state, "CalcTwoSpeedDXCoilStandardRating: air flow rate solver failed. Iteration limit exceeded ");
   15269             : 
   15270           0 :             SupAirMdot_TestPoint(1 + PartLoadTestPoint) = -999.0;
   15271           0 :             EER_TestPoint_SI(1 + PartLoadTestPoint) = -999.0;
   15272           0 :             EER_TestPoint_IP(1 + PartLoadTestPoint) = -999.0;
   15273           0 :             NetCapacity_TestPoint(1 + PartLoadTestPoint) = -999.0;
   15274           0 :             NetPower_TestPoint(1 + PartLoadTestPoint) = -999.0;
   15275             : 
   15276         156 :         } else if (SolverFlag == -2) {
   15277           0 :             ShowWarningError(state, "CalcTwoSpeedDXCoilStandardRating: air flow rate solver failed. root not bounded ");
   15278             : 
   15279           0 :             SupAirMdot_TestPoint(1 + PartLoadTestPoint) = -999.0;
   15280           0 :             EER_TestPoint_SI(1 + PartLoadTestPoint) = -999.0;
   15281           0 :             EER_TestPoint_IP(1 + PartLoadTestPoint) = -999.0;
   15282           0 :             NetCapacity_TestPoint(1 + PartLoadTestPoint) = -999.0;
   15283           0 :             NetPower_TestPoint(1 + PartLoadTestPoint) = -999.0;
   15284             :         } else {
   15285             :             // now we have the supply air flow rate
   15286         156 :             SupAirMdot_TestPoint(1 + PartLoadTestPoint) = PartLoadAirMassFlowRate;
   15287         156 :             AirMassFlowRatio = PartLoadAirMassFlowRate / state.dataDXCoils->DXCoil(DXCoilNum).RatedAirMassFlowRate(1);
   15288         156 :             SupplyAirHumRat = PsyWFnTdbTwbPb(
   15289         156 :                 state, CoolingCoilInletAirDryBulbTempRated, CoolingCoilInletAirWetBulbTempRated, state.dataEnvrn->OutBaroPress, RoutineName);
   15290         156 :             SupplyAirRho = PsyRhoAirFnPbTdbW(state, state.dataEnvrn->OutBaroPress, CoolingCoilInletAirDryBulbTempRated, SupplyAirHumRat, RoutineName);
   15291         156 :             SupplyAirVolFlowRate = PartLoadAirMassFlowRate / SupplyAirRho;
   15292             : 
   15293         156 :             if (state.dataDXCoils->DXCoil(DXCoilNum).RateWithInternalStaticAndFanObject) {
   15294          87 :                 FanStaticPressureRise = state.dataDXCoils->DXCoil(DXCoilNum).InternalStaticPressureDrop + (ExternalStatic * pow_2(AirMassFlowRatio));
   15295          87 :                 state.dataLoopNodes->Node(FanInletNode).MassFlowRate = PartLoadAirMassFlowRate;
   15296          87 :                 state.dataLoopNodes->Node(FanInletNode).Temp = CoolingCoilInletAirDryBulbTempRated;
   15297          87 :                 state.dataLoopNodes->Node(FanInletNode).HumRat = SupplyAirHumRat;
   15298          87 :                 state.dataLoopNodes->Node(FanInletNode).Enthalpy = PsyHFnTdbW(CoolingCoilInletAirDryBulbTempRated, SupplyAirHumRat);
   15299             : 
   15300          87 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).SupplyFan_TypeNum == DataHVACGlobals::FanType_SystemModelObject) {
   15301          12 :                     state.dataHVACFan->fanObjs[state.dataDXCoils->DXCoil(DXCoilNum).SupplyFanIndex]->simulate(
   15302             :                         state, _, true, false, FanStaticPressureRise);
   15303          12 :                     FanPowerCorrection = state.dataHVACFan->fanObjs[state.dataDXCoils->DXCoil(DXCoilNum).SupplyFanIndex]->fanPower();
   15304             :                 } else {
   15305         225 :                     Fans::SimulateFanComponents(state,
   15306          75 :                                                 state.dataDXCoils->DXCoil(DXCoilNum).SupplyFanName,
   15307             :                                                 true,
   15308          75 :                                                 state.dataDXCoils->DXCoil(DXCoilNum).SupplyFanIndex,
   15309             :                                                 _,
   15310             :                                                 true,
   15311             :                                                 false,
   15312             :                                                 FanStaticPressureRise);
   15313          75 :                     FanPowerCorrection = Fans::GetFanPower(state, state.dataDXCoils->DXCoil(DXCoilNum).SupplyFanIndex);
   15314             :                 }
   15315             : 
   15316          87 :                 FanHeatCorrection =
   15317          87 :                     PartLoadAirMassFlowRate * (state.dataLoopNodes->Node(FanOutletNode).Enthalpy - state.dataLoopNodes->Node(FanInletNode).Enthalpy);
   15318             : 
   15319             :             } else {
   15320          69 :                 FanPowerCorrection = FanPowerPerEvapAirFlowRate * PartLoadAirMassFlowRate;
   15321          69 :                 FanHeatCorrection = FanPowerPerEvapAirFlowRate * PartLoadAirMassFlowRate;
   15322             :             }
   15323             : 
   15324         156 :             TotCapFlowModFac = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).CCapFFlow(1), AirMassFlowRatio);
   15325             :             //    Warn user if curve output goes negative
   15326         156 :             if (TotCapFlowModFac < 0.0) {
   15327           0 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).CCapFFlowErrorIndex == 0) {
   15328           0 :                     ShowWarningMessage(
   15329             :                         state,
   15330           0 :                         format(
   15331           0 :                             "{}{} \"{}\":", RoutineName, state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType, state.dataDXCoils->DXCoil(DXCoilNum).Name));
   15332           0 :                     ShowContinueError(
   15333             :                         state,
   15334           0 :                         format(" Total Cooling Capacity Modifier curve (function of flow fraction) output is negative ({:.3T}).", TotCapFlowModFac));
   15335           0 :                     ShowContinueError(state, format(" Negative value occurs using an air flow fraction of {:.3T}.", AirMassFlowRatio));
   15336           0 :                     ShowContinueErrorTimeStamp(state, " Resetting curve output to zero and continuing simulation.");
   15337             :                 }
   15338           0 :                 ShowRecurringWarningErrorAtEnd(
   15339             :                     state,
   15340           0 :                     format("{}{}\"{}\": Total Cooling Capacity Modifier curve (function of flow fraction) output is negative warning continues...",
   15341             :                            RoutineName,
   15342           0 :                            state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
   15343           0 :                            state.dataDXCoils->DXCoil(DXCoilNum).Name),
   15344           0 :                     state.dataDXCoils->DXCoil(DXCoilNum).CCapFFlowErrorIndex,
   15345             :                     TotCapFlowModFac,
   15346             :                     TotCapFlowModFac);
   15347           0 :                 TotCapFlowModFac = 0.0;
   15348             :             }
   15349             : 
   15350         312 :             TotCapTempModFac = CurveValue(state,
   15351         156 :                                           state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp(1),
   15352             :                                           CoolingCoilInletAirWetBulbTempRated,
   15353             :                                           OutdoorUnitInletAirDryBulbTempPLTestPoint(PartLoadTestPoint));
   15354             :             //    Warn user if curve output goes negative
   15355         156 :             if (TotCapTempModFac < 0.0) {
   15356           0 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).CCapFTempErrorIndex == 0) {
   15357           0 :                     ShowWarningMessage(
   15358             :                         state,
   15359           0 :                         format(
   15360           0 :                             "{}{} \"{}\":", RoutineName, state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType, state.dataDXCoils->DXCoil(DXCoilNum).Name));
   15361           0 :                     ShowContinueError(
   15362             :                         state,
   15363           0 :                         format(" Total Cooling Capacity Modifier curve (function of temperature) output is negative ({:.3T}).", TotCapTempModFac));
   15364           0 :                     ShowContinueError(state,
   15365           0 :                                       format(" Negative value occurs using a coil inlet wet-bulb temperature of {:.1T} and an outdoor unit inlet air "
   15366             :                                              "dry-bulb temperature of {:.1T}.",
   15367             :                                              CoolingCoilInletAirWetBulbTempRated,
   15368           0 :                                              OutdoorUnitInletAirDryBulbTempPLTestPoint(PartLoadTestPoint)));
   15369           0 :                     ShowContinueErrorTimeStamp(state, " Resetting curve output to zero and continuing simulation.");
   15370             :                 }
   15371           0 :                 ShowRecurringWarningErrorAtEnd(
   15372             :                     state,
   15373           0 :                     format("{}{} \"{}\": Total Cooling Capacity Modifier curve (function of temperature) output is negative warning continues...",
   15374             :                            RoutineName,
   15375           0 :                            state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
   15376           0 :                            state.dataDXCoils->DXCoil(DXCoilNum).Name),
   15377           0 :                     state.dataDXCoils->DXCoil(DXCoilNum).CCapFTempErrorIndex,
   15378             :                     TotCapTempModFac,
   15379             :                     TotCapTempModFac);
   15380           0 :                 TotCapTempModFac = 0.0;
   15381             :             }
   15382             : 
   15383         156 :             HighSpeedTotCoolingCap = state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(1) * TotCapTempModFac * TotCapFlowModFac;
   15384         156 :             HighSpeedNetCoolingCap = HighSpeedTotCoolingCap - FanHeatCorrection;
   15385             : 
   15386         312 :             EIRTempModFac = CurveValue(state,
   15387         156 :                                        state.dataDXCoils->DXCoil(DXCoilNum).EIRFTemp(1),
   15388             :                                        CoolingCoilInletAirWetBulbTempRated,
   15389             :                                        OutdoorUnitInletAirDryBulbTempPLTestPoint(PartLoadTestPoint));
   15390         156 :             EIRFlowModFac = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).EIRFFlow(1), AirMassFlowRatio);
   15391         156 :             if (state.dataDXCoils->DXCoil(DXCoilNum).RatedCOP(1) > 0.0) {
   15392             :                 // RatedCOP <= 0.0 is trapped in GetInput, but keep this as "safety"
   15393         156 :                 EIR_HighSpeed = EIRTempModFac * EIRFlowModFac / state.dataDXCoils->DXCoil(DXCoilNum).RatedCOP(1);
   15394             :             } else {
   15395           0 :                 EIR = 0.0;
   15396             :             }
   15397             : 
   15398             :             // TotCapFlowModFac = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).CCapFFlow(1), AirMassFlowRatio);
   15399         312 :             TotCapTempModFac = CurveValue(state,
   15400         156 :                                           state.dataDXCoils->DXCoil(DXCoilNum).CCapFTemp2,
   15401             :                                           CoolingCoilInletAirWetBulbTempRated,
   15402             :                                           OutdoorUnitInletAirDryBulbTempPLTestPoint(PartLoadTestPoint));
   15403             :             //    Warn user if curve output goes negative
   15404         156 :             if (TotCapTempModFac < 0.0) {
   15405           0 :                 if (state.dataDXCoils->DXCoil(DXCoilNum).CCapFTempErrorIndex == 0) {
   15406           0 :                     ShowWarningMessage(
   15407             :                         state,
   15408           0 :                         format(
   15409           0 :                             "{}{} \"{}\":", RoutineName, state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType, state.dataDXCoils->DXCoil(DXCoilNum).Name));
   15410           0 :                     ShowContinueError(
   15411             :                         state,
   15412           0 :                         format(" Total Cooling Capacity Modifier curve (function of temperature) output is negative ({:.3T}).", TotCapTempModFac));
   15413           0 :                     ShowContinueError(state,
   15414           0 :                                       format(" Negative value occurs using a coil inlet wet-bulb temperature of {:.1T} and an outdoor unit inlet air "
   15415             :                                              "dry-bulb temperature of {:.1T}.",
   15416             :                                              CoolingCoilInletAirWetBulbTempRated,
   15417           0 :                                              OutdoorUnitInletAirDryBulbTempPLTestPoint(PartLoadTestPoint)));
   15418           0 :                     ShowContinueErrorTimeStamp(state, " Resetting curve output to zero and continuing simulation.");
   15419             :                 }
   15420           0 :                 ShowRecurringWarningErrorAtEnd(
   15421             :                     state,
   15422           0 :                     format("{}{} \"{}\": Total Cooling Capacity Modifier curve (function of temperature) output is negative warning continues...",
   15423             :                            RoutineName,
   15424           0 :                            state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
   15425           0 :                            state.dataDXCoils->DXCoil(DXCoilNum).Name),
   15426           0 :                     state.dataDXCoils->DXCoil(DXCoilNum).CCapFTempErrorIndex,
   15427             :                     TotCapTempModFac,
   15428             :                     TotCapTempModFac);
   15429           0 :                 TotCapTempModFac = 0.0;
   15430             :             }
   15431             : 
   15432         156 :             LowSpeedTotCoolingCap = state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap2 * TotCapTempModFac * TotCapFlowModFac;
   15433         156 :             LowSpeedNetCoolingCap = LowSpeedTotCoolingCap - FanHeatCorrection;
   15434             : 
   15435         312 :             EIRTempModFac = CurveValue(state,
   15436         156 :                                        state.dataDXCoils->DXCoil(DXCoilNum).EIRFTemp2,
   15437             :                                        CoolingCoilInletAirWetBulbTempRated,
   15438             :                                        OutdoorUnitInletAirDryBulbTempPLTestPoint(PartLoadTestPoint));
   15439         156 :             EIRFlowModFac = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).EIRFFlow(1), AirMassFlowRatio);
   15440         156 :             if (state.dataDXCoils->DXCoil(DXCoilNum).RatedCOP2 > 0.0) {
   15441             :                 // RatedCOP <= 0.0 is trapped in GetInput, but keep this as "safety"
   15442         156 :                 EIR_LowSpeed = EIRTempModFac * EIRFlowModFac / state.dataDXCoils->DXCoil(DXCoilNum).RatedCOP2;
   15443             :             } else {
   15444           0 :                 EIR_LowSpeed = 0.0;
   15445             :             }
   15446             : 
   15447         156 :             if (LowSpeedNetCoolingCap <= TargetNetCapacity) {
   15448         104 :                 CycRatio = 1.0;
   15449         104 :                 SpeedRatio = (TargetNetCapacity - LowSpeedNetCoolingCap) / (HighSpeedNetCoolingCap - LowSpeedNetCoolingCap);
   15450         104 :                 TotCoolingCap = HighSpeedTotCoolingCap * SpeedRatio + LowSpeedTotCoolingCap * (1.0 - SpeedRatio);
   15451         104 :                 NetCoolingCap = TotCoolingCap - FanHeatCorrection;
   15452         104 :                 EIR = EIR_HighSpeed * SpeedRatio + EIR_LowSpeed * (1.0 - SpeedRatio);
   15453         104 :                 TotalElecPowerRated = TotCoolingCap * EIR + FanPowerCorrection;
   15454         104 :                 EER_TestPoint_SI(1 + PartLoadTestPoint) = NetCoolingCap / TotalElecPowerRated;
   15455         104 :                 EER_TestPoint_IP(1 + PartLoadTestPoint) = EER_TestPoint_SI(1 + PartLoadTestPoint) * ConvFromSIToIP;
   15456         104 :                 NetCapacity_TestPoint(1 + PartLoadTestPoint) = NetCoolingCap;
   15457         104 :                 NetPower_TestPoint(1 + PartLoadTestPoint) = TotalElecPowerRated;
   15458             :             } else { // minimum unloading limit exceeded without cycling, so cycle
   15459          52 :                 SpeedRatio = 0.0;
   15460          52 :                 CycRatio = TargetNetCapacity / LowSpeedNetCoolingCap;
   15461          52 :                 PLF = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(1), CycRatio);
   15462          52 :                 if (PLF < 0.7) {
   15463           0 :                     PLF = 0.7;
   15464             :                 }
   15465          52 :                 RunTimeFraction = CycRatio / PLF;
   15466          52 :                 RunTimeFraction = min(RunTimeFraction, 1.0);
   15467          52 :                 TotCoolingCap = LowSpeedTotCoolingCap * RunTimeFraction;
   15468          52 :                 NetCoolingCap = TotCoolingCap - FanHeatCorrection;
   15469          52 :                 TotalElecPowerRated = LowSpeedTotCoolingCap * EIR_LowSpeed * RunTimeFraction + FanPowerCorrection;
   15470          52 :                 EER_TestPoint_SI(1 + PartLoadTestPoint) = NetCoolingCap / TotalElecPowerRated;
   15471          52 :                 EER_TestPoint_IP(1 + PartLoadTestPoint) = EER_TestPoint_SI(1 + PartLoadTestPoint) * ConvFromSIToIP;
   15472          52 :                 NetCapacity_TestPoint(1 + PartLoadTestPoint) = NetCoolingCap;
   15473          52 :                 NetPower_TestPoint(1 + PartLoadTestPoint) = TotalElecPowerRated;
   15474             :             }
   15475             :         }
   15476             :     } // loop over 3 part load test points
   15477             : 
   15478          52 :     IEER = (0.02 * EER_TestPoint_IP(1)) + (0.617 * EER_TestPoint_IP(2)) + (0.238 * EER_TestPoint_IP(3)) + (0.125 * EER_TestPoint_IP(4));
   15479             : 
   15480             :     // begin output
   15481          52 :     if (state.dataDXCoils->CalcTwoSpeedDXCoilStandardRatingOneTimeEIOHeaderWrite) {
   15482          23 :         print(state.files.eio, Header);
   15483          23 :         state.dataDXCoils->CalcTwoSpeedDXCoilStandardRatingOneTimeEIOHeaderWrite = false;
   15484          23 :         state.dataOutRptPredefined->pdstVAVDXCoolCoil =
   15485          46 :             newPreDefSubTable(state, state.dataOutRptPredefined->pdrEquip, "VAV DX Cooling Standard Rating Details");
   15486          23 :         state.dataOutRptPredefined->pdchVAVDXCoolCoilType =
   15487          46 :             newPreDefColumn(state, state.dataOutRptPredefined->pdstVAVDXCoolCoil, "DX Cooling Coil Type");
   15488          23 :         state.dataOutRptPredefined->pdchVAVDXFanName = newPreDefColumn(state, state.dataOutRptPredefined->pdstVAVDXCoolCoil, "Assocated Fan");
   15489          23 :         state.dataOutRptPredefined->pdchVAVDXCoolCoilNetCapSI =
   15490          46 :             newPreDefColumn(state, state.dataOutRptPredefined->pdstVAVDXCoolCoil, "Net Cooling Capacity [W]");
   15491          23 :         state.dataOutRptPredefined->pdchVAVDXCoolCoilCOP = newPreDefColumn(state, state.dataOutRptPredefined->pdstVAVDXCoolCoil, "COP [W/W]");
   15492          23 :         state.dataOutRptPredefined->pdchVAVDXCoolCoilEERIP = newPreDefColumn(state, state.dataOutRptPredefined->pdstVAVDXCoolCoil, "EER [Btu/W-h]");
   15493          23 :         state.dataOutRptPredefined->pdchVAVDXCoolCoilIEERIP = newPreDefColumn(state, state.dataOutRptPredefined->pdstVAVDXCoolCoil, "IEER [Btu/W-h]");
   15494          23 :         state.dataOutRptPredefined->pdchVAVDXCoolCoilMdotA =
   15495          46 :             newPreDefColumn(state, state.dataOutRptPredefined->pdstVAVDXCoolCoil, "Supply Air Flow 100% [kg/s]");
   15496          23 :         state.dataOutRptPredefined->pdchVAVDXCoolCoilCOP_B =
   15497          46 :             newPreDefColumn(state, state.dataOutRptPredefined->pdstVAVDXCoolCoil, "COP 75% Capacity [W/W]");
   15498          23 :         state.dataOutRptPredefined->pdchVAVDXCoolCoilEER_B_IP =
   15499          46 :             newPreDefColumn(state, state.dataOutRptPredefined->pdstVAVDXCoolCoil, "EER 75% Capacity [Btu/W-h]");
   15500          23 :         state.dataOutRptPredefined->pdchVAVDXCoolCoilMdotB =
   15501          46 :             newPreDefColumn(state, state.dataOutRptPredefined->pdstVAVDXCoolCoil, "Supply Air Flow 75% [kg/s]");
   15502          23 :         state.dataOutRptPredefined->pdchVAVDXCoolCoilCOP_C =
   15503          46 :             newPreDefColumn(state, state.dataOutRptPredefined->pdstVAVDXCoolCoil, "COP 50% Capacity [W/W]");
   15504          23 :         state.dataOutRptPredefined->pdchVAVDXCoolCoilEER_C_IP =
   15505          46 :             newPreDefColumn(state, state.dataOutRptPredefined->pdstVAVDXCoolCoil, "EER 50% Capacity [Btu/W-h]");
   15506          23 :         state.dataOutRptPredefined->pdchVAVDXCoolCoilMdotC =
   15507          46 :             newPreDefColumn(state, state.dataOutRptPredefined->pdstVAVDXCoolCoil, "Supply Air Flow 50% [kg/s]");
   15508          23 :         state.dataOutRptPredefined->pdchVAVDXCoolCoilCOP_D =
   15509          46 :             newPreDefColumn(state, state.dataOutRptPredefined->pdstVAVDXCoolCoil, "COP 25% Capacity [W/W]");
   15510          23 :         state.dataOutRptPredefined->pdchVAVDXCoolCoilEER_D_IP =
   15511          46 :             newPreDefColumn(state, state.dataOutRptPredefined->pdstVAVDXCoolCoil, "EER 25% Capacity [Btu/W-h]");
   15512          23 :         state.dataOutRptPredefined->pdchVAVDXCoolCoilMdotD =
   15513          46 :             newPreDefColumn(state, state.dataOutRptPredefined->pdstVAVDXCoolCoil, "Supply Air Flow 25% [kg/s]");
   15514             : 
   15515             :         // determine footnote content
   15516          23 :         countStaticInputs = 0;
   15517          92 :         for (index = 1; index <= state.dataDXCoils->NumDXCoils; ++index) {
   15518             : 
   15519          98 :             if (state.dataDXCoils->DXCoil(index).RateWithInternalStaticAndFanObject &&
   15520          29 :                 state.dataDXCoils->DXCoil(index).DXCoilType_Num == CoilDX_CoolingTwoSpeed) {
   15521          29 :                 ++countStaticInputs;
   15522             :             }
   15523             :         }
   15524             : 
   15525          23 :         if (countStaticInputs == state.dataDXCoils->NumDXMulSpeedCoils) {
   15526          11 :             addFootNoteSubTable(state,
   15527          11 :                                 state.dataOutRptPredefined->pdstVAVDXCoolCoil,
   15528          11 :                                 "Packaged VAV unit ratings per ANSI/AHRI Standard 340/360-2007 with Addenda 1 and 2");
   15529          12 :         } else if (countStaticInputs == 0) {
   15530          12 :             addFootNoteSubTable(state,
   15531          12 :                                 state.dataOutRptPredefined->pdstVAVDXCoolCoil,
   15532             :                                 "Indoor-coil-only unit ratings per ANSI/AHRI Standard 340/360-2007 with Addenda 1 and 2, with "
   15533          12 :                                 "supply fan specific power at 365 {{W/1000cfm}} (773.3 {{W/(m3/s)}})");
   15534             :         } else { // both
   15535           0 :             addFootNoteSubTable(state,
   15536           0 :                                 state.dataOutRptPredefined->pdstVAVDXCoolCoil,
   15537             :                                 "Packaged VAV unit ratings per ANSI/AHRI Standard 340/360-2007 with Addenda 1 and 2, "
   15538           0 :                                 "indoor-coil-only units with supply fan specific power at 365 {{W/1000cfm}} (773.3 {{W/(m3/s)}})");
   15539             :         }
   15540             :     }
   15541             : 
   15542          52 :     const auto &fan_type_name = [&]() -> std::pair<const char *, std::string> {
   15543         110 :         if (state.dataDXCoils->DXCoil(DXCoilNum).RateWithInternalStaticAndFanObject) {
   15544          87 :             return {"Fan:VariableVolume", state.dataDXCoils->DXCoil(DXCoilNum).SupplyFanName};
   15545             :         } else {
   15546          23 :             return {"N/A", "N/A"};
   15547             :         }
   15548         104 :     }();
   15549             : 
   15550         156 :     print(state.files.eio,
   15551             :           Format_891,
   15552             :           "Coil:Cooling:DX:TwoSpeed",
   15553          52 :           state.dataDXCoils->DXCoil(DXCoilNum).Name,
   15554             :           fan_type_name.first,
   15555             :           fan_type_name.second,
   15556             :           NetCoolingCapRated,
   15557         104 :           (NetCoolingCapRated * ConvFromSIToIP),
   15558             :           IEER,
   15559             :           EER_TestPoint_SI(1),
   15560             :           EER_TestPoint_SI(2),
   15561             :           EER_TestPoint_SI(3),
   15562             :           EER_TestPoint_SI(4),
   15563             :           EER_TestPoint_IP(1),
   15564             :           EER_TestPoint_IP(2),
   15565             :           EER_TestPoint_IP(3),
   15566             :           EER_TestPoint_IP(4),
   15567             :           SupAirMdot_TestPoint(1),
   15568             :           SupAirMdot_TestPoint(2),
   15569             :           SupAirMdot_TestPoint(3),
   15570             :           SupAirMdot_TestPoint(4));
   15571             : 
   15572          52 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilType, state.dataDXCoils->DXCoil(DXCoilNum).Name, "Coil:Cooling:DX:TwoSpeed");
   15573             :     // W to tons
   15574          52 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilNetCapSI, state.dataDXCoils->DXCoil(DXCoilNum).Name, NetCoolingCapRated, 1);
   15575             :     // These will convert with a factor of 1 which is ok
   15576          52 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilCOP, state.dataDXCoils->DXCoil(DXCoilNum).Name, EER_TestPoint_SI(1), 2);
   15577          52 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilEERIP, state.dataDXCoils->DXCoil(DXCoilNum).Name, EER_TestPoint_IP(1), 2);
   15578          52 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilIEERIP, state.dataDXCoils->DXCoil(DXCoilNum).Name, IEER, 2);
   15579          52 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilSEERUserIP, state.dataDXCoils->DXCoil(DXCoilNum).Name, "N/A");
   15580          52 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilSEERStandardIP, state.dataDXCoils->DXCoil(DXCoilNum).Name, "N/A");
   15581          52 :     addFootNoteSubTable(state, state.dataOutRptPredefined->pdstDXCoolCoil, "ANSI/AHRI ratings include supply fan");
   15582             : 
   15583          52 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchVAVDXCoolCoilType, state.dataDXCoils->DXCoil(DXCoilNum).Name, "Coil:Cooling:DX:TwoSpeed");
   15584          52 :     if (state.dataDXCoils->DXCoil(DXCoilNum).RateWithInternalStaticAndFanObject) {
   15585          87 :         PreDefTableEntry(state,
   15586          29 :                          state.dataOutRptPredefined->pdchVAVDXFanName,
   15587          29 :                          state.dataDXCoils->DXCoil(DXCoilNum).Name,
   15588          29 :                          state.dataDXCoils->DXCoil(DXCoilNum).SupplyFanName);
   15589             :     } else {
   15590          23 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchVAVDXFanName, state.dataDXCoils->DXCoil(DXCoilNum).Name, "None");
   15591             :     }
   15592          52 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchVAVDXCoolCoilNetCapSI, state.dataDXCoils->DXCoil(DXCoilNum).Name, NetCoolingCapRated, 2);
   15593          52 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchVAVDXCoolCoilCOP, state.dataDXCoils->DXCoil(DXCoilNum).Name, EER_TestPoint_SI(1), 2);
   15594          52 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchVAVDXCoolCoilIEERIP, state.dataDXCoils->DXCoil(DXCoilNum).Name, IEER, 2);
   15595          52 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchVAVDXCoolCoilEERIP, state.dataDXCoils->DXCoil(DXCoilNum).Name, EER_TestPoint_IP(1), 2);
   15596         208 :     PreDefTableEntry(
   15597         156 :         state, state.dataOutRptPredefined->pdchVAVDXCoolCoilMdotA, state.dataDXCoils->DXCoil(DXCoilNum).Name, SupAirMdot_TestPoint(1), 4);
   15598          52 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchVAVDXCoolCoilCOP_B, state.dataDXCoils->DXCoil(DXCoilNum).Name, EER_TestPoint_SI(2), 2);
   15599          52 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchVAVDXCoolCoilEER_B_IP, state.dataDXCoils->DXCoil(DXCoilNum).Name, EER_TestPoint_IP(2), 2);
   15600         208 :     PreDefTableEntry(
   15601         156 :         state, state.dataOutRptPredefined->pdchVAVDXCoolCoilMdotB, state.dataDXCoils->DXCoil(DXCoilNum).Name, SupAirMdot_TestPoint(2), 4);
   15602          52 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchVAVDXCoolCoilCOP_C, state.dataDXCoils->DXCoil(DXCoilNum).Name, EER_TestPoint_SI(3), 2);
   15603          52 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchVAVDXCoolCoilEER_C_IP, state.dataDXCoils->DXCoil(DXCoilNum).Name, EER_TestPoint_IP(3), 2);
   15604         208 :     PreDefTableEntry(
   15605         156 :         state, state.dataOutRptPredefined->pdchVAVDXCoolCoilMdotC, state.dataDXCoils->DXCoil(DXCoilNum).Name, SupAirMdot_TestPoint(3), 4);
   15606          52 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchVAVDXCoolCoilCOP_D, state.dataDXCoils->DXCoil(DXCoilNum).Name, EER_TestPoint_SI(4), 2);
   15607          52 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchVAVDXCoolCoilEER_D_IP, state.dataDXCoils->DXCoil(DXCoilNum).Name, EER_TestPoint_IP(4), 2);
   15608         208 :     PreDefTableEntry(
   15609         156 :         state, state.dataOutRptPredefined->pdchVAVDXCoolCoilMdotD, state.dataDXCoils->DXCoil(DXCoilNum).Name, SupAirMdot_TestPoint(4), 4);
   15610             : 
   15611          52 :     state.dataEnvrn->OutDryBulbTemp = heldOutDryBulb; // reset the outdoor dry bulb when done with it
   15612             : }
   15613             : 
   15614          66 : void GetFanIndexForTwoSpeedCoil(
   15615             :     EnergyPlusData &state, int const CoolingCoilIndex, int &SupplyFanIndex, std::string &SupplyFanName, int &SupplyFan_TypeNum)
   15616             : {
   15617             : 
   15618             :     // SUBROUTINE INFORMATION:
   15619             :     //       AUTHOR         <author>
   15620             :     //       DATE WRITTEN   <date_written>
   15621             : 
   15622             :     // PURPOSE OF THIS SUBROUTINE:
   15623             :     // This routine looks up the given TwoSpeed DX coil and returns the companion supply fan index
   15624             : 
   15625             :     // Using/Aliasing
   15626          66 :     auto &NumPrimaryAirSys = state.dataHVACGlobal->NumPrimaryAirSys;
   15627             : 
   15628             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   15629             :     int FoundBranch;
   15630             :     int FoundAirSysNum;
   15631             :     int AirSysNum;
   15632             :     int BranchNum;
   15633             :     int CompNum;
   15634          66 :     bool ErrorsFound(false);
   15635             : 
   15636          66 :     FoundBranch = 0;
   15637          66 :     FoundAirSysNum = 0;
   15638          66 :     SupplyFanIndex = -1;
   15639          66 :     SupplyFanName = "n/a";
   15640         322 :     for (AirSysNum = 1; AirSysNum <= NumPrimaryAirSys; ++AirSysNum) {
   15641             : 
   15642         512 :         for (BranchNum = 1; BranchNum <= state.dataAirSystemsData->PrimaryAirSystems(AirSysNum).NumBranches; ++BranchNum) {
   15643             : 
   15644        1066 :             for (CompNum = 1; CompNum <= state.dataAirSystemsData->PrimaryAirSystems(AirSysNum).Branch(BranchNum).TotalComponents; ++CompNum) {
   15645             : 
   15646         876 :                 if (state.dataAirSystemsData->PrimaryAirSystems(AirSysNum).Branch(BranchNum).Comp(CompNum).CompType_Num ==
   15647             :                     SimAirServingZones::CompType::DXSystem) {
   15648             : 
   15649         224 :                     if (UtilityRoutines::SameString(state.dataAirSystemsData->PrimaryAirSystems(AirSysNum).Branch(BranchNum).Comp(CompNum).Name,
   15650         224 :                                                     state.dataDXCoils->DXCoil(CoolingCoilIndex).CoilSystemName)) {
   15651          66 :                         FoundBranch = BranchNum;
   15652          66 :                         FoundAirSysNum = AirSysNum;
   15653          66 :                         break;
   15654             :                     }
   15655             :                     // these are specified in SimAirServingZones and need to be moved to a Data* file. UnitarySystem=19
   15656         652 :                 } else if (state.dataAirSystemsData->PrimaryAirSystems(AirSysNum).Branch(BranchNum).Comp(CompNum).CompType_Num ==
   15657             :                            SimAirServingZones::CompType::UnitarySystemModel) {
   15658             : 
   15659          12 :                     if (UtilityRoutines::SameString(state.dataAirSystemsData->PrimaryAirSystems(AirSysNum).Branch(BranchNum).Comp(CompNum).Name,
   15660          12 :                                                     state.dataDXCoils->DXCoil(CoolingCoilIndex).CoilSystemName)) {
   15661           0 :                         FoundBranch = BranchNum;
   15662           0 :                         FoundAirSysNum = AirSysNum;
   15663           0 :                         break;
   15664             :                     }
   15665             :                 }
   15666             :             }
   15667             : 
   15668         256 :             if (FoundBranch > 0 && FoundAirSysNum > 0) {
   15669         657 :                 for (CompNum = 1; CompNum <= state.dataAirSystemsData->PrimaryAirSystems(FoundAirSysNum).Branch(FoundBranch).TotalComponents;
   15670             :                      ++CompNum) {
   15671         604 :                     if (state.dataAirSystemsData->PrimaryAirSystems(FoundAirSysNum).Branch(FoundBranch).Comp(CompNum).CompType_Num ==
   15672             :                         SimAirServingZones::CompType::Fan_Simple_VAV) {
   15673          99 :                         SupplyFanName = state.dataAirSystemsData->PrimaryAirSystems(FoundAirSysNum).Branch(FoundBranch).Comp(CompNum).Name;
   15674          99 :                         Fans::GetFanIndex(state, SupplyFanName, SupplyFanIndex, ErrorsFound);
   15675          99 :                         SupplyFan_TypeNum = DataHVACGlobals::FanType_SimpleVAV;
   15676          99 :                         break;
   15677             :                         // these are specified in SimAirServingZones and need to be moved to a Data* file. UnitarySystem=19
   15678         505 :                     } else if (state.dataAirSystemsData->PrimaryAirSystems(FoundAirSysNum).Branch(FoundBranch).Comp(CompNum).CompType_Num ==
   15679             :                                SimAirServingZones::CompType::Fan_System_Object) {
   15680          12 :                         SupplyFanName = state.dataAirSystemsData->PrimaryAirSystems(FoundAirSysNum).Branch(FoundBranch).Comp(CompNum).Name;
   15681          12 :                         SupplyFanIndex = HVACFan::getFanObjectVectorIndex(state, SupplyFanName);
   15682          12 :                         SupplyFan_TypeNum = DataHVACGlobals::FanType_SystemModelObject;
   15683             : 
   15684         493 :                     } else if (state.dataAirSystemsData->PrimaryAirSystems(FoundAirSysNum).Branch(FoundBranch).Comp(CompNum).CompType_Num ==
   15685             :                                SimAirServingZones::CompType::UnitarySystemModel) {
   15686             :                         // fan may not be specified in a unitary system object, keep looking
   15687             :                         // Unitary System will "set" the fan index to the DX coil if contained within the HVAC system
   15688           0 :                         if (state.dataDXCoils->DXCoil(CoolingCoilIndex).SupplyFanIndex > -1) break;
   15689             :                     }
   15690             :                 }
   15691             :             }
   15692             :         }
   15693             :     }
   15694          66 : }
   15695             : 
   15696         956 : void GetDXCoilIndex(EnergyPlusData &state,
   15697             :                     std::string const &DXCoilName,
   15698             :                     int &DXCoilIndex,
   15699             :                     bool &ErrorsFound,
   15700             :                     std::string_view const ThisObjectType,
   15701             :                     bool const SuppressWarning)
   15702             : {
   15703             : 
   15704             :     // SUBROUTINE INFORMATION:
   15705             :     //       AUTHOR         Richard Raustad
   15706             :     //       DATE WRITTEN   March 2005
   15707             : 
   15708             :     // PURPOSE OF THIS SUBROUTINE:
   15709             :     // This subroutine sets an index for a given DX Coil -- issues error message if that
   15710             :     // DX Coil is not a legal DX Coil.
   15711             : 
   15712         956 :     if (state.dataDXCoils->GetCoilsInputFlag) {
   15713         135 :         GetDXCoils(state);
   15714         135 :         state.dataDXCoils->GetCoilsInputFlag = false;
   15715             :     }
   15716             : 
   15717         956 :     DXCoilIndex = UtilityRoutines::FindItemInList(DXCoilName, state.dataDXCoils->DXCoil);
   15718         956 :     if (DXCoilIndex == 0) {
   15719           7 :         if (!SuppressWarning) {
   15720             :             //     No warning printed if only searching for the existence of a DX Coil
   15721           0 :             if (!ThisObjectType.empty()) {
   15722           0 :                 ShowSevereError(state, fmt::format("{}, GetDXCoilIndex: DX Coil not found={}", ThisObjectType, DXCoilName));
   15723             :             } else {
   15724           0 :                 ShowSevereError(state, "GetDXCoilIndex: DX Coil not found=" + DXCoilName);
   15725             :             }
   15726             :         }
   15727           7 :         ErrorsFound = true;
   15728             :     }
   15729         956 : }
   15730             : 
   15731             : std::string
   15732          15 : GetDXCoilName(EnergyPlusData &state, int &DXCoilIndex, bool &ErrorsFound, std::string_view const ThisObjectType, bool const SuppressWarning)
   15733             : {
   15734             : 
   15735             :     // SUBROUTINE INFORMATION:
   15736             :     //       AUTHOR         Richard Raustad
   15737             :     //       DATE WRITTEN   May 2017
   15738             : 
   15739             :     // PURPOSE OF THIS SUBROUTINE:
   15740             :     // This subroutine gets a name for a given DX Coil -- issues error message if that
   15741             :     // DX Coil is not a legal DX Coil.
   15742             : 
   15743          15 :     if (state.dataDXCoils->GetCoilsInputFlag) {
   15744           0 :         GetDXCoils(state);
   15745           0 :         state.dataDXCoils->GetCoilsInputFlag = false;
   15746             :     }
   15747             : 
   15748          15 :     if (DXCoilIndex == 0) {
   15749           0 :         if (!SuppressWarning) {
   15750             :             //     No warning printed if only searching for the existence of a DX Coil
   15751           0 :             if (!ThisObjectType.empty()) {
   15752           0 :                 ShowSevereError(state, fmt::format("{}, GetDXCoilIndex: DX Coil not found ", ThisObjectType));
   15753             :             } else {
   15754           0 :                 ShowSevereError(state, "GetDXCoilIndex: DX Coil not found ");
   15755             :             }
   15756             :         }
   15757           0 :         ErrorsFound = true;
   15758           0 :         return " "; // This does not seem great
   15759             : 
   15760             :     } else {
   15761          15 :         return state.dataDXCoils->DXCoil(DXCoilIndex).Name;
   15762             :     }
   15763             : }
   15764             : 
   15765         238 : Real64 GetCoilCapacity(EnergyPlusData &state,
   15766             :                        std::string const &CoilType, // must match coil types in this module
   15767             :                        std::string const &CoilName, // must match coil names for the coil type
   15768             :                        bool &ErrorsFound            // set to true if problem
   15769             : )
   15770             : {
   15771             : 
   15772             :     // FUNCTION INFORMATION:
   15773             :     //       AUTHOR         Linda Lawrie
   15774             :     //       DATE WRITTEN   February 2006
   15775             : 
   15776             :     // PURPOSE OF THIS FUNCTION:
   15777             :     // This function looks up the coil capacity for the given coil and returns it.  If
   15778             :     // incorrect coil type or name is given, ErrorsFound is returned as true and capacity is returned
   15779             :     // as negative.
   15780             : 
   15781             :     // Return value
   15782             :     Real64 CoilCapacity; // returned capacity of matched coil
   15783             : 
   15784             :     // FUNCTION LOCAL VARIABLE DECLARATIONS:
   15785             :     int WhichCoil;
   15786             : 
   15787             :     // Obtains and Allocates DXCoils
   15788         238 :     if (state.dataDXCoils->GetCoilsInputFlag) {
   15789           0 :         GetDXCoils(state);
   15790           0 :         state.dataDXCoils->GetCoilsInputFlag = false;
   15791             :     }
   15792             : 
   15793         684 :     if (UtilityRoutines::SameString(CoilType, "Coil:Heating:DX:SingleSpeed") ||
   15794         446 :         UtilityRoutines::SameString(CoilType, "Coil:Cooling:DX:SingleSpeed")) {
   15795         238 :         WhichCoil = UtilityRoutines::FindItem(CoilName, state.dataDXCoils->DXCoil);
   15796         238 :         if (WhichCoil != 0) {
   15797         238 :             CoilCapacity = state.dataDXCoils->DXCoil(WhichCoil).RatedTotCap(1);
   15798             :         }
   15799           0 :     } else if (UtilityRoutines::SameString(CoilType, "Coil:Cooling:DX:TwoStageWithHumidityControlMode")) {
   15800           0 :         WhichCoil = UtilityRoutines::FindItem(CoilName, state.dataDXCoils->DXCoil);
   15801           0 :         if (WhichCoil != 0) {
   15802           0 :             CoilCapacity = state.dataDXCoils->DXCoil(WhichCoil).RatedTotCap(state.dataDXCoils->DXCoil(WhichCoil).NumCapacityStages);
   15803             :         }
   15804           0 :     } else if (UtilityRoutines::SameString(CoilType, "Coil:Cooling:DX:TwoSpeed")) {
   15805           0 :         WhichCoil = UtilityRoutines::FindItem(CoilName, state.dataDXCoils->DXCoil);
   15806           0 :         if (WhichCoil != 0) {
   15807           0 :             CoilCapacity = state.dataDXCoils->DXCoil(WhichCoil).RatedTotCap(1);
   15808             :         }
   15809           0 :     } else if (UtilityRoutines::SameString(CoilType, "Coil:Cooling:DX:MultiSpeed") ||
   15810           0 :                UtilityRoutines::SameString(CoilType, "Coil:Heating:DX:MultiSpeed")) {
   15811           0 :         WhichCoil = UtilityRoutines::FindItem(CoilName, state.dataDXCoils->DXCoil);
   15812           0 :         if (WhichCoil != 0) {
   15813           0 :             CoilCapacity = state.dataDXCoils->DXCoil(WhichCoil).MSRatedTotCap(state.dataDXCoils->DXCoil(WhichCoil).NumOfSpeeds);
   15814             :         }
   15815             :     } else {
   15816           0 :         WhichCoil = 0;
   15817             :     }
   15818             : 
   15819         238 :     if (WhichCoil == 0) {
   15820           0 :         ShowSevereError(state, "GetCoilCapacity: Could not find Coil, Type=\"" + CoilType + "\" Name=\"" + CoilName + "\"");
   15821           0 :         ShowContinueError(state, "... returning capacity as -1000.");
   15822           0 :         ErrorsFound = true;
   15823           0 :         CoilCapacity = -1000.0;
   15824             :     }
   15825             : 
   15826         238 :     return CoilCapacity;
   15827             : }
   15828             : 
   15829         406 : Real64 GetCoilCapacityByIndexType(EnergyPlusData &state,
   15830             :                                   int const CoilIndex,    // must match coil index for the coil type
   15831             :                                   int const CoilType_Num, // must match coil types in this module
   15832             :                                   bool &ErrorsFound       // set to true if problem
   15833             : )
   15834             : {
   15835             : 
   15836             :     // FUNCTION INFORMATION:
   15837             :     //       AUTHOR         Richard Raustad
   15838             :     //       DATE WRITTEN   October 2010
   15839             : 
   15840             :     // PURPOSE OF THIS FUNCTION:
   15841             :     // This function looks up the coil capacity for the given coil and returns it.  If
   15842             :     // incorrect coil index or type is given, ErrorsFound is returned as true and capacity is returned
   15843             :     // as negative.
   15844             : 
   15845             :     // Return value
   15846             :     Real64 CoilCapacity; // returned capacity of matched coil
   15847             : 
   15848             :     // Obtains and Allocates DXCoils
   15849         406 :     if (state.dataDXCoils->GetCoilsInputFlag) {
   15850           0 :         GetDXCoils(state);
   15851           0 :         state.dataDXCoils->GetCoilsInputFlag = false;
   15852             :     }
   15853             : 
   15854         406 :     if (CoilIndex == 0) {
   15855           0 :         ShowSevereError(state, "GetCoilCapacityByIndexType: Invalid index passed = 0");
   15856           0 :         ShowContinueError(state, "... returning capacity as -1000.");
   15857           0 :         ErrorsFound = true;
   15858           0 :         CoilCapacity = -1000.0;
   15859           0 :         return CoilCapacity;
   15860             :     }
   15861             : 
   15862         406 :     if (CoilType_Num != state.dataDXCoils->DXCoil(CoilIndex).DXCoilType_Num) {
   15863           0 :         ShowSevereError(state, "GetCoilCapacityByIndexType: Index passed does not match DX Coil type passed.");
   15864           0 :         ShowContinueError(state, "... returning capacity as -1000.");
   15865           0 :         ErrorsFound = true;
   15866           0 :         CoilCapacity = -1000.0;
   15867             :     } else {
   15868         406 :         switch (state.dataDXCoils->DXCoil(CoilIndex).DXCoilType_Num) {
   15869          33 :         case CoilDX_MultiSpeedCooling:
   15870             :         case CoilDX_MultiSpeedHeating: {
   15871          33 :             CoilCapacity = state.dataDXCoils->DXCoil(CoilIndex).MSRatedTotCap(state.dataDXCoils->DXCoil(CoilIndex).NumOfSpeeds);
   15872          33 :         } break;
   15873         373 :         default: {
   15874         373 :             CoilCapacity = state.dataDXCoils->DXCoil(CoilIndex).RatedTotCap(state.dataDXCoils->DXCoil(CoilIndex).NumCapacityStages);
   15875         373 :         } break;
   15876             :         }
   15877             :     }
   15878             : 
   15879         406 :     return CoilCapacity;
   15880             : }
   15881             : 
   15882         390 : int GetCoilTypeNum(EnergyPlusData &state,
   15883             :                    std::string const &CoilType,     // must match coil types in this module
   15884             :                    std::string const &CoilName,     // must match coil names for the coil type
   15885             :                    bool &ErrorsFound,               // set to true if problem
   15886             :                    Optional_bool_const PrintWarning // prints warning when true
   15887             : )
   15888             : {
   15889             : 
   15890             :     // FUNCTION INFORMATION:
   15891             :     //       AUTHOR         R. Raustad - FSEC
   15892             :     //       DATE WRITTEN   August 2008
   15893             : 
   15894             :     // PURPOSE OF THIS FUNCTION:
   15895             :     // This function looks up the integerized coil type for the given coil and returns it.  If
   15896             :     // incorrect coil type or name is given, ErrorsFound is returned as true and capacity is returned
   15897             :     // as negative.
   15898             : 
   15899             :     // Return value
   15900             :     int TypeNum; // returned integerized type of matched coil
   15901             : 
   15902             :     // FUNCTION LOCAL VARIABLE DECLARATIONS:
   15903             :     int WhichCoil;
   15904             :     bool PrintMessage;
   15905             : 
   15906             :     // Obtains and Allocates DXCoils
   15907         390 :     if (state.dataDXCoils->GetCoilsInputFlag) {
   15908          97 :         GetDXCoils(state);
   15909          97 :         state.dataDXCoils->GetCoilsInputFlag = false;
   15910             :     }
   15911             : 
   15912         390 :     if (present(PrintWarning)) {
   15913         360 :         PrintMessage = PrintWarning;
   15914             :     } else {
   15915          30 :         PrintMessage = true;
   15916             :     }
   15917             : 
   15918         390 :     WhichCoil = UtilityRoutines::FindItemInList(CoilName, state.dataDXCoils->DXCoil);
   15919         390 :     if (WhichCoil != 0) {
   15920         387 :         TypeNum = state.dataDXCoils->DXCoil(WhichCoil).DXCoilType_Num;
   15921             :     } else {
   15922           3 :         if (PrintMessage) {
   15923           0 :             ShowSevereError(state, "GetCoilTypeNum: Could not find Coil, Type=\"" + CoilType + "\" Name=\"" + CoilName + "\"");
   15924             :         }
   15925           3 :         ErrorsFound = true;
   15926           3 :         TypeNum = 0;
   15927             :     }
   15928             : 
   15929         390 :     return TypeNum;
   15930             : }
   15931             : 
   15932         799 : Real64 GetMinOATCompressor(EnergyPlusData &state,
   15933             :                            int const CoilIndex, // index to cooling coil
   15934             :                            bool &ErrorsFound    // set to true if problem
   15935             : )
   15936             : {
   15937             : 
   15938             :     // Obtains and Allocates DXCoils
   15939         799 :     if (state.dataDXCoils->GetCoilsInputFlag) {
   15940           0 :         GetDXCoils(state);
   15941           0 :         state.dataDXCoils->GetCoilsInputFlag = false;
   15942             :     }
   15943             : 
   15944         799 :     if (CoilIndex == 0) {
   15945           0 :         ShowSevereError(state, "GetMinOATCompressor: Index passed = 0");
   15946           0 :         ShowContinueError(state, "... returning Min OAT for compressor operation as -1000.");
   15947           0 :         ErrorsFound = true;
   15948           0 :         return -1000.0;
   15949             :     } else {
   15950         799 :         return state.dataDXCoils->DXCoil(CoilIndex).MinOATCompressor;
   15951             :     }
   15952             : }
   15953             : 
   15954         373 : int GetCoilInletNode(EnergyPlusData &state,
   15955             :                      std::string const &CoilType, // must match coil types in this module
   15956             :                      std::string const &CoilName, // must match coil names for the coil type
   15957             :                      bool &ErrorsFound            // set to true if problem
   15958             : )
   15959             : {
   15960             : 
   15961             :     // FUNCTION INFORMATION:
   15962             :     //       AUTHOR         Linda Lawrie
   15963             :     //       DATE WRITTEN   February 2006
   15964             : 
   15965             :     // PURPOSE OF THIS FUNCTION:
   15966             :     // This function looks up the given coil and returns the inlet node number.  If
   15967             :     // incorrect coil type or name is given, ErrorsFound is returned as true and node number is returned
   15968             :     // as zero.
   15969             : 
   15970             :     // Return value
   15971             :     int NodeNumber; // returned node number of matched coil
   15972             : 
   15973             :     // FUNCTION LOCAL VARIABLE DECLARATIONS:
   15974             :     int WhichCoil;
   15975             : 
   15976             :     // Obtains and Allocates DXCoils
   15977         373 :     if (state.dataDXCoils->GetCoilsInputFlag) {
   15978           3 :         GetDXCoils(state);
   15979           3 :         state.dataDXCoils->GetCoilsInputFlag = false;
   15980             :     }
   15981             : 
   15982         373 :     WhichCoil = UtilityRoutines::FindItemInList(CoilName, state.dataDXCoils->DXCoil);
   15983         373 :     if (WhichCoil != 0) {
   15984         373 :         NodeNumber = state.dataDXCoils->DXCoil(WhichCoil).AirInNode;
   15985             :     } else {
   15986           0 :         ShowSevereError(state, "GetCoilInletNode: Could not find Coil, Type=\"" + CoilType + "\" Name=\"" + CoilName + "\"");
   15987           0 :         ErrorsFound = true;
   15988           0 :         NodeNumber = 0;
   15989             :     }
   15990             : 
   15991         373 :     return NodeNumber;
   15992             : }
   15993             : 
   15994           0 : int getCoilInNodeIndex(EnergyPlusData &state,
   15995             :                        int const CoilIndex, // coil index
   15996             :                        bool &ErrorsFound    // set to true if problem
   15997             : )
   15998             : {
   15999             : 
   16000             :     int NodeNumber; // returned node number of matched coil
   16001             : 
   16002             :     // Obtains and Allocates DXCoils
   16003           0 :     if (state.dataDXCoils->GetCoilsInputFlag) {
   16004           0 :         GetDXCoils(state);
   16005           0 :         state.dataDXCoils->GetCoilsInputFlag = false;
   16006             :     }
   16007             : 
   16008           0 :     if (CoilIndex != 0) {
   16009           0 :         NodeNumber = state.dataDXCoils->DXCoil(CoilIndex).AirInNode;
   16010             :     } else {
   16011           0 :         ShowSevereError(state, "GetCoilInletNode: Could not find Coil Type");
   16012           0 :         ErrorsFound = true;
   16013           0 :         NodeNumber = 0;
   16014             :     }
   16015             : 
   16016           0 :     return NodeNumber;
   16017             : }
   16018             : 
   16019         394 : int GetCoilOutletNode(EnergyPlusData &state,
   16020             :                       std::string const &CoilType, // must match coil types in this module
   16021             :                       std::string const &CoilName, // must match coil names for the coil type
   16022             :                       bool &ErrorsFound            // set to true if problem
   16023             : )
   16024             : {
   16025             : 
   16026             :     // FUNCTION INFORMATION:
   16027             :     //       AUTHOR         Linda Lawrie
   16028             :     //       DATE WRITTEN   February 2006
   16029             : 
   16030             :     // PURPOSE OF THIS FUNCTION:
   16031             :     // This function looks up the given coil and returns the inlet node number.  If
   16032             :     // incorrect coil type or name is given, ErrorsFound is returned as true and node number is returned
   16033             :     // as zero.
   16034             : 
   16035             :     // Return value
   16036             :     int NodeNumber; // returned node number of matched coil
   16037             : 
   16038             :     // FUNCTION LOCAL VARIABLE DECLARATIONS:
   16039             :     int WhichCoil;
   16040             : 
   16041             :     // Obtains and Allocates DXCoils
   16042         394 :     if (state.dataDXCoils->GetCoilsInputFlag) {
   16043           6 :         GetDXCoils(state);
   16044           6 :         state.dataDXCoils->GetCoilsInputFlag = false;
   16045             :     }
   16046             : 
   16047         394 :     WhichCoil = UtilityRoutines::FindItemInList(CoilName, state.dataDXCoils->DXCoil);
   16048         394 :     if (WhichCoil != 0) {
   16049         394 :         NodeNumber = state.dataDXCoils->DXCoil(WhichCoil).AirOutNode;
   16050             :     } else {
   16051           0 :         ShowSevereError(state,
   16052           0 :                         "GetCoilOutletNode: Could not find Coil, Type=\"" + CoilType + "\" Name=\"" + CoilName +
   16053             :                             "\" when accessing coil outlet node number.");
   16054           0 :         ErrorsFound = true;
   16055           0 :         NodeNumber = 0;
   16056             :     }
   16057             : 
   16058         394 :     return NodeNumber;
   16059             : }
   16060             : 
   16061           0 : int getCoilOutNodeIndex(EnergyPlusData &state,
   16062             :                         int const CoilIndex, // must match coil types in this module
   16063             :                         bool &ErrorsFound    // set to true if problem
   16064             : )
   16065             : {
   16066             : 
   16067             :     int NodeNumber; // returned node number of matched coil
   16068             : 
   16069             :     // Obtains and Allocates DXCoils
   16070           0 :     if (state.dataDXCoils->GetCoilsInputFlag) {
   16071           0 :         GetDXCoils(state);
   16072           0 :         state.dataDXCoils->GetCoilsInputFlag = false;
   16073             :     }
   16074             : 
   16075           0 :     if (CoilIndex != 0) {
   16076           0 :         NodeNumber = state.dataDXCoils->DXCoil(CoilIndex).AirOutNode;
   16077             :     } else {
   16078           0 :         ShowSevereError(state, "GetCoilOutletNode: Could not find Coil Type");
   16079           0 :         ErrorsFound = true;
   16080           0 :         NodeNumber = 0;
   16081             :     }
   16082             : 
   16083           0 :     return NodeNumber;
   16084             : }
   16085             : 
   16086         588 : int GetCoilCondenserInletNode(EnergyPlusData &state,
   16087             :                               std::string const &CoilType, // must match coil types in this module
   16088             :                               std::string const &CoilName, // must match coil names for the coil type
   16089             :                               bool &ErrorsFound            // set to true if problem
   16090             : )
   16091             : {
   16092             : 
   16093             :     // FUNCTION INFORMATION:
   16094             :     //       AUTHOR         R. Raustad
   16095             :     //       DATE WRITTEN   January 2007
   16096             : 
   16097             :     // PURPOSE OF THIS FUNCTION:
   16098             :     // This function looks up the given coil and returns the condenser inlet node.  If
   16099             :     // incorrect coil type or name is given, ErrorsFound is returned as true.
   16100             : 
   16101             :     // Return value
   16102             :     int CondNode; // returned condenser node number of matched coil
   16103             : 
   16104             :     // FUNCTION LOCAL VARIABLE DECLARATIONS:
   16105             :     int WhichCoil;
   16106             : 
   16107             :     // Obtains and Allocates DXCoils
   16108         588 :     if (state.dataDXCoils->GetCoilsInputFlag) {
   16109           0 :         GetDXCoils(state);
   16110           0 :         state.dataDXCoils->GetCoilsInputFlag = false;
   16111             :     }
   16112             : 
   16113         588 :     WhichCoil = UtilityRoutines::FindItemInList(CoilName, state.dataDXCoils->DXCoil);
   16114         588 :     if (WhichCoil != 0) {
   16115         588 :         CondNode = state.dataDXCoils->DXCoil(WhichCoil).CondenserInletNodeNum(1);
   16116             :     } else {
   16117           0 :         ShowSevereError(state, "GetCoilCondenserInletNode: Invalid DX Coil, Type= \"" + CoilType + "\" Name=\"" + CoilName + "\"");
   16118           0 :         ErrorsFound = true;
   16119           0 :         CondNode = 0;
   16120             :     }
   16121             : 
   16122         588 :     return CondNode;
   16123             : }
   16124             : 
   16125           1 : Real64 GetDXCoilBypassedFlowFrac(EnergyPlusData &state,
   16126             :                                  std::string const &CoilType, // must match coil types in this module
   16127             :                                  std::string const &CoilName, // must match coil names for the coil type
   16128             :                                  bool &ErrorsFound            // set to true if problem
   16129             : )
   16130             : {
   16131             : 
   16132             :     // FUNCTION INFORMATION:
   16133             :     //       AUTHOR         R. Raustad
   16134             :     //       DATE WRITTEN   June 2007
   16135             : 
   16136             :     // PURPOSE OF THIS FUNCTION:
   16137             :     // This function looks up the given coil and returns the bypassed air flow fraction.
   16138             :     // Bypassed air flow fraction can only be greater than 0 for multimode DX cooling coils and is typical for 1st stage
   16139             :     // If incorrect coil type or name is given, ErrorsFound is returned as true.
   16140             : 
   16141             :     // Return value
   16142             :     Real64 BypassFraction; // returned bypass air fraction of matched coil
   16143             : 
   16144             :     // FUNCTION LOCAL VARIABLE DECLARATIONS:
   16145             :     int WhichCoil;
   16146             : 
   16147             :     // Obtains and Allocates DXCoils
   16148           1 :     if (state.dataDXCoils->GetCoilsInputFlag) {
   16149           0 :         GetDXCoils(state);
   16150           0 :         state.dataDXCoils->GetCoilsInputFlag = false;
   16151             :     }
   16152             : 
   16153           1 :     WhichCoil = UtilityRoutines::FindItemInList(CoilName, state.dataDXCoils->DXCoil);
   16154           1 :     if (WhichCoil != 0) {
   16155           1 :         BypassFraction = state.dataDXCoils->DXCoil(WhichCoil).BypassedFlowFrac(1);
   16156             :     } else {
   16157           0 :         ShowSevereError(state, "GetDXCoilBypassedFlowFrac: Invalid DX Coil Type=\"" + CoilType + "\" Name=\"" + CoilName + "\"");
   16158           0 :         ErrorsFound = true;
   16159           0 :         BypassFraction = 0.0;
   16160             :     }
   16161             : 
   16162           1 :     return BypassFraction;
   16163             : }
   16164             : 
   16165     1765231 : int GetHPCoolingCoilIndex(EnergyPlusData &state,
   16166             :                           std::string const &HeatingCoilType, // Type of DX heating coil used in HP
   16167             :                           std::string const &HeatingCoilName, // Name of DX heating coil used in HP
   16168             :                           int const HeatingCoilIndex          // Index of DX heating coil used in HP
   16169             : )
   16170             : {
   16171             : 
   16172             :     // FUNCTION INFORMATION:
   16173             :     //       AUTHOR         R. Raustad
   16174             :     //       DATE WRITTEN   February 2007
   16175             : 
   16176             :     // PURPOSE OF THIS FUNCTION:
   16177             :     // This function looks up the given DX heating coil and returns the companion DX cooling coil.
   16178             : 
   16179             :     // Return value
   16180             :     int DXCoolingCoilIndex; // Index of HP DX cooling coil returned from this function
   16181             : 
   16182             :     // FUNCTION LOCAL VARIABLE DECLARATIONS:
   16183             :     int WhichComp;           // DO loop counter to find correct comp set
   16184             :     int WhichCompanionComp;  // DO loop counter to find companion coil comp set
   16185             :     int WhichHXAssistedComp; // DO loop counter when DX coil is used in a HX assisted cooling coil
   16186             : 
   16187     1765231 :     DXCoolingCoilIndex = 0;
   16188             : 
   16189             :     DataLoopNode::ConnectionObjectType HeatingCoilTypeNum = static_cast<DataLoopNode::ConnectionObjectType>(
   16190     1765231 :         getEnumerationValue(BranchNodeConnections::ConnectionObjectTypeNamesUC, UtilityRoutines::MakeUPPERCase(HeatingCoilType)));
   16191             : 
   16192             :     DataLoopNode::ConnectionObjectType CompSetsParentType; // Parent object type which uses DX heating coil pass into this function
   16193     3530462 :     std::string CompSetsParentName;
   16194    55419282 :     for (WhichComp = 1; WhichComp <= state.dataBranchNodeConnections->NumCompSets; ++WhichComp) {
   16195             : 
   16196    57946626 :         if (HeatingCoilTypeNum != state.dataBranchNodeConnections->CompSets(WhichComp).ComponentObjectType ||
   16197     2527344 :             !UtilityRoutines::SameString(HeatingCoilName, state.dataBranchNodeConnections->CompSets(WhichComp).CName))
   16198    53654051 :             continue;
   16199     1765231 :         CompSetsParentType = state.dataBranchNodeConnections->CompSets(WhichComp).ParentObjectType;
   16200     1765231 :         CompSetsParentName = state.dataBranchNodeConnections->CompSets(WhichComp).ParentCName;
   16201     1765231 :         if ((CompSetsParentType == DataLoopNode::ConnectionObjectType::AirLoopHVACUnitaryHeatPumpAirToAir) ||
   16202     1765176 :             (CompSetsParentType == DataLoopNode::ConnectionObjectType::ZoneHVACPackagedTerminalHeatPump) ||
   16203     1765167 :             (CompSetsParentType == DataLoopNode::ConnectionObjectType::AirLoopHVACUnitaryHeatPumpAirToAirMultiSpeed) ||
   16204     1765167 :             (CompSetsParentType == DataLoopNode::ConnectionObjectType::AirLoopHVACUnitaryHeatCoolVAVChangeoverBypass) ||
   16205             :             (CompSetsParentType == DataLoopNode::ConnectionObjectType::AirLoopHVACUnitarySystem)) {
   16206             :             //       Search for DX cooling coils
   16207    63220175 :             for (WhichCompanionComp = 1; WhichCompanionComp <= state.dataBranchNodeConnections->NumCompSets; ++WhichCompanionComp) {
   16208    68497414 :                 if (!UtilityRoutines::SameString(state.dataBranchNodeConnections->CompSets(WhichCompanionComp).ParentCName, CompSetsParentName) ||
   16209     7042412 :                     (state.dataBranchNodeConnections->CompSets(WhichCompanionComp).ComponentObjectType !=
   16210             :                      DataLoopNode::ConnectionObjectType::CoilCoolingDXSingleSpeed))
   16211    61454944 :                     continue;
   16212          58 :                 DXCoolingCoilIndex =
   16213          58 :                     UtilityRoutines::FindItemInList(state.dataBranchNodeConnections->CompSets(WhichCompanionComp).CName, state.dataDXCoils->DXCoil);
   16214          58 :                 break;
   16215             :             }
   16216    63220796 :             for (WhichCompanionComp = 1; WhichCompanionComp <= state.dataBranchNodeConnections->NumCompSets; ++WhichCompanionComp) {
   16217    68498127 :                 if (!UtilityRoutines::SameString(state.dataBranchNodeConnections->CompSets(WhichCompanionComp).ParentCName, CompSetsParentName) ||
   16218     7042549 :                     (state.dataBranchNodeConnections->CompSets(WhichCompanionComp).ComponentObjectType !=
   16219             :                      DataLoopNode::ConnectionObjectType::CoilCoolingDXMultiSpeed))
   16220    61455565 :                     continue;
   16221          13 :                 DXCoolingCoilIndex =
   16222          13 :                     UtilityRoutines::FindItemInList(state.dataBranchNodeConnections->CompSets(WhichCompanionComp).CName, state.dataDXCoils->DXCoil);
   16223          13 :                 break;
   16224             :             }
   16225             :             //       Search for Heat Exchanger Assisted DX cooling coils
   16226     1765231 :             if (DXCoolingCoilIndex == 0) {
   16227    63219421 :                 for (WhichHXAssistedComp = 1; WhichHXAssistedComp <= state.dataBranchNodeConnections->NumCompSets; ++WhichHXAssistedComp) {
   16228   122908522 :                     if (!UtilityRoutines::SameString(state.dataBranchNodeConnections->CompSets(WhichHXAssistedComp).ParentCName,
   16229    68496532 :                                                      CompSetsParentName) ||
   16230     7042271 :                         (state.dataBranchNodeConnections->CompSets(WhichHXAssistedComp).ComponentObjectType !=
   16231             :                          DataLoopNode::ConnectionObjectType::CoilSystemCoolingDXHeatExchangerAssisted))
   16232    61454261 :                         continue;
   16233             :                     DataLoopNode::ConnectionObjectType HXCompSetsParentType; // Used when DX cooling coil is a child of a HX assisted cooling coil
   16234           0 :                     HXCompSetsParentType = state.dataBranchNodeConnections->CompSets(WhichHXAssistedComp).ComponentObjectType;
   16235           0 :                     std::string const &HXCompSetsParentName = state.dataBranchNodeConnections->CompSets(WhichHXAssistedComp).CName;
   16236           0 :                     for (WhichCompanionComp = 1; WhichCompanionComp <= state.dataBranchNodeConnections->NumCompSets; ++WhichCompanionComp) {
   16237           0 :                         if (!UtilityRoutines::SameString(state.dataBranchNodeConnections->CompSets(WhichCompanionComp).ParentCName,
   16238           0 :                                                          HXCompSetsParentName) ||
   16239           0 :                             (state.dataBranchNodeConnections->CompSets(WhichCompanionComp).ComponentObjectType !=
   16240             :                              DataLoopNode::ConnectionObjectType::CoilCoolingDXSingleSpeed))
   16241           0 :                             continue;
   16242           0 :                         DXCoolingCoilIndex = UtilityRoutines::FindItemInList(state.dataBranchNodeConnections->CompSets(WhichCompanionComp).CName,
   16243           0 :                                                                              state.dataDXCoils->DXCoil);
   16244           0 :                         break;
   16245             :                     }
   16246           0 :                     break;
   16247             :                 }
   16248     1765231 :             }
   16249             :         } else {
   16250             :             //     ErrorFound, Coil:Heating:DX:SingleSpeed is used in wrong type of parent object (should never get here)
   16251           0 :             ShowSevereError(state,
   16252           0 :                             format("Configuration error in {}\"{}\"",
   16253           0 :                                    BranchNodeConnections::ConnectionObjectTypeNames[static_cast<int>(CompSetsParentType)],
   16254           0 :                                    CompSetsParentName));
   16255           0 :             ShowContinueError(state, "DX heating coil not allowed in this configuration.");
   16256           0 :             ShowFatalError(state, "Preceding condition(s) causes termination.");
   16257             :         }
   16258     1765231 :         break;
   16259             :     }
   16260             : 
   16261             :     // Check and warn user is crankcase heater power or max OAT for crankcase heater differs in DX cooling and heating coils
   16262     1765231 :     if (DXCoolingCoilIndex > 0) {
   16263          71 :         if (state.dataDXCoils->DXCoil(DXCoolingCoilIndex).CrankcaseHeaterCapacity != 0.0) {
   16264          26 :             if (state.dataDXCoils->DXCoil(DXCoolingCoilIndex).CrankcaseHeaterCapacity !=
   16265          26 :                     state.dataDXCoils->DXCoil(HeatingCoilIndex).CrankcaseHeaterCapacity ||
   16266          13 :                 state.dataDXCoils->DXCoil(DXCoolingCoilIndex).MaxOATCrankcaseHeater !=
   16267          13 :                     state.dataDXCoils->DXCoil(HeatingCoilIndex).MaxOATCrankcaseHeater) {
   16268           0 :                 ShowWarningError(state, "Crankcase heater capacity or max outdoor temp for crankcase heater operation specified in");
   16269           0 :                 ShowContinueError(state, "Coil:Cooling:DX:SingleSpeed = " + state.dataDXCoils->DXCoil(DXCoolingCoilIndex).Name);
   16270           0 :                 ShowContinueError(state, "is different than that specified in Coil:Heating:DX:SingleSpeed = " + HeatingCoilName + '.');
   16271           0 :                 ShowContinueError(state,
   16272           0 :                                   format("Both of these DX coils are part of {}={}.",
   16273           0 :                                          BranchNodeConnections::ConnectionObjectTypeNames[static_cast<int>(CompSetsParentType)],
   16274           0 :                                          CompSetsParentName));
   16275           0 :                 ShowContinueError(state, "The value specified in the DX heating coil will be used and the simulation continues...");
   16276             :             }
   16277             :         }
   16278             :     }
   16279             : 
   16280     3530462 :     return DXCoolingCoilIndex;
   16281             : }
   16282             : 
   16283          20 : int GetDXCoilNumberOfSpeeds(EnergyPlusData &state,
   16284             :                             std::string const &CoilType, // must match coil types in this module
   16285             :                             std::string const &CoilName, // must match coil names for the coil type
   16286             :                             bool &ErrorsFound            // set to true if problem
   16287             : )
   16288             : {
   16289             : 
   16290             :     // FUNCTION INFORMATION:
   16291             :     //       AUTHOR         L. Gu
   16292             :     //       DATE WRITTEN   July 2007
   16293             : 
   16294             :     // PURPOSE OF THIS FUNCTION:
   16295             :     // This function looks up the given coil and returns the number of speeds for multispeed coils.
   16296             :     // If incorrect coil type or name is given, ErrorsFound is returned as true.
   16297             : 
   16298             :     // Return value
   16299             :     int NumberOfSpeeds; // returned the number of speed of matched coil
   16300             : 
   16301             :     // FUNCTION LOCAL VARIABLE DECLARATIONS:
   16302             :     int WhichCoil;
   16303             : 
   16304             :     // Obtains and Allocates DXCoils
   16305          20 :     if (state.dataDXCoils->GetCoilsInputFlag) {
   16306           0 :         GetDXCoils(state);
   16307           0 :         state.dataDXCoils->GetCoilsInputFlag = false;
   16308             :     }
   16309             : 
   16310          20 :     WhichCoil = UtilityRoutines::FindItemInList(CoilName, state.dataDXCoils->DXCoil);
   16311          20 :     if (WhichCoil != 0) {
   16312          20 :         NumberOfSpeeds = state.dataDXCoils->DXCoil(WhichCoil).NumOfSpeeds;
   16313             :     } else {
   16314           0 :         ShowSevereError(state, "GetDXCoilNumberOfSpeeds: Invalid DX Coil Type=\"" + CoilType + "\" Name=\"" + CoilName + "\"");
   16315           0 :         ErrorsFound = true;
   16316           0 :         NumberOfSpeeds = 0;
   16317             :     }
   16318             : 
   16319          20 :     return NumberOfSpeeds;
   16320             : }
   16321             : 
   16322      162557 : int GetDXCoilAvailSchPtr(EnergyPlusData &state,
   16323             :                          std::string const &CoilType, // must match coil types in this module
   16324             :                          std::string const &CoilName, // must match coil names for the coil type
   16325             :                          bool &ErrorsFound,           // set to true if problem
   16326             :                          Optional_int_const CoilIndex // Coil index number
   16327             : )
   16328             : {
   16329             : 
   16330             :     // FUNCTION INFORMATION:
   16331             :     //       AUTHOR         Richard Raustad
   16332             :     //       DATE WRITTEN   January 2013
   16333             : 
   16334             :     // PURPOSE OF THIS FUNCTION:
   16335             :     // This function looks up the given coil and returns the availability schedule index.  If
   16336             :     // incorrect coil type or name is given, ErrorsFound is returned as true and schedule index is returned
   16337             :     // as -1.
   16338             : 
   16339             :     // Return value
   16340             :     int SchPtr; // returned availabiltiy schedule of matched coil
   16341             : 
   16342             :     // FUNCTION LOCAL VARIABLE DECLARATIONS:
   16343             :     int WhichCoil;
   16344             : 
   16345             :     // Obtains and Allocates DXCoils
   16346      162557 :     if (state.dataDXCoils->GetCoilsInputFlag) {
   16347           0 :         GetDXCoils(state);
   16348           0 :         state.dataDXCoils->GetCoilsInputFlag = false;
   16349             :     }
   16350             : 
   16351      162557 :     if (present(CoilIndex)) {
   16352      162444 :         if (CoilIndex == 0) {
   16353           0 :             ShowSevereError(state, "GetDXCoilAvailSchPtr: Invalid index passed = 0");
   16354           0 :             ShowContinueError(state, "... returning DXCoilAvailSchPtr as -1.");
   16355           0 :             ErrorsFound = true;
   16356           0 :             SchPtr = -1;
   16357           0 :             return SchPtr;
   16358             :         } else {
   16359      162444 :             WhichCoil = CoilIndex;
   16360             :         }
   16361             :     } else {
   16362         113 :         WhichCoil = UtilityRoutines::FindItemInList(CoilName, state.dataDXCoils->DXCoil);
   16363             :     }
   16364      162557 :     if (WhichCoil != 0) {
   16365      162557 :         SchPtr = state.dataDXCoils->DXCoil(WhichCoil).SchedPtr;
   16366             :     } else {
   16367           0 :         if (!present(CoilIndex)) {
   16368           0 :             ShowSevereError(state,
   16369           0 :                             "GetDXCoilAvailSch: Could not find Coil, Type=\"" + CoilType + "\" Name=\"" + CoilName +
   16370             :                                 "\" when accessing coil availability schedule index.");
   16371             :         }
   16372           0 :         ErrorsFound = true;
   16373           0 :         SchPtr = -1;
   16374             :     }
   16375             : 
   16376      162557 :     return SchPtr;
   16377             : }
   16378             : 
   16379           1 : Real64 GetDXCoilAirFlow(EnergyPlusData &state,
   16380             :                         std::string const &CoilType, // must match coil types in this module
   16381             :                         std::string const &CoilName, // must match coil names for the coil type
   16382             :                         bool &ErrorsFound            // set to true if problem
   16383             : )
   16384             : {
   16385             : 
   16386             :     // FUNCTION INFORMATION:
   16387             :     //       AUTHOR         Richard Raustad
   16388             :     //       DATE WRITTEN   January 2013
   16389             : 
   16390             :     // PURPOSE OF THIS FUNCTION:
   16391             :     // This function looks up the given coil and returns the availability schedule index.  If
   16392             :     // incorrect coil type or name is given, ErrorsFound is returned as true and schedule index is returned
   16393             :     // as -1.
   16394             : 
   16395             :     // Return value
   16396             :     Real64 AirFlow; // returned coil air flow rate
   16397             : 
   16398             :     // FUNCTION LOCAL VARIABLE DECLARATIONS:
   16399             :     int WhichCoil;
   16400             : 
   16401             :     // Obtains and Allocates DXCoils
   16402           1 :     if (state.dataDXCoils->GetCoilsInputFlag) {
   16403           0 :         GetDXCoils(state);
   16404           0 :         state.dataDXCoils->GetCoilsInputFlag = false;
   16405             :     }
   16406             : 
   16407           1 :     WhichCoil = UtilityRoutines::FindItemInList(CoilName, state.dataDXCoils->DXCoil);
   16408           1 :     if (WhichCoil != 0) {
   16409           1 :         switch (state.dataDXCoils->DXCoil(WhichCoil).DXCoilType_Num) {
   16410           1 :         case CoilDX_CoolingSingleSpeed:
   16411             :         case CoilDX_CoolingTwoSpeed:
   16412             :         case CoilDX_HeatingEmpirical:
   16413             :         case CoilDX_CoolingTwoStageWHumControl: {
   16414           1 :             AirFlow = state.dataDXCoils->DXCoil(WhichCoil).RatedAirVolFlowRate(1);
   16415           1 :         } break;
   16416           0 :         case CoilDX_MultiSpeedCooling:
   16417             :         case CoilDX_MultiSpeedHeating: {
   16418           0 :             AirFlow = state.dataDXCoils->DXCoil(WhichCoil).MSRatedAirVolFlowRate(1);
   16419           0 :         } break;
   16420           0 :         default: {
   16421           0 :             ShowSevereError(state,
   16422           0 :                             "GetDXCoilAirFlow: Could not find Coil, Type=\"" + CoilType + "\" Name=\"" + CoilName +
   16423             :                                 "\" when accessing coil air flow rate.");
   16424           0 :             ErrorsFound = true;
   16425           0 :             AirFlow = -1.0;
   16426           0 :         } break;
   16427             :         }
   16428             :     } else {
   16429           0 :         ShowSevereError(
   16430           0 :             state, "GetDXCoilAirFlow: Could not find Coil, Type=\"" + CoilType + "\" Name=\"" + CoilName + "\" when accessing coil air flow rate.");
   16431           0 :         ErrorsFound = true;
   16432           0 :         AirFlow = -1.0;
   16433             :     }
   16434             : 
   16435           1 :     return AirFlow;
   16436             : }
   16437             : 
   16438         563 : int GetDXCoilCapFTCurveIndex(EnergyPlusData &state,
   16439             :                              int const CoilIndex, // coil index pointer
   16440             :                              bool &ErrorsFound    // set to true if problem
   16441             : )
   16442             : {
   16443             : 
   16444             :     // FUNCTION INFORMATION:
   16445             :     //       AUTHOR         Richard Raustad
   16446             :     //       DATE WRITTEN   August 2013
   16447             : 
   16448             :     // PURPOSE OF THIS FUNCTION:
   16449             :     // This function looks up the given coil and returns the CapFT schedule index.  If
   16450             :     // incorrect coil index is given, ErrorsFound is returned as true and schedule index is returned
   16451             :     // as -1.
   16452             : 
   16453             :     // Return value
   16454             :     int CapFTCurveIndex; // returned coil CapFT curve index
   16455             : 
   16456             :     // Obtains and Allocates DXCoils
   16457         563 :     if (state.dataDXCoils->GetCoilsInputFlag) {
   16458           0 :         GetDXCoils(state);
   16459           0 :         state.dataDXCoils->GetCoilsInputFlag = false;
   16460             :     }
   16461             : 
   16462         563 :     if (CoilIndex != 0) {
   16463         563 :         switch (state.dataDXCoils->DXCoil(CoilIndex).DXCoilType_Num) {
   16464         444 :         case CoilDX_CoolingSingleSpeed:
   16465             :         case CoilDX_CoolingTwoSpeed:
   16466             :         case CoilDX_HeatingEmpirical:
   16467             :         case CoilDX_CoolingTwoStageWHumControl: {
   16468         444 :             CapFTCurveIndex = state.dataDXCoils->DXCoil(CoilIndex).CCapFTemp(1);
   16469         444 :         } break;
   16470          48 :         case CoilDX_MultiSpeedCooling:
   16471             :         case CoilDX_MultiSpeedHeating: {
   16472          48 :             CapFTCurveIndex = state.dataDXCoils->DXCoil(CoilIndex).MSCCapFTemp(state.dataDXCoils->DXCoil(CoilIndex).NumOfSpeeds);
   16473          48 :         } break;
   16474          71 :         case CoilVRF_Heating: {
   16475          71 :             CapFTCurveIndex = state.dataDXCoils->DXCoil(CoilIndex).CCapFTemp(1);
   16476          71 :         } break;
   16477           0 :         default: {
   16478             :             //        CALL ShowSevereError(state, 'GetDXCoilCapFTCurveIndex: Could not find Coil, Type="'// &
   16479             :             //             TRIM(cAllCoilTypes(DXCoil(CoilIndex)%DXCoilType_Num))//'" Name="'//TRIM(DXCoil(CoilIndex)%Name)//  &
   16480             :             //              '" when accessing coil capacity as a function of temperture curve.')
   16481           0 :             ErrorsFound = true;
   16482           0 :             CapFTCurveIndex = 0;
   16483           0 :         } break;
   16484             :         }
   16485             :     } else {
   16486             :         //    CALL ShowSevereError(state, 'GetDXCoilCapFTCurveIndex: Could not find Coil, Index = 0'// &
   16487             :         //          ' when accessing coil air flow rate.')
   16488           0 :         ErrorsFound = true;
   16489           0 :         CapFTCurveIndex = 0;
   16490             :     }
   16491             : 
   16492         563 :     return CapFTCurveIndex;
   16493             : }
   16494             : 
   16495        1119 : void SetDXCoolingCoilData(EnergyPlusData &state,
   16496             :                           int const DXCoilNum,                                          // Number of DX Cooling Coil
   16497             :                           bool &ErrorsFound,                                            // Set to true if certain errors found
   16498             :                           Optional_int HeatingCoilPLFCurvePTR,                          // Parameter equivalent of heating coil PLR curve index
   16499             :                           Optional<DataHeatBalance::RefrigCondenserType> CondenserType, // Parameter equivalent of condenser type parameter
   16500             :                           Optional_int CondenserInletNodeNum,                           // Parameter equivalent of condenser inlet node number
   16501             :                           Optional<Real64> MaxOATCrankcaseHeater, // Parameter equivalent of condenser Max OAT for Crank Case Heater temp
   16502             :                           Optional<Real64> MinOATCooling,         // Parameter equivalent of condenser Min OAT for compressor cooling operation
   16503             :                           Optional<Real64> MaxOATCooling,         // Parameter equivalent of condenser Max OAT for compressor cooling operation
   16504             :                           Optional<Real64> MinOATHeating,         // Parameter equivalent of condenser Min OAT for compressor heating operation
   16505             :                           Optional<Real64> MaxOATHeating,         // Parameter equivalent of condenser Max OAT for compressor heating operation
   16506             :                           Optional_int HeatingPerformanceOATType, // Parameter equivalent to condenser entering air temp type (1-db, 2=wb)
   16507             :                           Optional<StandardRatings::DefrostStrat> DefrostStrategy,
   16508             :                           Optional<StandardRatings::HPdefrostControl> DefrostControl,
   16509             :                           Optional_int DefrostEIRPtr,
   16510             :                           Optional<Real64> DefrostFraction,
   16511             :                           Optional<Real64> DefrostCapacity,
   16512             :                           Optional<Real64> MaxOATDefrost,
   16513             :                           Optional_bool CoolingCoilPresent,
   16514             :                           Optional_bool HeatingCoilPresent,
   16515             :                           Optional<Real64> HeatSizeRatio,
   16516             :                           Optional<Real64> TotCap,
   16517             :                           Optional_int SupplyFanIndex,
   16518             :                           Optional_string SupplyFanName,
   16519             :                           Optional_int SupplyFan_TypeNum)
   16520             : {
   16521             : 
   16522             :     // SUBROUTINE INFORMATION:
   16523             :     //       AUTHOR         Richard Raustad, FSEC
   16524             :     //       DATE WRITTEN   December 2008
   16525             : 
   16526             :     // PURPOSE OF THIS SUBROUTINE:
   16527             :     // This routine was designed to allow the DX coil to access information from a gas or
   16528             :     // electric heating coil when these coils are each used in a parent object.
   16529             :     // Also, this is an illustration of setting Data from an outside source.
   16530             : 
   16531             :     // Using/Aliasing
   16532             : 
   16533             :     // Obtains and Allocates DXCoils
   16534        1119 :     if (state.dataDXCoils->GetCoilsInputFlag) {
   16535           0 :         GetDXCoils(state);
   16536           0 :         state.dataDXCoils->GetCoilsInputFlag = false;
   16537             :     }
   16538             : 
   16539        1119 :     if (DXCoilNum <= 0 || DXCoilNum > state.dataDXCoils->NumDXCoils) {
   16540           0 :         ShowSevereError(state,
   16541           0 :                         format("SetDXCoolingCoilData: called with DX Cooling Coil Number out of range={} should be >0 and <{}",
   16542             :                                DXCoilNum,
   16543           0 :                                state.dataDXCoils->NumDXCoils));
   16544           0 :         ErrorsFound = true;
   16545           0 :         return;
   16546             :     }
   16547             : 
   16548        1119 :     if (present(HeatingCoilPLFCurvePTR)) {
   16549          48 :         state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilPLFCurvePTR = HeatingCoilPLFCurvePTR;
   16550             :     }
   16551             : 
   16552        1119 :     if (present(CondenserType)) {
   16553         112 :         state.dataDXCoils->DXCoil(DXCoilNum).CondenserType = CondenserType;
   16554             :     }
   16555             : 
   16556        1119 :     if (present(CondenserInletNodeNum)) {
   16557         112 :         state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(1) = CondenserInletNodeNum;
   16558             :     }
   16559             : 
   16560        1119 :     if (present(MaxOATCrankcaseHeater)) {
   16561         112 :         state.dataDXCoils->DXCoil(DXCoilNum).MaxOATCrankcaseHeater = MaxOATCrankcaseHeater;
   16562             :     }
   16563             : 
   16564        1119 :     if (present(MaxOATCooling)) {
   16565          56 :         state.dataDXCoils->DXCoil(DXCoilNum).MaxOATCompressor = MaxOATCooling;
   16566             :     }
   16567             : 
   16568        1119 :     if (present(MaxOATHeating)) {
   16569          15 :         state.dataDXCoils->DXCoil(DXCoilNum).MaxOATCompressor = MaxOATHeating;
   16570             :     }
   16571             : 
   16572        1119 :     if (present(MinOATCooling)) {
   16573          56 :         state.dataDXCoils->DXCoil(DXCoilNum).MinOATCompressor = MinOATCooling;
   16574             :     }
   16575             : 
   16576        1119 :     if (present(MinOATHeating)) {
   16577          56 :         state.dataDXCoils->DXCoil(DXCoilNum).MinOATCompressor = MinOATHeating;
   16578             :     }
   16579             : 
   16580        1119 :     if (present(HeatingPerformanceOATType)) {
   16581          56 :         state.dataDXCoils->DXCoil(DXCoilNum).HeatingPerformanceOATType = HeatingPerformanceOATType;
   16582             :     }
   16583             : 
   16584        1119 :     if (present(DefrostStrategy)) {
   16585          56 :         state.dataDXCoils->DXCoil(DXCoilNum).DefrostStrategy = DefrostStrategy;
   16586             :     }
   16587             : 
   16588        1119 :     if (present(DefrostControl)) {
   16589          56 :         state.dataDXCoils->DXCoil(DXCoilNum).DefrostControl = DefrostControl;
   16590             :     }
   16591             : 
   16592        1119 :     if (present(DefrostEIRPtr)) {
   16593          56 :         state.dataDXCoils->DXCoil(DXCoilNum).DefrostEIRFT = DefrostEIRPtr;
   16594             :     }
   16595             : 
   16596        1119 :     if (present(DefrostFraction)) {
   16597          56 :         state.dataDXCoils->DXCoil(DXCoilNum).DefrostTime = DefrostFraction;
   16598             :     }
   16599             : 
   16600        1119 :     if (present(DefrostCapacity)) {
   16601          56 :         state.dataDXCoils->DXCoil(DXCoilNum).DefrostCapacity = DefrostCapacity;
   16602             :     }
   16603             : 
   16604        1119 :     if (present(MaxOATDefrost)) {
   16605          56 :         state.dataDXCoils->DXCoil(DXCoilNum).MaxOATDefrost = MaxOATDefrost;
   16606             :     }
   16607             : 
   16608        1119 :     if (present(CoolingCoilPresent)) {
   16609          56 :         state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilPresent = CoolingCoilPresent;
   16610             :     }
   16611             : 
   16612        1119 :     if (present(HeatingCoilPresent)) {
   16613          56 :         state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilPresent = HeatingCoilPresent;
   16614             :     }
   16615             : 
   16616        1119 :     if (present(HeatSizeRatio)) {
   16617           0 :         state.dataDXCoils->DXCoil(DXCoilNum).HeatSizeRatio = HeatSizeRatio;
   16618             :     }
   16619             : 
   16620        1119 :     if (present(TotCap)) {
   16621           0 :         state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(1) = TotCap;
   16622             :     }
   16623             : 
   16624        1119 :     if (present(SupplyFanIndex)) {
   16625          16 :         state.dataDXCoils->DXCoil(DXCoilNum).SupplyFanIndex = SupplyFanIndex;
   16626             :     }
   16627             : 
   16628        1119 :     if (present(SupplyFanName)) {
   16629          16 :         state.dataDXCoils->DXCoil(DXCoilNum).SupplyFanName = SupplyFanName;
   16630             :     }
   16631             : 
   16632        1119 :     if (present(SupplyFan_TypeNum)) {
   16633          16 :         state.dataDXCoils->DXCoil(DXCoilNum).SupplyFan_TypeNum = SupplyFan_TypeNum;
   16634          16 :         if (state.dataDXCoils->DXCoil(DXCoilNum).SupplyFanIndex > -1) {
   16635          16 :             if (SupplyFan_TypeNum == DataHVACGlobals::FanType_SystemModelObject) {
   16636          40 :                 state.dataRptCoilSelection->coilSelectionReportObj->setCoilSupplyFanInfo(
   16637             :                     state,
   16638           8 :                     state.dataDXCoils->DXCoil(DXCoilNum).Name,
   16639           8 :                     state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
   16640           8 :                     state.dataHVACFan->fanObjs[state.dataDXCoils->DXCoil(DXCoilNum).SupplyFanIndex]->name,
   16641             :                     DataAirSystems::ObjectVectorOOFanSystemModel,
   16642           8 :                     state.dataDXCoils->DXCoil(DXCoilNum).SupplyFanIndex);
   16643             :             } else {
   16644          40 :                 state.dataRptCoilSelection->coilSelectionReportObj->setCoilSupplyFanInfo(
   16645             :                     state,
   16646           8 :                     state.dataDXCoils->DXCoil(DXCoilNum).Name,
   16647           8 :                     state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
   16648           8 :                     state.dataFans->Fan(state.dataDXCoils->DXCoil(DXCoilNum).SupplyFanIndex).FanName,
   16649             :                     DataAirSystems::StructArrayLegacyFanModels,
   16650           8 :                     state.dataDXCoils->DXCoil(DXCoilNum).SupplyFanIndex);
   16651             :             }
   16652             :         }
   16653             :     }
   16654             : }
   16655             : 
   16656           2 : void SetCoilSystemHeatingDXFlag(EnergyPlusData &state,
   16657             :                                 std::string const &CoilType, // must match coil types in this module
   16658             :                                 std::string const &CoilName  // must match coil names for the coil type
   16659             : )
   16660             : {
   16661             : 
   16662             :     // SUBROUTINE INFORMATION:
   16663             :     //       AUTHOR         B. Griffith
   16664             :     //       DATE WRITTEN   Jan. 2012
   16665             : 
   16666             :     // PURPOSE OF THIS SUBROUTINE:
   16667             :     // inform DX heating coil that is is part of a CoilSystem:Heating:DX
   16668             :     // and therefore it need not find its companion cooling coil
   16669             : 
   16670             :     // METHODOLOGY EMPLOYED:
   16671             :     // set value of logical flag FindCompanionUpStreamCoil to true
   16672             : 
   16673             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   16674             :     int WhichCoil;
   16675             : 
   16676             :     // Obtains and Allocates DXCoils
   16677           2 :     if (state.dataDXCoils->GetCoilsInputFlag) {
   16678           0 :         GetDXCoils(state);
   16679           0 :         state.dataDXCoils->GetCoilsInputFlag = false;
   16680             :     }
   16681             : 
   16682           2 :     WhichCoil = UtilityRoutines::FindItemInList(CoilName, state.dataDXCoils->DXCoil);
   16683           2 :     if (WhichCoil != 0) {
   16684           2 :         state.dataDXCoils->DXCoil(WhichCoil).FindCompanionUpStreamCoil = false;
   16685             :     } else {
   16686           0 :         ShowSevereError(state, "SetCoilSystemHeatingDXFlag: Could not find Coil, Type=\"" + CoilType + "\"Name=\"" + CoilName + "\"");
   16687             :     }
   16688           2 : }
   16689             : 
   16690          67 : void SetCoilSystemCoolingData(EnergyPlusData &state,
   16691             :                               std::string const &CoilName, // must match coil names for the coil type
   16692             :                               std::string const &CoilSystemName)
   16693             : {
   16694             : 
   16695             :     // SUBROUTINE INFORMATION:
   16696             :     //       AUTHOR         B. Griffith
   16697             :     //       DATE WRITTEN   July 2012
   16698             : 
   16699             :     // PURPOSE OF THIS SUBROUTINE:
   16700             :     // inform the child DX coil what the name of its parent is.
   16701             : 
   16702             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   16703             :     int WhichCoil;
   16704             : 
   16705          67 :     if (state.dataDXCoils->GetCoilsInputFlag) {
   16706           0 :         GetDXCoils(state);
   16707           0 :         state.dataDXCoils->GetCoilsInputFlag = false;
   16708             :     }
   16709             : 
   16710          67 :     WhichCoil = UtilityRoutines::FindItemInList(CoilName, state.dataDXCoils->DXCoil);
   16711          67 :     if (WhichCoil != 0) {
   16712          67 :         state.dataDXCoils->DXCoil(WhichCoil).CoilSystemName = CoilSystemName;
   16713             :     } else {
   16714           0 :         ShowSevereError(state, "SetCoilSystemCoolingData: Could not find Coil \"Name=\"" + CoilName + "\"");
   16715             :     }
   16716          67 : }
   16717             : 
   16718       39387 : Real64 CalcSHRUserDefinedCurves(EnergyPlusData &state,
   16719             :                                 Real64 const InletDryBulb,     // inlet air dry bulb temperature [C]
   16720             :                                 Real64 const InletWetBulb,     // inlet air wet bulb temperature [C]
   16721             :                                 Real64 const AirMassFlowRatio, // ratio of actual air mass flow to rated air mass flow
   16722             :                                 int const SHRFTempCurveIndex,  // SHR modifier curve index
   16723             :                                 int const SHRFFlowCurveIndex,  // SHR modifier curve index
   16724             :                                 Real64 const SHRRated          // rated sensible heat ratio, user input
   16725             : )
   16726             : {
   16727             : 
   16728             :     // SUBROUTINE INFORMATION:
   16729             :     //       AUTHOR         Bereket Nigusse, FSEC
   16730             :     //       DATE WRITTEN   December 2012
   16731             : 
   16732             :     // PURPOSE OF THIS FUNCTION:
   16733             :     //    Returns the oprating sensible heat ratio for a given Rated SHR abd coil entering
   16734             :     //    air DBT and WBT, and supply air mass flow fraction.
   16735             : 
   16736             :     // METHODOLOGY EMPLOYED:
   16737             :     //    Model uses user specified rated SHR, and SHR modifying curves for temperature and flow
   16738             :     //    fraction.  The curves adjust the rated SHR based on biquadratic curve for temperatures
   16739             :     //    and quadratic function for supply air mass flow ratio (actual vs rated).
   16740             :     //    The biquadratic and quadratic curves are normalized caurves generated from manufacturer's
   16741             :     //    performance data
   16742             : 
   16743             :     // Using/Aliasing
   16744             :     using Curve::CurveValue;
   16745             : 
   16746             :     // Return value
   16747             :     Real64 SHRopr; // operating SHR, corrected for Temp and Flow Fraction
   16748             : 
   16749             :     // FUNCTION LOCAL VARIABLE DECLARATIONS:
   16750             :     Real64 SHRTempModFac; // Sensible Heat Ratio modifier (function of entering wetbulb, entering drybulb)
   16751             :     Real64 SHRFlowModFac; // Sensible Heat Ratio modifier (function of actual vs rated flow)
   16752             : 
   16753             :     //   Get SHR modifying factor (function of inlet wetbulb & drybulb) for off-rated conditions
   16754       39387 :     if (SHRFTempCurveIndex == 0) {
   16755           0 :         SHRTempModFac = 1.0;
   16756             :     } else {
   16757       39387 :         SHRTempModFac = CurveValue(state, SHRFTempCurveIndex, InletWetBulb, InletDryBulb);
   16758       39387 :         if (SHRTempModFac < 0.0) {
   16759           0 :             SHRTempModFac = 0.0;
   16760             :         }
   16761             :     }
   16762             :     //   Get SHR modifying factor (function of mass flow ratio) for off-rated conditions
   16763       39387 :     if (SHRFFlowCurveIndex == 0) {
   16764           0 :         SHRFlowModFac = 1.0;
   16765             :     } else {
   16766       39387 :         SHRFlowModFac = CurveValue(state, SHRFFlowCurveIndex, AirMassFlowRatio);
   16767       39387 :         if (SHRFlowModFac < 0.0) {
   16768           0 :             SHRFlowModFac = 0.0;
   16769             :         }
   16770             :     }
   16771             :     //  Calculate "operating" sensible heat ratio
   16772       39387 :     SHRopr = SHRRated * SHRTempModFac * SHRFlowModFac;
   16773             : 
   16774       39387 :     if (SHRopr < 0.0) SHRopr = 0.0; // SHR cannot be less than zero
   16775       39387 :     if (SHRopr > 1.0) SHRopr = 1.0; // SHR cannot be greater than 1.0
   16776             : 
   16777       39387 :     return SHRopr;
   16778             : }
   16779             : 
   16780           7 : void SetDXCoilTypeData(EnergyPlusData &state, std::string const &CoilName) // must match coil names for the coil type
   16781             : {
   16782             : 
   16783             :     // SUBROUTINE INFORMATION:
   16784             :     //       AUTHOR         B. Nigusse
   16785             :     //       DATE WRITTEN   January 2013
   16786             : 
   16787             :     // PURPOSE OF THIS SUBROUTINE:
   16788             :     // inform the child DX coil if the DX cooling coil is for 100% DOAS application.
   16789             : 
   16790             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   16791             :     int WhichCoil;
   16792             : 
   16793           7 :     if (state.dataDXCoils->GetCoilsInputFlag) {
   16794           0 :         GetDXCoils(state);
   16795           0 :         state.dataDXCoils->GetCoilsInputFlag = false;
   16796             :     }
   16797             : 
   16798           7 :     WhichCoil = UtilityRoutines::FindItemInList(CoilName, state.dataDXCoils->DXCoil);
   16799           7 :     if (WhichCoil != 0) {
   16800           7 :         state.dataDXCoils->DXCoil(WhichCoil).ISHundredPercentDOASDXCoil = true;
   16801             :     } else {
   16802             :         // DXCoil(WhichCoil)%ISHundredPercentDOASDXCoil = .FALSE. //Autodesk:BoundsViolation DXCoil(0): DXCoil is not allocated with a 0
   16803             :         // element: Commented out
   16804           0 :         ShowSevereError(state, "SetDXCoilTypeData: Could not find Coil \"Name=\"" + CoilName + "\"");
   16805             :     }
   16806           7 : }
   16807             : 
   16808      167787 : void CalcSecondaryDXCoils(EnergyPlusData &state, int const DXCoilNum)
   16809             : {
   16810             : 
   16811             :     // SUBROUTINE INFORMATION:
   16812             :     //       AUTHOR         B. Nigusse
   16813             :     //       DATE WRITTEN   February 2015
   16814             : 
   16815             :     // PURPOSE OF THIS SUBROUTINE:
   16816             :     // Calculates secondary zone heat gain from secondary DX coils placed in a zone.
   16817             : 
   16818             :     // METHODOLOGY EMPLOYED:
   16819             :     // Energy balance:
   16820             :     //  (1) Condenser placed in a zone, the zone total (sensible) heat
   16821             :     //      gain rate is given Qcond = QEvap + WcompPluscondFanPower
   16822             :     //  (2) Evaporator placed in a zone, the zone total heat removal
   16823             :     //      rate is given Qevap = Qcond - WcompPluscondFanPower
   16824             :     //      Furthermore, the evaporator total heat removal is split into
   16825             :     //      latent and sensible components using user specified SHR
   16826             : 
   16827             :     // Using/Aliasing
   16828             :     using Curve::CurveValue;
   16829             : 
   16830             :     // SUBROUTINE PARAMETER DEFINITIONS:
   16831             :     static constexpr std::string_view RoutineName("CalcSecondaryDXCoils");
   16832             : 
   16833             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   16834             :     Real64 CondInletDryBulb;       // condenser entering air dry-bulb temperature (C)
   16835             :     Real64 EvapAirMassFlow;        // Condenser air mass flow rate [kg/s]
   16836             :     Real64 EvapInletDryBulb;       // evaporator inlet air drybulb [C]
   16837             :     Real64 EvapInletHumRat;        // evaporator inlet air humidity ratio [kg/kg]
   16838             :     Real64 EvapInletWetBulb;       // evaporator inlet air wetbulb [C]
   16839             :     Real64 EvapInletEnthalpy;      // evaporator inlet air enthalpy [J/kg]
   16840             :     Real64 FullLoadOutAirEnth;     // evaporator outlet full load enthalpy [J/kg]
   16841             :     Real64 FullLoadOutAirHumRat;   // evaporator outlet humidity ratio at full load
   16842             :     Real64 FullLoadOutAirTemp;     // evaporator outlet air temperature at full load [C]
   16843             :     Real64 hTinwout;               // Enthalpy at inlet dry-bulb and outlet humidity ratio [J/kg]
   16844      167787 :     Real64 SHR(0);                 // sensible heat ratio
   16845             :     Real64 RhoAir;                 // secondary coil entering air density [kg/m3]
   16846      167787 :     Real64 PartLoadRatio(0);       // primary coil part-load ratio [-]
   16847             :     Real64 SecCoilRatedSHR;        // secondary DX coil nominal or rated sensible heat ratio
   16848             :     Real64 SecCoilFlowFraction;    // secondary coil flow fraction, is 1.0 for single speed machine
   16849             :     Real64 TotalHeatRemovalRate;   // secondary coil total heat removal rate
   16850             :     Real64 TotalHeatRejectionRate; // secondary coil total heat rejection rate
   16851             :     int SecCoilSHRFT;              // index of the SHR modifier curve for temperature of a secondary DX coil
   16852             :     int SecCoilSHRFF;              // index of the sHR modifier curve for flow fraction of a secondary DX coil
   16853             :     int MSSpeedNumLS;              // current low speed number of multspeed HP
   16854             :     int MSSpeedNumHS;              // current high speed number of multspeed HP
   16855             :     Real64 MSSpeedRatio;           // current speed ratio of multspeed HP
   16856             :     Real64 MSCycRatio;             // current cycling ratio of multspeed HP
   16857             :     Real64 SHRHighSpeed;           // sensible heat ratio at high speed
   16858             :     Real64 SHRLowSpeed;            // sensible heat ratio at low speed
   16859             : 
   16860      167787 :     EvapAirMassFlow = 0.0;
   16861             : 
   16862      167787 :     if (state.dataDXCoils->DXCoil(DXCoilNum).IsSecondaryDXCoilInZone) {
   16863      167787 :         auto &secZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(state.dataDXCoils->DXCoil(DXCoilNum).SecZonePtr);
   16864             :         // Select the correct unit type
   16865      167787 :         switch (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num) {
   16866       83894 :         case CoilDX_CoolingSingleSpeed:
   16867             :         case CoilDX_CoolingTwoSpeed:
   16868             :         case CoilDX_MultiSpeedCooling: {
   16869             :             // total sensible heat gain of the secondary zone from the secondary coil (condenser)
   16870       83894 :             if (state.dataDXCoils->DXCoil(DXCoilNum).ElecCoolingPower > 0.0) {
   16871       19517 :                 TotalHeatRejectionRate =
   16872       19517 :                     state.dataDXCoils->DXCoil(DXCoilNum).TotalCoolingEnergyRate + state.dataDXCoils->DXCoil(DXCoilNum).ElecCoolingPower;
   16873             :             } else {
   16874       64377 :                 TotalHeatRejectionRate = 0.0;
   16875       64377 :                 return;
   16876             :             }
   16877       19517 :             state.dataDXCoils->DXCoil(DXCoilNum).SecCoilSensibleHeatGainRate = TotalHeatRejectionRate;
   16878       19517 :         } break;
   16879       83893 :         case CoilDX_HeatingEmpirical: {
   16880             :             // evaporator coil in the secondary zone
   16881       83893 :             if (state.dataDXCoils->DXCoil(DXCoilNum).ElecHeatingPower > 0.0) {
   16882       30177 :                 TotalHeatRemovalRate =
   16883       30177 :                     max(0.0, state.dataDXCoils->DXCoil(DXCoilNum).TotalHeatingEnergyRate - state.dataDXCoils->DXCoil(DXCoilNum).ElecHeatingPower);
   16884             :             } else {
   16885       53716 :                 TotalHeatRemovalRate = 0.0;
   16886       53716 :                 state.dataDXCoils->DXCoil(DXCoilNum).SecCoilSHR = 0.0;
   16887       53716 :                 return;
   16888             :             }
   16889       30177 :             state.dataDXCoils->DXCoil(DXCoilNum).SecCoilTotalHeatRemovalRate = -TotalHeatRemovalRate; // +DXCoil( DXCoilNum ).DefrostPower;
   16890       30177 :             EvapInletDryBulb = secZoneHB.ZT;
   16891       30177 :             EvapInletHumRat = secZoneHB.ZoneAirHumRat;
   16892       30177 :             RhoAir = PsyRhoAirFnPbTdbW(state, state.dataEnvrn->OutBaroPress, EvapInletDryBulb, EvapInletHumRat);
   16893       30177 :             EvapAirMassFlow = RhoAir * state.dataDXCoils->DXCoil(DXCoilNum).SecCoilAirFlow;
   16894             :             ;
   16895       30177 :             PartLoadRatio = state.dataDXCoils->DXCoil(DXCoilNum).CompressorPartLoadRatio;
   16896       30177 :             SecCoilRatedSHR = state.dataDXCoils->DXCoil(DXCoilNum).SecCoilRatedSHR;
   16897       60354 :             if ((EvapAirMassFlow > SmallMassFlow) && (PartLoadRatio > 0.0) &&
   16898       30177 :                 (EvapInletDryBulb > state.dataDXCoils->DXCoil(DXCoilNum).MinOATCompressor)) { // coil is running
   16899       30177 :                 SecCoilFlowFraction = 1.0; // for single speed DX coil the secondary coil (condenser) flow fraction is 1.0
   16900       30177 :                 CondInletDryBulb = state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(DXCoilNum).AirInNode).Temp;
   16901       30177 :                 EvapInletWetBulb = PsyTwbFnTdbWPb(state, EvapInletDryBulb, EvapInletHumRat, state.dataEnvrn->OutBaroPress, RoutineName);
   16902       30177 :                 EvapInletEnthalpy = PsyHFnTdbW(EvapInletDryBulb, EvapInletHumRat);
   16903       30177 :                 SecCoilSHRFT = state.dataDXCoils->DXCoil(DXCoilNum).SecCoilSHRFT;
   16904       30177 :                 SecCoilSHRFF = state.dataDXCoils->DXCoil(DXCoilNum).SecCoilSHRFF;
   16905             :                 // determine the current SHR
   16906       30177 :                 SHR = CalcSecondaryDXCoilsSHR(state,
   16907             :                                               DXCoilNum,
   16908             :                                               EvapAirMassFlow,
   16909             :                                               TotalHeatRemovalRate,
   16910             :                                               PartLoadRatio,
   16911             :                                               SecCoilRatedSHR,
   16912             :                                               EvapInletDryBulb,
   16913             :                                               EvapInletHumRat,
   16914             :                                               EvapInletWetBulb,
   16915             :                                               EvapInletEnthalpy,
   16916             :                                               CondInletDryBulb,
   16917             :                                               SecCoilFlowFraction,
   16918             :                                               SecCoilSHRFT,
   16919             :                                               SecCoilSHRFF);
   16920             :                 // Calculate full load output conditions
   16921       30177 :                 FullLoadOutAirEnth = EvapInletEnthalpy - (TotalHeatRemovalRate / PartLoadRatio) / EvapAirMassFlow;
   16922       30177 :                 hTinwout = EvapInletEnthalpy - (1.0 - SHR) * ((TotalHeatRemovalRate / PartLoadRatio) / EvapAirMassFlow);
   16923       30177 :                 FullLoadOutAirHumRat = PsyWFnTdbH(state, EvapInletDryBulb, hTinwout, RoutineName, true);
   16924       30177 :                 FullLoadOutAirTemp = PsyTdbFnHW(FullLoadOutAirEnth, FullLoadOutAirHumRat);
   16925             :                 // when the air outlet temperature falls below the saturation temperature, it is reset to saturation temperature
   16926       30177 :                 if (FullLoadOutAirTemp < PsyTsatFnHPb(state, FullLoadOutAirEnth, state.dataEnvrn->OutBaroPress, RoutineName)) {
   16927           0 :                     FullLoadOutAirTemp = PsyTsatFnHPb(state, FullLoadOutAirEnth, state.dataEnvrn->OutBaroPress, RoutineName);
   16928           0 :                     FullLoadOutAirHumRat = PsyWFnTdbH(state, FullLoadOutAirTemp, FullLoadOutAirEnth, RoutineName);
   16929             :                     // Adjust SHR for the new outlet condition that balances energy
   16930           0 :                     hTinwout = PsyHFnTdbW(EvapInletDryBulb, FullLoadOutAirHumRat);
   16931           0 :                     SHR = 1.0 - (EvapInletEnthalpy - hTinwout) / ((TotalHeatRemovalRate / PartLoadRatio) / EvapAirMassFlow);
   16932           0 :                     SHR = min(SHR, 1.0);
   16933             :                 }
   16934             :                 // calculate the sensible and latent zone heat removal (extraction) rate by the secondary coil
   16935       30177 :                 state.dataDXCoils->DXCoil(DXCoilNum).SecCoilSensibleHeatRemovalRate =
   16936       30177 :                     state.dataDXCoils->DXCoil(DXCoilNum).SecCoilTotalHeatRemovalRate * SHR;
   16937       30177 :                 state.dataDXCoils->DXCoil(DXCoilNum).SecCoilLatentHeatRemovalRate =
   16938       60354 :                     state.dataDXCoils->DXCoil(DXCoilNum).SecCoilTotalHeatRemovalRate -
   16939       30177 :                     state.dataDXCoils->DXCoil(DXCoilNum).SecCoilSensibleHeatRemovalRate;
   16940             :             } else {
   16941             :                 // DX coil is off;
   16942           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).SecCoilTotalHeatRemovalRate = 0.0;
   16943           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).SecCoilSensibleHeatRemovalRate = 0.0;
   16944           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).SecCoilLatentHeatRemovalRate = 0.0;
   16945           0 :                 SHR = 0.0; // SHR is set to zero if the coil is off
   16946             :             }
   16947       30177 :             state.dataDXCoils->DXCoil(DXCoilNum).SecCoilSHR = SHR;
   16948       30177 :         } break;
   16949           0 :         case CoilDX_MultiSpeedHeating: {
   16950           0 :             EvapInletDryBulb = secZoneHB.ZT;
   16951           0 :             EvapInletHumRat = secZoneHB.ZoneAirHumRat;
   16952           0 :             RhoAir = PsyRhoAirFnPbTdbW(state, state.dataEnvrn->OutBaroPress, EvapInletDryBulb, EvapInletHumRat);
   16953           0 :             MSSpeedRatio = state.dataDXCoils->DXCoil(DXCoilNum).MSSpeedRatio;
   16954           0 :             MSCycRatio = state.dataDXCoils->DXCoil(DXCoilNum).MSCycRatio;
   16955           0 :             MSSpeedNumHS = state.dataDXCoils->DXCoil(DXCoilNum).MSSpeedNumHS;
   16956           0 :             MSSpeedNumLS = state.dataDXCoils->DXCoil(DXCoilNum).MSSpeedNumLS;
   16957           0 :             if (MSSpeedRatio > 0.0) {
   16958           0 :                 EvapAirMassFlow = RhoAir * (state.dataDXCoils->DXCoil(DXCoilNum).MSSecCoilAirFlow(MSSpeedNumHS) * MSSpeedRatio +
   16959           0 :                                             state.dataDXCoils->DXCoil(DXCoilNum).MSSecCoilAirFlow(MSSpeedNumLS) * (1.0 - MSSpeedRatio));
   16960           0 :             } else if (MSCycRatio > 0.0) {
   16961           0 :                 EvapAirMassFlow = RhoAir * state.dataDXCoils->DXCoil(DXCoilNum).MSSecCoilAirFlow(MSSpeedNumLS);
   16962             :             }
   16963           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).ElecHeatingPower > 0.0) {
   16964           0 :                 TotalHeatRemovalRate =
   16965           0 :                     max(0.0, state.dataDXCoils->DXCoil(DXCoilNum).TotalHeatingEnergyRate - state.dataDXCoils->DXCoil(DXCoilNum).ElecHeatingPower);
   16966             :             } else {
   16967           0 :                 TotalHeatRemovalRate = 0.0;
   16968           0 :                 return;
   16969             :             }
   16970           0 :             state.dataDXCoils->DXCoil(DXCoilNum).SecCoilTotalHeatRemovalRate = -TotalHeatRemovalRate; // +DXCoil( DXCoilNum ).DefrostPower;
   16971           0 :             if ((EvapAirMassFlow > SmallMassFlow) && (MSSpeedRatio > 0.0 || MSCycRatio > 0.0) &&
   16972           0 :                 (EvapInletDryBulb > state.dataDXCoils->DXCoil(DXCoilNum).MinOATCompressor)) { // coil is running
   16973           0 :                 SecCoilFlowFraction = 1.0; // for single speed DX coil the secondary coil (condenser) flow fraction is 1.0
   16974           0 :                 CondInletDryBulb = state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(DXCoilNum).AirInNode).Temp;
   16975           0 :                 EvapInletWetBulb = PsyTwbFnTdbWPb(state, EvapInletDryBulb, EvapInletHumRat, state.dataEnvrn->OutBaroPress, RoutineName);
   16976           0 :                 EvapInletEnthalpy = PsyHFnTdbW(EvapInletDryBulb, EvapInletHumRat);
   16977             :                 // determine the current SHR
   16978           0 :                 if (MSSpeedRatio > 0.0) {
   16979             :                     // calculate SHR for the higher speed
   16980           0 :                     PartLoadRatio = 1.0;
   16981           0 :                     SecCoilFlowFraction = 1.0;
   16982           0 :                     SecCoilSHRFT = state.dataDXCoils->DXCoil(DXCoilNum).MSSecCoilSHRFT(MSSpeedNumHS);
   16983           0 :                     SecCoilSHRFF = state.dataDXCoils->DXCoil(DXCoilNum).MSSecCoilSHRFF(MSSpeedNumHS);
   16984           0 :                     SecCoilRatedSHR = state.dataDXCoils->DXCoil(DXCoilNum).MSSecCoilRatedSHR(MSSpeedNumHS);
   16985           0 :                     SHRHighSpeed = CalcSecondaryDXCoilsSHR(state,
   16986             :                                                            DXCoilNum,
   16987             :                                                            EvapAirMassFlow,
   16988             :                                                            TotalHeatRemovalRate,
   16989             :                                                            PartLoadRatio,
   16990             :                                                            SecCoilRatedSHR,
   16991             :                                                            EvapInletDryBulb,
   16992             :                                                            EvapInletHumRat,
   16993             :                                                            EvapInletWetBulb,
   16994             :                                                            EvapInletEnthalpy,
   16995             :                                                            CondInletDryBulb,
   16996             :                                                            SecCoilFlowFraction,
   16997             :                                                            SecCoilSHRFT,
   16998             :                                                            SecCoilSHRFF);
   16999             :                     // calculate SHR for the lower speed
   17000           0 :                     SecCoilSHRFT = state.dataDXCoils->DXCoil(DXCoilNum).MSSecCoilSHRFT(MSSpeedNumLS);
   17001           0 :                     SecCoilSHRFF = state.dataDXCoils->DXCoil(DXCoilNum).MSSecCoilSHRFF(MSSpeedNumLS);
   17002           0 :                     SecCoilRatedSHR = state.dataDXCoils->DXCoil(DXCoilNum).MSSecCoilRatedSHR(MSSpeedNumLS);
   17003           0 :                     SHRLowSpeed = CalcSecondaryDXCoilsSHR(state,
   17004             :                                                           DXCoilNum,
   17005             :                                                           EvapAirMassFlow,
   17006             :                                                           TotalHeatRemovalRate,
   17007             :                                                           PartLoadRatio,
   17008             :                                                           SecCoilRatedSHR,
   17009             :                                                           EvapInletDryBulb,
   17010             :                                                           EvapInletHumRat,
   17011             :                                                           EvapInletWetBulb,
   17012             :                                                           EvapInletEnthalpy,
   17013             :                                                           CondInletDryBulb,
   17014             :                                                           SecCoilFlowFraction,
   17015             :                                                           SecCoilSHRFT,
   17016             :                                                           SecCoilSHRFF);
   17017           0 :                     SHR = SHRHighSpeed * MSSpeedRatio + SHRLowSpeed * (1.0 - MSSpeedRatio);
   17018             : 
   17019           0 :                 } else if (MSCycRatio > 0.0) {
   17020             :                     // calculate SHR for the lower speed
   17021           0 :                     PartLoadRatio = MSCycRatio;
   17022           0 :                     SecCoilSHRFT = state.dataDXCoils->DXCoil(DXCoilNum).MSSecCoilSHRFT(MSSpeedNumLS);
   17023           0 :                     SecCoilSHRFF = state.dataDXCoils->DXCoil(DXCoilNum).MSSecCoilSHRFF(MSSpeedNumLS);
   17024           0 :                     SecCoilRatedSHR = state.dataDXCoils->DXCoil(DXCoilNum).MSSecCoilRatedSHR(MSSpeedNumLS);
   17025           0 :                     SecCoilFlowFraction = 1.0;
   17026           0 :                     SHRLowSpeed = CalcSecondaryDXCoilsSHR(state,
   17027             :                                                           DXCoilNum,
   17028             :                                                           EvapAirMassFlow,
   17029             :                                                           TotalHeatRemovalRate,
   17030             :                                                           MSCycRatio,
   17031             :                                                           SecCoilRatedSHR,
   17032             :                                                           EvapInletDryBulb,
   17033             :                                                           EvapInletHumRat,
   17034             :                                                           EvapInletWetBulb,
   17035             :                                                           EvapInletEnthalpy,
   17036             :                                                           CondInletDryBulb,
   17037             :                                                           SecCoilFlowFraction,
   17038             :                                                           SecCoilSHRFT,
   17039             :                                                           SecCoilSHRFF);
   17040           0 :                     SHR = SHRLowSpeed;
   17041             :                 }
   17042             :                 // Calculate full load output conditions
   17043           0 :                 FullLoadOutAirEnth = EvapInletEnthalpy - (TotalHeatRemovalRate / PartLoadRatio) / EvapAirMassFlow;
   17044           0 :                 hTinwout = EvapInletEnthalpy - (1.0 - SHR) * ((TotalHeatRemovalRate / PartLoadRatio) / EvapAirMassFlow);
   17045           0 :                 FullLoadOutAirHumRat = PsyWFnTdbH(state, EvapInletDryBulb, hTinwout, RoutineName, true);
   17046           0 :                 FullLoadOutAirTemp = PsyTdbFnHW(FullLoadOutAirEnth, FullLoadOutAirHumRat);
   17047             :                 // when the air outlet temperature falls below the saturation temperature, it is reset to saturation temperature
   17048           0 :                 if (FullLoadOutAirTemp < PsyTsatFnHPb(state, FullLoadOutAirEnth, state.dataEnvrn->OutBaroPress, RoutineName)) {
   17049           0 :                     FullLoadOutAirTemp = PsyTsatFnHPb(state, FullLoadOutAirEnth, state.dataEnvrn->OutBaroPress, RoutineName);
   17050           0 :                     FullLoadOutAirHumRat = PsyWFnTdbH(state, FullLoadOutAirTemp, FullLoadOutAirEnth, RoutineName);
   17051             :                     // Adjust SHR for the new outlet condition that balances energy
   17052           0 :                     hTinwout = PsyHFnTdbW(EvapInletDryBulb, FullLoadOutAirHumRat);
   17053           0 :                     SHR = 1.0 - (EvapInletEnthalpy - hTinwout) / (TotalHeatRemovalRate / PartLoadRatio) / EvapAirMassFlow;
   17054           0 :                     SHR = min(SHR, 1.0);
   17055             :                 }
   17056             :                 // calculate the sensible and latent zone heat removal (extraction) rate by the secondary coil
   17057           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).SecCoilSensibleHeatRemovalRate =
   17058           0 :                     state.dataDXCoils->DXCoil(DXCoilNum).SecCoilTotalHeatRemovalRate * SHR;
   17059           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).SecCoilLatentHeatRemovalRate =
   17060           0 :                     state.dataDXCoils->DXCoil(DXCoilNum).SecCoilTotalHeatRemovalRate -
   17061           0 :                     state.dataDXCoils->DXCoil(DXCoilNum).SecCoilSensibleHeatRemovalRate;
   17062             :             } else {
   17063             :                 // DX coil is off;
   17064           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).SecCoilTotalHeatRemovalRate = 0.0;
   17065           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).SecCoilSensibleHeatRemovalRate = 0.0;
   17066           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).SecCoilLatentHeatRemovalRate = 0.0;
   17067           0 :                 SHR = 0.0; // SHR is set to rated value if the coil is off
   17068             :             }
   17069           0 :             state.dataDXCoils->DXCoil(DXCoilNum).SecCoilSHR = SHR;
   17070           0 :         } break;
   17071           0 :         default:
   17072           0 :             break;
   17073             :         }
   17074             : 
   17075             :     } else {
   17076           0 :         state.dataDXCoils->DXCoil(DXCoilNum).SecCoilSensibleHeatGainRate = 0.0;
   17077           0 :         state.dataDXCoils->DXCoil(DXCoilNum).SecCoilTotalHeatRemovalRate = 0.0;
   17078           0 :         state.dataDXCoils->DXCoil(DXCoilNum).SecCoilSensibleHeatRemovalRate = 0.0;
   17079           0 :         state.dataDXCoils->DXCoil(DXCoilNum).SecCoilLatentHeatRemovalRate = 0.0;
   17080             :     }
   17081             : }
   17082             : 
   17083       30177 : Real64 CalcSecondaryDXCoilsSHR(EnergyPlusData &state,
   17084             :                                [[maybe_unused]] int const DXCoilNum,
   17085             :                                Real64 const EvapAirMassFlow,
   17086             :                                Real64 const TotalHeatRemovalRate,
   17087             :                                Real64 const PartLoadRatio,
   17088             :                                Real64 const SecCoilRatedSHR,
   17089             :                                Real64 const EvapInletDryBulb,
   17090             :                                Real64 const EvapInletHumRat,
   17091             :                                Real64 const EvapInletWetBulb,
   17092             :                                Real64 const EvapInletEnthalpy,
   17093             :                                Real64 const CondInletDryBulb,
   17094             :                                Real64 const SecCoilFlowFraction,
   17095             :                                int const SecCoilSHRFT,
   17096             :                                int const SecCoilSHRFF)
   17097             : {
   17098             : 
   17099             :     // SUBROUTINE INFORMATION:
   17100             :     //       AUTHOR         B. Nigusse
   17101             :     //       DATE WRITTEN   February 2015
   17102             : 
   17103             :     // PURPOSE OF THIS SUBROUTINE:
   17104             :     // Calculates secondary coil (evaporator) sensible heat ratio.
   17105             : 
   17106             :     // METHODOLOGY EMPLOYED:
   17107             :     // Energy balance:
   17108             :     //  (1) checks if the seconday coil operation is dry and calculates appliavle SHR.
   17109             :     //  (2) determines SHR from user specified rated SHR values and SHR modifier curves for
   17110             :     //      temperature and flor fraction.
   17111             :     //  (3) if secondary coil operates dry then the larger of the user SHR value and dry
   17112             :     //      coil operation SHR is selected.
   17113             : 
   17114             :     // Using/Aliasing
   17115             :     using Curve::CurveValue;
   17116             : 
   17117             :     // SUBROUTINE PARAMETER DEFINITIONS:
   17118       30177 :     int constexpr MaxIter(30);
   17119       30177 :     Real64 constexpr RelaxationFactor(0.4);
   17120       30177 :     Real64 constexpr Tolerance(0.1);
   17121       30177 :     Real64 constexpr DryCoilTestEvapInletHumRatReset(0.00001);
   17122             :     static constexpr std::string_view RoutineName("CalcSecondaryDXCoilsSHR");
   17123             : 
   17124             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   17125             :     Real64 DryCoilTestEvapInletHumRat;  // evaporator coil inlet humidity ratio test for dry coil
   17126             :     Real64 DryCoilTestEvapInletWetBulb; // evaporator coil inlet dry bulb temperature test for dry coil
   17127             :     Real64 FullLoadOutAirEnth;          // evaporator outlet full load enthalpy [J/kg]
   17128             :     Real64 FullLoadOutAirTemp;          // evaporator outlet air temperature at full load [C]
   17129             :     Real64 hTinwADP;                    // enthaly of air at secondary coil entering temperature and Humidity ratio at ADP
   17130             :     Real64 SHRadp;                      // Sensible heat ratio
   17131             :     Real64 hADP;                        // enthaly of air at secondary coil at ADP
   17132             :     Real64 tADP;                        // dry bulb temperature of air at secondary coil at ADP
   17133             :     Real64 wADP;                        // humidity ratio of air at secondary coil at ADP
   17134             :     Real64 HumRatError;                 // humidity ratio error
   17135             :     bool CoilMightBeDry;                // TRUE means the secondary DX coi runs dry
   17136             :     int Counter;                        // iteration counter
   17137             :     bool Converged;                     // convergence flag
   17138             :     Real64 SHR;                         // current time step sensible heat ratio of secondary coil
   17139             : 
   17140       30177 :     CoilMightBeDry = false;
   17141       30177 :     FullLoadOutAirEnth = EvapInletEnthalpy - (TotalHeatRemovalRate / PartLoadRatio) / EvapAirMassFlow;
   17142       30177 :     FullLoadOutAirTemp = PsyTdbFnHW(FullLoadOutAirEnth, EvapInletHumRat);
   17143       30177 :     if (FullLoadOutAirTemp > PsyTsatFnHPb(state, FullLoadOutAirEnth, state.dataEnvrn->OutBaroPress, RoutineName)) {
   17144       30177 :         CoilMightBeDry = true;
   17145             :         // find wADP, humidity ratio at apparatus dewpoint and inlet hum rat that would have dry coil
   17146       30177 :         DryCoilTestEvapInletHumRat = EvapInletHumRat;
   17147       30177 :         DryCoilTestEvapInletWetBulb = EvapInletWetBulb;
   17148       30177 :         Counter = 0;
   17149       30177 :         Converged = false;
   17150       90531 :         while (!Converged) {
   17151             :             // assumes coil bypass factor (CBF) = 0.0
   17152       30177 :             hADP = EvapInletEnthalpy - (TotalHeatRemovalRate / PartLoadRatio) / EvapAirMassFlow;
   17153       30177 :             tADP = PsyTsatFnHPb(state, hADP, state.dataEnvrn->OutBaroPress, RoutineName);
   17154       30177 :             wADP = min(EvapInletHumRat, PsyWFnTdbH(state, tADP, hADP, RoutineName));
   17155       30177 :             hTinwADP = PsyHFnTdbW(EvapInletDryBulb, wADP);
   17156       30177 :             if ((EvapInletEnthalpy - hADP) > 1.e-10) {
   17157       30177 :                 SHRadp = min((hTinwADP - hADP) / (EvapInletEnthalpy - hADP), 1.0);
   17158             :             } else {
   17159           0 :                 SHRadp = 1.0;
   17160             :             }
   17161       30177 :             if ((wADP > DryCoilTestEvapInletHumRat) || (Counter >= 1 && Counter < MaxIter)) {
   17162           0 :                 if (DryCoilTestEvapInletHumRat <= 0.0) DryCoilTestEvapInletHumRat = DryCoilTestEvapInletHumRatReset;
   17163           0 :                 HumRatError = (DryCoilTestEvapInletHumRat - wADP) / DryCoilTestEvapInletHumRat;
   17164           0 :                 DryCoilTestEvapInletHumRat = RelaxationFactor * wADP + (1.0 - RelaxationFactor) * DryCoilTestEvapInletHumRat;
   17165           0 :                 DryCoilTestEvapInletWetBulb =
   17166           0 :                     PsyTwbFnTdbWPb(state, EvapInletDryBulb, DryCoilTestEvapInletHumRat, state.dataEnvrn->OutBaroPress, RoutineName);
   17167           0 :                 ++Counter;
   17168           0 :                 if (std::abs(HumRatError) <= Tolerance) {
   17169           0 :                     Converged = true;
   17170             :                 } else {
   17171           0 :                     Converged = false;
   17172             :                 }
   17173             :             } else {
   17174       30177 :                 Converged = true;
   17175             :             }
   17176             :         }
   17177             :     }
   17178             :     // determine SHR from user specified nominal value and SHR modifier curves
   17179       30177 :     SHR = CalcSHRUserDefinedCurves(state, CondInletDryBulb, EvapInletWetBulb, SecCoilFlowFraction, SecCoilSHRFT, SecCoilSHRFF, SecCoilRatedSHR);
   17180       30177 :     if (CoilMightBeDry) {
   17181       30177 :         if ((EvapInletHumRat < DryCoilTestEvapInletHumRat) && (SHRadp > SHR)) { // coil is dry for sure
   17182           0 :             SHR = 1.0;
   17183       30177 :         } else if (SHRadp > SHR) {
   17184           0 :             SHR = SHRadp;
   17185             :         }
   17186             :     }
   17187       30177 :     return SHR;
   17188             : }
   17189             : 
   17190      656387 : void CalcVRFCoolingCoil_FluidTCtrl(EnergyPlusData &state,
   17191             :                                    int const DXCoilNum,                     // the number of the DX coil to be simulated
   17192             :                                    CompressorOperation const CompressorOp,  // compressor operation; 1=on, 0=off
   17193             :                                    bool const FirstHVACIteration,           // true if this is the first iteration of HVAC
   17194             :                                    Real64 const PartLoadRatio,              // sensible cooling load / full load sensible cooling capacity
   17195             :                                    int const FanOpMode,                     // Allows parent object to control fan operation
   17196             :                                    Real64 const CompCycRatio,               // cycling ratio of VRF condenser
   17197             :                                    Optional_int_const PerfMode,             // Performance mode for MultiMode DX coil; Always 1 for other coil types
   17198             :                                    Optional<Real64 const> OnOffAirFlowRatio // ratio of compressor on airflow to compressor off airflow
   17199             : )
   17200             : {
   17201             :     // SUBROUTINE INFORMATION:
   17202             :     //       AUTHOR         Xiufeng Pang, LBNL
   17203             :     //       DATE WRITTEN   Jan 2013
   17204             :     //       MODIFIED       Nov 2015, RP Zhang, LBNL
   17205             : 
   17206             :     // PURPOSE OF THIS SUBROUTINE:
   17207             :     //         Calculates the air-side performance of a direct-expansion, air-cooled
   17208             :     //         VRF terminal unit cooling coil, for the VRF_FluidTCtrl model.
   17209             : 
   17210             :     // METHODOLOGY EMPLOYED:
   17211             :     //         This subroutine is derived from CalcVRFCoolingCoil, and implements the new VRF model for FluidTCtrl.
   17212             : 
   17213             :     // Using/Aliasing
   17214             :     using Curve::CurveValue;
   17215      656387 :     auto &SysTimeElapsed = state.dataHVACGlobal->SysTimeElapsed;
   17216      656387 :     auto &TimeStepSys = state.dataHVACGlobal->TimeStepSys;
   17217             :     using General::CreateSysTimeIntervalString;
   17218             : 
   17219             :     using namespace HVACVariableRefrigerantFlow;
   17220             : 
   17221             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   17222             : 
   17223             :     Real64 AirMassFlow;       // dry air mass flow rate through coil [kg/s] (adjusted for bypass if any)
   17224             :     Real64 AirVolumeFlowRate; // Air volume flow rate across the cooling coil [m3/s] (adjusted for bypass if any)
   17225             :     // (average flow if cycling fan, full flow if constant fan)
   17226             :     Real64 VolFlowperRatedTotCap; // Air volume flow rate divided by rated total cooling capacity [m3/s-W] (adjusted for bypass)
   17227             :     Real64 TotCap;                // gross total cooling capacity at off-rated conditions [W]
   17228             :     Real64 InletAirDryBulbTemp;   // inlet air dry bulb temperature [C]
   17229             :     Real64 InletAirEnthalpy;      // inlet air enthalpy [J/kg]
   17230             :     Real64 InletAirHumRat;        // inlet air humidity ratio [kg/kg]
   17231             :     //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   17232             :     Real64 RatedCBF;      // coil bypass factor at rated conditions
   17233             :     Real64 CBF;           // coil bypass factor at off rated conditions
   17234             :     Real64 A0;            // NTU * air mass flow rate, used in CBF calculation
   17235             :     Real64 PLF;           // Part load factor, accounts for thermal lag at compressor startup, used in power calculation
   17236             :     Real64 CondInletTemp; // Condenser inlet temperature (C). Outdoor dry-bulb temp for air-cooled condenser.
   17237             :     // Outdoor Wetbulb +(1 - effectiveness)*(outdoor drybulb - outdoor wetbulb) for evap condenser.
   17238             :     Real64 CondInletHumRat; // Condenser inlet humidity ratio (kg/kg). Zero for air-cooled condenser.
   17239             :     // For evap condenser, its the humidity ratio of the air leaving the evap cooling pads.
   17240             :     Real64 CondAirMassFlow;       // Condenser air mass flow rate [kg/s]
   17241             :     Real64 RhoAir;                // Density of air [kg/m3]
   17242             :     Real64 CrankcaseHeatingPower; // power due to crankcase heater
   17243      656387 :     Real64 CompAmbTemp(0.0);      // Ambient temperature at compressor
   17244             :     Real64 AirFlowRatio;          // ratio of compressor on airflow to average timestep airflow
   17245             :     // used when constant fan mode yields different air flow rates when compressor is ON and OFF
   17246             :     // (e.g. Packaged Terminal Heat Pump)
   17247             :     Real64 OutdoorDryBulb;  // Outdoor dry-bulb temperature at condenser (C)
   17248             :     Real64 OutdoorWetBulb;  // Outdoor wet-bulb temperature at condenser (C)
   17249             :     Real64 OutdoorHumRat;   // Outdoor humidity ratio at condenser (kg/kg)
   17250             :     Real64 OutdoorPressure; // Outdoor barometric pressure at condenser (Pa)
   17251             : 
   17252      656387 :     auto &CurrentEndTime = state.dataDXCoils->CalcVRFCoolingCoil_FluidTCtrlCurrentEndTime;
   17253             :     int Mode;                 // Performance mode for Multimode DX coil; Always 1 for other coil types
   17254             :     Real64 OutletAirTemp;     // Supply air temperature (average value if constant fan, full output if cycling fan)
   17255             :     Real64 OutletAirHumRat;   // Supply air humidity ratio (average value if constant fan, full output if cycling fan)
   17256             :     Real64 OutletAirEnthalpy; // Supply air enthalpy (average value if constant fan, full output if cycling fan)
   17257             :     Real64 ADiff;             // Used for exponential
   17258             : 
   17259             :     // Followings for VRF FluidTCtrl Only
   17260             :     Real64 QCoilReq;       // Coil load (W)
   17261             :     Real64 FanSpdRatio;    // Fan speed ratio
   17262             :     Real64 AirMassFlowMin; // Min air mass flow rate due to OA requirement [kg/s]
   17263             :     Real64 ActualSH;       // Super heating degrees (C)
   17264             :     Real64 ActualSC;       // Sub cooling degrees (C)
   17265             : 
   17266             :     // If Performance mode not present, then set to 1.  Used only by Multimode/Multispeed DX coil (otherwise mode = 1)
   17267      656387 :     if (present(PerfMode)) {
   17268           0 :         Mode = PerfMode;
   17269             :     } else {
   17270      656387 :         Mode = 1;
   17271             :     }
   17272             : 
   17273             :     // If AirFlowRatio not present, then set to 1. Used only by DX coils with different air flow
   17274             :     // during cooling and when no cooling is required (constant fan, fan speed changes)
   17275      656387 :     if (present(OnOffAirFlowRatio)) {
   17276           0 :         AirFlowRatio = OnOffAirFlowRatio;
   17277             :     } else {
   17278      656387 :         AirFlowRatio = 1.0;
   17279             :     }
   17280             : 
   17281             :     // Initialize coil air side parameters
   17282      656387 :     CondInletTemp = 0.0;
   17283      656387 :     CondInletHumRat = 0.0;
   17284      656387 :     AirMassFlow = state.dataDXCoils->DXCoil(DXCoilNum).InletAirMassFlowRate;
   17285      656387 :     InletAirDryBulbTemp = state.dataDXCoils->DXCoil(DXCoilNum).InletAirTemp;
   17286      656387 :     InletAirEnthalpy = state.dataDXCoils->DXCoil(DXCoilNum).InletAirEnthalpy;
   17287      656387 :     InletAirHumRat = state.dataDXCoils->DXCoil(DXCoilNum).InletAirHumRat;
   17288      656387 :     state.dataHeatBal->HeatReclaimDXCoil(DXCoilNum).AvailCapacity = 0.0;
   17289      656387 :     state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction = 0.0;
   17290      656387 :     state.dataDXCoils->DXCoil(DXCoilNum).PartLoadRatio = 0.0;
   17291      656387 :     state.dataDXCoils->DXCoil(DXCoilNum).BasinHeaterPower = 0.0;
   17292      656387 :     state.dataDXCoils->DXCoil(DXCoilNum).EvaporatingTemp =
   17293      656387 :         state.dataHVACVarRefFlow->VRF(state.dataDXCoils->DXCoil(DXCoilNum).VRFOUPtr).IUEvaporatingTemp;
   17294             : 
   17295      656387 :     if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(Mode) != 0) {
   17296           0 :         OutdoorDryBulb = state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(Mode)).Temp;
   17297           0 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(Mode) == DataHeatBalance::RefrigCondenserType::Water) {
   17298           0 :             OutdoorHumRat = state.dataEnvrn->OutHumRat;
   17299           0 :             OutdoorPressure = state.dataEnvrn->OutBaroPress;
   17300           0 :             OutdoorWetBulb = state.dataEnvrn->OutWetBulbTemp;
   17301             :         } else {
   17302           0 :             OutdoorPressure = state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(Mode)).Press;
   17303             :             // If node is not connected to anything, pressure = default, use weather data
   17304           0 :             if (OutdoorPressure == state.dataLoopNodes->DefaultNodeValues.Press) {
   17305           0 :                 OutdoorDryBulb = state.dataEnvrn->OutDryBulbTemp;
   17306           0 :                 OutdoorHumRat = state.dataEnvrn->OutHumRat;
   17307           0 :                 OutdoorPressure = state.dataEnvrn->OutBaroPress;
   17308           0 :                 OutdoorWetBulb = state.dataEnvrn->OutWetBulbTemp;
   17309             :             } else {
   17310           0 :                 OutdoorHumRat = state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(Mode)).HumRat;
   17311           0 :                 OutdoorWetBulb = state.dataLoopNodes->Node(state.dataDXCoils->DXCoil(DXCoilNum).CondenserInletNodeNum(Mode)).OutAirWetBulb;
   17312             :             }
   17313             :         }
   17314             :     } else {
   17315      656387 :         OutdoorDryBulb = state.dataEnvrn->OutDryBulbTemp;
   17316      656387 :         OutdoorHumRat = state.dataEnvrn->OutHumRat;
   17317      656387 :         OutdoorPressure = state.dataEnvrn->OutBaroPress;
   17318      656387 :         OutdoorWetBulb = state.dataEnvrn->OutWetBulbTemp;
   17319             :     }
   17320             : 
   17321      656387 :     if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(Mode) == DataHeatBalance::RefrigCondenserType::Evap) {
   17322           0 :         RhoAir = PsyRhoAirFnPbTdbW(state, OutdoorPressure, OutdoorDryBulb, OutdoorHumRat);
   17323           0 :         CondAirMassFlow = RhoAir * state.dataDXCoils->DXCoil(DXCoilNum).EvapCondAirFlow(Mode);
   17324             :         // (Outdoor wet-bulb temp from DataEnvironment) + (1.0-EvapCondEffectiveness) * (drybulb - wetbulb)
   17325           0 :         CondInletTemp = OutdoorWetBulb + (OutdoorDryBulb - OutdoorWetBulb) * (1.0 - state.dataDXCoils->DXCoil(DXCoilNum).EvapCondEffect(Mode));
   17326           0 :         CondInletHumRat = PsyWFnTdbTwbPb(state, CondInletTemp, OutdoorWetBulb, OutdoorPressure);
   17327           0 :         CompAmbTemp = OutdoorDryBulb;
   17328             :     } else {                            // for air or water-cooled, inlet temp is stored in OutdoorDryBulb temp
   17329      656387 :         CondInletTemp = OutdoorDryBulb; // Outdoor dry-bulb temp or water inlet temp
   17330      656387 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CondenserType(Mode) == DataHeatBalance::RefrigCondenserType::Water) {
   17331           0 :             CompAmbTemp = state.dataEnvrn->OutDryBulbTemp; // for crankcase heater use actual outdoor temp for water-cooled
   17332             :         } else {
   17333      656387 :             CompAmbTemp = OutdoorDryBulb;
   17334             :         }
   17335             :     }
   17336             : 
   17337             :     // Initialize crankcase heater, operates below OAT defined in input deck for HP DX cooling coil
   17338             :     // If used in a heat pump, the value of MaxOAT in the heating coil overrides that in the cooling coil (in GetInput)
   17339      656387 :     if (CompAmbTemp < state.dataDXCoils->DXCoil(DXCoilNum).MaxOATCrankcaseHeater) {
   17340       53963 :         CrankcaseHeatingPower = state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterCapacity;
   17341             :     } else {
   17342      602424 :         CrankcaseHeatingPower = 0.0;
   17343             :     }
   17344             : 
   17345             :     // calculate end time of current time step to determine if error messages should be printed
   17346      656387 :     CurrentEndTime = state.dataGlobal->CurrentTime + SysTimeElapsed;
   17347             : 
   17348             :     // The following checks are not necessary for VRF-FluidTCtrl model. (1) OAT check is already performed in the VRF OU routines (2)
   17349             :     // VRF-FluidTCtrl model is physics based, not system curve based, and thus doesn't require special performance curves for operations at
   17350             :     // low inlet temperatures
   17351             :     //   Print warning messages only when valid and only for the first occurrence. Let summary provide statistics.
   17352             :     //   Wait for next time step to print warnings. If simulation iterates, print out
   17353             :     //   the warning for the last iteration only. Must wait for next time step to accomplish this.
   17354             :     //   If a warning occurs and the simulation down shifts, the warning is not valid.
   17355             :     // if ( DXCoil( DXCoilNum ).PrintLowAmbMessage ) { // .AND. &
   17356             :     //     if ( CurrentEndTime > DXCoil( DXCoilNum ).CurrentEndTimeLast && TimeStepSys >= DXCoil( DXCoilNum ).TimeStepSysLast ) {
   17357             :     //         if ( DXCoil( DXCoilNum ).LowAmbErrIndex == 0 ) {
   17358             :     //             ShowWarningMessage(state,  DXCoil( DXCoilNum ).LowAmbBuffer1 );
   17359             :     //             ShowContinueError(state,  DXCoil( DXCoilNum ).LowAmbBuffer2 );
   17360             :     //             ShowContinueError(state,  "... Operation at low inlet temperatures may require special performance curves." );
   17361             :     //         }
   17362             :     //         ShowRecurringWarningErrorAtEnd(state,  DXCoil( DXCoilNum ).DXCoilType + " \"" + DXCoil( DXCoilNum ).Name + "\" - Low condenser inlet
   17363             :     // temperature error continues...", DXCoil( DXCoilNum ).LowAmbErrIndex, DXCoil( DXCoilNum ).LowTempLast, DXCoil( DXCoilNum ).LowTempLast,
   17364             :     // _,
   17365             :     // "[C]", "[C]" );
   17366             :     //     }
   17367             :     // }
   17368             :     //
   17369             :     // if ( DXCoil( DXCoilNum ).PrintHighAmbMessage ) { // .AND. &
   17370             :     //     if ( CurrentEndTime > DXCoil( DXCoilNum ).CurrentEndTimeLast && TimeStepSys >= DXCoil( DXCoilNum ).TimeStepSysLast ) {
   17371             :     //         if ( DXCoil( DXCoilNum ).HighAmbErrIndex == 0 ) {
   17372             :     //             ShowWarningMessage(state,  DXCoil( DXCoilNum ).HighAmbBuffer1 );
   17373             :     //             ShowContinueError(state,  DXCoil( DXCoilNum ).HighAmbBuffer2 );
   17374             :     //             ShowContinueError(state,  "... Operation at high inlet temperatures may require special performance curves." );
   17375             :     //         }
   17376             :     //         ShowRecurringWarningErrorAtEnd(state,  DXCoil( DXCoilNum ).DXCoilType + " \"" + DXCoil( DXCoilNum ).Name + "\" - High condenser inlet
   17377             :     // temperature error continues...", DXCoil( DXCoilNum ).HighAmbErrIndex, DXCoil( DXCoilNum ).HighTempLast, DXCoil( DXCoilNum
   17378             :     // ).HighTempLast,
   17379             :     // _, "[C]", "[C]" );
   17380             :     //     }
   17381             :     // }
   17382             : 
   17383      656387 :     if (state.dataDXCoils->DXCoil(DXCoilNum).PrintLowOutTempMessage) {
   17384           0 :         if (CurrentEndTime > state.dataDXCoils->DXCoil(DXCoilNum).CurrentEndTimeLast &&
   17385           0 :             TimeStepSys >= state.dataDXCoils->DXCoil(DXCoilNum).TimeStepSysLast) {
   17386           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).LowOutletTempIndex == 0) {
   17387           0 :                 ShowWarningMessage(state, state.dataDXCoils->DXCoil(DXCoilNum).LowOutTempBuffer1);
   17388           0 :                 ShowContinueError(state, state.dataDXCoils->DXCoil(DXCoilNum).LowOutTempBuffer2);
   17389           0 :                 ShowContinueError(state, "... Possible reasons for low outlet air dry-bulb temperatures are: This DX coil");
   17390           0 :                 ShowContinueError(state,
   17391           0 :                                   format("   1) may have a low inlet air dry-bulb temperature. Inlet air temperature = {:.3T} C.",
   17392           0 :                                          state.dataDXCoils->DXCoil(DXCoilNum).FullLoadInletAirTempLast));
   17393           0 :                 ShowContinueError(state, "   2) may have a low air flow rate per watt of cooling capacity. Check inputs.");
   17394           0 :                 ShowContinueError(state,
   17395             :                                   "   3) is used as part of a HX assisted cooling coil which uses a high sensible effectiveness. Check inputs.");
   17396             :             }
   17397           0 :             ShowRecurringWarningErrorAtEnd(state,
   17398           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + " \"" + state.dataDXCoils->DXCoil(DXCoilNum).Name +
   17399             :                                                "\" - Full load outlet temperature indicates a possibility of frost/freeze error continues. "
   17400             :                                                "Outlet air temperature statistics follow:",
   17401           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).LowOutletTempIndex,
   17402           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).FullLoadOutAirTempLast,
   17403           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).FullLoadOutAirTempLast);
   17404             :         }
   17405             :     }
   17406             : 
   17407             :     // save last system time step and last end time of current time step (used to determine if warning is valid)
   17408      656387 :     state.dataDXCoils->DXCoil(DXCoilNum).TimeStepSysLast = TimeStepSys;
   17409      656387 :     state.dataDXCoils->DXCoil(DXCoilNum).CurrentEndTimeLast = CurrentEndTime;
   17410      656387 :     state.dataDXCoils->DXCoil(DXCoilNum).PrintLowAmbMessage = false;
   17411      656387 :     state.dataDXCoils->DXCoil(DXCoilNum).PrintLowOutTempMessage = false;
   17412             : 
   17413      656387 :     if ((AirMassFlow > 0.0) && (GetCurrentScheduleValue(state, state.dataDXCoils->DXCoil(DXCoilNum).SchedPtr) > 0.0) && (PartLoadRatio > 0.0) &&
   17414             :         (CompressorOp == CompressorOperation::On)) { // for cycling fan, reset mass flow to full on rate
   17415             : 
   17416      288920 :         if (state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode) <= 0.0) {
   17417           0 :             ShowFatalError(state,
   17418           0 :                            state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + " \"" + state.dataDXCoils->DXCoil(DXCoilNum).Name +
   17419             :                                "\" - Rated total cooling capacity is zero or less.");
   17420             :         }
   17421             : 
   17422      288920 :         TotCap = state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode);
   17423      288920 :         QCoilReq = -PartLoadRatio * TotCap;
   17424      288920 :         if (PartLoadRatio == 0.0) {
   17425           0 :             AirMassFlowMin = state.dataHVACVarRefFlow->OACompOffMassFlow;
   17426             :         } else {
   17427      288920 :             AirMassFlowMin = state.dataHVACVarRefFlow->OACompOnMassFlow;
   17428             :         }
   17429             : 
   17430             :         // Call ControlVRFIUCoil to calculate: (1) FanSpdRatio, (2) coil inlet/outlet conditions, and (3) SH/SC
   17431      866760 :         ControlVRFIUCoil(state,
   17432             :                          DXCoilNum,
   17433             :                          QCoilReq,
   17434      288920 :                          state.dataDXCoils->DXCoil(DXCoilNum).InletAirTemp,
   17435      288920 :                          state.dataDXCoils->DXCoil(DXCoilNum).InletAirHumRat,
   17436      288920 :                          state.dataDXCoils->DXCoil(DXCoilNum).EvaporatingTemp,
   17437             :                          AirMassFlowMin,
   17438             :                          FanSpdRatio,
   17439             :                          OutletAirHumRat,
   17440             :                          OutletAirTemp,
   17441             :                          OutletAirEnthalpy,
   17442             :                          ActualSH,
   17443             :                          ActualSC);
   17444      288920 :         AirMassFlow = FanSpdRatio * state.dataDXCoils->DXCoil(DXCoilNum).RatedAirMassFlowRate(Mode);
   17445             : 
   17446      288920 :         AirVolumeFlowRate = AirMassFlow / PsyRhoAirFnPbTdbW(state, OutdoorPressure, InletAirDryBulbTemp, InletAirHumRat);
   17447      288920 :         VolFlowperRatedTotCap = AirVolumeFlowRate / state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode);
   17448             :         // VolFlowperRatedTotCap was checked at the initialization step
   17449             :         // No need to check VolFlowperRatedTotCap at the simulation
   17450             :         // New VRF_FluidTCtrl model implements VAV fan which can vary air flow rate during simulation
   17451             : 
   17452      288920 :         RatedCBF = state.dataDXCoils->DXCoil(DXCoilNum).RatedCBF(Mode);
   17453      288920 :         if (RatedCBF > 0.0) {
   17454      288920 :             A0 = -std::log(RatedCBF) * state.dataDXCoils->DXCoil(DXCoilNum).RatedAirMassFlowRate(Mode);
   17455             :         } else {
   17456           0 :             A0 = 0.0;
   17457             :         }
   17458      288920 :         ADiff = -A0 / AirMassFlow;
   17459      288920 :         if (ADiff >= DataPrecisionGlobals::EXP_LowerLimit) {
   17460      288920 :             CBF = std::exp(ADiff);
   17461             :         } else {
   17462           0 :             CBF = 0.0;
   17463             :         }
   17464             : 
   17465             :         // The following checks are not necessary for VRF-FluidTCtrl model. (1) OAT check is already performed in the VRF OU routines (2)
   17466             :         // VRF-FluidTCtrl model is physics based, not system curve based, and thus doesn't require special performance curves for operations
   17467             :         // at low inlet temperatures
   17468             :         // // check boundary for low ambient temperature and post warnings to individual DX coil buffers to print at end of time step
   17469             :         // if ( OutdoorDryBulb < DXCoil( DXCoilNum ).MinOATCompressor && ! WarmupFlag ) {
   17470             :         //     DXCoil( DXCoilNum ).PrintLowAmbMessage = true;
   17471             :         //     DXCoil( DXCoilNum ).LowTempLast = OutdoorDryBulb;
   17472             :         //     if ( DXCoil( DXCoilNum ).LowAmbErrIndex == 0 ) {
   17473             :         //         DXCoil( DXCoilNum ).LowAmbBuffer1 = DXCoil( DXCoilNum ).DXCoilType + " \"" + DXCoil( DXCoilNum ).Name + "\" - Condenser
   17474             :         // inlet temperature below " + RoundSigDigits( DXCoil( DXCoilNum ).MinOATCompressor, 2 ) + " C. Condenser inlet temperature = " +
   17475             :         // RoundSigDigits( OutdoorDryBulb, 2 );
   17476             :         //         DXCoil( DXCoilNum ).LowAmbBuffer2 = " ... Occurrence info = " + EnvironmentName + ", " + CurMnDy + " " +
   17477             :         // CreateSysTimeIntervalString();
   17478             :         //     }
   17479             :         // }
   17480             :         //
   17481             :         // // check boundary for high ambient temperature and post warnings to individual DX coil buffers to print at end of time step
   17482             :         // if ( OutdoorDryBulb > DXCoil( DXCoilNum ).MaxOATCompressor && ! WarmupFlag ) {
   17483             :         //     DXCoil( DXCoilNum ).PrintHighAmbMessage = true;
   17484             :         //     DXCoil( DXCoilNum ).HighTempLast = OutdoorDryBulb;
   17485             :         //     if ( DXCoil( DXCoilNum ).HighAmbErrIndex == 0 ) {
   17486             :         //         DXCoil( DXCoilNum ).HighAmbBuffer1 = DXCoil( DXCoilNum ).DXCoilType + " \"" + DXCoil( DXCoilNum ).Name + "\" - Condenser
   17487             :         // inlet temperature above " + RoundSigDigits( DXCoil( DXCoilNum ).MaxOATCompressor, 2 ) + " C. Condenser temperature = " +
   17488             :         // RoundSigDigits( OutdoorDryBulb, 2 );         DXCoil( DXCoilNum ).HighAmbBuffer2 = " ... Occurrence info = " + EnvironmentName + ",
   17489             :         // "
   17490             :         // + CurMnDy + " " + CreateSysTimeIntervalString();
   17491             :         //     }
   17492             :         // }
   17493             : 
   17494             :         //  Get total capacity modifying factor (function of temperature) for off-rated conditions
   17495             :         //  InletAirHumRat may be modified in this ADP/BF loop, use temporary varible for calculations
   17496             : 
   17497             :         // commented, not used issue #6950
   17498             :         // InletAirHumRatTemp = InletAirHumRat;
   17499             : 
   17500             :         //// Calculate apparatus dew point conditions using TotCap and CBF
   17501             :         // hDelta = TotCap / AirMassFlow;
   17502             :         //// there is an issue here with using CBF to calculate the ADP enthalpy.
   17503             :         //// at low loads the bypass factor increases significantly.
   17504             :         // hADP = InletAirEnthalpy - hDelta / (1.0 - CBF);
   17505             :         // tADP = PsyTsatFnHPb(hADP, OutdoorPressure, RoutineName);
   17506             :         ////  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   17507             :         ////  tADP = PsyTsatFnHPb(hADP,InletAirPressure)
   17508             :         // wADP = min(InletAirHumRat, PsyWFnTdbH(tADP, hADP, RoutineName));
   17509             :         // hTinwADP = PsyHFnTdbW(InletAirDryBulbTemp, wADP);
   17510             :         // if ((InletAirEnthalpy - hADP) > 1.e-10) {
   17511             :         //    SHR = min((hTinwADP - hADP) / (InletAirEnthalpy - hADP), 1.0);
   17512             :         //} else {
   17513             :         //    SHR = 1.0;
   17514             :         //}
   17515             :         // commented, not used issue #6950 ends here
   17516             : 
   17517      288920 :         if (state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(Mode) > 0 && CompCycRatio < 1.0) {
   17518           0 :             PLF = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(Mode), CompCycRatio); // Calculate part-load factor
   17519             :         } else {
   17520      288920 :             PLF = 1.0;
   17521             :         }
   17522             : 
   17523      288920 :         if (PLF < 0.7) {
   17524           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).ErrIndex2 == 0) {
   17525           0 :                 ShowWarningMessage(state,
   17526           0 :                                    format("The PLF curve value for the DX cooling coil {} ={:.3R} for part-load ratio ={:.3R}",
   17527           0 :                                           state.dataDXCoils->DXCoil(DXCoilNum).Name,
   17528             :                                           PLF,
   17529           0 :                                           PartLoadRatio));
   17530           0 :                 ShowContinueErrorTimeStamp(state, "PLF curve values must be >= 0.7. PLF has been reset to 0.7 and simulation is continuing.");
   17531           0 :                 ShowContinueError(state, "Check the IO reference manual for PLF curve guidance [Coil:Cooling:DX:SingleSpeed].");
   17532             :             }
   17533           0 :             ShowRecurringWarningErrorAtEnd(state,
   17534           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).Name + ", DX cooling coil PLF curve < 0.7 warning continues...",
   17535           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).ErrIndex2,
   17536             :                                            PLF,
   17537             :                                            PLF);
   17538           0 :             PLF = 0.7;
   17539             :         }
   17540             : 
   17541      288920 :         state.dataDXCoils->DXCoil(DXCoilNum).PartLoadRatio = PartLoadRatio;
   17542      288920 :         state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction = CompCycRatio / PLF;
   17543      288920 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction > 1.0 &&
   17544           0 :             std::abs(state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction - 1.0) > 0.001) {
   17545           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).ErrIndex3 == 0) {
   17546           0 :                 ShowWarningMessage(state,
   17547           0 :                                    format("The runtime fraction for DX cooling coil {} exceeded 1.0. [{:.4R}].",
   17548           0 :                                           state.dataDXCoils->DXCoil(DXCoilNum).Name,
   17549           0 :                                           state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction));
   17550           0 :                 ShowContinueError(state, "Runtime fraction reset to 1 and the simulation will continue.");
   17551           0 :                 ShowContinueError(state, "Check the IO reference manual for PLF curve guidance [Coil:Cooling:DX:SingleSpeed].");
   17552           0 :                 ShowContinueErrorTimeStamp(state, "");
   17553             :             }
   17554           0 :             ShowRecurringWarningErrorAtEnd(state,
   17555           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).Name +
   17556             :                                                ", DX cooling coil runtime fraction > 1.0 warning continues...",
   17557           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).ErrIndex3,
   17558           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction,
   17559           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction);
   17560           0 :             state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction = 1.0; // Reset coil runtime fraction to 1.0
   17561      288920 :         } else if (state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction > 1.0) {
   17562           0 :             state.dataDXCoils->DXCoil(DXCoilNum).CoolingCoilRuntimeFraction = 1.0; // Reset coil runtime fraction to 1.0
   17563             :         }
   17564             : 
   17565             :         // If cycling fan, send coil part-load fraction to on/off fan via HVACDataGlobals
   17566      288920 :         if (FanOpMode == CycFanCycCoil) state.dataHVACGlobal->OnOffFanPartLoadFraction = PLF;
   17567             : 
   17568             :         // Check for saturation error and modify temperature at constant enthalpy
   17569      288920 :         if (OutletAirTemp < PsyTsatFnHPb(state, OutletAirEnthalpy, OutdoorPressure)) {
   17570         176 :             OutletAirTemp = PsyTsatFnHPb(state, OutletAirEnthalpy, OutdoorPressure);
   17571             :             //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   17572             :             //   IF(FullLoadOutAirTemp .LT. PsyTsatFnHPb(FullLoadOutAirEnth,InletAirPressure)) THEN
   17573             :             //    FullLoadOutAirTemp = PsyTsatFnHPb(FullLoadOutAirEnth,InletAirPressure)
   17574         176 :             OutletAirHumRat = PsyWFnTdbH(state, OutletAirTemp, OutletAirEnthalpy);
   17575             :         }
   17576             : 
   17577             :         // Store actual outlet conditions when DX coil is ON for use in heat recovery module
   17578      288920 :         state.dataDXCoils->DXCoilFullLoadOutAirTemp(DXCoilNum) = OutletAirTemp;
   17579      288920 :         state.dataDXCoils->DXCoilFullLoadOutAirHumRat(DXCoilNum) = OutletAirHumRat;
   17580             : 
   17581             :         // Add warning message for cold cooling coil (OutletAirTemp < 2 C)
   17582      288920 :         if (OutletAirTemp < 2.0 && !FirstHVACIteration && !state.dataGlobal->WarmupFlag) {
   17583           0 :             state.dataDXCoils->DXCoil(DXCoilNum).PrintLowOutTempMessage = true;
   17584           0 :             state.dataDXCoils->DXCoil(DXCoilNum).FullLoadOutAirTempLast = OutletAirTemp;
   17585           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).LowOutletTempIndex == 0) {
   17586           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).FullLoadInletAirTempLast = InletAirDryBulbTemp;
   17587           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).LowOutTempBuffer1 =
   17588           0 :                     format("{} \"{}\" - Full load outlet air dry-bulb temperature < 2C. This indicates the "
   17589             :                            "possibility of coil frost/freeze. Outlet temperature = {:.2R} C.",
   17590           0 :                            state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType,
   17591           0 :                            state.dataDXCoils->DXCoil(DXCoilNum).Name,
   17592           0 :                            OutletAirTemp);
   17593           0 :                 state.dataDXCoils->DXCoil(DXCoilNum).LowOutTempBuffer2 = " ...Occurrence info = " + state.dataEnvrn->EnvironmentName + ", " +
   17594           0 :                                                                          state.dataEnvrn->CurMnDy + " " + CreateSysTimeIntervalString(state);
   17595             :             }
   17596             :         }
   17597             : 
   17598             :         // Coil total cooling
   17599      288920 :         Real64 AirMassFlowRate = state.dataDXCoils->DXCoil(DXCoilNum).InletAirMassFlowRate;
   17600             :         // Coil total/sensible/latent cooling rates
   17601      866760 :         CalcComponentSensibleLatentOutput(AirMassFlowRate,
   17602             :                                           InletAirDryBulbTemp,
   17603             :                                           InletAirHumRat,
   17604             :                                           OutletAirTemp,
   17605             :                                           OutletAirHumRat,
   17606      288920 :                                           state.dataDXCoils->DXCoil(DXCoilNum).SensCoolingEnergyRate,
   17607      288920 :                                           state.dataDXCoils->DXCoil(DXCoilNum).LatCoolingEnergyRate,
   17608      288920 :                                           state.dataDXCoils->DXCoil(DXCoilNum).TotalCoolingEnergyRate);
   17609             : 
   17610             :         // Coil outlet conditions
   17611      288920 :         state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp = OutletAirTemp;
   17612      288920 :         state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat = OutletAirHumRat;
   17613      288920 :         state.dataDXCoils->DXCoil(DXCoilNum).OutletAirEnthalpy = OutletAirEnthalpy;
   17614             : 
   17615             :         // Coil SH/SC
   17616      288920 :         state.dataDXCoils->DXCoil(DXCoilNum).ActualSH = ActualSH;
   17617      288920 :         state.dataDXCoils->DXCoil(DXCoilNum).ActualSC = ActualSC;
   17618             : 
   17619             :     } else {
   17620             :         // DX coil is off; just pass through conditions
   17621             : 
   17622      367467 :         state.dataDXCoils->DXCoil(DXCoilNum).OutletAirEnthalpy = state.dataDXCoils->DXCoil(DXCoilNum).InletAirEnthalpy;
   17623      367467 :         state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat = state.dataDXCoils->DXCoil(DXCoilNum).InletAirHumRat;
   17624      367467 :         state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp = state.dataDXCoils->DXCoil(DXCoilNum).InletAirTemp;
   17625             : 
   17626      367467 :         state.dataDXCoils->DXCoil(DXCoilNum).ElecCoolingPower = 0.0;
   17627      367467 :         state.dataDXCoils->DXCoil(DXCoilNum).TotalCoolingEnergyRate = 0.0;
   17628      367467 :         state.dataDXCoils->DXCoil(DXCoilNum).SensCoolingEnergyRate = 0.0;
   17629      367467 :         state.dataDXCoils->DXCoil(DXCoilNum).LatCoolingEnergyRate = 0.0;
   17630      367467 :         state.dataDXCoils->DXCoil(DXCoilNum).EvapCondPumpElecPower = 0.0;
   17631      367467 :         state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterConsumpRate = 0.0;
   17632             : 
   17633      367467 :         state.dataDXCoils->DXCoil(DXCoilNum).ActualSH = 999.0;
   17634      367467 :         state.dataDXCoils->DXCoil(DXCoilNum).ActualSC = 999.0;
   17635             : 
   17636             :         // Reset globals when DX coil is OFF for use in heat recovery module
   17637      367467 :         state.dataDXCoils->DXCoilFullLoadOutAirTemp(DXCoilNum) = 0.0;
   17638      367467 :         state.dataDXCoils->DXCoilFullLoadOutAirHumRat(DXCoilNum) = 0.0;
   17639             : 
   17640             :     } // end of on/off
   17641             : 
   17642             :     // set water system demand request (if needed)
   17643      656387 :     if (state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterSupplyMode == EvapWaterSupply::FromTank) {
   17644           0 :         state.dataWaterData->WaterStorage(state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterSupTankID)
   17645           0 :             .VdotRequestDemand(state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterTankDemandARRID) =
   17646           0 :             state.dataDXCoils->DXCoil(DXCoilNum).EvapWaterConsumpRate;
   17647             :     }
   17648             : 
   17649      656387 :     state.dataDXCoils->DXCoilOutletTemp(DXCoilNum) = state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp;
   17650      656387 :     state.dataDXCoils->DXCoilOutletHumRat(DXCoilNum) = state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat;
   17651      656387 :     state.dataDXCoils->DXCoilPartLoadRatio(DXCoilNum) = state.dataDXCoils->DXCoil(DXCoilNum).PartLoadRatio;
   17652      656387 :     state.dataDXCoils->DXCoilFanOpMode(DXCoilNum) = FanOpMode;
   17653      656387 :     state.dataDXCoils->DXCoil(DXCoilNum).CondInletTemp = CondInletTemp;
   17654      656387 :     state.dataDXCoils->DXCoilTotalCooling(DXCoilNum) = state.dataDXCoils->DXCoil(DXCoilNum).TotalCoolingEnergyRate;
   17655      656387 :     state.dataDXCoils->DXCoilCoolInletAirWBTemp(DXCoilNum) = PsyTwbFnTdbWPb(state, InletAirDryBulbTemp, InletAirHumRat, OutdoorPressure);
   17656      656387 : }
   17657             : 
   17658      656387 : void CalcVRFHeatingCoil_FluidTCtrl(EnergyPlusData &state,
   17659             :                                    CompressorOperation const CompressorOp,   // compressor operation; 1=on, 0=off
   17660             :                                    int const DXCoilNum,                      // the number of the DX heating coil to be simulated
   17661             :                                    Real64 const PartLoadRatio,               // sensible cooling load / full load sensible cooling capacity
   17662             :                                    int const FanOpMode,                      // Allows parent object to control fan mode
   17663             :                                    Optional<Real64 const> OnOffAirFlowRatio, // ratio of compressor on airflow to compressor off airflow
   17664             :                                    Optional<Real64 const> MaxHeatCap         // maximum allowed heating capacity
   17665             : )
   17666             : {
   17667             :     // SUBROUTINE INFORMATION:
   17668             :     //       AUTHOR         Xiufeng Pang (XP), LBNL
   17669             :     //       DATE WRITTEN   Mar 2013
   17670             :     //       MODIFIED       Nov 2015, RP Zhang, LBNL
   17671             : 
   17672             :     // PURPOSE OF THIS SUBROUTINE:
   17673             :     //         Calculates the air-side performance of a direct-expansion, air-cooled
   17674             :     //         VRF terminal unit heating coil, for the new VRF model.
   17675             : 
   17676             :     // METHODOLOGY EMPLOYED:
   17677             :     //         This subroutine is derived from CalcVRFCoolingCoil, and implements the new VRF model for FluidTCtrl.
   17678             : 
   17679             :     // Using/Aliasing
   17680             :     using Curve::CurveValue;
   17681             : 
   17682             :     using namespace HVACVariableRefrigerantFlow;
   17683             : 
   17684             :     // INTERFACE BLOCK SPECIFICATIONS
   17685             :     static constexpr std::string_view RoutineNameFullLoad("CalcVRFHeatingCoil_FluidTCtrl:fullload");
   17686             : 
   17687             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   17688             :     Real64 AirMassFlow;           // dry air mass flow rate through coil [kg/s]
   17689             :     Real64 AirMassFlowRatio;      // Ratio of actual air mass flow to rated air mass flow
   17690             :     Real64 AirVolumeFlowRate;     // Air volume flow rate across the cooling coil [m3/s]
   17691             :     Real64 VolFlowperRatedTotCap; // Air volume flow rate divided by rated total cooling capacity [m3/s-W]
   17692             :     Real64 TotCap;                // gross total cooling capacity at off-rated conditions [W]
   17693             :     Real64 TotCapAdj;             // adjusted total cooling capacity at off-rated conditions [W]
   17694             :     // on the type of curve
   17695             :     Real64 InletAirDryBulbTemp;  // inlet air dry bulb temperature [C]
   17696             :     Real64 InletAirWetBulbC;     // wetbulb temperature of inlet air [C]
   17697             :     Real64 InletAirEnthalpy;     // inlet air enthalpy [J/kg]
   17698             :     Real64 InletAirHumRat;       // inlet air humidity ratio [kg/kg]
   17699             :     Real64 FullLoadOutAirEnth;   // outlet full load enthalpy [J/kg]
   17700             :     Real64 FullLoadOutAirHumRat; // outlet humidity ratio at full load
   17701             :     Real64 FullLoadOutAirTemp;   // outlet air temperature at full load [C]
   17702             :     Real64 FullLoadOutAirRH;     // outlet air relative humidity at full load
   17703      656387 :     Real64 EIRTempModFac(0.0);   // EIR modifier (function of entering drybulb, outside drybulb) depending on the
   17704             :     //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   17705             :     // type of curve
   17706             :     // Real64 DefrostEIRTempModFac; // EIR modifier for defrost (function of entering wetbulb, outside drybulb)
   17707             :     Real64 EIRFlowModFac;             // EIR modifier (function of actual supply air flow vs rated flow)
   17708             :     Real64 EIR;                       // EIR at part load and off rated conditions
   17709             :     Real64 PLF;                       // Part load factor, accounts for thermal lag at compressor startup
   17710             :     Real64 PLRHeating;                // PartLoadRatio in heating
   17711             :     Real64 OutdoorCoilT;              // Outdoor coil temperature (C)
   17712             :     Real64 OutdoorCoildw;             // Outdoor coil delta w assuming coil temp of OutdoorCoilT (kg/kg)
   17713             :     Real64 FractionalDefrostTime;     // Fraction of time step system is in defrost
   17714             :     Real64 HeatingCapacityMultiplier; // Multiplier for heating capacity when system is in defrost
   17715             :     Real64 InputPowerMultiplier;      // Multiplier for power when system is in defrost
   17716             :     Real64 LoadDueToDefrost;          // Additional load due to defrost
   17717             :     Real64 CrankcaseHeatingPower;     // power due to crankcase heater
   17718             :     Real64 OutdoorDryBulb;            // Outdoor dry-bulb temperature at condenser (C)
   17719             :     Real64 OutdoorWetBulb;            // Outdoor wet-bulb temperature at condenser (C)
   17720             :     Real64 OutdoorHumRat;             // Outdoor humidity ratio at condenser (kg/kg)
   17721             :     Real64 OutdoorPressure;           // Outdoor barometric pressure at condenser (Pa)
   17722      656387 :     constexpr int Mode(1);            // Performance mode for MultiMode DX coil. Always 1 for other coil types
   17723             :     Real64 AirFlowRatio;              // Ratio of compressor on airflow to average timestep airflow
   17724             :     Real64 OutletAirTemp;             // Supply air temperature (average value if constant fan, full output if cycling fan)
   17725             :     Real64 OutletAirHumRat;           // Supply air humidity ratio (average value if constant fan, full output if cycling fan)
   17726             :     Real64 OutletAirEnthalpy;         // Supply air enthalpy (average value if constant fan, full output if cycling fan)
   17727             : 
   17728             :     // Followings for VRF FluidTCtrl Only
   17729             :     Real64 QCoilReq;       // Coil load (W)
   17730             :     Real64 FanSpdRatio;    // Fan Speed Ratio
   17731             :     Real64 AirMassFlowMin; // Min air mass flow rate due to OA requirement [kg/s]
   17732             :     Real64 ActualSH;       // Actual Super Heating
   17733             :     Real64 ActualSC;       // Actual Sub Cooling
   17734             : 
   17735      656387 :     if (present(OnOffAirFlowRatio)) {
   17736           0 :         AirFlowRatio = OnOffAirFlowRatio;
   17737             :     } else {
   17738      656387 :         AirFlowRatio = 1.0;
   17739             :     }
   17740             : 
   17741             :     // Air cooled condenser
   17742      656387 :     OutdoorDryBulb = state.dataEnvrn->OutDryBulbTemp;
   17743      656387 :     OutdoorWetBulb = state.dataEnvrn->OutWetBulbTemp;
   17744      656387 :     OutdoorHumRat = state.dataEnvrn->OutHumRat;
   17745      656387 :     OutdoorPressure = state.dataEnvrn->OutBaroPress;
   17746             : 
   17747      656387 :     AirMassFlow = state.dataDXCoils->DXCoil(DXCoilNum).InletAirMassFlowRate;
   17748      656387 :     InletAirDryBulbTemp = state.dataDXCoils->DXCoil(DXCoilNum).InletAirTemp;
   17749      656387 :     InletAirEnthalpy = state.dataDXCoils->DXCoil(DXCoilNum).InletAirEnthalpy;
   17750      656387 :     InletAirHumRat = state.dataDXCoils->DXCoil(DXCoilNum).InletAirHumRat;
   17751      656387 :     InletAirWetBulbC = PsyTwbFnTdbWPb(state, InletAirDryBulbTemp, InletAirHumRat, OutdoorPressure);
   17752      656387 :     PLRHeating = 0.0;
   17753      656387 :     state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction = 0.0;
   17754      656387 :     state.dataDXCoils->DXCoil(DXCoilNum).CondensingTemp =
   17755      656387 :         state.dataHVACVarRefFlow->VRF(state.dataDXCoils->DXCoil(DXCoilNum).VRFOUPtr).IUCondensingTemp;
   17756             : 
   17757             :     // Initialize crankcase heater, operates below OAT defined in input deck for HP DX heating coil
   17758      656387 :     if (OutdoorDryBulb < state.dataDXCoils->DXCoil(DXCoilNum).MaxOATCrankcaseHeater) {
   17759       53963 :         CrankcaseHeatingPower = state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterCapacity;
   17760             :     } else {
   17761      602424 :         CrankcaseHeatingPower = 0.0;
   17762             :     }
   17763             : 
   17764     1508698 :     if ((AirMassFlow > 0.0) && (CompressorOp == CompressorOperation::On) &&
   17765     1177824 :         (GetCurrentScheduleValue(state, state.dataDXCoils->DXCoil(DXCoilNum).SchedPtr) > 0.0) && (PartLoadRatio > 0.0) &&
   17766      129463 :         (OutdoorDryBulb > state.dataDXCoils->DXCoil(DXCoilNum).MinOATCompressor)) {
   17767             : 
   17768      129463 :         TotCap = state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode);
   17769      129463 :         QCoilReq = PartLoadRatio * TotCap;
   17770      129463 :         if (PartLoadRatio == 0.0) {
   17771           0 :             AirMassFlowMin = state.dataHVACVarRefFlow->OACompOffMassFlow;
   17772             :         } else {
   17773      129463 :             AirMassFlowMin = state.dataHVACVarRefFlow->OACompOnMassFlow;
   17774             :         }
   17775             : 
   17776             :         // Call ControlVRFIUCoil to calculate: (1) FanSpdRatio, (2) coil inlet/outlet conditions, and (3) SH/SC
   17777      388389 :         ControlVRFIUCoil(state,
   17778             :                          DXCoilNum,
   17779             :                          QCoilReq,
   17780      129463 :                          state.dataDXCoils->DXCoil(DXCoilNum).InletAirTemp,
   17781      129463 :                          state.dataDXCoils->DXCoil(DXCoilNum).InletAirHumRat,
   17782      129463 :                          state.dataDXCoils->DXCoil(DXCoilNum).CondensingTemp,
   17783             :                          AirMassFlowMin,
   17784             :                          FanSpdRatio,
   17785             :                          OutletAirHumRat,
   17786             :                          OutletAirTemp,
   17787             :                          OutletAirEnthalpy,
   17788             :                          ActualSH,
   17789             :                          ActualSC);
   17790      129463 :         AirMassFlow = FanSpdRatio * state.dataDXCoils->DXCoil(DXCoilNum).RatedAirMassFlowRate(Mode);
   17791             : 
   17792      129463 :         AirVolumeFlowRate = AirMassFlow / PsyRhoAirFnPbTdbW(state, OutdoorPressure, InletAirDryBulbTemp, InletAirHumRat);
   17793             :         // Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   17794      129463 :         VolFlowperRatedTotCap = AirVolumeFlowRate / state.dataDXCoils->DXCoil(DXCoilNum).RatedTotCap(Mode);
   17795             :         // VolFlowperRatedTotCap was checked at the initialization step
   17796             :         // No need to check VolFlowperRatedTotCap at the simulation
   17797             :         // New VRF_FluidTCtrl model implements VAV fan which can vary air flow rate during simulation
   17798             : 
   17799      129463 :         AirMassFlowRatio = AirMassFlow / state.dataDXCoils->DXCoil(DXCoilNum).RatedAirMassFlowRate(Mode);
   17800             : 
   17801             :         // Calculating adjustment factors for defrost
   17802             :         // Calculate delta w through outdoor coil by assuming a coil temp of 0.82*DBT-9.7(F) per DOE2.1E
   17803      129463 :         OutdoorCoilT = 0.82 * OutdoorDryBulb - 8.589;
   17804      129463 :         OutdoorCoildw = max(1.0e-6, (OutdoorHumRat - PsyWFnTdpPb(state, OutdoorCoilT, OutdoorPressure)));
   17805             : 
   17806             :         // Initializing defrost adjustment factors
   17807      129463 :         LoadDueToDefrost = 0.0;
   17808      129463 :         HeatingCapacityMultiplier = 1.0;
   17809      129463 :         FractionalDefrostTime = 0.0;
   17810      129463 :         InputPowerMultiplier = 1.0;
   17811             : 
   17812             :         // Modify total heating capacity based on defrost heating capacity multiplier
   17813             :         // MaxHeatCap passed from parent object VRF Condenser and is used to limit capacity of TU's to that available from condenser
   17814      129463 :         if (present(MaxHeatCap)) {
   17815      129448 :             TotCapAdj = min(MaxHeatCap, TotCap * HeatingCapacityMultiplier);
   17816      129448 :             TotCap = min(MaxHeatCap, TotCap);
   17817             :         } else {
   17818          15 :             TotCapAdj = TotCap * HeatingCapacityMultiplier;
   17819             :         }
   17820             : 
   17821             :         // Calculate full load outlet conditions
   17822      129463 :         FullLoadOutAirEnth = InletAirEnthalpy + TotCapAdj / AirMassFlow;
   17823      129463 :         FullLoadOutAirHumRat = InletAirHumRat;
   17824      129463 :         FullLoadOutAirTemp = PsyTdbFnHW(FullLoadOutAirEnth, FullLoadOutAirHumRat);
   17825      129463 :         FullLoadOutAirRH = PsyRhFnTdbWPb(state, FullLoadOutAirTemp, FullLoadOutAirHumRat, OutdoorPressure, RoutineNameFullLoad);
   17826             :         //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   17827             :         //  FullLoadOutAirRH = PsyRhFnTdbWPb(FullLoadOutAirTemp,FullLoadOutAirHumRat,InletAirPressure)
   17828      129463 :         if (FullLoadOutAirRH > 1.0) { // Limit to saturated conditions at FullLoadOutAirEnth
   17829           0 :             FullLoadOutAirTemp = PsyTsatFnHPb(state, FullLoadOutAirEnth, OutdoorPressure);
   17830             :             //  Eventually inlet air conditions will be used in DX Coil, these lines are commented out and marked with this comment line
   17831             :             //    FullLoadOutAirTemp = PsyTsatFnHPb(FullLoadOutAirEnth,InletAirPressure)
   17832           0 :             FullLoadOutAirHumRat = PsyWFnTdbH(state, FullLoadOutAirTemp, FullLoadOutAirEnth);
   17833             :         }
   17834             : 
   17835             :         // Calculate electricity consumed. First, get EIR modifying factors for off-rated conditions
   17836             :         // Model was extended to accept bi-quadratic curves. This allows sensitivity of the EIR
   17837             :         // to the entering dry-bulb temperature as well as the outside dry-bulb temperature. User is
   17838             :         // advised to use the bi-quaratic curve if sufficient manufacturer data is available.
   17839      258926 :         if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num != CoilVRF_Heating &&
   17840      129463 :             state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num != CoilVRF_FluidTCtrl_Heating) {
   17841           0 :             if (state.dataCurveManager->PerfCurve(state.dataDXCoils->DXCoil(DXCoilNum).EIRFTemp(Mode)).numDims == 1) {
   17842           0 :                 EIRTempModFac = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).EIRFTemp(Mode), OutdoorDryBulb);
   17843             :             } else {
   17844           0 :                 EIRTempModFac = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).EIRFTemp(Mode), InletAirDryBulbTemp, OutdoorDryBulb);
   17845             :             }
   17846           0 :             EIRFlowModFac = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).EIRFFlow(Mode), AirMassFlowRatio);
   17847             :         } else {
   17848      129463 :             EIRTempModFac = 1.0;
   17849      129463 :             EIRFlowModFac = 1.0;
   17850             :         }
   17851      129463 :         EIR = state.dataDXCoils->DXCoil(DXCoilNum).RatedEIR(Mode) * EIRTempModFac * EIRFlowModFac;
   17852             : 
   17853             :         // Calculate PLRHeating: modified PartLoadRatio due to defrost ( reverse-cycle defrost only )
   17854      129463 :         if (TotCap > 0.0) {
   17855      129436 :             PLRHeating = min(1.0, (PartLoadRatio + LoadDueToDefrost / TotCap));
   17856             :         } else {
   17857          27 :             PLRHeating = min(1.0, PartLoadRatio);
   17858             :         }
   17859             : 
   17860      258926 :         if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num != CoilVRF_Heating &&
   17861      129463 :             state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num != CoilVRF_FluidTCtrl_Heating) {
   17862           0 :             PLF = CurveValue(state, state.dataDXCoils->DXCoil(DXCoilNum).PLFFPLR(Mode), PLRHeating); // Calculate part-load factor
   17863             :         } else {
   17864      129463 :             PLF = 1.0;
   17865             :         }
   17866             : 
   17867      129463 :         if (PLF < 0.7) {
   17868           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).PLRErrIndex == 0) {
   17869           0 :                 ShowWarningMessage(state,
   17870           0 :                                    format("The PLF curve value for DX heating coil {} ={:.2R} for part-load ratio ={:.2R}",
   17871           0 :                                           state.dataDXCoils->DXCoil(DXCoilNum).Name,
   17872             :                                           PLF,
   17873           0 :                                           PLRHeating));
   17874           0 :                 ShowContinueError(state, "PLF curve values must be >= 0.7. PLF has been reset to 0.7 and simulation is continuing.");
   17875           0 :                 ShowContinueError(state, "Check the IO reference manual for PLF curve guidance [Coil:Heating:DX:SingleSpeed].");
   17876           0 :                 ShowContinueErrorTimeStamp(state, "");
   17877             :             }
   17878           0 :             ShowRecurringWarningErrorAtEnd(
   17879           0 :                 state, "DX heating coil PLF curve < 0.7 warning continues... ", state.dataDXCoils->DXCoil(DXCoilNum).PLRErrIndex, PLF, PLF);
   17880           0 :             PLF = 0.7;
   17881             :         }
   17882             : 
   17883      129463 :         state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction = (PLRHeating / PLF);
   17884      129463 :         if (state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction > 1.0 &&
   17885           0 :             std::abs(state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction - 1.0) > 0.001) {
   17886           0 :             if (state.dataDXCoils->DXCoil(DXCoilNum).ErrIndex4 == 0) {
   17887           0 :                 ShowWarningMessage(state,
   17888           0 :                                    format("The runtime fraction for DX heating coil {} exceeded 1.0. [{:.4R}].",
   17889           0 :                                           state.dataDXCoils->DXCoil(DXCoilNum).Name,
   17890           0 :                                           state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction));
   17891           0 :                 ShowContinueError(state, "Runtime fraction is set to 1.0 and the simulation continues...");
   17892           0 :                 ShowContinueError(state, "Check the IO reference manual for PLF curve guidance [Coil:Heating:DX:SingleSpeed].");
   17893           0 :                 ShowContinueErrorTimeStamp(state, "");
   17894             :             }
   17895           0 :             ShowRecurringWarningErrorAtEnd(state,
   17896           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).Name +
   17897             :                                                ", DX heating coil runtime fraction > 1.0 warning continues...",
   17898           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).ErrIndex4,
   17899           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction,
   17900           0 :                                            state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction);
   17901           0 :             state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction = 1.0; // Reset coil runtime fraction to 1.0
   17902      129463 :         } else if (state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction > 1.0) {
   17903           0 :             state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction = 1.0; // Reset coil runtime fraction to 1.0
   17904             :         }
   17905             : 
   17906             :         // if cycling fan, send coil part-load fraction to on / off fan via HVACDataGlobals
   17907      129463 :         if (FanOpMode == CycFanCycCoil) state.dataHVACGlobal->OnOffFanPartLoadFraction = PLF;
   17908      129463 :         state.dataDXCoils->DXCoil(DXCoilNum).ElecHeatingPower =
   17909      129463 :             TotCap * EIR * state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction * InputPowerMultiplier;
   17910             : 
   17911             :         // Calculate crankcase heater power using the runtime fraction for this DX heating coil only if there is no companion DX coil.
   17912             :         // Else use the largest runtime fraction of this DX heating coil and the companion DX cooling coil.
   17913      129463 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CompanionUpstreamDXCoil == 0) {
   17914      129463 :             state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterPower =
   17915      129463 :                 CrankcaseHeatingPower * (1.0 - state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction);
   17916             :         } else {
   17917           0 :             state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterPower =
   17918           0 :                 CrankcaseHeatingPower *
   17919           0 :                 (1.0 - max(state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction,
   17920           0 :                            state.dataDXCoils->DXCoil(state.dataDXCoils->DXCoil(DXCoilNum).CompanionUpstreamDXCoil).CoolingCoilRuntimeFraction));
   17921             :         }
   17922             : 
   17923      129463 :         state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp = OutletAirTemp;
   17924      129463 :         state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat = OutletAirHumRat;
   17925      129463 :         state.dataDXCoils->DXCoil(DXCoilNum).OutletAirEnthalpy = OutletAirEnthalpy;
   17926      129463 :         state.dataDXCoils->DXCoil(DXCoilNum).CompressorPartLoadRatio = PartLoadRatio;
   17927      129463 :         state.dataDXCoils->DXCoil(DXCoilNum).ActualSH = ActualSH;
   17928      129463 :         state.dataDXCoils->DXCoil(DXCoilNum).ActualSC = ActualSC;
   17929      129463 :         state.dataDXCoils->DXCoil(DXCoilNum).TotalHeatingEnergyRate = AirMassFlow * (OutletAirEnthalpy - InletAirEnthalpy);
   17930      129463 :         state.dataDXCoils->DXCoil(DXCoilNum).DefrostPower =
   17931      129463 :             state.dataDXCoils->DXCoil(DXCoilNum).DefrostPower * state.dataDXCoils->DXCoil(DXCoilNum).HeatingCoilRuntimeFraction;
   17932             : 
   17933             :     } else {
   17934             :         // DX coil is off; just pass through conditions
   17935             : 
   17936      526924 :         state.dataDXCoils->DXCoil(DXCoilNum).OutletAirEnthalpy = state.dataDXCoils->DXCoil(DXCoilNum).InletAirEnthalpy;
   17937      526924 :         state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat = state.dataDXCoils->DXCoil(DXCoilNum).InletAirHumRat;
   17938      526924 :         state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp = state.dataDXCoils->DXCoil(DXCoilNum).InletAirTemp;
   17939             : 
   17940      526924 :         state.dataDXCoils->DXCoil(DXCoilNum).ElecHeatingPower = 0.0;
   17941      526924 :         state.dataDXCoils->DXCoil(DXCoilNum).TotalHeatingEnergyRate = 0.0;
   17942      526924 :         state.dataDXCoils->DXCoil(DXCoilNum).DefrostPower = 0.0;
   17943             : 
   17944             :         // Calculate crankcase heater power using the runtime fraction for this DX heating coil (here DXHeatingCoilRTF=0) if
   17945             :         // there is no companion DX coil, or the runtime fraction of the companion DX cooling coil (here DXCoolingCoilRTF>=0).
   17946      526924 :         if (state.dataDXCoils->DXCoil(DXCoilNum).CompanionUpstreamDXCoil == 0) {
   17947      526924 :             state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterPower = CrankcaseHeatingPower;
   17948             :         } else {
   17949           0 :             state.dataDXCoils->DXCoil(DXCoilNum).CrankcaseHeaterPower =
   17950           0 :                 CrankcaseHeatingPower *
   17951           0 :                 (1.0 - state.dataDXCoils->DXCoil(state.dataDXCoils->DXCoil(DXCoilNum).CompanionUpstreamDXCoil).CoolingCoilRuntimeFraction);
   17952             :         }
   17953      526924 :         state.dataDXCoils->DXCoil(DXCoilNum).CompressorPartLoadRatio = 0.0;
   17954             : 
   17955      526924 :         state.dataDXCoils->DXCoil(DXCoilNum).ActualSH = 999.0;
   17956      526924 :         state.dataDXCoils->DXCoil(DXCoilNum).ActualSC = 999.0;
   17957             :     } // end of on/off if - else
   17958             : 
   17959      656387 :     state.dataDXCoils->DXCoilOutletTemp(DXCoilNum) = state.dataDXCoils->DXCoil(DXCoilNum).OutletAirTemp;
   17960      656387 :     state.dataDXCoils->DXCoilOutletHumRat(DXCoilNum) = state.dataDXCoils->DXCoil(DXCoilNum).OutletAirHumRat;
   17961      656387 :     state.dataDXCoils->DXCoilFanOpMode(DXCoilNum) = FanOpMode;
   17962      656387 :     state.dataDXCoils->DXCoilPartLoadRatio(DXCoilNum) = PLRHeating;
   17963      656387 :     state.dataDXCoils->DXCoilTotalHeating(DXCoilNum) = state.dataDXCoils->DXCoil(DXCoilNum).TotalHeatingEnergyRate;
   17964      656387 :     state.dataDXCoils->DXCoilHeatInletAirDBTemp(DXCoilNum) = InletAirDryBulbTemp;
   17965      656387 :     state.dataDXCoils->DXCoilHeatInletAirWBTemp(DXCoilNum) = InletAirWetBulbC;
   17966             : 
   17967             :     // calc secondary coil if specified
   17968      656387 :     if (state.dataDXCoils->DXCoil(DXCoilNum).IsSecondaryDXCoilInZone) {
   17969           0 :         CalcSecondaryDXCoils(state, DXCoilNum);
   17970             :     }
   17971      656387 : }
   17972             : 
   17973     1764193 : void ControlVRFIUCoil(EnergyPlusData &state,
   17974             :                       int const CoilIndex,     // index to VRFTU coil
   17975             :                       Real64 const QCoil,      // coil load
   17976             :                       Real64 const Tin,        // inlet air temperature
   17977             :                       Real64 const Win,        // inlet air humidity ratio
   17978             :                       Real64 const TeTc,       // evaporating or condensing temperature
   17979             :                       Real64 const OAMassFlow, // mass flow rate of outdoor air
   17980             :                       Real64 &FanSpdRatio,     // fan speed ratio: actual flow rate / rated flow rate
   17981             :                       Real64 &Wout,            // outlet air humidity ratio
   17982             :                       Real64 &Tout,            // outlet air temperature
   17983             :                       Real64 &Hout,            // outlet air enthalpy
   17984             :                       Real64 &SHact,           // actual SH
   17985             :                       Real64 &SCact            // actual SC
   17986             : )
   17987             : {
   17988             :     // SUBROUTINE INFORMATION:
   17989             :     //       AUTHOR         Xiufeng Pang, LBNL
   17990             :     //       DATE WRITTEN   Feb 2013
   17991             :     //       MODIFIED       Nov 2015, RP Zhang, LBNL
   17992             :     //
   17993             :     // PURPOSE OF THIS SUBROUTINE:
   17994             :     //       Analyze the VRF Indoor Unit operations given coil loads.
   17995             :     //       Calculated parameters include: (1) Fan Speed Ratio (2) SH/SC, (3) Coil Outlet conditions
   17996             :     //
   17997             :     // METHODOLOGY EMPLOYED:
   17998             :     //       A new physics based VRF model applicable for Fluid Temperature Control.
   17999             :     //
   18000             :     // USE STATEMENTS:
   18001             :     using Psychrometrics::PsyHFnTdbW;
   18002             : 
   18003             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   18004     1764193 :     int MaxIter(500);              // Max iteration numbers (-)
   18005             :     int SolFla;                    // Solving flag for SolveRoot (-)
   18006     1764193 :     int constexpr FlagCoolMode(0); // Flag for cooling mode
   18007     1764193 :     int constexpr FlagHeatMode(1); // Flag for heating mode
   18008             :     Real64 BF;                     // Bypass factor (-)
   18009             :     Real64 C1Tevap;                // Coefficient for indoor unit coil evaporating temperature curve (-)
   18010             :     Real64 C2Tevap;                // Coefficient for indoor unit coil evaporating temperature curve (-)
   18011             :     Real64 C3Tevap;                // Coefficient for indoor unit coil evaporating temperature curve (-)
   18012             :     Real64 C1Tcond;                // Coefficient for indoor unit coil condensing temperature curve (-)
   18013             :     Real64 C2Tcond;                // Coefficient for indoor unit coil condensing temperature curve (-)
   18014             :     Real64 C3Tcond;                // Coefficient for indoor unit coil condensing temperature curve (-)
   18015             :     Real64 CoilOnOffRatio;         // coil on/off ratio: time coil is on divided by total time
   18016             :     Real64 deltaT;                 // Difference between evaporating/condensing temperature and coil surface temperature (C)
   18017             :     Real64 FanSpdRatioMin;         // Min fan speed ratio, below which the cycling will be activated (-)
   18018             :     Real64 FanSpdRatioMax;         // Max fan speed ratio (-)
   18019             :     Real64 Garate;                 // Nominal air mass flow rate (m3/s)
   18020             :     Real64 MaxSH;                  // Max super heating degrees (C)
   18021             :     Real64 MaxSC;                  // Max subcooling degrees (C)
   18022             :     Real64 QinSenMin1;             // Coil capacity at minimum fan speed, corresponding to real SH (W)
   18023             :     Real64 QinSenMin2;             // Coil capacity at minimum fan speed, corresponding to corresponds maximum SH (W)
   18024             :     Real64 QinSenPerFlowRate;      // Coil capacity per air mass flow rate(W-s/kg)
   18025             :     Real64 QCoilSenCoolingLoad;    // Coil sensible cooling load (W)
   18026             :     Real64 QCoilSenHeatingLoad;    // Coil sensible heating load (W)
   18027             :     Real64 Ratio1;                 // Fan speed ratio (-)
   18028             :     Real64 RHsat;                  // Relative humidity of the air at saturated condition(-)
   18029             :     Real64 SH;                     // Super heating degrees (C)
   18030             :     Real64 SC;                     // Subcooling degrees (C)
   18031             :     Real64 Ts_1;                   // Air temperature at the coil surface, corresponding to SH (C)
   18032             :     Real64 Ts_2;                   // Air temperature at the coil surface, corresponding to MaxSH (C)
   18033             :     Real64 To_1;                   // Air temperature at the coil outlet, corresponding to SH (C)
   18034             :     Real64 To_2;                   // Air temperature at the coil outlet, corresponding to MaxSH (C)
   18035             :     Real64 Ts;                     // Air temperature at the coil surface (C)
   18036             :     Real64 Ws;                     // Air humidity ratio at the coil surface (kg/kg)
   18037             : 
   18038     1764193 :     RHsat = 0.98; // Saturated RH
   18039     1764193 :     MaxSH = 15;
   18040     1764193 :     MaxSC = 20;
   18041     1764193 :     Garate = state.dataDXCoils->DXCoil(CoilIndex).RatedAirMassFlowRate(1);
   18042             :     // why always limit the minimum fan speed ratio to 0.65?
   18043     1764193 :     FanSpdRatioMin = min(max(OAMassFlow / Garate, 0.65), 1.0); // ensure that coil flow rate is higher than OA flow rate
   18044             : 
   18045     1764193 :     if (QCoil == 0) {
   18046             :         // No Heating or Cooling
   18047           0 :         FanSpdRatio = OAMassFlow / Garate;
   18048           0 :         CoilOnOffRatio = 0.0;
   18049             : 
   18050           0 :         SHact = 999.0;
   18051           0 :         SCact = 999.0;
   18052           0 :         Tout = Tin;
   18053           0 :         Hout = PsyHFnTdbW(Tin, Win);
   18054           0 :         Wout = Win;
   18055             : 
   18056     1764193 :     } else if (QCoil < 0) {
   18057             :         // Cooling Mode
   18058             : 
   18059             :         // Obtain coil cooling loads
   18060     1229480 :         QCoilSenCoolingLoad = -QCoil;
   18061             : 
   18062             :         // Coefficients describing coil performance
   18063     1229480 :         SH = state.dataDXCoils->DXCoil(CoilIndex).SH;
   18064     1229480 :         C1Tevap = state.dataDXCoils->DXCoil(CoilIndex).C1Te;
   18065     1229480 :         C2Tevap = state.dataDXCoils->DXCoil(CoilIndex).C2Te;
   18066     1229480 :         C3Tevap = state.dataDXCoils->DXCoil(CoilIndex).C3Te;
   18067     1229480 :         BF = state.dataDXCoils->DXCoil(CoilIndex).RateBFVRFIUEvap;
   18068             : 
   18069             :         // Coil sensible heat transfer_minimum value
   18070     1229480 :         CalcVRFCoilSenCap(state, FlagCoolMode, CoilIndex, Tin, TeTc, SH, BF, QinSenPerFlowRate, Ts_1);
   18071     1229480 :         To_1 = Tin - QinSenPerFlowRate / 1005;
   18072     1229480 :         QinSenMin1 = FanSpdRatioMin * Garate * QinSenPerFlowRate; // Corresponds real SH
   18073             : 
   18074     1229480 :         CalcVRFCoilSenCap(state, FlagCoolMode, CoilIndex, Tin, TeTc, MaxSH, BF, QinSenPerFlowRate, Ts_2);
   18075     1229480 :         To_2 = Tin - QinSenPerFlowRate / 1005;
   18076     1229480 :         QinSenMin2 = FanSpdRatioMin * Garate * QinSenPerFlowRate; // Corresponds maximum SH
   18077             : 
   18078     1229480 :         if (QCoilSenCoolingLoad > QinSenMin1) {
   18079             :             // Increase fan speed to meet room sensible load; SH is not updated
   18080      721851 :             FanSpdRatioMax = 1.0;
   18081     1913811 :             auto f = [QCoilSenCoolingLoad, Ts_1, Tin, Garate, BF](Real64 FanSpdRto) {
   18082             :                 return FanSpdResidualCool(FanSpdRto, QCoilSenCoolingLoad, Ts_1, Tin, Garate, BF);
   18083     2635662 :             };
   18084      721851 :             General::SolveRoot(state, 1.0e-3, MaxIter, SolFla, Ratio1, f, FanSpdRatioMin, FanSpdRatioMax);
   18085      721851 :             if (SolFla < 0) Ratio1 = FanSpdRatioMax; // over capacity
   18086      721851 :             FanSpdRatio = Ratio1;
   18087      721851 :             CoilOnOffRatio = 1.0;
   18088             : 
   18089      721851 :             Tout = To_1; // Since SH is not updated
   18090      721851 :             Ws = PsyWFnTdbRhPb(state, Ts_1, RHsat, state.dataEnvrn->OutBaroPress, "ControlVRFIUCoil");
   18091      721851 :             if (Ws < Win) {
   18092      717287 :                 Wout = Win - (Win - Ws) * (1 - BF);
   18093             :             } else {
   18094        4564 :                 Wout = Win;
   18095             :             }
   18096      721851 :             Hout = PsyHFnTdbW(Tout, Wout);
   18097      721851 :             SCact = 999.0;
   18098      721851 :             SHact = SH;
   18099             : 
   18100             :         } else {
   18101             :             // Low load modification algorithm
   18102             :             // Need to increase SH to further reduce coil capacity
   18103             :             // May further implement coil cycling control if SC modification is not enough
   18104             : 
   18105      507629 :             FanSpdRatio = FanSpdRatioMin;
   18106             : 
   18107      507629 :             CoilOnOffRatio = 1.0;
   18108             : 
   18109      507629 :             Tout = Tin - QCoilSenCoolingLoad / 1005.0 / FanSpdRatioMin / Garate;
   18110      507629 :             Ts = Tin - (Tin - Tout) / (1 - BF);
   18111      507629 :             deltaT = Ts - TeTc;
   18112             : 
   18113             :             // Update SH
   18114      507629 :             if (C3Tevap <= 0.0) {
   18115      507629 :                 if (C2Tevap > 0.0) {
   18116      507629 :                     SHact = (deltaT - C1Tevap) / C2Tevap;
   18117             :                 } else {
   18118           0 :                     SHact = 998.0;
   18119             :                 }
   18120             :             } else {
   18121           0 :                 SHact = (-C2Tevap + sqrt(pow_2(C2Tevap) - 4 * C3Tevap * (C1Tevap - deltaT))) / 2 / C3Tevap;
   18122             :             }
   18123             : 
   18124      507629 :             Ws = PsyWFnTdbRhPb(state, Ts, RHsat, state.dataEnvrn->OutBaroPress, "ControlVRFIUCoil");
   18125      507629 :             if (Ws < Win) {
   18126      339561 :                 Wout = Win - (Win - Ws) * (1 - BF);
   18127             :             } else {
   18128      168068 :                 Wout = Win;
   18129             :             }
   18130             : 
   18131      507629 :             if (SHact > MaxSH) {
   18132             :                 // Further implement On/Off Control
   18133      141360 :                 SHact = MaxSH;
   18134      141360 :                 CoilOnOffRatio = QCoilSenCoolingLoad / QinSenMin2;
   18135             : 
   18136      141360 :                 Ts = Ts_2;
   18137      141360 :                 Ws = PsyWFnTdbRhPb(state, Ts, RHsat, state.dataEnvrn->OutBaroPress, "ControlVRFIUCoil");
   18138      141360 :                 if (Ws < Win) {
   18139      128876 :                     Wout = Win - (Win - Ws) * (1 - BF);
   18140             :                 } else {
   18141       12484 :                     Wout = Win;
   18142             :                 }
   18143             : 
   18144             :                 // outlet air temperature and humidity ratio is time-weighted
   18145      141360 :                 Tout = CoilOnOffRatio * To_2 + (1 - CoilOnOffRatio) * Tin;
   18146      141360 :                 Wout = CoilOnOffRatio * Wout + (1 - CoilOnOffRatio) * Win;
   18147             :             }
   18148             : 
   18149      507629 :             Hout = PsyHFnTdbW(Tout, Wout);
   18150      507629 :             SCact = 999.0;
   18151             :         }
   18152             : 
   18153      534713 :     } else if (QCoil > 0) {
   18154             :         // Heating Mode
   18155             : 
   18156             :         // Obtain zonal heating loads
   18157      534713 :         QCoilSenHeatingLoad = QCoil;
   18158             : 
   18159             :         // Coefficients describing coil performance
   18160      534713 :         SC = state.dataDXCoils->DXCoil(CoilIndex).SC;
   18161      534713 :         C1Tcond = state.dataDXCoils->DXCoil(CoilIndex).C1Tc;
   18162      534713 :         C2Tcond = state.dataDXCoils->DXCoil(CoilIndex).C2Tc;
   18163      534713 :         C3Tcond = state.dataDXCoils->DXCoil(CoilIndex).C3Tc;
   18164      534713 :         BF = state.dataDXCoils->DXCoil(CoilIndex).RateBFVRFIUCond;
   18165             : 
   18166             :         // Coil sensible heat transfer_minimum value
   18167      534713 :         CalcVRFCoilSenCap(state, FlagHeatMode, CoilIndex, Tin, TeTc, SC, BF, QinSenPerFlowRate, Ts_1);
   18168      534713 :         To_1 = QinSenPerFlowRate / 1005 + Tin;
   18169      534713 :         QinSenMin1 = FanSpdRatioMin * Garate * QinSenPerFlowRate; // Corresponds real SH
   18170             : 
   18171      534713 :         CalcVRFCoilSenCap(state, FlagHeatMode, CoilIndex, Tin, TeTc, MaxSC, BF, QinSenPerFlowRate, Ts_2);
   18172      534713 :         To_2 = QinSenPerFlowRate / 1005 + Tin;
   18173      534713 :         QinSenMin2 = FanSpdRatioMin * Garate * QinSenPerFlowRate; // Corresponds maximum SH
   18174             : 
   18175      534713 :         if (QCoilSenHeatingLoad > QinSenMin1) {
   18176             :             // Modulate fan speed to meet room sensible load; SC is not updated
   18177      118905 :             FanSpdRatioMax = 1.0;
   18178      317995 :             auto f = [QCoilSenHeatingLoad, Ts_1, Tin, Garate, BF](Real64 FanSpdRto) {
   18179             :                 return FanSpdResidualHeat(FanSpdRto, QCoilSenHeatingLoad, Ts_1, Tin, Garate, BF);
   18180      436900 :             };
   18181      118905 :             General::SolveRoot(state, 1.0e-3, MaxIter, SolFla, Ratio1, f, FanSpdRatioMin, FanSpdRatioMax);
   18182             :             // this will likely cause problems eventually, -1 and -2 mean different things
   18183      118905 :             if (SolFla < 0) Ratio1 = FanSpdRatioMax; // over capacity
   18184      118905 :             FanSpdRatio = Ratio1;
   18185      118905 :             CoilOnOffRatio = 1.0;
   18186             : 
   18187      118905 :             Tout = Tin + (Ts_1 - Tin) * (1 - BF);
   18188      118905 :             Wout = Win;
   18189      118905 :             Hout = PsyHFnTdbW(Tout, Wout);
   18190      118905 :             SHact = 999.0;
   18191      118905 :             SCact = SC;
   18192             : 
   18193             :         } else {
   18194             :             // Low load modification algorithm
   18195             :             // Need to increase SC to further reduce coil heating capacity
   18196             :             // May further implement coil cycling control if SC modification is not enough
   18197             : 
   18198      415808 :             FanSpdRatio = FanSpdRatioMin;
   18199      415808 :             CoilOnOffRatio = 1.0;
   18200             : 
   18201      415808 :             Tout = Tin + QCoilSenHeatingLoad / 1005.0 / FanSpdRatio / Garate;
   18202      415808 :             Ts = Tin + (Tout - Tin) / (1 - BF);
   18203      415808 :             deltaT = TeTc - Ts;
   18204             : 
   18205             :             // Update SC
   18206      415808 :             if (C3Tcond <= 0.0) {
   18207           0 :                 if (C2Tcond > 0.0) {
   18208           0 :                     SCact = (deltaT - C1Tcond) / C2Tcond;
   18209             :                 } else {
   18210           0 :                     SCact = 998.0;
   18211             :                 }
   18212             :             } else {
   18213      415808 :                 SCact = (-C2Tcond + sqrt(pow_2(C2Tcond) - 4 * C3Tcond * (C1Tcond - deltaT))) / 2 / C3Tcond;
   18214             :             }
   18215             : 
   18216      415808 :             if (SCact > MaxSC) {
   18217             :                 // Implement On/Off Control
   18218      268938 :                 SCact = MaxSC;
   18219      268938 :                 CoilOnOffRatio = QCoilSenHeatingLoad / QinSenMin2;
   18220             :                 // outlet air temperature is time-weighted
   18221      268938 :                 Tout = CoilOnOffRatio * To_2 + (1 - CoilOnOffRatio) * Tin;
   18222             :             }
   18223             : 
   18224      415808 :             Wout = Win;
   18225      415808 :             Hout = PsyHFnTdbW(Tout, Wout);
   18226      415808 :             SHact = 999.0;
   18227             :         }
   18228             :     }
   18229     1764193 : }
   18230             : 
   18231     3528416 : void CalcVRFCoilSenCap(EnergyPlusData &state,
   18232             :                        int const OperationMode, // mode 0 for cooling, 1 for heating
   18233             :                        int const CoilNum,       // index to VRFTU cooling or heating coil
   18234             :                        Real64 const Tinlet,     // dry bulb temperature of air entering the coil
   18235             :                        Real64 const TeTc,       // evaporating or condensing temperature
   18236             :                        Real64 const SHSC,       // SH at cooling /SC at heating
   18237             :                        Real64 const BF,         // Bypass factor
   18238             :                        Real64 &Q_sen,           // VRF coil sensible capacity per air mass flow rate
   18239             :                        Real64 &T_coil_surf      // Air temperature at coil surface
   18240             : )
   18241             : {
   18242             :     // SUBROUTINE INFORMATION:
   18243             :     //       AUTHOR         Rongpeng Zhang, LBNL
   18244             :     //       DATE WRITTEN   Jul 2015
   18245             :     //
   18246             :     // PURPOSE OF THIS SUBROUTINE:
   18247             :     //        Calculate the VRF coil sensible capacity per air mass flow rate, given:
   18248             :     //        (1) refrigerant temperature (Te or Tc), (2) SH or SC, and (3) inlet air temperature.
   18249             :     //
   18250             :     // METHODOLOGY EMPLOYED:
   18251             :     //        A new physics based VRF model appliable for Fluid Temperature Control.
   18252             :     //
   18253             : 
   18254     3528416 :     int constexpr FlagCoolMode(0); // Flag for cooling mode
   18255     3528416 :     int constexpr FlagHeatMode(1); // Flag for heating mode
   18256             :     Real64 C1Tevap;                // Coefficient for indoor unit coil evaporating temperature curve (-)
   18257             :     Real64 C2Tevap;                // Coefficient for indoor unit coil evaporating temperature curve (-)
   18258             :     Real64 C3Tevap;                // Coefficient for indoor unit coil evaporating temperature curve (-)
   18259             :     Real64 C1Tcond;                // Coefficient for indoor unit coil condensing temperature curve (-)
   18260             :     Real64 C2Tcond;                // Coefficient for indoor unit coil condensing temperature curve (-)
   18261             :     Real64 C3Tcond;                // Coefficient for indoor unit coil condensing temperature curve (-)
   18262             :     Real64 deltaT;                 // Difference between Te/Tc and coil surface temperature (C)
   18263             :     Real64 SH;                     // Super heating at cooling mode(C)
   18264             :     Real64 SC;                     // Subcooling at heating mode (C)
   18265             :     Real64 T_coil_in;              // Air temperature at coil inlet (C)
   18266             :     Real64 T_coil_out;             // Air temperature at coil outlet (C)
   18267             : 
   18268     3528416 :     if (OperationMode == FlagCoolMode) {
   18269             :         // Cooling: OperationMode 0
   18270             : 
   18271     2458990 :         C1Tevap = state.dataDXCoils->DXCoil(CoilNum).C1Te;
   18272     2458990 :         C2Tevap = state.dataDXCoils->DXCoil(CoilNum).C2Te;
   18273     2458990 :         C3Tevap = state.dataDXCoils->DXCoil(CoilNum).C3Te;
   18274     2458990 :         SH = SHSC;
   18275     2458990 :         T_coil_in = Tinlet;
   18276             : 
   18277             :         // Coil surface temperature
   18278     2458990 :         deltaT = C3Tevap * SH * SH + C2Tevap * SH + C1Tevap;
   18279     2458990 :         T_coil_surf = TeTc + deltaT;
   18280             : 
   18281             :         // Outlet air temperature
   18282     2458990 :         T_coil_out = T_coil_in - (T_coil_in - T_coil_surf) * (1 - BF);
   18283             : 
   18284             :         // Coil sensilbe heat transfer per mass flow rate
   18285     2458990 :         Q_sen = max(1005 * (T_coil_in - T_coil_out), 0.0);
   18286             : 
   18287     1069426 :     } else if (OperationMode == FlagHeatMode) {
   18288             :         // Heating: OperationMode 1
   18289             : 
   18290     1069426 :         C1Tcond = state.dataDXCoils->DXCoil(CoilNum).C1Tc;
   18291     1069426 :         C2Tcond = state.dataDXCoils->DXCoil(CoilNum).C2Tc;
   18292     1069426 :         C3Tcond = state.dataDXCoils->DXCoil(CoilNum).C3Tc;
   18293     1069426 :         SC = SHSC;
   18294     1069426 :         T_coil_in = Tinlet;
   18295             : 
   18296             :         // Coil surface temperature
   18297     1069426 :         deltaT = C3Tcond * SC * SC + C2Tcond * SC + C1Tcond;
   18298     1069426 :         T_coil_surf = TeTc - deltaT;
   18299             : 
   18300             :         // Coil outlet air temperature
   18301     1069426 :         T_coil_out = T_coil_in + (T_coil_surf - T_coil_in) * (1 - BF);
   18302             : 
   18303             :         // Coil sensilbe heat transfer_minimum value
   18304     1069426 :         Q_sen = max(1005 * (T_coil_out - T_coil_in), 0.0);
   18305             :     }
   18306     3528416 : }
   18307             : 
   18308          15 : void CalcVRFCoilCapModFac(EnergyPlusData &state,
   18309             :                           int const OperationMode,        // mode 0 for cooling, 1 for heating
   18310             :                           Optional<int const> CoilIndex,  // index to VRFTU cooling or heating coil
   18311             :                           Optional<std::string> CoilName, // name of VRFTU cooling or heating coil
   18312             :                           Real64 const Tinlet,            // dry bulb temperature of air entering the coil
   18313             :                           Optional<Real64 const> TeTc,    // evaporating or condensing temperature
   18314             :                           Optional<Real64 const> SHSC,    // SH at cooling /SC at heating
   18315             :                           Optional<Real64 const> BF,      // Bypass factor
   18316             :                           Real64 &CapModFac               // Coil capacity modification factor
   18317             : )
   18318             : {
   18319             :     // SUBROUTINE INFORMATION:
   18320             :     //       AUTHOR         Rongpeng Zhang, LBNL
   18321             :     //       DATE WRITTEN   Jul 2015
   18322             :     //
   18323             :     // PURPOSE OF THIS SUBROUTINE:
   18324             :     //        Calculate the VRF coil capacity modification factor, which is the ratio of
   18325             :     //        the capacity at real conditions and that at rated conditions.
   18326             :     //        This is used for the coil sizing subroutine.
   18327             :     //
   18328             :     // METHODOLOGY EMPLOYED:
   18329             :     //        A new physics based VRF model applicable for Fluid Temperature Control.
   18330             :     //
   18331             : 
   18332          15 :     bool ErrorsFound(false);       // Flag for errors
   18333          15 :     int constexpr FlagCoolMode(0); // Flag for cooling mode
   18334          15 :     int constexpr FlagHeatMode(1); // Flag for heating mode
   18335          15 :     Real64 constexpr SH_rate(3);   // Super heating at cooling mode, default 3(C)
   18336          15 :     Real64 constexpr SC_rate(5);   // Subcooling at heating mode, default 5 (C)
   18337          15 :     Real64 constexpr Te_rate(6);   // Evaporating temperature at cooling mode, default 6 (C)
   18338          15 :     Real64 constexpr Tc_rate(44);  // Condensing temperature at heating mode, default 44 (C)
   18339             :     int CoilNum;                   // index to VRFTU cooling or heating coil
   18340             :     Real64 BF_real;                // Bypass factor (-)
   18341             :     Real64 BFC_rate;               // Bypass factor at cooling mode (-)
   18342             :     Real64 BFH_rate;               // Bypass factor at heating mode (-)
   18343             :     Real64 SHSC_real;              // Super heating or Subcooling (C)
   18344             :     Real64 TeTc_real;              // Evaporating temperature or condensing temperature (C)
   18345             :     Real64 Ts;                     // Air temperature at coil surface (C)
   18346             :     Real64 Q_real;                 // Coil capacity at given condition (W)
   18347             :     Real64 Q_rate;                 // Coil capacity at rated condition (W)
   18348             : 
   18349          15 :     if (present(CoilIndex)) {
   18350           0 :         CoilNum = CoilIndex;
   18351             :     } else {
   18352          15 :         GetDXCoilIndex(state, CoilName, CoilNum, ErrorsFound, {}, true);
   18353             :     }
   18354             : 
   18355          15 :     BFC_rate = state.dataDXCoils->DXCoil(CoilNum).RateBFVRFIUEvap;
   18356          15 :     BFH_rate = state.dataDXCoils->DXCoil(CoilNum).RateBFVRFIUCond;
   18357             : 
   18358          15 :     if (OperationMode == FlagCoolMode) {
   18359             :         // Cooling: OperationMode 0
   18360             : 
   18361          15 :         if (present(BF)) {
   18362           0 :             BF_real = BF;
   18363             :         } else {
   18364          15 :             BF_real = BFC_rate;
   18365             :         }
   18366          15 :         if (present(TeTc)) {
   18367           0 :             TeTc_real = TeTc;
   18368             :         } else {
   18369          15 :             TeTc_real = Te_rate;
   18370             :         }
   18371          15 :         if (present(SHSC)) {
   18372           0 :             SHSC_real = SHSC;
   18373             :         } else {
   18374          15 :             SHSC_real = SH_rate;
   18375             :         }
   18376             : 
   18377             :         // Coil capacity at rated conditions
   18378          15 :         CalcVRFCoilSenCap(state, FlagCoolMode, CoilNum, 26, Te_rate, SH_rate, BFC_rate, Q_rate, Ts);
   18379             : 
   18380             :         // Coil capacity at given conditions
   18381          15 :         CalcVRFCoilSenCap(state, FlagCoolMode, CoilNum, Tinlet, TeTc_real, SHSC_real, BF_real, Q_real, Ts);
   18382             : 
   18383          15 :         if (Q_rate > 0) {
   18384          15 :             CapModFac = Q_real / Q_rate;
   18385             :         } else {
   18386           0 :             CapModFac = 1.0;
   18387             :         }
   18388             : 
   18389           0 :     } else if (OperationMode == FlagHeatMode) {
   18390             :         // Heating: OperationMode 1
   18391             : 
   18392           0 :         if (present(BF)) {
   18393           0 :             BF_real = BF;
   18394             :         } else {
   18395           0 :             BF_real = BFH_rate;
   18396             :         }
   18397           0 :         if (present(TeTc)) {
   18398           0 :             TeTc_real = TeTc;
   18399             :         } else {
   18400           0 :             TeTc_real = Tc_rate;
   18401             :         }
   18402           0 :         if (present(SHSC)) {
   18403           0 :             SHSC_real = SHSC;
   18404             :         } else {
   18405           0 :             SHSC_real = SC_rate;
   18406             :         }
   18407             : 
   18408             :         // Coil capacity at rated conditions
   18409           0 :         CalcVRFCoilSenCap(state, FlagHeatMode, CoilNum, 20, Tc_rate, SC_rate, BFH_rate, Q_rate, Ts);
   18410             : 
   18411             :         // Coil capacity at given conditions
   18412           0 :         CalcVRFCoilSenCap(state, FlagHeatMode, CoilNum, Tinlet, TeTc_real, SHSC_real, BF_real, Q_real, Ts);
   18413             : 
   18414           0 :         if (Q_rate > 0) {
   18415           0 :             CapModFac = Q_real / Q_rate;
   18416             :         } else {
   18417           0 :             CapModFac = 1.0;
   18418             :         }
   18419             :     }
   18420          15 : }
   18421             : 
   18422     1913811 : Real64 FanSpdResidualCool(
   18423             :     Real64 const FanSpdRto, Real64 const QCoilSenCoolingLoad, Real64 const Ts_1, Real64 const Tin, Real64 const Garate, Real64 const BF)
   18424             : {
   18425             :     // FUNCTION INFORMATION:
   18426             :     //       AUTHOR         Xiufeng Pang (XP)
   18427             :     //       DATE WRITTEN   Mar 2013
   18428             :     //       MODIFIED       Nov 2015, RP Zhang, LBNL
   18429             :     //
   18430             :     // PURPOSE OF THIS FUNCTION:
   18431             :     //       Calculates residual function (desired zone cooling load - actual coil cooling capacity)
   18432             :     //       This is used to modify the fan speed to adjust the coil cooling capacity to match
   18433             :     //       the zone cooling load.
   18434             :     //
   18435     1913811 :     Real64 ZnSenLoad = QCoilSenCoolingLoad;
   18436             :     // +-100 W minimum zone load?
   18437     1913811 :     if (std::abs(ZnSenLoad) < 100.0) ZnSenLoad = sign(100.0, ZnSenLoad);
   18438     1913811 :     Real64 Tout = Tin - (Tin - Ts_1) * (1 - BF);
   18439     1913811 :     Real64 TotCap = FanSpdRto * Garate * 1005.0 * (Tin - Tout);
   18440     1913811 :     return (TotCap - ZnSenLoad) / ZnSenLoad;
   18441             : }
   18442             : 
   18443      317995 : Real64 FanSpdResidualHeat(Real64 FanSpdRto, Real64 QCoilSenHeatingLoad, Real64 Ts_1, Real64 Tin, Real64 Garate, Real64 BF)
   18444             : {
   18445             : 
   18446             :     // FUNCTION INFORMATION:
   18447             :     //       AUTHOR         Xiufeng Pang (XP)
   18448             :     //       DATE WRITTEN   Mar 2013
   18449             :     //       MODIFIED       Nov 2015, RP Zhang, LBNL
   18450             :     //
   18451             :     // PURPOSE OF THIS FUNCTION:
   18452             :     //       Calculates residual function (desired zone heating load - actual heating coil capacity)
   18453             :     //       This is used to modify the fan speed to adjust the coil heating capacity to match
   18454             :     //       the zone heating load.
   18455             :     //
   18456             : 
   18457      317995 :     Real64 ZnSenLoad = QCoilSenHeatingLoad;
   18458             :     // +-100 W minimum zone load?
   18459      317995 :     if (std::abs(ZnSenLoad) < 100.0) ZnSenLoad = sign(100.0, ZnSenLoad);
   18460      317995 :     Real64 Tout = Tin + (Ts_1 - Tin) * (1 - BF);
   18461      317995 :     Real64 TotCap = FanSpdRto * Garate * 1005.0 * (Tout - Tin);
   18462      317995 :     return (TotCap - ZnSenLoad) / ZnSenLoad;
   18463             : }
   18464             : 
   18465           0 : void SetMSHPDXCoilHeatRecoveryFlag(EnergyPlusData &state, int const DXCoilNum)
   18466             : {
   18467             : 
   18468             :     // SUBROUTINE INFORMATION:
   18469             :     //       AUTHOR         L. Gu
   18470             :     //       DATE WRITTEN   Sep. 2015
   18471             : 
   18472             :     // PURPOSE OF THIS SUBROUTINE:
   18473             :     // Set the heat recovery flag true when the parent object requests heat recovery.
   18474             : 
   18475           0 :     if (state.dataDXCoils->DXCoil(DXCoilNum).FuelTypeNum != DataGlobalConstants::ResourceType::Electricity) {
   18476           0 :         state.dataDXCoils->DXCoil(DXCoilNum).MSHPHeatRecActive = true;
   18477             :     }
   18478           0 : }
   18479             : 
   18480          32 : void SetDXCoilAirLoopNumber(EnergyPlusData &state, std::string const &CoilName, int const AirLoopNum)
   18481             : {
   18482             :     // SUBROUTINE INFORMATION:
   18483             :     //       AUTHOR         L. Gu
   18484             :     //       DATE WRITTEN   March, 2018
   18485             : 
   18486             :     // PURPOSE OF THIS SUBROUTINE:
   18487             :     // Set AirLoopNum for AFN model with multiple AirLoops
   18488             : 
   18489             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   18490             :     int WhichCoil;
   18491             : 
   18492          32 :     if (state.dataDXCoils->GetCoilsInputFlag) {
   18493           0 :         GetDXCoils(state);
   18494           0 :         state.dataDXCoils->GetCoilsInputFlag = false;
   18495             :     }
   18496             : 
   18497          32 :     WhichCoil = UtilityRoutines::FindItemInList(CoilName, state.dataDXCoils->DXCoil);
   18498          32 :     if (WhichCoil != 0) {
   18499          32 :         state.dataDXCoils->DXCoil(WhichCoil).AirLoopNum = AirLoopNum;
   18500             :     } else {
   18501           0 :         ShowSevereError(state, "SetDXCoilAirLoopNumber: Could not find Coil \"Name=\"" + CoilName + "\"");
   18502             :     }
   18503          32 : } // must match coil names for the coil type
   18504             : 
   18505           1 : void DisableLatentDegradation(EnergyPlusData &state, int const DXCoilNum)
   18506             : {
   18507             :     // SUBROUTINE INFORMATION:
   18508             :     //       AUTHOR         L. Gu
   18509             :     //       DATE WRITTEN   JUne, 2019
   18510             : 
   18511             :     // PURPOSE OF THIS SUBROUTINE:
   18512             :     // Disable latent degradation when direct solution is used.
   18513             : 
   18514           1 :     state.dataDXCoils->DXCoil(DXCoilNum).Twet_Rated(1) = 0.0;
   18515           1 : }
   18516             : 
   18517        2313 : } // namespace EnergyPlus::DXCoils

Generated by: LCOV version 1.13