LCOV - code coverage report
Current view: top level - EnergyPlus - VariableSpeedCoils.cc (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 3263 4493 72.6 %
Date: 2024-08-24 18:31:18 Functions: 25 25 100.0 %

          Line data    Source code
       1             : // EnergyPlus, Copyright (c) 1996-2024, 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             : 
      50             : // ObjexxFCL Headers
      51             : #include <ObjexxFCL/Array.functions.hh>
      52             : 
      53             : // EnergyPlus Headers
      54             : #include <EnergyPlus/Autosizing/Base.hh>
      55             : #include <EnergyPlus/BranchNodeConnections.hh>
      56             : #include <EnergyPlus/CurveManager.hh>
      57             : #include <EnergyPlus/DXCoils.hh>
      58             : #include <EnergyPlus/Data/EnergyPlusData.hh>
      59             : #include <EnergyPlus/DataAirSystems.hh>
      60             : #include <EnergyPlus/DataContaminantBalance.hh>
      61             : #include <EnergyPlus/DataEnvironment.hh>
      62             : #include <EnergyPlus/DataHVACGlobals.hh>
      63             : #include <EnergyPlus/DataHeatBalance.hh>
      64             : #include <EnergyPlus/DataSizing.hh>
      65             : #include <EnergyPlus/DataWater.hh>
      66             : #include <EnergyPlus/Fans.hh>
      67             : #include <EnergyPlus/FluidProperties.hh>
      68             : #include <EnergyPlus/General.hh>
      69             : #include <EnergyPlus/GeneralRoutines.hh>
      70             : #include <EnergyPlus/GlobalNames.hh>
      71             : #include <EnergyPlus/InputProcessing/InputProcessor.hh>
      72             : #include <EnergyPlus/NodeInputManager.hh>
      73             : #include <EnergyPlus/OutAirNodeManager.hh>
      74             : #include <EnergyPlus/OutputProcessor.hh>
      75             : #include <EnergyPlus/OutputReportPredefined.hh>
      76             : #include <EnergyPlus/PlantUtilities.hh>
      77             : #include <EnergyPlus/Psychrometrics.hh>
      78             : #include <EnergyPlus/ReportCoilSelection.hh>
      79             : #include <EnergyPlus/ScheduleManager.hh>
      80             : #include <EnergyPlus/UnitarySystem.hh>
      81             : #include <EnergyPlus/VariableSpeedCoils.hh>
      82             : #include <EnergyPlus/WaterManager.hh>
      83             : 
      84             : namespace EnergyPlus {
      85             : 
      86             : namespace VariableSpeedCoils {
      87             : 
      88             :     // Using/Aliasing
      89             :     using namespace DataLoopNode;
      90             :     using namespace Psychrometrics;
      91             :     using namespace DataSizing;
      92             : 
      93             :     using DXCoils::AdjustCBF;
      94             :     using DXCoils::CalcCBF;
      95             : 
      96             :     Real64 constexpr RatedInletAirTemp = 26.6667;       // 26.6667C or 80F
      97             :     Real64 constexpr RatedInletWetBulbTemp = 19.4444;   // 19.44 or 67F, cooling mode
      98             :     Real64 constexpr RatedInletAirHumRat = 0.0111847;   // Humidity ratio corresponding to 80F dry bulb/67F wet bulb
      99             :     Real64 constexpr RatedInletWaterTemp = 29.4444;     // 85 F cooling mode
     100             :     Real64 constexpr RatedAmbAirTemp = 35.0;            // 95 F cooling mode
     101             :     Real64 constexpr RatedInletAirTempHeat = 21.1111;   // 21.11C or 70F, heating mode
     102             :     Real64 constexpr RatedInletWaterTempHeat = 21.1111; // 21.11C or 70F, heating mode
     103             :     Real64 constexpr RatedAmbAirTempHeat = 8.3333;      // 8.33 or 47F, heating mode
     104             :     Real64 constexpr RatedAmbAirWBHeat = 6.1111;        // 8.33 or 43F, heating mode, rated wet bulb temperature
     105             :                                                         // Water Systems
     106             :     int constexpr CondensateDiscarded = 1001;           // default mode where water is "lost"
     107             :     int constexpr CondensateToTank = 1002;              // collect coil condensate from air and store in water storage tank
     108             : 
     109             :     int constexpr WaterSupplyFromMains = 101;
     110             :     int constexpr WaterSupplyFromTank = 102;
     111             : 
     112             :     // Defrost strategy (heat pump only)
     113             :     int constexpr ReverseCycle = 1; // uses reverse cycle defrost strategy
     114             :     int constexpr Resistive = 2;    // uses electric resistance heater for defrost
     115             :                                     // Defrost control  (heat pump only)
     116             :     int constexpr Timed = 1;        // defrost cycle is timed
     117             :     int constexpr OnDemand = 2;     // defrost cycle occurs only when required
     118             : 
     119    45106592 :     void SimVariableSpeedCoils(EnergyPlusData &state,
     120             :                                std::string_view CompName,             // Coil Name
     121             :                                int &CompIndex,                        // Index for Component name
     122             :                                HVAC::FanOp const fanOp,               // Continuous fan OR cycling compressor
     123             :                                HVAC::CompressorOp const compressorOp, // compressor on/off. 0 = off; 1= on
     124             :                                Real64 const PartLoadFrac,
     125             :                                int const SpeedNum,            // compressor speed number
     126             :                                Real64 const SpeedRatio,       // compressor speed ratio
     127             :                                Real64 const SensLoad,         // Sensible demand load [W]
     128             :                                Real64 const LatentLoad,       // Latent demand load [W]
     129             :                                const Real64 OnOffAirFlowRatio // ratio of comp on to comp off air flow rate
     130             :     )
     131             :     {
     132             : 
     133             :         //       AUTHOR         Bo Shen, ORNL
     134             :         //       DATE WRITTEN   March 2012
     135             :         //       MODIFIED       Bo Shen, 12/2014, add variable-speed HPWH
     136             :         //       RE-ENGINEERED  na
     137             : 
     138             :         // PURPOSE OF THIS SUBROUTINE:
     139             :         // This subroutine manages variable-speed Water to Air Heat Pump component simulation.
     140             : 
     141             :         // Using/Aliasing
     142             :         using General::SolveRoot;
     143             : 
     144             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     145             :         int DXCoilNum; // The WatertoAirHP that you are currently loading input into
     146             :         int SpeedCal;  // variable for error proof speed input
     147             : 
     148             :         // Obtains and Allocates WatertoAirHP related parameters from input file
     149    45106592 :         if (state.dataVariableSpeedCoils->GetCoilsInputFlag) { // First time subroutine has been entered
     150           0 :             GetVarSpeedCoilInput(state);
     151           0 :             state.dataVariableSpeedCoils->GetCoilsInputFlag = false;
     152             :         }
     153             : 
     154    45106592 :         if (CompIndex == 0) {
     155           4 :             DXCoilNum = Util::FindItemInList(CompName, state.dataVariableSpeedCoils->VarSpeedCoil);
     156           4 :             if (DXCoilNum == 0) {
     157           0 :                 ShowFatalError(state, format("WaterToAirHPVSWEquationFit not found={}", CompName));
     158             :             }
     159           4 :             CompIndex = DXCoilNum;
     160             :         } else {
     161    45106588 :             DXCoilNum = CompIndex;
     162    45106588 :             if (DXCoilNum > state.dataVariableSpeedCoils->NumVarSpeedCoils || DXCoilNum < 1) {
     163           0 :                 ShowFatalError(state,
     164           0 :                                format("SimVariableSpeedCoils: Invalid CompIndex passed={}, Number of Water to Air HPs={}, WaterToAir HP name={}",
     165             :                                       DXCoilNum,
     166           0 :                                       state.dataVariableSpeedCoils->NumVarSpeedCoils,
     167             :                                       CompName));
     168             :             }
     169    45106588 :             if (!CompName.empty() && CompName != state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name) {
     170           0 :                 ShowFatalError(
     171             :                     state,
     172           0 :                     format("SimVariableSpeedCoils: Invalid CompIndex passed={}, WaterToAir HP name={}, stored WaterToAir HP Name for that index={}",
     173             :                            DXCoilNum,
     174             :                            CompName,
     175           0 :                            state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
     176             :             }
     177             :         }
     178             : 
     179             :         // ERROR PROOF
     180    45106592 :         if (SpeedNum < 1) {
     181     1479400 :             SpeedCal = 1;
     182             :         } else {
     183    43627192 :             SpeedCal = SpeedNum;
     184             :         }
     185             : 
     186    85691391 :         if ((state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_CoolingWaterToAirHPVSEquationFit) ||
     187    40584799 :             (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_CoolingAirToAirVariableSpeed)) {
     188             :             // Cooling mode
     189    37957041 :             InitVarSpeedCoil(state, DXCoilNum, SensLoad, LatentLoad, fanOp, OnOffAirFlowRatio, SpeedRatio, SpeedCal);
     190    37957041 :             CalcVarSpeedCoilCooling(
     191             :                 state, DXCoilNum, fanOp, SensLoad, LatentLoad, compressorOp, PartLoadFrac, OnOffAirFlowRatio, SpeedRatio, SpeedCal);
     192    37957041 :             UpdateVarSpeedCoil(state, DXCoilNum);
     193     9777309 :         } else if ((state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_HeatingWaterToAirHPVSEquationFit) ||
     194     2627758 :                    (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_HeatingAirToAirVariableSpeed)) {
     195             :             // Heating mode
     196     5463079 :             InitVarSpeedCoil(state, DXCoilNum, SensLoad, LatentLoad, fanOp, OnOffAirFlowRatio, SpeedRatio, SpeedCal);
     197     5463079 :             CalcVarSpeedCoilHeating(state, DXCoilNum, fanOp, SensLoad, compressorOp, PartLoadFrac, OnOffAirFlowRatio, SpeedRatio, SpeedCal);
     198     5463079 :             UpdateVarSpeedCoil(state, DXCoilNum);
     199     1686472 :         } else if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::CoilDX_HeatPumpWaterHeaterVariableSpeed) {
     200             :             // Heating mode
     201     1686472 :             InitVarSpeedCoil(state, DXCoilNum, SensLoad, LatentLoad, fanOp, OnOffAirFlowRatio, SpeedRatio, SpeedCal);
     202     1686472 :             CalcVarSpeedHPWH(state, DXCoilNum, PartLoadFrac, SpeedRatio, SpeedNum, fanOp);
     203     1686472 :             UpdateVarSpeedCoil(state, DXCoilNum);
     204             :         } else {
     205           0 :             ShowFatalError(state, "SimVariableSpeedCoils: WatertoAir heatpump not in either HEATING or COOLING mode");
     206             :         }
     207             : 
     208             :         // two additional output variables
     209    45106592 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SpeedNumReport = SpeedCal;
     210    45106592 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SpeedRatioReport = SpeedRatio;
     211    45106592 :     }
     212             : 
     213          22 :     void GetVarSpeedCoilInput(EnergyPlusData &state)
     214             :     {
     215             : 
     216             :         // SUBROUTINE INFORMATION:
     217             :         //       AUTHOR         Bo Shen
     218             :         //       DATE WRITTEN   March, 2012
     219             :         //       MODIFIED       Bo Shen, 12/2014, add variable-speed HPWH
     220             :         //       RE-ENGINEERED  na
     221             : 
     222             :         // PURPOSE OF THIS SUBROUTINE:
     223             :         // Obtains input data for HPs and stores it in HP data structures
     224             : 
     225             :         // METHODOLOGY EMPLOYED:
     226             :         // Uses "Get" routines to read in data.
     227             : 
     228             :         // Using/Aliasing
     229             :         using namespace NodeInputManager;
     230             :         using BranchNodeConnections::TestCompSet;
     231             :         using GlobalNames::VerifyUniqueCoilName;
     232             :         using namespace OutputReportPredefined;
     233             :         using Curve::CurveValue;
     234             :         using Curve::GetCurveIndex;
     235             : 
     236             :         using OutAirNodeManager::CheckOutAirNodeNumber;
     237             :         using ScheduleManager::GetScheduleIndex;
     238             :         using WaterManager::SetupTankDemandComponent;
     239             :         using WaterManager::SetupTankSupplyComponent;
     240             : 
     241             :         // SUBROUTINE PARAMETER DEFINITIONS:
     242             :         static constexpr std::string_view RoutineName("GetVarSpeedCoilInput: "); // include trailing blank space
     243             : 
     244             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     245             :         int DXCoilNum;         // The Water to Air HP that you are currently loading input into
     246             :         int NumCool;           // Counter for cooling coil, water source
     247             :         int NumCoolAS;         // Counter for cooling coil, air source
     248             :         int NumHeat;           // Counter for heating coil, water source
     249             :         int NumHeatAS;         // Counter for heating coil, air source
     250             :         int NumHPWHAirToWater; // counter for air source HPWH
     251             :         int CoilCounter;       // Counter
     252             :         int I;                 // Loop index increment
     253             :         int NumAlphas;         // Number of variables in String format
     254             :         int NumNums;           // Number of variables in Numeric format
     255             :         int NumParams;         // Total number of input fields
     256          22 :         int MaxNums(0);        // Maximum number of numeric input fields
     257          22 :         int MaxAlphas(0);      // Maximum number of alpha input fields
     258             :         int IOStat;
     259             :         int AlfaFieldIncre;              // increment number of Alfa field
     260          22 :         bool ErrorsFound(false);         // If errors detected in input
     261             :         Real64 CurveVal;                 // Used to verify modifier curves equal 1 at rated conditions
     262             :         Real64 WHInletAirTemp;           // Used to pass proper inlet air temp to HPWH DX coil performance curves
     263             :         Real64 WHInletWaterTemp;         // Used to pass proper inlet water temp to HPWH DX coil performance curves
     264          22 :         std::string CurrentModuleObject; // for ease in getting objects
     265          22 :         Array1D_string AlphArray;        // Alpha input items for object
     266          22 :         Array1D_string cAlphaFields;     // Alpha field names
     267          22 :         Array1D_string cNumericFields;   // Numeric field names
     268          22 :         Array1D<Real64> NumArray;        // Numeric input items for object
     269          22 :         Array1D_bool lAlphaBlanks;       // Logical array, alpha field input BLANK = .TRUE.
     270          22 :         Array1D_bool lNumericBlanks;     // Logical array, numeric field input BLANK = .TRUE.
     271             : 
     272          22 :         NumCool = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "COIL:COOLING:WATERTOAIRHEATPUMP:VARIABLESPEEDEQUATIONFIT");
     273          22 :         NumHeat = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "COIL:HEATING:WATERTOAIRHEATPUMP:VARIABLESPEEDEQUATIONFIT");
     274          22 :         NumCoolAS = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "COIL:COOLING:DX:VARIABLESPEED");
     275          22 :         NumHeatAS = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "COIL:HEATING:DX:VARIABLESPEED");
     276             :         NumHPWHAirToWater =
     277          22 :             state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "COIL:WATERHEATING:AIRTOWATERHEATPUMP:VARIABLESPEED");
     278          22 :         state.dataVariableSpeedCoils->NumVarSpeedCoils = NumCool + NumHeat + NumCoolAS + NumHeatAS + NumHPWHAirToWater;
     279          22 :         DXCoilNum = 0;
     280             : 
     281          22 :         if (state.dataVariableSpeedCoils->NumVarSpeedCoils <= 0) {
     282           0 :             ShowSevereError(state, "No Equipment found in GetVarSpeedCoilInput");
     283           0 :             ErrorsFound = true;
     284             :         }
     285             : 
     286             :         // Allocate Arrays
     287          22 :         if (state.dataVariableSpeedCoils->NumVarSpeedCoils > 0) {
     288          22 :             state.dataVariableSpeedCoils->VarSpeedCoil.allocate(state.dataVariableSpeedCoils->NumVarSpeedCoils);
     289          22 :             state.dataHeatBal->HeatReclaimVS_DXCoil.allocate(state.dataVariableSpeedCoils->NumVarSpeedCoils);
     290             :         }
     291             : 
     292          22 :         state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     293             :             state, "COIL:COOLING:WATERTOAIRHEATPUMP:VARIABLESPEEDEQUATIONFIT", NumParams, NumAlphas, NumNums);
     294          22 :         MaxNums = max(MaxNums, NumNums);
     295          22 :         MaxAlphas = max(MaxAlphas, NumAlphas);
     296          22 :         state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     297             :             state, "COIL:HEATING:WATERTOAIRHEATPUMP:VARIABLESPEEDEQUATIONFIT", NumParams, NumAlphas, NumNums);
     298          22 :         MaxNums = max(MaxNums, NumNums);
     299          22 :         MaxAlphas = max(MaxAlphas, NumAlphas);
     300             : 
     301          22 :         state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, "COIL:COOLING:DX:VARIABLESPEED", NumParams, NumAlphas, NumNums);
     302          22 :         MaxNums = max(MaxNums, NumNums);
     303          22 :         MaxAlphas = max(MaxAlphas, NumAlphas);
     304          22 :         state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, "COIL:HEATING:DX:VARIABLESPEED", NumParams, NumAlphas, NumNums);
     305          22 :         MaxNums = max(MaxNums, NumNums);
     306          22 :         MaxAlphas = max(MaxAlphas, NumAlphas);
     307             : 
     308             :         // variable speed air-source HPWH
     309          22 :         state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     310             :             state, "COIL:WATERHEATING:AIRTOWATERHEATPUMP:VARIABLESPEED", NumParams, NumAlphas, NumNums);
     311          22 :         MaxNums = max(MaxNums, NumNums);
     312          22 :         MaxAlphas = max(MaxAlphas, NumAlphas);
     313             : 
     314          22 :         AlphArray.allocate(MaxAlphas);
     315          22 :         cAlphaFields.allocate(MaxAlphas);
     316          22 :         lAlphaBlanks.dimension(MaxAlphas, true);
     317          22 :         cNumericFields.allocate(MaxNums);
     318          22 :         lNumericBlanks.dimension(MaxNums, true);
     319          22 :         NumArray.dimension(MaxNums, 0.0);
     320             : 
     321             :         // Get the data for cooling coil, WATER SOURCE
     322          22 :         CurrentModuleObject = "Coil:Cooling:WaterToAirHeatPump:VariableSpeedEquationFit"; // for reporting
     323             : 
     324          40 :         for (CoilCounter = 1; CoilCounter <= NumCool; ++CoilCounter) {
     325             : 
     326          18 :             ++DXCoilNum;
     327          18 :             AlfaFieldIncre = 1;
     328             : 
     329          18 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
     330             :                                                                      CurrentModuleObject,
     331             :                                                                      CoilCounter,
     332             :                                                                      AlphArray,
     333             :                                                                      NumAlphas,
     334             :                                                                      NumArray,
     335             :                                                                      NumNums,
     336             :                                                                      IOStat,
     337             :                                                                      lNumericBlanks,
     338             :                                                                      lAlphaBlanks,
     339             :                                                                      cAlphaFields,
     340             :                                                                      cNumericFields);
     341             : 
     342             :             // ErrorsFound will be set to True if problem was found, left untouched otherwise
     343          18 :             VerifyUniqueCoilName(state, CurrentModuleObject, AlphArray(1), ErrorsFound, CurrentModuleObject + " Name");
     344             : 
     345          18 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).bIsDesuperheater = false;
     346          18 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name = AlphArray(1);
     347          18 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CoolHeatType = "COOLING";
     348          18 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType = HVAC::Coil_CoolingWaterToAirHPVSEquationFit;
     349          18 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VarSpeedCoilType =
     350          36 :                 HVAC::cAllCoilTypes(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType);
     351          18 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds = int(NumArray(1));
     352          18 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel = int(NumArray(2));
     353          18 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedCapCoolTotal = NumArray(3);
     354          18 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedAirVolFlowRate = NumArray(4);
     355          18 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedWaterVolFlowRate = NumArray(5);
     356          18 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Twet_Rated = NumArray(6);
     357          18 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Gamma_Rated = NumArray(7);
     358          18 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MaxONOFFCyclesperHour = NumArray(8);
     359          18 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).LatentCapacityTimeConstant = NumArray(9);
     360          18 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).FanDelayTime = NumArray(10);
     361          18 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HOTGASREHEATFLG = int(NumArray(11));
     362          18 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserType = DataHeatBalance::RefrigCondenserType::Water;
     363             : 
     364          18 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterInletNodeNum =
     365          36 :                 GetOnlySingleNode(state,
     366          18 :                                   AlphArray(2),
     367             :                                   ErrorsFound,
     368             :                                   DataLoopNode::ConnectionObjectType::CoilCoolingWaterToAirHeatPumpVariableSpeedEquationFit,
     369          18 :                                   AlphArray(1),
     370             :                                   DataLoopNode::NodeFluidType::Water,
     371             :                                   DataLoopNode::ConnectionType::Inlet,
     372             :                                   NodeInputManager::CompFluidStream::Secondary,
     373             :                                   ObjectIsNotParent);
     374          18 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterOutletNodeNum =
     375          36 :                 GetOnlySingleNode(state,
     376          18 :                                   AlphArray(3),
     377             :                                   ErrorsFound,
     378             :                                   DataLoopNode::ConnectionObjectType::CoilCoolingWaterToAirHeatPumpVariableSpeedEquationFit,
     379          18 :                                   AlphArray(1),
     380             :                                   DataLoopNode::NodeFluidType::Water,
     381             :                                   DataLoopNode::ConnectionType::Outlet,
     382             :                                   NodeInputManager::CompFluidStream::Secondary,
     383             :                                   ObjectIsNotParent);
     384          18 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirInletNodeNum =
     385          36 :                 GetOnlySingleNode(state,
     386          18 :                                   AlphArray(4),
     387             :                                   ErrorsFound,
     388             :                                   DataLoopNode::ConnectionObjectType::CoilCoolingWaterToAirHeatPumpVariableSpeedEquationFit,
     389          18 :                                   AlphArray(1),
     390             :                                   DataLoopNode::NodeFluidType::Air,
     391             :                                   DataLoopNode::ConnectionType::Inlet,
     392             :                                   NodeInputManager::CompFluidStream::Primary,
     393             :                                   ObjectIsNotParent);
     394          18 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirOutletNodeNum =
     395          36 :                 GetOnlySingleNode(state,
     396          18 :                                   AlphArray(5),
     397             :                                   ErrorsFound,
     398             :                                   DataLoopNode::ConnectionObjectType::CoilCoolingWaterToAirHeatPumpVariableSpeedEquationFit,
     399          18 :                                   AlphArray(1),
     400             :                                   DataLoopNode::NodeFluidType::Air,
     401             :                                   DataLoopNode::ConnectionType::Outlet,
     402             :                                   NodeInputManager::CompFluidStream::Primary,
     403             :                                   ObjectIsNotParent);
     404             : 
     405          18 :             TestCompSet(state, CurrentModuleObject, AlphArray(1), AlphArray(2), AlphArray(3), "Water Nodes");
     406          18 :             TestCompSet(state, CurrentModuleObject, AlphArray(1), AlphArray(4), AlphArray(5), "Air Nodes");
     407             : 
     408             :             //   If (VarSpeedCoil(DXCoilNum)%NumOfSpeeds .LT. 2) Then
     409          18 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds < 1) {
     410           0 :                 ShowSevereError(
     411             :                     state,
     412           0 :                     format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
     413           0 :                 ShowContinueError(state, format("...{} must be >= 1. entered number is {:.0T}", cNumericFields(1), NumArray(1)));
     414           0 :                 ErrorsFound = true;
     415             :             }
     416             : 
     417          18 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel >
     418          18 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds) {
     419           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel =
     420           0 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds;
     421             :             }
     422             : 
     423          18 :             if ((state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel >
     424          36 :                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds) ||
     425          18 :                 (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel <= 0)) {
     426           0 :                 ShowSevereError(
     427             :                     state,
     428           0 :                     format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
     429           0 :                 ShowContinueError(state, format("...{} must be valid speed level entered number is {:.0T}", cNumericFields(2), NumArray(2)));
     430           0 :                 ErrorsFound = true;
     431             :             }
     432             : 
     433             :             // part load curve
     434          18 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PLFFPLR = GetCurveIndex(state, AlphArray(6)); // convert curve name to number
     435          18 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PLFFPLR == 0) {
     436           0 :                 if (lAlphaBlanks(6)) {
     437           0 :                     ShowSevereError(
     438             :                         state,
     439           0 :                         format("{}{}=\"{}\", missing", RoutineName, CurrentModuleObject, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
     440           0 :                     ShowContinueError(state, format("...required {} is blank.", cAlphaFields(6)));
     441             :                 } else {
     442           0 :                     ShowSevereError(
     443             :                         state,
     444           0 :                         format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
     445           0 :                     ShowContinueError(state, format("...not found {}=\"{}\".", cAlphaFields(6), AlphArray(6)));
     446             :                 }
     447           0 :                 ErrorsFound = true;
     448             :             } else {
     449          18 :                 CurveVal = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PLFFPLR, 1.0);
     450          18 :                 if (CurveVal > 1.10 || CurveVal < 0.90) {
     451           0 :                     ShowWarningError(state,
     452           0 :                                      format("{}{}=\"{}\", curve values",
     453             :                                             RoutineName,
     454             :                                             CurrentModuleObject,
     455           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
     456           0 :                     ShowContinueError(state, format("...{} output is not equal to 1.0 (+ or - 10%) at rated conditions.", cAlphaFields(6)));
     457           0 :                     ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
     458             :                 }
     459             :             }
     460             : 
     461         198 :             for (I = 1; I <= state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds; ++I) {
     462         180 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I) = NumArray(12 + (I - 1) * 6);
     463         180 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedSHR(I) = NumArray(13 + (I - 1) * 6);
     464         180 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedCOP(I) = NumArray(14 + (I - 1) * 6);
     465         180 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowRate(I) = NumArray(15 + (I - 1) * 6);
     466         180 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterVolFlowRate(I) = NumArray(16 + (I - 1) * 6);
     467         180 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeatFrac(I) = NumArray(17 + (I - 1) * 6);
     468             : 
     469         180 :                 AlfaFieldIncre = 7 + (I - 1) * 7;
     470         180 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(I) =
     471         180 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
     472         180 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(I) == 0) {
     473           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
     474           0 :                         ShowSevereError(state,
     475           0 :                                         format("{}{}=\"{}\", missing",
     476             :                                                RoutineName,
     477             :                                                CurrentModuleObject,
     478           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
     479           0 :                         ShowContinueError(state, format("...required {} is blank.", cAlphaFields(AlfaFieldIncre)));
     480             :                     } else {
     481           0 :                         ShowSevereError(state,
     482           0 :                                         format("{}{}=\"{}\", invalid",
     483             :                                                RoutineName,
     484             :                                                CurrentModuleObject,
     485           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
     486           0 :                         ShowContinueError(state, format("...not found {}=\"{}\".", cAlphaFields(AlfaFieldIncre), AlphArray(AlfaFieldIncre)));
     487             :                     }
     488           0 :                     ErrorsFound = true;
     489             :                 } else {
     490             :                     // Verify Curve Object, only legal type is BiQuadratic
     491         360 :                     ErrorsFound |= Curve::CheckCurveDims(state,
     492         180 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(I), // Curve index
     493             :                                                          {2},                                                                  // Valid dimensions
     494             :                                                          RoutineName,                                                          // Routine name
     495             :                                                          CurrentModuleObject,                                                  // Object Type
     496         180 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,           // Object Name
     497         180 :                                                          cAlphaFields(AlfaFieldIncre));                                        // Field Name
     498             : 
     499         180 :                     if (!ErrorsFound) {
     500         360 :                         CurveVal = CurveValue(
     501         180 :                             state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(I), RatedInletWetBulbTemp, RatedInletWaterTemp);
     502         180 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
     503           0 :                             ShowWarningError(state,
     504           0 :                                              format("{}{}=\"{}\", curve values",
     505             :                                                     RoutineName,
     506             :                                                     CurrentModuleObject,
     507           0 :                                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
     508           0 :                             ShowContinueError(
     509           0 :                                 state, format("...{} output is not equal to 1.0 (+ or - 10%) at rated conditions.", cAlphaFields(AlfaFieldIncre)));
     510           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
     511             :                         }
     512             :                     }
     513             :                 }
     514             : 
     515         180 :                 AlfaFieldIncre = 8 + (I - 1) * 7;
     516         180 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(I) =
     517         180 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
     518         180 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(I) == 0) {
     519           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
     520           0 :                         ShowSevereError(state,
     521           0 :                                         format("{}{}=\"{}\", missing",
     522             :                                                RoutineName,
     523             :                                                CurrentModuleObject,
     524           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
     525           0 :                         ShowContinueError(state, format("...required {} is blank.", cAlphaFields(AlfaFieldIncre)));
     526             :                     } else {
     527           0 :                         ShowSevereError(state,
     528           0 :                                         format("{}{}=\"{}\", invalid",
     529             :                                                RoutineName,
     530             :                                                CurrentModuleObject,
     531           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
     532           0 :                         ShowContinueError(state, format("...not found {}=\"{}\".", cAlphaFields(AlfaFieldIncre), AlphArray(AlfaFieldIncre)));
     533             :                     }
     534           0 :                     ErrorsFound = true;
     535             :                 } else {
     536             :                     // Verify Curve Object, only legal type is Quadratic
     537         360 :                     ErrorsFound |= Curve::CheckCurveDims(state,
     538         180 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(I), // Curve index
     539             :                                                          {1},                                                                     // Valid dimensions
     540             :                                                          RoutineName,                                                             // Routine name
     541             :                                                          CurrentModuleObject,                                                     // Object Type
     542         180 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,              // Object Name
     543         180 :                                                          cAlphaFields(AlfaFieldIncre));                                           // Field Name
     544             : 
     545         180 :                     if (!ErrorsFound) {
     546         180 :                         CurveVal = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(I), 1.0);
     547         180 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
     548           0 :                             ShowWarningError(state,
     549           0 :                                              format("{}{}=\"{}\", curve values",
     550             :                                                     RoutineName,
     551             :                                                     CurrentModuleObject,
     552           0 :                                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
     553           0 :                             ShowContinueError(
     554           0 :                                 state, format("...{} output is not equal to 1.0 (+ or - 10%) at rated conditions.", cAlphaFields(AlfaFieldIncre)));
     555           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
     556             :                         }
     557             :                     }
     558             :                 }
     559             : 
     560         180 :                 AlfaFieldIncre = 9 + (I - 1) * 7;
     561         180 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(I) =
     562         180 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
     563         180 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(I) == 0) {
     564           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
     565           0 :                         ShowSevereError(state,
     566           0 :                                         format("{}{}=\"{}\", missing",
     567             :                                                RoutineName,
     568             :                                                CurrentModuleObject,
     569           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
     570           0 :                         ShowContinueError(state, format("...required {} is blank.", cAlphaFields(AlfaFieldIncre)));
     571             :                     } else {
     572           0 :                         ShowSevereError(state,
     573           0 :                                         format("{}{}=\"{}\", invalid",
     574             :                                                RoutineName,
     575             :                                                CurrentModuleObject,
     576           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
     577           0 :                         ShowContinueError(state, format("...not found {}=\"{}\".", cAlphaFields(AlfaFieldIncre), AlphArray(AlfaFieldIncre)));
     578             :                     }
     579           0 :                     ErrorsFound = true;
     580             :                 } else {
     581             :                     // Verify Curve Object, only legal type is Quadratic
     582         360 :                     ErrorsFound |= Curve::CheckCurveDims(state,
     583         180 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(I), // Curve index
     584             :                                                          {1},                                                        // Valid dimensions
     585             :                                                          RoutineName,                                                // Routine name
     586             :                                                          CurrentModuleObject,                                        // Object Type
     587         180 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name, // Object Name
     588         180 :                                                          cAlphaFields(AlfaFieldIncre));                              // Field Name
     589             : 
     590         180 :                     if (!ErrorsFound) {
     591         180 :                         CurveVal = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(I), 1.0);
     592         180 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
     593           0 :                             ShowWarningError(state,
     594           0 :                                              format("{}{}=\"{}\", curve values",
     595             :                                                     RoutineName,
     596             :                                                     CurrentModuleObject,
     597           0 :                                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
     598           0 :                             ShowContinueError(
     599           0 :                                 state, format("...{} output is not equal to 1.0 (+ or - 10%) at rated conditions.", cAlphaFields(AlfaFieldIncre)));
     600           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
     601             :                         }
     602             :                     }
     603             :                 }
     604             : 
     605         180 :                 AlfaFieldIncre = 10 + (I - 1) * 7;
     606         180 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(I) =
     607         180 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
     608         180 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(I) == 0) {
     609           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
     610           0 :                         ShowSevereError(state,
     611           0 :                                         format("{}{}=\"{}\", missing",
     612             :                                                RoutineName,
     613             :                                                CurrentModuleObject,
     614           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
     615           0 :                         ShowContinueError(state, format("...required {} is blank.", cAlphaFields(AlfaFieldIncre)));
     616             :                     } else {
     617           0 :                         ShowSevereError(state,
     618           0 :                                         format("{}{}=\"{}\", invalid",
     619             :                                                RoutineName,
     620             :                                                CurrentModuleObject,
     621           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
     622           0 :                         ShowContinueError(state, format("...not found {}=\"{}\".", cAlphaFields(AlfaFieldIncre), AlphArray(AlfaFieldIncre)));
     623             :                     }
     624           0 :                     ErrorsFound = true;
     625             :                 } else {
     626             :                     // Verify Curve Object, only legal type is BiQuadratic
     627         360 :                     ErrorsFound |= Curve::CheckCurveDims(state,
     628         180 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(I), // Curve index
     629             :                                                          {2},                                                                 // Valid dimensions
     630             :                                                          RoutineName,                                                         // Routine name
     631             :                                                          CurrentModuleObject,                                                 // Object Type
     632         180 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,          // Object Name
     633         180 :                                                          cAlphaFields(AlfaFieldIncre));                                       // Field Name
     634             : 
     635         180 :                     if (!ErrorsFound) {
     636         360 :                         CurveVal = CurveValue(
     637         180 :                             state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(I), RatedInletWetBulbTemp, RatedInletWaterTemp);
     638         180 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
     639           0 :                             ShowWarningError(state,
     640           0 :                                              format("{}{}=\"{}\", curve values",
     641             :                                                     RoutineName,
     642             :                                                     CurrentModuleObject,
     643           0 :                                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
     644           0 :                             ShowContinueError(
     645           0 :                                 state, format("...{} output is not equal to 1.0 (+ or - 10%) at rated conditions.", cAlphaFields(AlfaFieldIncre)));
     646           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
     647             :                         }
     648             :                     }
     649             :                 }
     650             : 
     651         180 :                 AlfaFieldIncre = 11 + (I - 1) * 7;
     652         180 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(I) =
     653         180 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
     654         180 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(I) == 0) {
     655           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
     656           0 :                         ShowSevereError(state,
     657           0 :                                         format("{}{}=\"{}\", missing",
     658             :                                                RoutineName,
     659             :                                                CurrentModuleObject,
     660           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
     661           0 :                         ShowContinueError(state, format("...required {} is blank.", cAlphaFields(AlfaFieldIncre)));
     662             :                     } else {
     663           0 :                         ShowSevereError(state,
     664           0 :                                         format("{}{}=\"{}\", invalid",
     665             :                                                RoutineName,
     666             :                                                CurrentModuleObject,
     667           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
     668           0 :                         ShowContinueError(state, format("...not found {}=\"{}\".", cAlphaFields(AlfaFieldIncre), AlphArray(AlfaFieldIncre)));
     669             :                     }
     670           0 :                     ErrorsFound = true;
     671             :                 } else {
     672             :                     // Verify Curve Object, only legal type is Quadratic
     673         360 :                     ErrorsFound |= Curve::CheckCurveDims(state,
     674         180 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(I), // Curve index
     675             :                                                          {1},                                                                    // Valid dimensions
     676             :                                                          RoutineName,                                                            // Routine name
     677             :                                                          CurrentModuleObject,                                                    // Object Type
     678         180 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,             // Object Name
     679         180 :                                                          cAlphaFields(AlfaFieldIncre));                                          // Field Name
     680             : 
     681         180 :                     if (!ErrorsFound) {
     682         180 :                         CurveVal = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(I), 1.0);
     683         180 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
     684           0 :                             ShowWarningError(state,
     685           0 :                                              format("{}{}=\"{}\", curve values",
     686             :                                                     RoutineName,
     687             :                                                     CurrentModuleObject,
     688           0 :                                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
     689           0 :                             ShowContinueError(
     690           0 :                                 state, format("...{} output is not equal to 1.0 (+ or - 10%) at rated conditions.", cAlphaFields(AlfaFieldIncre)));
     691           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
     692             :                         }
     693             :                     }
     694             :                 }
     695             : 
     696         180 :                 AlfaFieldIncre = 12 + (I - 1) * 7;
     697         180 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRWaterFFlow(I) =
     698         180 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
     699         180 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRWaterFFlow(I) == 0) {
     700           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
     701           0 :                         ShowSevereError(state,
     702           0 :                                         format("{}{}=\"{}\", missing",
     703             :                                                RoutineName,
     704             :                                                CurrentModuleObject,
     705           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
     706           0 :                         ShowContinueError(state, format("...required {} is blank.", cAlphaFields(AlfaFieldIncre)));
     707             :                     } else {
     708           0 :                         ShowSevereError(state,
     709           0 :                                         format("{}{}=\"{}\", invalid",
     710             :                                                RoutineName,
     711             :                                                CurrentModuleObject,
     712           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
     713           0 :                         ShowContinueError(state, format("...not found {}=\"{}\".", cAlphaFields(AlfaFieldIncre), AlphArray(AlfaFieldIncre)));
     714             :                     }
     715           0 :                     ErrorsFound = true;
     716             :                 } else {
     717             :                     // Verify Curve Object, only legal type is Quadratic
     718         360 :                     ErrorsFound |= Curve::CheckCurveDims(state,
     719         180 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRWaterFFlow(I), // Curve index
     720             :                                                          {1},                                                                      // Valid dimensions
     721             :                                                          RoutineName,                                                              // Routine name
     722             :                                                          CurrentModuleObject,                                                      // Object Type
     723         180 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,               // Object Name
     724         180 :                                                          cAlphaFields(AlfaFieldIncre));                                            // Field Name
     725             : 
     726         180 :                     if (!ErrorsFound) {
     727         180 :                         CurveVal = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRWaterFFlow(I), 1.0);
     728         180 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
     729           0 :                             ShowWarningError(state,
     730           0 :                                              format("{}{}=\"{}\", curve values",
     731             :                                                     RoutineName,
     732             :                                                     CurrentModuleObject,
     733           0 :                                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
     734           0 :                             ShowContinueError(
     735           0 :                                 state, format("...{} output is not equal to 1.0 (+ or - 10%) at rated conditions.", cAlphaFields(AlfaFieldIncre)));
     736           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
     737             :                         }
     738             :                     }
     739             :                 }
     740             : 
     741         180 :                 AlfaFieldIncre = 13 + (I - 1) * 7;
     742             :                 // Read waste heat modifier curve name
     743         180 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeat(I) =
     744         180 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
     745         180 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeat(I) == 0) {
     746           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
     747           0 :                         ShowSevereError(state,
     748           0 :                                         format("{}{}=\"{}\", missing",
     749             :                                                RoutineName,
     750             :                                                CurrentModuleObject,
     751           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
     752           0 :                         ShowContinueError(state, format("...required {} is blank.", cAlphaFields(AlfaFieldIncre)));
     753             :                     } else {
     754           0 :                         ShowSevereError(state,
     755           0 :                                         format("{}{}=\"{}\", invalid",
     756             :                                                RoutineName,
     757             :                                                CurrentModuleObject,
     758           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
     759           0 :                         ShowContinueError(state, format("...not found {}=\"{}\".", cAlphaFields(AlfaFieldIncre), AlphArray(AlfaFieldIncre)));
     760             :                     }
     761           0 :                     ErrorsFound = true;
     762             :                 } else {
     763             :                     // Verify Curve Object, only legal types are BiQuadratic
     764         360 :                     ErrorsFound |= Curve::CheckCurveDims(state,
     765         180 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeat(I), // Curve index
     766             :                                                          {2},                                                                  // Valid dimensions
     767             :                                                          RoutineName,                                                          // Routine name
     768             :                                                          CurrentModuleObject,                                                  // Object Type
     769         180 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,           // Object Name
     770         180 :                                                          cAlphaFields(AlfaFieldIncre));                                        // Field Name
     771             : 
     772         180 :                     if (!ErrorsFound) {
     773         360 :                         CurveVal = CurveValue(
     774         180 :                             state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeat(I), RatedInletWaterTemp, RatedInletAirTemp);
     775         180 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
     776           0 :                             ShowWarningError(state,
     777           0 :                                              format("{}{}=\"{}\", curve values",
     778             :                                                     RoutineName,
     779             :                                                     CurrentModuleObject,
     780           0 :                                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
     781           0 :                             ShowContinueError(
     782           0 :                                 state, format("...{} output is not equal to 1.0 (+ or - 10%) at rated conditions.", cAlphaFields(AlfaFieldIncre)));
     783           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
     784             :                         }
     785             :                     }
     786             :                 }
     787             :             }
     788             : 
     789         198 :             for (I = 1; I <= state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds; ++I) {
     790         180 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedPercentTotCap(I) =
     791         180 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I) /
     792         360 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(
     793         180 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds);
     794         180 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowPerRatedTotCap(I) =
     795         180 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowRate(I) /
     796         180 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I);
     797         180 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterVolFlowPerRatedTotCap(I) =
     798         180 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterVolFlowRate(I) /
     799         180 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I);
     800             :             }
     801             : 
     802             :             // CurrentModuleObject = "Coil:Cooling:WaterToAirHeatPump:VariableSpeedEquationFit"
     803          36 :             SetupOutputVariable(state,
     804             :                                 "Cooling Coil Electricity Energy",
     805             :                                 Constant::Units::J,
     806          18 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Energy,
     807             :                                 OutputProcessor::TimeStepType::System,
     808             :                                 OutputProcessor::StoreType::Sum,
     809          18 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
     810             :                                 Constant::eResource::Electricity,
     811             :                                 OutputProcessor::Group::HVAC,
     812             :                                 OutputProcessor::EndUseCat::Cooling);
     813          36 :             SetupOutputVariable(state,
     814             :                                 "Cooling Coil Total Cooling Energy",
     815             :                                 Constant::Units::J,
     816          18 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLoadTotal,
     817             :                                 OutputProcessor::TimeStepType::System,
     818             :                                 OutputProcessor::StoreType::Sum,
     819          18 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
     820             :                                 Constant::eResource::EnergyTransfer,
     821             :                                 OutputProcessor::Group::HVAC,
     822             :                                 OutputProcessor::EndUseCat::CoolingCoils);
     823          36 :             SetupOutputVariable(state,
     824             :                                 "Cooling Coil Sensible Cooling Energy",
     825             :                                 Constant::Units::J,
     826          18 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergySensible,
     827             :                                 OutputProcessor::TimeStepType::System,
     828             :                                 OutputProcessor::StoreType::Sum,
     829          18 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
     830          36 :             SetupOutputVariable(state,
     831             :                                 "Cooling Coil Latent Cooling Energy",
     832             :                                 Constant::Units::J,
     833          18 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLatent,
     834             :                                 OutputProcessor::TimeStepType::System,
     835             :                                 OutputProcessor::StoreType::Sum,
     836          18 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
     837          36 :             SetupOutputVariable(state,
     838             :                                 "Cooling Coil Source Side Heat Transfer Energy",
     839             :                                 Constant::Units::J,
     840          18 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergySource,
     841             :                                 OutputProcessor::TimeStepType::System,
     842             :                                 OutputProcessor::StoreType::Sum,
     843          18 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
     844             :                                 Constant::eResource::PlantLoopCoolingDemand,
     845             :                                 OutputProcessor::Group::HVAC,
     846             :                                 OutputProcessor::EndUseCat::CoolingCoils);
     847             : 
     848             :             // for table output, being consistent with outher water-to-air coils
     849             :             //        IF (VarSpeedCoil(DXCoilNum)%RatedCapCoolTotal /= AutoSize) THEN
     850             :             //            VarSpeedCoil(DXCoilNum)%RatedCapCoolSens = VarSpeedCoil(DXCoilNum)%RatedCapCoolTotal &
     851             :             //                *VarSpeedCoil(DXCoilNum)%MSRatedSHR(VarSpeedCoil(DXCoilNum)%NormSpedLevel)
     852             :             //        ELSE
     853             :             //            VarSpeedCoil(DXCoilNum)%RatedCapCoolSens = AUTOSIZE
     854             :             //        END IF
     855             : 
     856          18 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedCapCoolSens =
     857             :                 AutoSize; // always auto-sized, to be determined in the sizing calculation
     858             : 
     859             :             // BAN Sept 30 2103, CR9322, commented out, now it is redundant, it is reported from sizing routine
     860             :             // create predefined report entries
     861             :             // PreDefTableEntry(state,  pdchCoolCoilType, VarSpeedCoil( DXCoilNum ).Name, CurrentModuleObject );
     862             :             // PreDefTableEntry(state,  pdchCoolCoilTotCap, VarSpeedCoil( DXCoilNum ).Name, VarSpeedCoil( DXCoilNum ).RatedCapCoolTotal );
     863             :             // PreDefTableEntry(state,  pdchCoolCoilSensCap, VarSpeedCoil( DXCoilNum ).Name, VarSpeedCoil( DXCoilNum ).RatedCapCoolSens );
     864             :             // PreDefTableEntry(state,  pdchCoolCoilLatCap, VarSpeedCoil( DXCoilNum ).Name, VarSpeedCoil( DXCoilNum ).RatedCapCoolTotal -
     865             :             // VarSpeedCoil( DXCoilNum ).RatedCapCoolSens );  PreDefTableEntry(state,  pdchCoolCoilSHR, VarSpeedCoil( DXCoilNum ).Name, VarSpeedCoil(
     866             :             // DXCoilNum
     867             :             // ).RatedCapCoolSens / VarSpeedCoil( DXCoilNum ).RatedCapCoolTotal );  PreDefTableEntry(state,  pdchCoolCoilNomEff, VarSpeedCoil(
     868             :             // DXCoilNum
     869             :             // ).Name, VarSpeedCoil( DXCoilNum ).MSRatedCOP( VarSpeedCoil( DXCoilNum ).NormSpedLevel ) );
     870             :         }
     871             : 
     872             :         //-------------------------AIR SOURCE, COOLING---BEGIN
     873             :         // Get the data for cooling coil, AIR SOURCE
     874          22 :         CurrentModuleObject = "Coil:Cooling:DX:VariableSpeed"; // for reporting
     875             : 
     876          44 :         for (CoilCounter = 1; CoilCounter <= NumCoolAS; ++CoilCounter) {
     877             : 
     878          22 :             ++DXCoilNum;
     879          22 :             AlfaFieldIncre = 1;
     880             : 
     881          22 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
     882             :                                                                      CurrentModuleObject,
     883             :                                                                      CoilCounter,
     884             :                                                                      AlphArray,
     885             :                                                                      NumAlphas,
     886             :                                                                      NumArray,
     887             :                                                                      NumNums,
     888             :                                                                      IOStat,
     889             :                                                                      lNumericBlanks,
     890             :                                                                      lAlphaBlanks,
     891             :                                                                      cAlphaFields,
     892             :                                                                      cNumericFields);
     893             :             // ErrorsFound will be set to True if problem was found, left untouched otherwise
     894          22 :             VerifyUniqueCoilName(state, CurrentModuleObject, AlphArray(1), ErrorsFound, CurrentModuleObject + " Name");
     895             : 
     896          22 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).bIsDesuperheater = false;
     897          22 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name = AlphArray(1);
     898             :             // Initialize DataHeatBalance heat reclaim variable name for use by heat reclaim coils
     899          22 :             state.dataHeatBal->HeatReclaimVS_DXCoil(DXCoilNum).Name = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name;
     900          22 :             state.dataHeatBal->HeatReclaimVS_DXCoil(DXCoilNum).SourceType = CurrentModuleObject;
     901          22 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CoolHeatType = "COOLING";
     902          22 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType = HVAC::Coil_CoolingAirToAirVariableSpeed;
     903          22 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VarSpeedCoilType = HVAC::cAllCoilTypes(HVAC::Coil_CoolingAirToAirVariableSpeed);
     904          22 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds = int(NumArray(1));
     905          22 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel = int(NumArray(2));
     906          22 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedCapCoolTotal = NumArray(3);
     907          22 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedAirVolFlowRate = NumArray(4);
     908          22 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Twet_Rated = NumArray(5);
     909          22 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Gamma_Rated = NumArray(6);
     910          22 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MaxONOFFCyclesperHour = NumArray(7);
     911          22 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).LatentCapacityTimeConstant = NumArray(8);
     912          22 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).FanDelayTime = NumArray(9);
     913             : 
     914          22 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirInletNodeNum =
     915          44 :                 GetOnlySingleNode(state,
     916          22 :                                   AlphArray(2),
     917             :                                   ErrorsFound,
     918             :                                   DataLoopNode::ConnectionObjectType::CoilCoolingDXVariableSpeed,
     919          22 :                                   AlphArray(1),
     920             :                                   DataLoopNode::NodeFluidType::Air,
     921             :                                   DataLoopNode::ConnectionType::Inlet,
     922             :                                   NodeInputManager::CompFluidStream::Primary,
     923             :                                   ObjectIsNotParent);
     924          22 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirOutletNodeNum =
     925          44 :                 GetOnlySingleNode(state,
     926          22 :                                   AlphArray(3),
     927             :                                   ErrorsFound,
     928             :                                   DataLoopNode::ConnectionObjectType::CoilCoolingDXVariableSpeed,
     929          22 :                                   AlphArray(1),
     930             :                                   DataLoopNode::NodeFluidType::Air,
     931             :                                   DataLoopNode::ConnectionType::Outlet,
     932             :                                   NodeInputManager::CompFluidStream::Primary,
     933             :                                   ObjectIsNotParent);
     934             : 
     935          22 :             TestCompSet(state, CurrentModuleObject, AlphArray(1), AlphArray(2), AlphArray(3), "Air Nodes");
     936             : 
     937          22 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds < 1) {
     938           0 :                 ShowSevereError(
     939             :                     state,
     940           0 :                     format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
     941           0 :                 ShowContinueError(state, format("...{} must be >= 1. entered number is {:.0T}", cNumericFields(1), NumArray(1)));
     942           0 :                 ErrorsFound = true;
     943             :             }
     944             : 
     945          22 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel >
     946          22 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds) {
     947           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel =
     948           0 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds;
     949             :             }
     950             : 
     951          22 :             if ((state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel >
     952          44 :                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds) ||
     953          22 :                 (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel <= 0)) {
     954           0 :                 ShowSevereError(
     955             :                     state,
     956           0 :                     format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
     957           0 :                 ShowContinueError(state, format("...{} must be valid speed level entered number is {:.0T}", cNumericFields(2), NumArray(2)));
     958           0 :                 ErrorsFound = true;
     959             :             }
     960             : 
     961             :             // part load curve
     962          22 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PLFFPLR = GetCurveIndex(state, AlphArray(4)); // convert curve name to number
     963          22 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PLFFPLR == 0) {
     964           0 :                 if (lAlphaBlanks(4)) {
     965           0 :                     ShowSevereError(
     966             :                         state,
     967           0 :                         format("{}{}=\"{}\", missing", RoutineName, CurrentModuleObject, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
     968           0 :                     ShowContinueError(state, format("...required {} is blank.", cAlphaFields(6)));
     969             :                 } else {
     970           0 :                     ShowSevereError(
     971             :                         state,
     972           0 :                         format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
     973           0 :                     ShowContinueError(state, format("...not found {}=\"{}\".", cAlphaFields(4), AlphArray(4)));
     974             :                 }
     975           0 :                 ErrorsFound = true;
     976             :             } else {
     977          22 :                 CurveVal = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PLFFPLR, 1.0);
     978          22 :                 if (CurveVal > 1.10 || CurveVal < 0.90) {
     979           0 :                     ShowWarningError(state,
     980           0 :                                      format("{}{}=\"{}\", curve values",
     981             :                                             RoutineName,
     982             :                                             CurrentModuleObject,
     983           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
     984           0 :                     ShowContinueError(state, format("...{} output is not equal to 1.0 (+ or - 10%) at rated conditions.", cAlphaFields(4)));
     985           0 :                     ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
     986             :                 }
     987             :             }
     988             : 
     989             :             // outdoor condenser node
     990          22 :             if (lAlphaBlanks(5)) {
     991          21 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum = 0;
     992             :             } else {
     993           1 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum =
     994           2 :                     GetOnlySingleNode(state,
     995           1 :                                       AlphArray(5),
     996             :                                       ErrorsFound,
     997             :                                       DataLoopNode::ConnectionObjectType::CoilCoolingDXVariableSpeed,
     998           1 :                                       state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
     999             :                                       DataLoopNode::NodeFluidType::Air,
    1000             :                                       DataLoopNode::ConnectionType::OutsideAirReference,
    1001             :                                       NodeInputManager::CompFluidStream::Primary,
    1002             :                                       ObjectIsNotParent);
    1003             : 
    1004           1 :                 if (!CheckOutAirNodeNumber(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum)) {
    1005           0 :                     ShowWarningError(state,
    1006           0 :                                      format("{}{}=\"{}\", may be invalid",
    1007             :                                             RoutineName,
    1008             :                                             CurrentModuleObject,
    1009           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1010           0 :                     ShowContinueError(state,
    1011           0 :                                       format("{}=\"{}\", node does not appear in an OutdoorAir:NodeList or as an OutdoorAir:Node.",
    1012             :                                              cAlphaFields(10),
    1013             :                                              AlphArray(5)));
    1014           0 :                     ShowContinueError(
    1015             :                         state, "This node needs to be included in an air system or the coil model will not be valid, and the simulation continues");
    1016             :                 }
    1017             :             }
    1018             : 
    1019          22 :             if ((Util::SameString(AlphArray(6), "AirCooled")) || lAlphaBlanks(6)) {
    1020          22 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserType = DataHeatBalance::RefrigCondenserType::Air;
    1021           0 :             } else if (Util::SameString(AlphArray(6), "EvaporativelyCooled")) {
    1022           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserType = DataHeatBalance::RefrigCondenserType::Evap;
    1023           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).ReportEvapCondVars = true;
    1024             :             } else {
    1025           0 :                 ShowSevereError(
    1026             :                     state,
    1027           0 :                     format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1028           0 :                 ShowContinueError(state, format("...{}=\"{}\":", cAlphaFields(6), AlphArray(6)));
    1029           0 :                 ShowContinueError(state, "...must be AirCooled or EvaporativelyCooled.");
    1030           0 :                 ErrorsFound = true;
    1031             :             }
    1032             : 
    1033          22 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondPumpElecNomPower = NumArray(10);
    1034             : 
    1035          22 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondPumpElecNomPower != DataSizing::AutoSize) {
    1036          22 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondPumpElecNomPower < 0.0) {
    1037           0 :                     ShowSevereError(
    1038             :                         state,
    1039           0 :                         format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1040           0 :                     ShowContinueError(state, format("...{} cannot be < 0.0.", cNumericFields(10)));
    1041           0 :                     ShowContinueError(state, format("...entered value=[{:.2T}].", NumArray(10)));
    1042           0 :                     ErrorsFound = true;
    1043             :                 }
    1044             :             }
    1045             : 
    1046             :             // Set crankcase heater capacity
    1047          22 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterCapacity = NumArray(11);
    1048          22 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterCapacity < 0.0) {
    1049           0 :                 ShowSevereError(
    1050             :                     state,
    1051           0 :                     format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1052           0 :                 ShowContinueError(state, format("...{} cannot be < 0.0.", cNumericFields(11)));
    1053           0 :                 ShowContinueError(state, format("...entered value=[{:.2T}].", NumArray(11)));
    1054           0 :                 ErrorsFound = true;
    1055             :             }
    1056             : 
    1057             :             // Set crankcase heater cutout temperature
    1058          22 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MaxOATCrankcaseHeater = NumArray(12);
    1059             : 
    1060             :             // Set crankcase heater cutout temperature
    1061          22 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MinOATCompressor = NumArray(13);
    1062             : 
    1063             :             // A7; \field Crankcase Heater Capacity Function of Outdoor Temperature Curve Name
    1064          22 :             if (!lAlphaBlanks(7)) {
    1065           1 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterCapacityCurveIndex = Curve::GetCurveIndex(state, AlphArray(7));
    1066           1 :                 ErrorsFound |=
    1067           2 :                     Curve::CheckCurveDims(state,
    1068           1 :                                           state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterCapacityCurveIndex, // Curve index
    1069             :                                           {1},                                                                                     // Valid dimensions
    1070             :                                           RoutineName,                                                                             // Routine name
    1071             :                                           CurrentModuleObject,                                                                     // Object Type
    1072           1 :                                           state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,                              // Object Name
    1073           1 :                                           cAlphaFields(7));                                                                        // Field Name
    1074             :             }
    1075             : 
    1076             :             // Get Water System tank connections
    1077             :             //  A8, \field Name of Water Storage Tank for Supply
    1078          22 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapWaterSupplyName = AlphArray(8);
    1079          22 :             if (lAlphaBlanks(8)) {
    1080          22 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapWaterSupplyMode = WaterSupplyFromMains;
    1081             :             } else {
    1082           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapWaterSupplyMode = WaterSupplyFromTank;
    1083           0 :                 SetupTankDemandComponent(state,
    1084           0 :                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    1085             :                                          CurrentModuleObject,
    1086           0 :                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapWaterSupplyName,
    1087             :                                          ErrorsFound,
    1088           0 :                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapWaterSupTankID,
    1089           0 :                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapWaterTankDemandARRID);
    1090             :             }
    1091             : 
    1092             :             // A9; \field Name of Water Storage Tank for Condensate Collection
    1093          22 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondensateCollectName = AlphArray(9);
    1094          22 :             if (lAlphaBlanks(9)) {
    1095          22 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondensateCollectMode = CondensateDiscarded;
    1096             :             } else {
    1097           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondensateCollectMode = CondensateToTank;
    1098           0 :                 SetupTankSupplyComponent(state,
    1099           0 :                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    1100             :                                          CurrentModuleObject,
    1101           0 :                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondensateCollectName,
    1102             :                                          ErrorsFound,
    1103           0 :                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondensateTankID,
    1104           0 :                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondensateTankSupplyARRID);
    1105             :             }
    1106             : 
    1107             :             //   Basin heater power as a function of temperature must be greater than or equal to 0
    1108          22 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterPowerFTempDiff = NumArray(14);
    1109          22 :             if (NumArray(14) < 0.0) {
    1110           0 :                 ShowSevereError(
    1111             :                     state,
    1112           0 :                     format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1113           0 :                 ShowContinueError(state, format("...{} must be >= 0.0.", cNumericFields(14)));
    1114           0 :                 ShowContinueError(state, format("...entered value=[{:.2T}].", NumArray(14)));
    1115           0 :                 ErrorsFound = true;
    1116             :             }
    1117             : 
    1118          22 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterSetPointTemp = NumArray(15);
    1119          22 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterPowerFTempDiff > 0.0) {
    1120           0 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterSetPointTemp < 2.0) {
    1121           0 :                     ShowWarningError(state,
    1122           0 :                                      format("{}{}=\"{}\", freeze possible",
    1123             :                                             RoutineName,
    1124             :                                             CurrentModuleObject,
    1125           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1126           0 :                     ShowContinueError(state, format("...{} is < 2 {{C}}. Freezing could occur.", cNumericFields(15)));
    1127           0 :                     ShowContinueError(state, format("...entered value=[{:.2T}].", NumArray(15)));
    1128             :                 }
    1129             :             }
    1130             : 
    1131          22 :             if (!lAlphaBlanks(10)) {
    1132           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterSchedulePtr = GetScheduleIndex(state, AlphArray(10));
    1133           0 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterSchedulePtr == 0) {
    1134           0 :                     ShowWarningError(
    1135             :                         state,
    1136           0 :                         format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1137           0 :                     ShowContinueError(state, format("...not found {}=\"{}\".", cAlphaFields(10), AlphArray(10)));
    1138           0 :                     ShowContinueError(state, "Basin heater will be available to operate throughout the simulation.");
    1139             :                 }
    1140             :             }
    1141             : 
    1142         182 :             for (I = 1; I <= state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds; ++I) {
    1143         160 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I) = NumArray(16 + (I - 1) * 8);
    1144         160 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedSHR(I) = NumArray(17 + (I - 1) * 8);
    1145         160 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedCOP(I) = NumArray(18 + (I - 1) * 8);
    1146         160 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowRate(I) = NumArray(19 + (I - 1) * 8);
    1147         160 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedEvaporatorFanPowerPerVolumeFlowRate2017(I) = NumArray(20 + (I - 1) * 8);
    1148         160 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedEvaporatorFanPowerPerVolumeFlowRate2023(I) = NumArray(21 + (I - 1) * 8);
    1149         160 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondAirFlow(I) = NumArray(22 + (I - 1) * 8);
    1150         160 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondEffect(I) = NumArray(23 + (I - 1) * 8);
    1151         320 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondEffect(I) < 0.0 ||
    1152         160 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondEffect(I) > 1.0) {
    1153           0 :                     ShowSevereError(
    1154             :                         state,
    1155           0 :                         format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1156           0 :                     ShowContinueError(state, format("...{} cannot be < 0.0 or > 1.0.", cNumericFields(23 + (I - 1) * 8)));
    1157           0 :                     ShowContinueError(state, format("...entered value=[{:.2T}].", NumArray(23 + (I - 1) * 8)));
    1158           0 :                     ErrorsFound = true;
    1159             :                 }
    1160             : 
    1161         160 :                 AlfaFieldIncre = 11 + (I - 1) * 4;
    1162         160 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(I) =
    1163         160 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
    1164         160 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(I) == 0) {
    1165           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
    1166           0 :                         ShowSevereError(state,
    1167           0 :                                         format("{}{}=\"{}\", missing",
    1168             :                                                RoutineName,
    1169             :                                                CurrentModuleObject,
    1170           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1171           0 :                         ShowContinueError(state, format("...required {} is blank.", cAlphaFields(AlfaFieldIncre)));
    1172             :                     } else {
    1173           0 :                         ShowSevereError(state,
    1174           0 :                                         format("{}{}=\"{}\", invalid",
    1175             :                                                RoutineName,
    1176             :                                                CurrentModuleObject,
    1177           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1178           0 :                         ShowContinueError(state, format("...not found {}=\"{}\".", cAlphaFields(AlfaFieldIncre), AlphArray(AlfaFieldIncre)));
    1179             :                     }
    1180           0 :                     ErrorsFound = true;
    1181             :                 } else {
    1182             :                     // Verify Curve Object, only legal type is BiQuadratic
    1183         320 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    1184         160 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(I), // Curve index
    1185             :                                                          {2},                                                                  // Valid dimensions
    1186             :                                                          RoutineName,                                                          // Routine name
    1187             :                                                          CurrentModuleObject,                                                  // Object Type
    1188         160 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,           // Object Name
    1189         160 :                                                          cAlphaFields(AlfaFieldIncre));                                        // Field Name
    1190             : 
    1191         160 :                     if (!ErrorsFound) {
    1192         320 :                         CurveVal = CurveValue(
    1193         160 :                             state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(I), RatedInletWetBulbTemp, RatedAmbAirTemp);
    1194         160 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
    1195           0 :                             ShowWarningError(state,
    1196           0 :                                              format("{}{}=\"{}\", curve values",
    1197             :                                                     RoutineName,
    1198             :                                                     CurrentModuleObject,
    1199           0 :                                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1200           0 :                             ShowContinueError(
    1201           0 :                                 state, format("...{} output is not equal to 1.0 (+ or - 10%) at rated conditions.", cAlphaFields(AlfaFieldIncre)));
    1202           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    1203             :                         }
    1204             :                     }
    1205             :                 }
    1206             : 
    1207         160 :                 AlfaFieldIncre = 12 + (I - 1) * 4;
    1208         160 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(I) =
    1209         160 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
    1210         160 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(I) == 0) {
    1211           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
    1212           0 :                         ShowSevereError(state,
    1213           0 :                                         format("{}{}=\"{}\", missing",
    1214             :                                                RoutineName,
    1215             :                                                CurrentModuleObject,
    1216           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1217           0 :                         ShowContinueError(state, format("...required {} is blank.", cAlphaFields(AlfaFieldIncre)));
    1218             :                     } else {
    1219           0 :                         ShowSevereError(state,
    1220           0 :                                         format("{}{}=\"{}\", invalid",
    1221             :                                                RoutineName,
    1222             :                                                CurrentModuleObject,
    1223           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1224           0 :                         ShowContinueError(state, format("...not found {}=\"{}\".", cAlphaFields(AlfaFieldIncre), AlphArray(AlfaFieldIncre)));
    1225             :                     }
    1226           0 :                     ErrorsFound = true;
    1227             :                 } else {
    1228             :                     // Verify Curve Object, only legal type is Quadratic
    1229         320 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    1230         160 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(I), // Curve index
    1231             :                                                          {1},                                                                     // Valid dimensions
    1232             :                                                          RoutineName,                                                             // Routine name
    1233             :                                                          CurrentModuleObject,                                                     // Object Type
    1234         160 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,              // Object Name
    1235         160 :                                                          cAlphaFields(AlfaFieldIncre));                                           // Field Name
    1236             : 
    1237         160 :                     if (!ErrorsFound) {
    1238         160 :                         CurveVal = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(I), 1.0);
    1239         160 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
    1240           0 :                             ShowWarningError(state,
    1241           0 :                                              format("{}{}=\"{}\", curve values",
    1242             :                                                     RoutineName,
    1243             :                                                     CurrentModuleObject,
    1244           0 :                                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1245           0 :                             ShowContinueError(
    1246           0 :                                 state, format("...{} output is not equal to 1.0 (+ or - 10%) at rated conditions.", cAlphaFields(AlfaFieldIncre)));
    1247           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    1248             :                         }
    1249             :                     }
    1250             :                 }
    1251             : 
    1252         160 :                 AlfaFieldIncre = 13 + (I - 1) * 4;
    1253         160 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(I) =
    1254         160 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
    1255         160 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(I) == 0) {
    1256           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
    1257           0 :                         ShowSevereError(state,
    1258           0 :                                         format("{}{}=\"{}\", missing",
    1259             :                                                RoutineName,
    1260             :                                                CurrentModuleObject,
    1261           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1262           0 :                         ShowContinueError(state, format("...required {} is blank.", cAlphaFields(AlfaFieldIncre)));
    1263             :                     } else {
    1264           0 :                         ShowSevereError(state,
    1265           0 :                                         format("{}{}=\"{}\", invalid",
    1266             :                                                RoutineName,
    1267             :                                                CurrentModuleObject,
    1268           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1269           0 :                         ShowContinueError(state, format("...not found {}=\"{}\".", cAlphaFields(AlfaFieldIncre), AlphArray(AlfaFieldIncre)));
    1270             :                     }
    1271           0 :                     ErrorsFound = true;
    1272             :                 } else {
    1273             :                     // Verify Curve Object, only legal type is BiQuadratic
    1274         320 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    1275         160 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(I), // Curve index
    1276             :                                                          {2},                                                                 // Valid dimensions
    1277             :                                                          RoutineName,                                                         // Routine name
    1278             :                                                          CurrentModuleObject,                                                 // Object Type
    1279         160 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,          // Object Name
    1280         160 :                                                          cAlphaFields(AlfaFieldIncre));                                       // Field Name
    1281             : 
    1282         160 :                     if (!ErrorsFound) {
    1283         320 :                         CurveVal = CurveValue(
    1284         160 :                             state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(I), RatedInletWetBulbTemp, RatedAmbAirTemp);
    1285         160 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
    1286           0 :                             ShowWarningError(state,
    1287           0 :                                              format("{}{}=\"{}\", curve values",
    1288             :                                                     RoutineName,
    1289             :                                                     CurrentModuleObject,
    1290           0 :                                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1291           0 :                             ShowContinueError(
    1292           0 :                                 state, format("...{} output is not equal to 1.0 (+ or - 10%) at rated conditions.", cAlphaFields(AlfaFieldIncre)));
    1293           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    1294             :                         }
    1295             :                     }
    1296             :                 }
    1297             : 
    1298         160 :                 AlfaFieldIncre = 14 + (I - 1) * 4;
    1299         160 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(I) =
    1300         160 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
    1301         160 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(I) == 0) {
    1302           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
    1303           0 :                         ShowSevereError(state,
    1304           0 :                                         format("{}{}=\"{}\", missing",
    1305             :                                                RoutineName,
    1306             :                                                CurrentModuleObject,
    1307           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1308           0 :                         ShowContinueError(state, format("...required {} is blank.", cAlphaFields(AlfaFieldIncre)));
    1309             :                     } else {
    1310           0 :                         ShowSevereError(state,
    1311           0 :                                         format("{}{}=\"{}\", invalid",
    1312             :                                                RoutineName,
    1313             :                                                CurrentModuleObject,
    1314           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1315           0 :                         ShowContinueError(state, format("...not found {}=\"{}\".", cAlphaFields(AlfaFieldIncre), AlphArray(AlfaFieldIncre)));
    1316             :                     }
    1317           0 :                     ErrorsFound = true;
    1318             :                 } else {
    1319             :                     // Verify Curve Object, only legal type is Quadratic
    1320         320 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    1321         160 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(I), // Curve index
    1322             :                                                          {1},                                                                    // Valid dimensions
    1323             :                                                          RoutineName,                                                            // Routine name
    1324             :                                                          CurrentModuleObject,                                                    // Object Type
    1325         160 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,             // Object Name
    1326         160 :                                                          cAlphaFields(AlfaFieldIncre));                                          // Field Name
    1327             : 
    1328         160 :                     if (!ErrorsFound) {
    1329         160 :                         CurveVal = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(I), 1.0);
    1330         160 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
    1331           0 :                             ShowWarningError(state,
    1332           0 :                                              format("{}{}=\"{}\", curve values",
    1333             :                                                     RoutineName,
    1334             :                                                     CurrentModuleObject,
    1335           0 :                                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1336           0 :                             ShowContinueError(
    1337           0 :                                 state, format("...{} output is not equal to 1.0 (+ or - 10%) at rated conditions.", cAlphaFields(AlfaFieldIncre)));
    1338           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    1339             :                         }
    1340             :                     }
    1341             :                 }
    1342             :             }
    1343             : 
    1344         182 :             for (I = 1; I <= state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds; ++I) {
    1345         160 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedPercentTotCap(I) =
    1346         160 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I) /
    1347         320 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(
    1348         160 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds);
    1349         160 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowPerRatedTotCap(I) =
    1350         160 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowRate(I) /
    1351         160 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I);
    1352         160 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedEvapCondVolFlowPerRatedTotCap(I) =
    1353         160 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondAirFlow(I) /
    1354         160 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I);
    1355             :             }
    1356             : 
    1357             :             // CurrentModuleObject = "Coil:Cooling:DX:VariableSpeed"
    1358          44 :             SetupOutputVariable(state,
    1359             :                                 "Cooling Coil Electricity Energy",
    1360             :                                 Constant::Units::J,
    1361          22 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Energy,
    1362             :                                 OutputProcessor::TimeStepType::System,
    1363             :                                 OutputProcessor::StoreType::Sum,
    1364          22 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    1365             :                                 Constant::eResource::Electricity,
    1366             :                                 OutputProcessor::Group::HVAC,
    1367             :                                 OutputProcessor::EndUseCat::Cooling);
    1368          44 :             SetupOutputVariable(state,
    1369             :                                 "Cooling Coil Total Cooling Energy",
    1370             :                                 Constant::Units::J,
    1371          22 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLoadTotal,
    1372             :                                 OutputProcessor::TimeStepType::System,
    1373             :                                 OutputProcessor::StoreType::Sum,
    1374          22 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    1375             :                                 Constant::eResource::EnergyTransfer,
    1376             :                                 OutputProcessor::Group::HVAC,
    1377             :                                 OutputProcessor::EndUseCat::CoolingCoils);
    1378          44 :             SetupOutputVariable(state,
    1379             :                                 "Cooling Coil Sensible Cooling Energy",
    1380             :                                 Constant::Units::J,
    1381          22 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergySensible,
    1382             :                                 OutputProcessor::TimeStepType::System,
    1383             :                                 OutputProcessor::StoreType::Sum,
    1384          22 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    1385          44 :             SetupOutputVariable(state,
    1386             :                                 "Cooling Coil Latent Cooling Energy",
    1387             :                                 Constant::Units::J,
    1388          22 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLatent,
    1389             :                                 OutputProcessor::TimeStepType::System,
    1390             :                                 OutputProcessor::StoreType::Sum,
    1391          22 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    1392          44 :             SetupOutputVariable(state,
    1393             :                                 "Cooling Coil Source Side Heat Transfer Energy",
    1394             :                                 Constant::Units::J,
    1395          22 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergySource,
    1396             :                                 OutputProcessor::TimeStepType::System,
    1397             :                                 OutputProcessor::StoreType::Sum,
    1398          22 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    1399             : 
    1400          22 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedCapCoolSens =
    1401             :                 AutoSize; // always auto-sized, to be determined in the sizing calculation
    1402             : 
    1403             :             // BAN Sept 30 2103, CR9322, commented out, now it is redundant, it is reported from sizing routine
    1404             :             // create predefined report entries
    1405             :             // PreDefTableEntry(state,  pdchCoolCoilType, VarSpeedCoil( DXCoilNum ).Name, CurrentModuleObject );
    1406             :             // PreDefTableEntry(state,  pdchCoolCoilTotCap, VarSpeedCoil( DXCoilNum ).Name, VarSpeedCoil( DXCoilNum ).RatedCapCoolTotal );
    1407             :             // PreDefTableEntry(state,  pdchCoolCoilSensCap, VarSpeedCoil( DXCoilNum ).Name, VarSpeedCoil( DXCoilNum ).RatedCapCoolSens );
    1408             :             // PreDefTableEntry(state,  pdchCoolCoilLatCap, VarSpeedCoil( DXCoilNum ).Name, VarSpeedCoil( DXCoilNum ).RatedCapCoolTotal -
    1409             :             // VarSpeedCoil( DXCoilNum ).RatedCapCoolSens );  PreDefTableEntry(state,  pdchCoolCoilSHR, VarSpeedCoil( DXCoilNum ).Name, VarSpeedCoil(
    1410             :             // DXCoilNum
    1411             :             // ).RatedCapCoolSens / VarSpeedCoil( DXCoilNum ).RatedCapCoolTotal );  PreDefTableEntry(state,  pdchCoolCoilNomEff, VarSpeedCoil(
    1412             :             // DXCoilNum
    1413             :             // ).Name, VarSpeedCoil( DXCoilNum ).MSRatedCOP( VarSpeedCoil( DXCoilNum ).NormSpedLevel ) );
    1414             :         }
    1415             : 
    1416             :         //-------------------------AIR SOURCE COOLING---END
    1417             : 
    1418             :         // Get the data for heating coil, WATER SOURCE
    1419          22 :         CurrentModuleObject = "Coil:Heating:WaterToAirHeatPump:VariableSpeedEquationFit";
    1420             : 
    1421          40 :         for (CoilCounter = 1; CoilCounter <= NumHeat; ++CoilCounter) {
    1422             : 
    1423          18 :             ++DXCoilNum;
    1424             : 
    1425          18 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
    1426             :                                                                      CurrentModuleObject,
    1427             :                                                                      CoilCounter,
    1428             :                                                                      AlphArray,
    1429             :                                                                      NumAlphas,
    1430             :                                                                      NumArray,
    1431             :                                                                      NumNums,
    1432             :                                                                      IOStat,
    1433             :                                                                      lNumericBlanks,
    1434             :                                                                      lAlphaBlanks,
    1435             :                                                                      cAlphaFields,
    1436             :                                                                      cNumericFields);
    1437             :             // ErrorsFound will be set to True if problem was found, left untouched otherwise
    1438          18 :             VerifyUniqueCoilName(state, CurrentModuleObject, AlphArray(1), ErrorsFound, CurrentModuleObject + " Name");
    1439             : 
    1440          18 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).bIsDesuperheater = false;
    1441          18 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name = AlphArray(1);
    1442          18 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CoolHeatType = "HEATING";
    1443          18 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType = HVAC::Coil_HeatingWaterToAirHPVSEquationFit; // fix coil type
    1444             : 
    1445          18 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VarSpeedCoilType =
    1446          36 :                 HVAC::cAllCoilTypes(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType);
    1447          18 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds = int(NumArray(1));
    1448          18 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel = int(NumArray(2));
    1449          18 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedCapHeat = NumArray(3);
    1450          18 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedAirVolFlowRate = NumArray(4);
    1451          18 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedWaterVolFlowRate = NumArray(5);
    1452          18 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserType = DataHeatBalance::RefrigCondenserType::Water;
    1453             : 
    1454             :             // Previously set by parent objects, but not user-definable
    1455          18 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MaxONOFFCyclesperHour = 4;
    1456          18 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).LatentCapacityTimeConstant = 0.;
    1457          18 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).FanDelayTime = 0.;
    1458             : 
    1459          18 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterInletNodeNum =
    1460          36 :                 GetOnlySingleNode(state,
    1461          18 :                                   AlphArray(2),
    1462             :                                   ErrorsFound,
    1463             :                                   DataLoopNode::ConnectionObjectType::CoilHeatingWaterToAirHeatPumpVariableSpeedEquationFit,
    1464          18 :                                   AlphArray(1),
    1465             :                                   DataLoopNode::NodeFluidType::Water,
    1466             :                                   DataLoopNode::ConnectionType::Inlet,
    1467             :                                   NodeInputManager::CompFluidStream::Secondary,
    1468             :                                   ObjectIsNotParent);
    1469          18 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterOutletNodeNum =
    1470          36 :                 GetOnlySingleNode(state,
    1471          18 :                                   AlphArray(3),
    1472             :                                   ErrorsFound,
    1473             :                                   DataLoopNode::ConnectionObjectType::CoilHeatingWaterToAirHeatPumpVariableSpeedEquationFit,
    1474          18 :                                   AlphArray(1),
    1475             :                                   DataLoopNode::NodeFluidType::Water,
    1476             :                                   DataLoopNode::ConnectionType::Outlet,
    1477             :                                   NodeInputManager::CompFluidStream::Secondary,
    1478             :                                   ObjectIsNotParent);
    1479          18 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirInletNodeNum =
    1480          36 :                 GetOnlySingleNode(state,
    1481          18 :                                   AlphArray(4),
    1482             :                                   ErrorsFound,
    1483             :                                   DataLoopNode::ConnectionObjectType::CoilHeatingWaterToAirHeatPumpVariableSpeedEquationFit,
    1484          18 :                                   AlphArray(1),
    1485             :                                   DataLoopNode::NodeFluidType::Air,
    1486             :                                   DataLoopNode::ConnectionType::Inlet,
    1487             :                                   NodeInputManager::CompFluidStream::Primary,
    1488             :                                   ObjectIsNotParent);
    1489          18 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirOutletNodeNum =
    1490          36 :                 GetOnlySingleNode(state,
    1491          18 :                                   AlphArray(5),
    1492             :                                   ErrorsFound,
    1493             :                                   DataLoopNode::ConnectionObjectType::CoilHeatingWaterToAirHeatPumpVariableSpeedEquationFit,
    1494          18 :                                   AlphArray(1),
    1495             :                                   DataLoopNode::NodeFluidType::Air,
    1496             :                                   DataLoopNode::ConnectionType::Outlet,
    1497             :                                   NodeInputManager::CompFluidStream::Primary,
    1498             :                                   ObjectIsNotParent);
    1499             : 
    1500          18 :             TestCompSet(state, CurrentModuleObject, AlphArray(1), AlphArray(2), AlphArray(3), "Water Nodes");
    1501          18 :             TestCompSet(state, CurrentModuleObject, AlphArray(1), AlphArray(4), AlphArray(5), "Air Nodes");
    1502             : 
    1503             :             //       If (VarSpeedCoil(DXCoilNum)%NumOfSpeeds .LT. 2) Then
    1504          18 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds < 1) {
    1505           0 :                 ShowSevereError(
    1506             :                     state,
    1507           0 :                     format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1508           0 :                 ShowContinueError(state, format("...{} must be >= 1. entered number is {:.0T}", cNumericFields(1), NumArray(1)));
    1509           0 :                 ErrorsFound = true;
    1510             :             }
    1511             : 
    1512          18 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel >
    1513          18 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds) {
    1514           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel =
    1515           0 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds;
    1516             :             }
    1517             : 
    1518          18 :             if ((state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel >
    1519          36 :                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds) ||
    1520          18 :                 (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel <= 0)) {
    1521           0 :                 ShowSevereError(
    1522             :                     state,
    1523           0 :                     format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1524           0 :                 ShowContinueError(state, format("...{} must be valid speed level entered number is {:.0T}", cNumericFields(2), NumArray(2)));
    1525           0 :                 ErrorsFound = true;
    1526             :             }
    1527             : 
    1528             :             // part load curve
    1529          18 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PLFFPLR = GetCurveIndex(state, AlphArray(6)); // convert curve name to number
    1530          18 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PLFFPLR == 0) {
    1531           0 :                 if (lAlphaBlanks(6)) {
    1532           0 :                     ShowSevereError(
    1533             :                         state,
    1534           0 :                         format("{}{}=\"{}\", missing", RoutineName, CurrentModuleObject, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1535           0 :                     ShowContinueError(state, format("...required {} is blank.", cAlphaFields(6)));
    1536             :                 } else {
    1537           0 :                     ShowSevereError(
    1538             :                         state,
    1539           0 :                         format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1540           0 :                     ShowContinueError(state, format("...not found {}=\"{}\".", cAlphaFields(6), AlphArray(6)));
    1541             :                 }
    1542           0 :                 ErrorsFound = true;
    1543             :             } else {
    1544          18 :                 CurveVal = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PLFFPLR, 1.0);
    1545          18 :                 if (CurveVal > 1.10 || CurveVal < 0.90) {
    1546           0 :                     ShowWarningError(state,
    1547           0 :                                      format("{}{}=\"{}\", curve values",
    1548             :                                             RoutineName,
    1549             :                                             CurrentModuleObject,
    1550           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1551           0 :                     ShowContinueError(state, format("...{} output is not equal to 1.0 (+ or - 10%) at rated conditions.", cAlphaFields(6)));
    1552           0 :                     ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    1553             :                 }
    1554             :             }
    1555             : 
    1556         198 :             for (I = 1; I <= state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds; ++I) {
    1557         180 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I) = NumArray(6 + (I - 1) * 5);
    1558         180 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedCOP(I) = NumArray(7 + (I - 1) * 5);
    1559         180 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowRate(I) = NumArray(8 + (I - 1) * 5);
    1560         180 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterVolFlowRate(I) = NumArray(9 + (I - 1) * 5);
    1561         180 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeatFrac(I) = NumArray(10 + (I - 1) * 5);
    1562             : 
    1563         180 :                 AlfaFieldIncre = 7 + (I - 1) * 7;
    1564         180 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(I) =
    1565         180 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
    1566         180 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(I) == 0) {
    1567           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
    1568           0 :                         ShowSevereError(state,
    1569           0 :                                         format("{}{}=\"{}\", missing",
    1570             :                                                RoutineName,
    1571             :                                                CurrentModuleObject,
    1572           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1573           0 :                         ShowContinueError(state, format("...required {} is blank.", cAlphaFields(AlfaFieldIncre)));
    1574             :                     } else {
    1575           0 :                         ShowSevereError(state,
    1576           0 :                                         format("{}{}=\"{}\", invalid",
    1577             :                                                RoutineName,
    1578             :                                                CurrentModuleObject,
    1579           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1580           0 :                         ShowContinueError(state, format("...not found {}=\"{}\".", cAlphaFields(AlfaFieldIncre), AlphArray(AlfaFieldIncre)));
    1581             :                     }
    1582           0 :                     ErrorsFound = true;
    1583             :                 } else {
    1584             :                     // Verify Curve Object, only legal type is BiQuadratic
    1585         360 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    1586         180 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(I), // Curve index
    1587             :                                                          {2},                                                                  // Valid dimensions
    1588             :                                                          RoutineName,                                                          // Routine name
    1589             :                                                          CurrentModuleObject,                                                  // Object Type
    1590         180 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,           // Object Name
    1591         180 :                                                          cAlphaFields(AlfaFieldIncre));                                        // Field Name
    1592             : 
    1593         180 :                     if (!ErrorsFound) {
    1594         360 :                         CurveVal = CurveValue(state,
    1595         180 :                                               state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(I),
    1596             :                                               RatedInletAirTempHeat,
    1597             :                                               RatedInletWaterTempHeat);
    1598         180 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
    1599           0 :                             ShowWarningError(state,
    1600           0 :                                              format("{}{}=\"{}\", curve values",
    1601             :                                                     RoutineName,
    1602             :                                                     CurrentModuleObject,
    1603           0 :                                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1604           0 :                             ShowContinueError(
    1605           0 :                                 state, format("...{} output is not equal to 1.0 (+ or - 10%) at rated conditions.", cAlphaFields(AlfaFieldIncre)));
    1606           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    1607             :                         }
    1608             :                     }
    1609             :                 }
    1610             : 
    1611         180 :                 AlfaFieldIncre = 8 + (I - 1) * 7;
    1612         180 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(I) =
    1613         180 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
    1614         180 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(I) == 0) {
    1615           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
    1616           0 :                         ShowSevereError(state,
    1617           0 :                                         format("{}{}=\"{}\", missing",
    1618             :                                                RoutineName,
    1619             :                                                CurrentModuleObject,
    1620           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1621           0 :                         ShowContinueError(state, format("...required {} is blank.", cAlphaFields(AlfaFieldIncre)));
    1622             :                     } else {
    1623           0 :                         ShowSevereError(state,
    1624           0 :                                         format("{}{}=\"{}\", invalid",
    1625             :                                                RoutineName,
    1626             :                                                CurrentModuleObject,
    1627           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1628           0 :                         ShowContinueError(state, format("...not found {}=\"{}\".", cAlphaFields(AlfaFieldIncre), AlphArray(AlfaFieldIncre)));
    1629             :                     }
    1630           0 :                     ErrorsFound = true;
    1631             :                 } else {
    1632             :                     // Verify Curve Object, only legal type is Quadratic
    1633         360 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    1634         180 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(I), // Curve index
    1635             :                                                          {1},                                                                     // Valid dimensions
    1636             :                                                          RoutineName,                                                             // Routine name
    1637             :                                                          CurrentModuleObject,                                                     // Object Type
    1638         180 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,              // Object Name
    1639         180 :                                                          cAlphaFields(AlfaFieldIncre));                                           // Field Name
    1640             : 
    1641         180 :                     if (!ErrorsFound) {
    1642         180 :                         CurveVal = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(I), 1.0);
    1643         180 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
    1644           0 :                             ShowWarningError(state,
    1645           0 :                                              format("{}{}=\"{}\", curve values",
    1646             :                                                     RoutineName,
    1647             :                                                     CurrentModuleObject,
    1648           0 :                                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1649           0 :                             ShowContinueError(
    1650           0 :                                 state, format("...{} output is not equal to 1.0 (+ or - 10%) at rated conditions.", cAlphaFields(AlfaFieldIncre)));
    1651           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    1652             :                         }
    1653             :                     }
    1654             :                 }
    1655             : 
    1656         180 :                 AlfaFieldIncre = 9 + (I - 1) * 7;
    1657         180 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(I) =
    1658         180 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
    1659         180 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(I) == 0) {
    1660           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
    1661           0 :                         ShowSevereError(state,
    1662           0 :                                         format("{}{}=\"{}\", missing",
    1663             :                                                RoutineName,
    1664             :                                                CurrentModuleObject,
    1665           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1666           0 :                         ShowContinueError(state, format("...required {} is blank.", cAlphaFields(AlfaFieldIncre)));
    1667             :                     } else {
    1668           0 :                         ShowSevereError(state,
    1669           0 :                                         format("{}{}=\"{}\", invalid",
    1670             :                                                RoutineName,
    1671             :                                                CurrentModuleObject,
    1672           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1673           0 :                         ShowContinueError(state, format("...not found {}=\"{}\".", cAlphaFields(AlfaFieldIncre), AlphArray(AlfaFieldIncre)));
    1674             :                     }
    1675           0 :                     ErrorsFound = true;
    1676             :                 } else {
    1677             :                     // Verify Curve Object, only legal type is Quadratic
    1678         360 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    1679         180 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(I), // Curve index
    1680             :                                                          {1},                                                        // Valid dimensions
    1681             :                                                          RoutineName,                                                // Routine name
    1682             :                                                          CurrentModuleObject,                                        // Object Type
    1683         180 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name, // Object Name
    1684         180 :                                                          cAlphaFields(AlfaFieldIncre));                              // Field Name
    1685             : 
    1686         180 :                     if (!ErrorsFound) {
    1687         180 :                         CurveVal = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(I), 1.0);
    1688         180 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
    1689           0 :                             ShowWarningError(state,
    1690           0 :                                              format("{}{}=\"{}\", curve values",
    1691             :                                                     RoutineName,
    1692             :                                                     CurrentModuleObject,
    1693           0 :                                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1694           0 :                             ShowContinueError(
    1695           0 :                                 state, format("...{} output is not equal to 1.0 (+ or - 10%) at rated conditions.", cAlphaFields(AlfaFieldIncre)));
    1696           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    1697             :                         }
    1698             :                     }
    1699             :                 }
    1700             : 
    1701         180 :                 AlfaFieldIncre = 10 + (I - 1) * 7;
    1702         180 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(I) =
    1703         180 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
    1704         180 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(I) == 0) {
    1705           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
    1706           0 :                         ShowSevereError(state,
    1707           0 :                                         format("{}{}=\"{}\", missing",
    1708             :                                                RoutineName,
    1709             :                                                CurrentModuleObject,
    1710           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1711           0 :                         ShowContinueError(state, format("...required {} is blank.", cAlphaFields(AlfaFieldIncre)));
    1712             :                     } else {
    1713           0 :                         ShowSevereError(state,
    1714           0 :                                         format("{}{}=\"{}\", invalid",
    1715             :                                                RoutineName,
    1716             :                                                CurrentModuleObject,
    1717           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1718           0 :                         ShowContinueError(state, format("...not found {}=\"{}\".", cAlphaFields(AlfaFieldIncre), AlphArray(AlfaFieldIncre)));
    1719             :                     }
    1720           0 :                     ErrorsFound = true;
    1721             :                 } else {
    1722             :                     // Verify Curve Object, only legal type is BiQuadratic
    1723         360 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    1724         180 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(I), // Curve index
    1725             :                                                          {2},                                                                 // Valid dimensions
    1726             :                                                          RoutineName,                                                         // Routine name
    1727             :                                                          CurrentModuleObject,                                                 // Object Type
    1728         180 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,          // Object Name
    1729         180 :                                                          cAlphaFields(AlfaFieldIncre));                                       // Field Name
    1730             : 
    1731         180 :                     if (!ErrorsFound) {
    1732         360 :                         CurveVal = CurveValue(state,
    1733         180 :                                               state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(I),
    1734             :                                               RatedInletAirTempHeat,
    1735             :                                               RatedInletWaterTempHeat);
    1736         180 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
    1737           0 :                             ShowWarningError(state,
    1738           0 :                                              format("{}{}=\"{}\", curve values",
    1739             :                                                     RoutineName,
    1740             :                                                     CurrentModuleObject,
    1741           0 :                                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1742           0 :                             ShowContinueError(
    1743           0 :                                 state, format("...{} output is not equal to 1.0 (+ or - 10%) at rated conditions.", cAlphaFields(AlfaFieldIncre)));
    1744           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    1745             :                         }
    1746             :                     }
    1747             :                 }
    1748             : 
    1749         180 :                 AlfaFieldIncre = 11 + (I - 1) * 7;
    1750         180 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(I) =
    1751         180 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
    1752         180 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(I) == 0) {
    1753           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
    1754           0 :                         ShowSevereError(state,
    1755           0 :                                         format("{}{}=\"{}\", missing",
    1756             :                                                RoutineName,
    1757             :                                                CurrentModuleObject,
    1758           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1759           0 :                         ShowContinueError(state, format("...required {} is blank.", cAlphaFields(AlfaFieldIncre)));
    1760             :                     } else {
    1761           0 :                         ShowSevereError(state,
    1762           0 :                                         format("{}{}=\"{}\", invalid",
    1763             :                                                RoutineName,
    1764             :                                                CurrentModuleObject,
    1765           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1766           0 :                         ShowContinueError(state, format("...not found {}=\"{}\".", cAlphaFields(AlfaFieldIncre), AlphArray(AlfaFieldIncre)));
    1767             :                     }
    1768           0 :                     ErrorsFound = true;
    1769             :                 } else {
    1770             :                     // Verify Curve Object, only legal type is Quadratic
    1771         360 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    1772         180 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(I), // Curve index
    1773             :                                                          {1},                                                                    // Valid dimensions
    1774             :                                                          RoutineName,                                                            // Routine name
    1775             :                                                          CurrentModuleObject,                                                    // Object Type
    1776         180 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,             // Object Name
    1777         180 :                                                          cAlphaFields(AlfaFieldIncre));                                          // Field Name
    1778             : 
    1779         180 :                     if (!ErrorsFound) {
    1780         180 :                         CurveVal = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(I), 1.0);
    1781         180 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
    1782           0 :                             ShowWarningError(state,
    1783           0 :                                              format("{}{}=\"{}\", curve values",
    1784             :                                                     RoutineName,
    1785             :                                                     CurrentModuleObject,
    1786           0 :                                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1787           0 :                             ShowContinueError(
    1788           0 :                                 state, format("...{} output is not equal to 1.0 (+ or - 10%) at rated conditions.", cAlphaFields(AlfaFieldIncre)));
    1789           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    1790             :                         }
    1791             :                     }
    1792             :                 }
    1793             : 
    1794         180 :                 AlfaFieldIncre = 12 + (I - 1) * 7;
    1795         180 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRWaterFFlow(I) =
    1796         180 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
    1797         180 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRWaterFFlow(I) == 0) {
    1798           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
    1799           0 :                         ShowSevereError(state,
    1800           0 :                                         format("{}{}=\"{}\", missing",
    1801             :                                                RoutineName,
    1802             :                                                CurrentModuleObject,
    1803           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1804           0 :                         ShowContinueError(state, format("...required {} is blank.", cAlphaFields(AlfaFieldIncre)));
    1805             :                     } else {
    1806           0 :                         ShowSevereError(state,
    1807           0 :                                         format("{}{}=\"{}\", invalid",
    1808             :                                                RoutineName,
    1809             :                                                CurrentModuleObject,
    1810           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1811           0 :                         ShowContinueError(state, format("...not found {}=\"{}\".", cAlphaFields(AlfaFieldIncre), AlphArray(AlfaFieldIncre)));
    1812             :                     }
    1813           0 :                     ErrorsFound = true;
    1814             :                 } else {
    1815             :                     // Verify Curve Object, only legal type is Quadratic
    1816         360 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    1817         180 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRWaterFFlow(I), // Curve index
    1818             :                                                          {1},                                                                      // Valid dimensions
    1819             :                                                          RoutineName,                                                              // Routine name
    1820             :                                                          CurrentModuleObject,                                                      // Object Type
    1821         180 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,               // Object Name
    1822         180 :                                                          cAlphaFields(AlfaFieldIncre));                                            // Field Name
    1823             : 
    1824         180 :                     if (!ErrorsFound) {
    1825         180 :                         CurveVal = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRWaterFFlow(I), 1.0);
    1826         180 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
    1827           0 :                             ShowWarningError(state,
    1828           0 :                                              format("{}{}=\"{}\", curve values",
    1829             :                                                     RoutineName,
    1830             :                                                     CurrentModuleObject,
    1831           0 :                                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1832           0 :                             ShowContinueError(
    1833           0 :                                 state, format("...{} output is not equal to 1.0 (+ or - 10%) at rated conditions.", cAlphaFields(AlfaFieldIncre)));
    1834           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    1835             :                         }
    1836             :                     }
    1837             :                 }
    1838             : 
    1839         180 :                 AlfaFieldIncre = 13 + (I - 1) * 7;
    1840             :                 // Read waste heat modifier curve name
    1841         180 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeat(I) =
    1842         180 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
    1843         180 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeat(I) == 0) {
    1844           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
    1845           0 :                         ShowSevereError(state,
    1846           0 :                                         format("{}{}=\"{}\", missing",
    1847             :                                                RoutineName,
    1848             :                                                CurrentModuleObject,
    1849           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1850           0 :                         ShowContinueError(state, format("...required {} is blank.", cAlphaFields(AlfaFieldIncre)));
    1851             :                     } else {
    1852           0 :                         ShowSevereError(state,
    1853           0 :                                         format("{}{}=\"{}\", invalid",
    1854             :                                                RoutineName,
    1855             :                                                CurrentModuleObject,
    1856           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1857           0 :                         ShowContinueError(state, format("...not found {}=\"{}\".", cAlphaFields(AlfaFieldIncre), AlphArray(AlfaFieldIncre)));
    1858             :                     }
    1859           0 :                     ErrorsFound = true;
    1860             :                 } else {
    1861             :                     // Verify Curve Object, only legal types are BiQuadratic
    1862         360 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    1863         180 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeat(I), // Curve index
    1864             :                                                          {2},                                                                  // Valid dimensions
    1865             :                                                          RoutineName,                                                          // Routine name
    1866             :                                                          CurrentModuleObject,                                                  // Object Type
    1867         180 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,           // Object Name
    1868         180 :                                                          cAlphaFields(AlfaFieldIncre));                                        // Field Name
    1869             : 
    1870         180 :                     if (!ErrorsFound) {
    1871         360 :                         CurveVal = CurveValue(state,
    1872         180 :                                               state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeat(I),
    1873             :                                               RatedInletAirTempHeat,
    1874             :                                               RatedInletWaterTempHeat);
    1875         180 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
    1876           0 :                             ShowWarningError(state,
    1877           0 :                                              format("{}{}=\"{}\", curve values",
    1878             :                                                     RoutineName,
    1879             :                                                     CurrentModuleObject,
    1880           0 :                                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    1881           0 :                             ShowContinueError(
    1882           0 :                                 state, format("...{} output is not equal to 1.0 (+ or - 10%) at rated conditions.", cAlphaFields(AlfaFieldIncre)));
    1883           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    1884             :                         }
    1885             :                     }
    1886             :                 }
    1887             :             }
    1888             : 
    1889         198 :             for (I = 1; I <= state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds; ++I) {
    1890         180 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedPercentTotCap(I) =
    1891         180 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I) /
    1892         360 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(
    1893         180 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds);
    1894         180 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowPerRatedTotCap(I) =
    1895         180 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowRate(I) /
    1896         180 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I);
    1897         180 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterVolFlowPerRatedTotCap(I) =
    1898         180 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterVolFlowRate(I) /
    1899         180 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I);
    1900             :             }
    1901             : 
    1902             :             // CurrentModuleObject = "Coil:Heating:WaterToAirHeatPump:VariableSpeedEquationFit"
    1903          36 :             SetupOutputVariable(state,
    1904             :                                 "Heating Coil Electricity Energy",
    1905             :                                 Constant::Units::J,
    1906          18 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Energy,
    1907             :                                 OutputProcessor::TimeStepType::System,
    1908             :                                 OutputProcessor::StoreType::Sum,
    1909          18 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    1910             :                                 Constant::eResource::Electricity,
    1911             :                                 OutputProcessor::Group::HVAC,
    1912             :                                 OutputProcessor::EndUseCat::Heating);
    1913          36 :             SetupOutputVariable(state,
    1914             :                                 "Heating Coil Heating Energy",
    1915             :                                 Constant::Units::J,
    1916          18 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLoadTotal,
    1917             :                                 OutputProcessor::TimeStepType::System,
    1918             :                                 OutputProcessor::StoreType::Sum,
    1919          18 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    1920             :                                 Constant::eResource::EnergyTransfer,
    1921             :                                 OutputProcessor::Group::HVAC,
    1922             :                                 OutputProcessor::EndUseCat::HeatingCoils);
    1923          36 :             SetupOutputVariable(state,
    1924             :                                 "Heating Coil Source Side Heat Transfer Energy",
    1925             :                                 Constant::Units::J,
    1926          18 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergySource,
    1927             :                                 OutputProcessor::TimeStepType::System,
    1928             :                                 OutputProcessor::StoreType::Sum,
    1929          18 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    1930             :                                 Constant::eResource::PlantLoopHeatingDemand,
    1931             :                                 OutputProcessor::Group::HVAC,
    1932             :                                 OutputProcessor::EndUseCat::HeatingCoils);
    1933             : 
    1934             :             // create predefined report entries
    1935          36 :             PreDefTableEntry(
    1936          18 :                 state, state.dataOutRptPredefined->pdchHeatCoilType, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name, CurrentModuleObject);
    1937          36 :             PreDefTableEntry(state,
    1938          18 :                              state.dataOutRptPredefined->pdchHeatCoilNomCap,
    1939          18 :                              state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    1940          18 :                              state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedCapHeat);
    1941          36 :             PreDefTableEntry(state,
    1942          18 :                              state.dataOutRptPredefined->pdchHeatCoilNomEff,
    1943          18 :                              state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    1944          36 :                              state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedCOP(
    1945          18 :                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel));
    1946             :         }
    1947             : 
    1948             :         //-------------------------AIR SOURCE, HEATING---BEGIN
    1949             :         // Get the data for heating coil, AIR SOURCE
    1950          22 :         CurrentModuleObject = "COIL:HEATING:DX:VARIABLESPEED";
    1951             : 
    1952          31 :         for (CoilCounter = 1; CoilCounter <= NumHeatAS; ++CoilCounter) {
    1953             : 
    1954           9 :             ++DXCoilNum;
    1955             : 
    1956           9 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
    1957             :                                                                      CurrentModuleObject,
    1958             :                                                                      CoilCounter,
    1959             :                                                                      AlphArray,
    1960             :                                                                      NumAlphas,
    1961             :                                                                      NumArray,
    1962             :                                                                      NumNums,
    1963             :                                                                      IOStat,
    1964             :                                                                      lNumericBlanks,
    1965             :                                                                      lAlphaBlanks,
    1966             :                                                                      cAlphaFields,
    1967             :                                                                      cNumericFields);
    1968             :             // ErrorsFound will be set to True if problem was found, left untouched otherwise
    1969           9 :             VerifyUniqueCoilName(state, CurrentModuleObject, AlphArray(1), ErrorsFound, CurrentModuleObject + " Name");
    1970             : 
    1971           9 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).bIsDesuperheater = false;
    1972           9 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name = AlphArray(1);
    1973           9 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CoolHeatType = "HEATING";
    1974           9 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType = HVAC::Coil_HeatingAirToAirVariableSpeed;
    1975           9 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VarSpeedCoilType = HVAC::cAllCoilTypes(HVAC::Coil_HeatingAirToAirVariableSpeed);
    1976           9 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds = int(NumArray(1));
    1977           9 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel = int(NumArray(2));
    1978           9 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedCapHeat = NumArray(3);
    1979           9 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedAirVolFlowRate = NumArray(4);
    1980             : 
    1981             :             // Previously set by parent objects, but not user-definable
    1982           9 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MaxONOFFCyclesperHour = 4;
    1983           9 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).LatentCapacityTimeConstant = 0.;
    1984           9 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).FanDelayTime = 0.;
    1985             : 
    1986           9 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirInletNodeNum =
    1987          18 :                 GetOnlySingleNode(state,
    1988           9 :                                   AlphArray(2),
    1989             :                                   ErrorsFound,
    1990             :                                   DataLoopNode::ConnectionObjectType::CoilHeatingDXVariableSpeed,
    1991           9 :                                   AlphArray(1),
    1992             :                                   DataLoopNode::NodeFluidType::Air,
    1993             :                                   DataLoopNode::ConnectionType::Inlet,
    1994             :                                   NodeInputManager::CompFluidStream::Primary,
    1995             :                                   ObjectIsNotParent);
    1996           9 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirOutletNodeNum =
    1997          18 :                 GetOnlySingleNode(state,
    1998           9 :                                   AlphArray(3),
    1999             :                                   ErrorsFound,
    2000             :                                   DataLoopNode::ConnectionObjectType::CoilHeatingDXVariableSpeed,
    2001           9 :                                   AlphArray(1),
    2002             :                                   DataLoopNode::NodeFluidType::Air,
    2003             :                                   DataLoopNode::ConnectionType::Outlet,
    2004             :                                   NodeInputManager::CompFluidStream::Primary,
    2005             :                                   ObjectIsNotParent);
    2006             : 
    2007           9 :             TestCompSet(state, CurrentModuleObject, AlphArray(1), AlphArray(2), AlphArray(3), "Air Nodes");
    2008             : 
    2009           9 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds < 1) {
    2010           0 :                 ShowSevereError(
    2011             :                     state,
    2012           0 :                     format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2013           0 :                 ShowContinueError(state, format("...{} must be >= 1. entered number is {:.0T}", cNumericFields(1), NumArray(1)));
    2014           0 :                 ErrorsFound = true;
    2015             :             }
    2016             : 
    2017           9 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel >
    2018           9 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds) {
    2019           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel =
    2020           0 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds;
    2021             :             }
    2022             : 
    2023           9 :             if ((state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel >
    2024          18 :                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds) ||
    2025           9 :                 (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel <= 0)) {
    2026           0 :                 ShowSevereError(
    2027             :                     state,
    2028           0 :                     format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2029           0 :                 ShowContinueError(state, format("...{} must be valid speed level entered number is {:.0T}", cNumericFields(2), NumArray(2)));
    2030           0 :                 ErrorsFound = true;
    2031             :             }
    2032             : 
    2033             :             // part load curve
    2034           9 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PLFFPLR = GetCurveIndex(state, AlphArray(4)); // convert curve name to number
    2035           9 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PLFFPLR == 0) {
    2036           0 :                 if (lAlphaBlanks(4)) {
    2037           0 :                     ShowSevereError(
    2038             :                         state,
    2039           0 :                         format("{}{}=\"{}\", missing", RoutineName, CurrentModuleObject, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2040           0 :                     ShowContinueError(state, format("...required {} is blank.", cAlphaFields(4)));
    2041             :                 } else {
    2042           0 :                     ShowSevereError(
    2043             :                         state,
    2044           0 :                         format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2045           0 :                     ShowContinueError(state, format("...not found {}=\"{}\".", cAlphaFields(4), AlphArray(4)));
    2046             :                 }
    2047           0 :                 ErrorsFound = true;
    2048             :             } else {
    2049           9 :                 CurveVal = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PLFFPLR, 1.0);
    2050           9 :                 if (CurveVal > 1.10 || CurveVal < 0.90) {
    2051           0 :                     ShowWarningError(state,
    2052           0 :                                      format("{}{}=\"{}\", curve values",
    2053             :                                             RoutineName,
    2054             :                                             CurrentModuleObject,
    2055           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2056           0 :                     ShowContinueError(state, format("...{} output is not equal to 1.0 (+ or - 10%) at rated conditions.", cAlphaFields(4)));
    2057           0 :                     ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    2058             :                 }
    2059             :             }
    2060             : 
    2061           9 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostEIRFT = GetCurveIndex(state, AlphArray(5)); // convert curve name to number
    2062             : 
    2063           9 :             if (!lAlphaBlanks(6)) {
    2064           1 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterCapacityCurveIndex = Curve::GetCurveIndex(state, AlphArray(6));
    2065           1 :                 ErrorsFound |=
    2066           2 :                     Curve::CheckCurveDims(state,
    2067           1 :                                           state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterCapacityCurveIndex, // Curve index
    2068             :                                           {1},                                                                                     // Valid dimensions
    2069             :                                           RoutineName,                                                                             // Routine name
    2070             :                                           CurrentModuleObject,                                                                     // Object Type
    2071           1 :                                           state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,                              // Object Name
    2072           1 :                                           cAlphaFields(6));                                                                        // Field Name
    2073             :             }
    2074             : 
    2075           9 :             if (Util::SameString(AlphArray(7), "ReverseCycle")) {
    2076           0 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostEIRFT == 0) {
    2077           0 :                     if (lAlphaBlanks(5)) {
    2078           0 :                         ShowSevereError(state,
    2079           0 :                                         format("{}{}=\"{}\", missing",
    2080             :                                                RoutineName,
    2081             :                                                CurrentModuleObject,
    2082           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2083           0 :                         ShowContinueError(state, format("...required {} is blank.", cAlphaFields(5)));
    2084           0 :                         ShowContinueError(state, format("...field is required because {} is \"ReverseCycle\".", cAlphaFields(7)));
    2085             :                     } else {
    2086           0 :                         ShowSevereError(state,
    2087           0 :                                         format("{}{}=\"{}\", invalid",
    2088             :                                                RoutineName,
    2089             :                                                CurrentModuleObject,
    2090           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2091           0 :                         ShowContinueError(state, format("...not found {}=\"{}\".", cAlphaFields(5), AlphArray(5)));
    2092             :                     }
    2093           0 :                     ErrorsFound = true;
    2094             :                 } else {
    2095             :                     // Verify Curve Object, only legal type is BiQuadratic
    2096           0 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    2097           0 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostEIRFT, // Curve index
    2098             :                                                          {2},                                                                // Valid dimensions
    2099             :                                                          RoutineName,                                                        // Routine name
    2100             :                                                          CurrentModuleObject,                                                // Object Type
    2101           0 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,         // Object Name
    2102           0 :                                                          cAlphaFields(AlfaFieldIncre));                                      // Field Name
    2103             :                 }
    2104             :             }
    2105             : 
    2106           9 :             if (Util::SameString(AlphArray(7), "ReverseCycle")) state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostStrategy = ReverseCycle;
    2107           9 :             if (Util::SameString(AlphArray(7), "Resistive")) state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostStrategy = Resistive;
    2108           9 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostStrategy == 0) {
    2109           0 :                 ShowSevereError(
    2110             :                     state,
    2111           0 :                     format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2112           0 :                 ShowContinueError(state, format("...illegal {}=\"{}\".", cAlphaFields(7), AlphArray(7)));
    2113           0 :                 ShowContinueError(state, "...valid values for this field are ReverseCycle or Resistive.");
    2114           0 :                 ErrorsFound = true;
    2115             :             }
    2116             : 
    2117           9 :             if (Util::SameString(AlphArray(8), "Timed")) state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostControl = Timed;
    2118           9 :             if (Util::SameString(AlphArray(8), "OnDemand")) state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostControl = OnDemand;
    2119           9 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostControl == 0) {
    2120           0 :                 ShowSevereError(
    2121             :                     state,
    2122           0 :                     format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2123           0 :                 ShowContinueError(state, format("...illegal {}=\"{}\".", cAlphaFields(8), AlphArray(8)));
    2124           0 :                 ShowContinueError(state, "...valid values for this field are Timed or OnDemand.");
    2125           0 :                 ErrorsFound = true;
    2126             :             }
    2127             : 
    2128             :             // Set minimum OAT for heat pump compressor operation
    2129           9 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MinOATCompressor = NumArray(5);
    2130             : 
    2131             :             // reserved for HSPF calculation
    2132           9 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OATempCompressorOn = NumArray(6);
    2133             : 
    2134             :             // Set maximum outdoor temp for defrost to occur
    2135           9 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MaxOATDefrost = NumArray(7);
    2136             : 
    2137             :             // Set crankcase heater capacity
    2138           9 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterCapacity = NumArray(8);
    2139           9 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterCapacity < 0.0) {
    2140           0 :                 ShowSevereError(
    2141             :                     state,
    2142           0 :                     format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2143           0 :                 ShowContinueError(state, format("...{} cannot be < 0.0.", cNumericFields(9)));
    2144           0 :                 ShowContinueError(state, format("...entered value=[{:.2T}].", NumArray(9)));
    2145           0 :                 ErrorsFound = true;
    2146             :             }
    2147             : 
    2148             :             // Set crankcase heater cutout temperature
    2149           9 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MaxOATCrankcaseHeater = NumArray(9);
    2150             : 
    2151             :             // Set defrost time period
    2152           9 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostTime = NumArray(10);
    2153           9 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostTime == 0.0 &&
    2154           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostControl == 1) {
    2155           0 :                 ShowWarningError(
    2156           0 :                     state, format("{}{}=\"{}\", ", RoutineName, CurrentModuleObject, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2157           0 :                 ShowContinueError(state, format("...{} = 0.0 for defrost control = TIMED.", cNumericFields(5)));
    2158             :             }
    2159             : 
    2160             :             // Set defrost capacity (for resistive defrost)
    2161           9 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostCapacity = NumArray(11);
    2162           9 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostCapacity == 0.0 &&
    2163           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostStrategy == 2) {
    2164           0 :                 ShowWarningError(
    2165           0 :                     state, format("{}{}=\"{}\", ", RoutineName, CurrentModuleObject, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2166           0 :                 ShowContinueError(state, format("...{} = 0.0 for defrost strategy = RESISTIVE.", cNumericFields(6)));
    2167             :             }
    2168             : 
    2169          89 :             for (I = 1; I <= state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds; ++I) {
    2170          80 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I) = NumArray(12 + (I - 1) * 5);
    2171          80 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedCOP(I) = NumArray(13 + (I - 1) * 5);
    2172          80 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowRate(I) = NumArray(14 + (I - 1) * 5);
    2173          80 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedEvaporatorFanPowerPerVolumeFlowRate2017(I) = NumArray(15 + (I - 1) * 5);
    2174          80 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedEvaporatorFanPowerPerVolumeFlowRate2023(I) = NumArray(16 + (I - 1) * 5);
    2175             : 
    2176          80 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I) < 1.e-10) {
    2177           0 :                     ShowSevereError(state,
    2178           0 :                                     format("{}{}=\"{}\", invalid value",
    2179             :                                            RoutineName,
    2180             :                                            CurrentModuleObject,
    2181           0 :                                            state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2182           0 :                     ShowContinueError(state,
    2183           0 :                                       format("...too small {}=[{:.2R}].",
    2184           0 :                                              cNumericFields(12 + (I - 1) * 3),
    2185           0 :                                              state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I)));
    2186           0 :                     ErrorsFound = true;
    2187             :                 }
    2188             : 
    2189          80 :                 AlfaFieldIncre = 9 + (I - 1) * 4;
    2190          80 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(I) =
    2191          80 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
    2192          80 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(I) == 0) {
    2193           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
    2194           0 :                         ShowSevereError(state,
    2195           0 :                                         format("{}{}=\"{}\", missing",
    2196             :                                                RoutineName,
    2197             :                                                CurrentModuleObject,
    2198           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2199           0 :                         ShowContinueError(state, format("...required {} is blank.", cAlphaFields(AlfaFieldIncre)));
    2200             :                     } else {
    2201           0 :                         ShowSevereError(state,
    2202           0 :                                         format("{}{}=\"{}\", invalid",
    2203             :                                                RoutineName,
    2204             :                                                CurrentModuleObject,
    2205           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2206           0 :                         ShowContinueError(state, format("...not found {}=\"{}\".", cAlphaFields(AlfaFieldIncre), AlphArray(AlfaFieldIncre)));
    2207             :                     }
    2208           0 :                     ErrorsFound = true;
    2209             :                 } else {
    2210             :                     // Verify Curve Object, only legal type is BiQuadratic
    2211         160 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    2212          80 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(I), // Curve index
    2213             :                                                          {2},                                                                  // Valid dimensions
    2214             :                                                          RoutineName,                                                          // Routine name
    2215             :                                                          CurrentModuleObject,                                                  // Object Type
    2216          80 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,           // Object Name
    2217          80 :                                                          cAlphaFields(AlfaFieldIncre));                                        // Field Name
    2218             : 
    2219          80 :                     if (!ErrorsFound) {
    2220         160 :                         CurveVal = CurveValue(
    2221          80 :                             state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(I), RatedInletAirTempHeat, RatedAmbAirTempHeat);
    2222          80 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
    2223           0 :                             ShowWarningError(state,
    2224           0 :                                              format("{}{}=\"{}\", curve values",
    2225             :                                                     RoutineName,
    2226             :                                                     CurrentModuleObject,
    2227           0 :                                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2228           0 :                             ShowContinueError(
    2229           0 :                                 state, format("...{} output is not equal to 1.0 (+ or - 10%) at rated conditions.", cAlphaFields(AlfaFieldIncre)));
    2230           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    2231             :                         }
    2232             :                     }
    2233             :                 }
    2234             : 
    2235          80 :                 AlfaFieldIncre = 10 + (I - 1) * 4;
    2236          80 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(I) =
    2237          80 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
    2238          80 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(I) == 0) {
    2239           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
    2240           0 :                         ShowSevereError(state,
    2241           0 :                                         format("{}{}=\"{}\", missing",
    2242             :                                                RoutineName,
    2243             :                                                CurrentModuleObject,
    2244           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2245           0 :                         ShowContinueError(state, format("...required {} is blank.", cAlphaFields(AlfaFieldIncre)));
    2246             :                     } else {
    2247           0 :                         ShowSevereError(state,
    2248           0 :                                         format("{}{}=\"{}\", invalid",
    2249             :                                                RoutineName,
    2250             :                                                CurrentModuleObject,
    2251           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2252           0 :                         ShowContinueError(state, format("...not found {}=\"{}\".", cAlphaFields(AlfaFieldIncre), AlphArray(AlfaFieldIncre)));
    2253             :                     }
    2254           0 :                     ErrorsFound = true;
    2255             :                 } else {
    2256             :                     // Verify Curve Object, only legal type is Quadratic
    2257         160 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    2258          80 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(I), // Curve index
    2259             :                                                          {1},                                                                     // Valid dimensions
    2260             :                                                          RoutineName,                                                             // Routine name
    2261             :                                                          CurrentModuleObject,                                                     // Object Type
    2262          80 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,              // Object Name
    2263          80 :                                                          cAlphaFields(AlfaFieldIncre));                                           // Field Name
    2264             : 
    2265          80 :                     if (!ErrorsFound) {
    2266          80 :                         CurveVal = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(I), 1.0);
    2267          80 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
    2268           0 :                             ShowWarningError(state,
    2269           0 :                                              format("{}{}=\"{}\", curve values",
    2270             :                                                     RoutineName,
    2271             :                                                     CurrentModuleObject,
    2272           0 :                                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2273           0 :                             ShowContinueError(
    2274           0 :                                 state, format("...{} output is not equal to 1.0 (+ or - 10%) at rated conditions.", cAlphaFields(AlfaFieldIncre)));
    2275           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    2276             :                         }
    2277             :                     }
    2278             :                 }
    2279             : 
    2280          80 :                 AlfaFieldIncre = 11 + (I - 1) * 4;
    2281          80 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(I) =
    2282          80 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
    2283          80 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(I) == 0) {
    2284           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
    2285           0 :                         ShowSevereError(state,
    2286           0 :                                         format("{}{}=\"{}\", missing",
    2287             :                                                RoutineName,
    2288             :                                                CurrentModuleObject,
    2289           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2290           0 :                         ShowContinueError(state, format("...required {} is blank.", cAlphaFields(AlfaFieldIncre)));
    2291             :                     } else {
    2292           0 :                         ShowSevereError(state,
    2293           0 :                                         format("{}{}=\"{}\", invalid",
    2294             :                                                RoutineName,
    2295             :                                                CurrentModuleObject,
    2296           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2297           0 :                         ShowContinueError(state, format("...not found {}=\"{}\".", cAlphaFields(AlfaFieldIncre), AlphArray(AlfaFieldIncre)));
    2298             :                     }
    2299           0 :                     ErrorsFound = true;
    2300             :                 } else {
    2301             :                     // Verify Curve Object, only legal type is BiQuadratic
    2302         160 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    2303          80 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(I), // Curve index
    2304             :                                                          {2},                                                                 // Valid dimensions
    2305             :                                                          RoutineName,                                                         // Routine name
    2306             :                                                          CurrentModuleObject,                                                 // Object Type
    2307          80 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,          // Object Name
    2308          80 :                                                          cAlphaFields(AlfaFieldIncre));                                       // Field Name
    2309             : 
    2310          80 :                     if (!ErrorsFound) {
    2311         160 :                         CurveVal = CurveValue(
    2312          80 :                             state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(I), RatedInletAirTempHeat, RatedAmbAirTempHeat);
    2313          80 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
    2314           0 :                             ShowWarningError(state,
    2315           0 :                                              format("{}{}=\"{}\", curve values",
    2316             :                                                     RoutineName,
    2317             :                                                     CurrentModuleObject,
    2318           0 :                                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2319           0 :                             ShowContinueError(
    2320           0 :                                 state, format("...{} output is not equal to 1.0 (+ or - 10%) at rated conditions.", cAlphaFields(AlfaFieldIncre)));
    2321           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    2322             :                         }
    2323             :                     }
    2324             :                 }
    2325             : 
    2326          80 :                 AlfaFieldIncre = 12 + (I - 1) * 4;
    2327          80 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(I) =
    2328          80 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
    2329          80 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(I) == 0) {
    2330           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
    2331           0 :                         ShowSevereError(state,
    2332           0 :                                         format("{}{}=\"{}\", missing",
    2333             :                                                RoutineName,
    2334             :                                                CurrentModuleObject,
    2335           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2336           0 :                         ShowContinueError(state, format("...required {} is blank.", cAlphaFields(AlfaFieldIncre)));
    2337             :                     } else {
    2338           0 :                         ShowSevereError(state,
    2339           0 :                                         format("{}{}=\"{}\", invalid",
    2340             :                                                RoutineName,
    2341             :                                                CurrentModuleObject,
    2342           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2343           0 :                         ShowContinueError(state, format("...not found {}=\"{}\".", cAlphaFields(AlfaFieldIncre), AlphArray(AlfaFieldIncre)));
    2344             :                     }
    2345           0 :                     ErrorsFound = true;
    2346             :                 } else {
    2347             :                     // Verify Curve Object, only legal type is Quadratic
    2348         160 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    2349          80 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(I), // Curve index
    2350             :                                                          {1},                                                                    // Valid dimensions
    2351             :                                                          RoutineName,                                                            // Routine name
    2352             :                                                          CurrentModuleObject,                                                    // Object Type
    2353          80 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,             // Object Name
    2354          80 :                                                          cAlphaFields(AlfaFieldIncre));                                          // Field Name
    2355             : 
    2356          80 :                     if (!ErrorsFound) {
    2357          80 :                         CurveVal = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(I), 1.0);
    2358          80 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
    2359           0 :                             ShowWarningError(state,
    2360           0 :                                              format("{}{}=\"{}\", curve values",
    2361             :                                                     RoutineName,
    2362             :                                                     CurrentModuleObject,
    2363           0 :                                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2364           0 :                             ShowContinueError(
    2365           0 :                                 state, format("...{} output is not equal to 1.0 (+ or - 10%) at rated conditions.", cAlphaFields(AlfaFieldIncre)));
    2366           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    2367             :                         }
    2368             :                     }
    2369             :                 }
    2370             :             }
    2371             : 
    2372           9 :             if (ErrorsFound) continue;
    2373             : 
    2374          89 :             for (I = 1; I <= state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds; ++I) {
    2375          80 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedPercentTotCap(I) =
    2376          80 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I) /
    2377         160 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(
    2378          80 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds);
    2379          80 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowPerRatedTotCap(I) =
    2380          80 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowRate(I) /
    2381          80 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I);
    2382             :             }
    2383             : 
    2384             :             // CurrentModuleObject = "Coil:Heating:DX:Variablespeed "
    2385          18 :             SetupOutputVariable(state,
    2386             :                                 "Heating Coil Electricity Energy",
    2387             :                                 Constant::Units::J,
    2388           9 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Energy,
    2389             :                                 OutputProcessor::TimeStepType::System,
    2390             :                                 OutputProcessor::StoreType::Sum,
    2391           9 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    2392             :                                 Constant::eResource::Electricity,
    2393             :                                 OutputProcessor::Group::HVAC,
    2394             :                                 OutputProcessor::EndUseCat::Heating);
    2395          18 :             SetupOutputVariable(state,
    2396             :                                 "Heating Coil Heating Energy",
    2397             :                                 Constant::Units::J,
    2398           9 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLoadTotal,
    2399             :                                 OutputProcessor::TimeStepType::System,
    2400             :                                 OutputProcessor::StoreType::Sum,
    2401           9 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    2402             :                                 Constant::eResource::EnergyTransfer,
    2403             :                                 OutputProcessor::Group::HVAC,
    2404             :                                 OutputProcessor::EndUseCat::HeatingCoils);
    2405          18 :             SetupOutputVariable(state,
    2406             :                                 "Heating Coil Source Side Heat Transfer Energy",
    2407             :                                 Constant::Units::J,
    2408           9 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergySource,
    2409             :                                 OutputProcessor::TimeStepType::System,
    2410             :                                 OutputProcessor::StoreType::Sum,
    2411           9 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    2412             : 
    2413             :             // create predefined report entries
    2414          18 :             PreDefTableEntry(
    2415           9 :                 state, state.dataOutRptPredefined->pdchHeatCoilType, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name, CurrentModuleObject);
    2416          18 :             PreDefTableEntry(state,
    2417           9 :                              state.dataOutRptPredefined->pdchHeatCoilNomCap,
    2418           9 :                              state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    2419           9 :                              state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedCapHeat);
    2420          18 :             PreDefTableEntry(state,
    2421           9 :                              state.dataOutRptPredefined->pdchHeatCoilNomEff,
    2422           9 :                              state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    2423          18 :                              state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedCOP(
    2424           9 :                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel));
    2425             :         }
    2426             : 
    2427             :         //-------------------------AIR SOURCE HEATING---END
    2428             : 
    2429             :         //------------------------VARIABLE-SPEED AIR SOURCE HPWH---BEGIN
    2430          22 :         CurrentModuleObject = "COIL:WATERHEATING:AIRTOWATERHEATPUMP:VARIABLESPEED"; // for reporting
    2431             : 
    2432          32 :         for (CoilCounter = 1; CoilCounter <= NumHPWHAirToWater; ++CoilCounter) {
    2433             : 
    2434          10 :             ++DXCoilNum;
    2435          10 :             AlfaFieldIncre = 1;
    2436             : 
    2437          10 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
    2438             :                                                                      CurrentModuleObject,
    2439             :                                                                      CoilCounter,
    2440             :                                                                      AlphArray,
    2441             :                                                                      NumAlphas,
    2442             :                                                                      NumArray,
    2443             :                                                                      NumNums,
    2444             :                                                                      IOStat,
    2445             :                                                                      lNumericBlanks,
    2446             :                                                                      lAlphaBlanks,
    2447             :                                                                      cAlphaFields,
    2448             :                                                                      cNumericFields);
    2449             :             // ErrorsFound will be set to True if problem was found, left untouched otherwise
    2450          10 :             VerifyUniqueCoilName(state, CurrentModuleObject, AlphArray(1), ErrorsFound, CurrentModuleObject + " Name");
    2451             : 
    2452          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).bIsDesuperheater = false;
    2453          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserType = DataHeatBalance::RefrigCondenserType::WaterHeater;
    2454          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CoolHeatType = "WATERHEATING";
    2455          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType = HVAC::CoilDX_HeatPumpWaterHeaterVariableSpeed;
    2456          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VarSpeedCoilType =
    2457          20 :                 HVAC::cAllCoilTypes(HVAC::CoilDX_HeatPumpWaterHeaterVariableSpeed);
    2458             : 
    2459          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name = AlphArray(1);
    2460          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds = int(NumArray(1));
    2461          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel = int(NumArray(2));
    2462             : 
    2463          10 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds < 1) {
    2464           0 :                 ShowSevereError(
    2465             :                     state,
    2466           0 :                     format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2467           0 :                 ShowContinueError(state, format("...{} must be >= 1. entered number is {:.0T}", cNumericFields(1), NumArray(1)));
    2468           0 :                 ErrorsFound = true;
    2469             :             }
    2470             : 
    2471          10 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel >
    2472          10 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds) {
    2473           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel =
    2474           0 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds;
    2475             :             }
    2476             : 
    2477          10 :             if ((state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel >
    2478          20 :                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds) ||
    2479          10 :                 (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel <= 0)) {
    2480           0 :                 ShowSevereError(
    2481             :                     state,
    2482           0 :                     format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2483           0 :                 ShowContinueError(state, format("...{} must be valid speed level entered number is {:.0T}", cNumericFields(2), NumArray(2)));
    2484           0 :                 ErrorsFound = true;
    2485             :             }
    2486             : 
    2487          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedCapWH = NumArray(3);
    2488          10 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedCapWH <= 0.0) {
    2489           0 :                 ShowSevereError(
    2490             :                     state,
    2491           0 :                     format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2492           0 :                 ShowContinueError(state, format("...{} must be > 0.0, entered value=[{:.2T}].", cNumericFields(3), NumArray(3)));
    2493           0 :                 ErrorsFound = true;
    2494             :             }
    2495             : 
    2496          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WHRatedInletDBTemp = NumArray(4);
    2497          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WHRatedInletWBTemp = NumArray(5);
    2498          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WHRatedInletWaterTemp = NumArray(6);
    2499             : 
    2500          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedAirVolFlowRate = NumArray(7);
    2501          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedWaterVolFlowRate = NumArray(8);
    2502             : 
    2503          10 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedAirVolFlowRate != Constant::AutoCalculate) {
    2504           6 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedAirVolFlowRate <= 0.0) {
    2505           0 :                     ShowSevereError(
    2506             :                         state,
    2507           0 :                         format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2508           0 :                     ShowContinueError(state, format("...{} must be > 0.0.  entered value=[{:.3T}].", cNumericFields(7), NumArray(7)));
    2509           0 :                     ErrorsFound = true;
    2510             :                 }
    2511             :             }
    2512             : 
    2513          10 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedWaterVolFlowRate != Constant::AutoCalculate) {
    2514           6 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedWaterVolFlowRate <= 0.0) {
    2515           0 :                     ShowSevereError(
    2516             :                         state,
    2517           0 :                         format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2518           0 :                     ShowContinueError(state, format("...{} must be > 0.0  entered value=[{:.3T}].", cNumericFields(8), NumArray(8)));
    2519           0 :                     ErrorsFound = true;
    2520             :                 }
    2521             :             }
    2522             : 
    2523          10 :             if (Util::SameString(AlphArray(2), "Yes") || Util::SameString(AlphArray(2), "No")) {
    2524             :                 //  initialized to TRUE on allocate
    2525          10 :                 if (Util::SameString(AlphArray(2), "No"))
    2526           9 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).FanPowerIncludedInCOP = false;
    2527             :                 else
    2528           1 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).FanPowerIncludedInCOP = true;
    2529             :             } else {
    2530           0 :                 ShowSevereError(
    2531             :                     state,
    2532           0 :                     format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2533           0 :                 ShowContinueError(state, format(",,,invalid choice for {}.  Entered choice = {}", cAlphaFields(2), AlphArray(2)));
    2534           0 :                 ShowContinueError(state, "Valid choices are Yes or No.");
    2535           0 :                 ErrorsFound = true;
    2536             :             }
    2537             : 
    2538          10 :             if (Util::SameString(AlphArray(3), "Yes") || Util::SameString(AlphArray(3), "No")) {
    2539             :                 //  initialized to FALSE on allocate
    2540          10 :                 if (Util::SameString(AlphArray(3), "Yes"))
    2541           0 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondPumpPowerInCOP = true;
    2542             :                 else
    2543          10 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondPumpPowerInCOP = false;
    2544             :             } else {
    2545           0 :                 ShowSevereError(
    2546             :                     state,
    2547           0 :                     format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2548           0 :                 ShowContinueError(state, format(",,,invalid choice for {}.  Entered choice = {}", cAlphaFields(3), AlphArray(3)));
    2549           0 :                 ShowContinueError(state, "Valid choices are Yes or No.");
    2550           0 :                 ErrorsFound = true;
    2551             :             }
    2552             : 
    2553          10 :             if (Util::SameString(AlphArray(4), "Yes") || Util::SameString(AlphArray(4), "No")) {
    2554             :                 //  initialized to FALSE on allocate
    2555          10 :                 if (Util::SameString(AlphArray(4), "Yes"))
    2556           0 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondPumpHeatInCapacity = true;
    2557             :                 else
    2558          10 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondPumpHeatInCapacity = false;
    2559             :             } else {
    2560           0 :                 ShowSevereError(
    2561             :                     state,
    2562           0 :                     format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2563           0 :                 ShowContinueError(state, format(",,,invalid choice for {}.  Entered choice = {}", cAlphaFields(4), AlphArray(4)));
    2564           0 :                 ShowContinueError(state, "Valid choices are Yes or No.");
    2565           0 :                 ErrorsFound = true;
    2566             :             }
    2567             : 
    2568          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpFracToWater = NumArray(9);
    2569          20 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpFracToWater <= 0.0 ||
    2570          10 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpFracToWater > 1.0) {
    2571           0 :                 ShowSevereError(
    2572             :                     state,
    2573           0 :                     format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2574           0 :                 ShowContinueError(state, format("...{} must be >= 0 and <= 1.  entered value=[{:.3T}].", cNumericFields(10), NumArray(9)));
    2575           0 :                 ErrorsFound = true;
    2576             :             }
    2577             : 
    2578          10 :             if (!state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondPumpHeatInCapacity) {
    2579          10 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpFracToWater = 0.0;
    2580             :             }
    2581             : 
    2582             :             // Air nodes
    2583          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirInletNodeNum =
    2584          20 :                 GetOnlySingleNode(state,
    2585          10 :                                   AlphArray(5),
    2586             :                                   ErrorsFound,
    2587             :                                   DataLoopNode::ConnectionObjectType::CoilWaterHeatingAirToWaterHeatPumpVariableSpeed,
    2588          10 :                                   AlphArray(1),
    2589             :                                   DataLoopNode::NodeFluidType::Air,
    2590             :                                   DataLoopNode::ConnectionType::Inlet,
    2591             :                                   NodeInputManager::CompFluidStream::Primary,
    2592             :                                   ObjectIsNotParent);
    2593             : 
    2594          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirOutletNodeNum =
    2595          20 :                 GetOnlySingleNode(state,
    2596          10 :                                   AlphArray(6),
    2597             :                                   ErrorsFound,
    2598             :                                   DataLoopNode::ConnectionObjectType::CoilWaterHeatingAirToWaterHeatPumpVariableSpeed,
    2599          10 :                                   AlphArray(1),
    2600             :                                   DataLoopNode::NodeFluidType::Air,
    2601             :                                   DataLoopNode::ConnectionType::Outlet,
    2602             :                                   NodeInputManager::CompFluidStream::Primary,
    2603             :                                   ObjectIsNotParent);
    2604             : 
    2605          10 :             TestCompSet(state, CurrentModuleObject, AlphArray(1), AlphArray(5), AlphArray(6), "Air Nodes");
    2606             : 
    2607             :             // Check if the air inlet node is OA node, to justify whether the coil is placed in zone or not
    2608          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).IsDXCoilInZone =
    2609          10 :                 !CheckOutAirNodeNumber(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirInletNodeNum);
    2610             : 
    2611             :             // Water nodes
    2612          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterInletNodeNum =
    2613          20 :                 GetOnlySingleNode(state,
    2614          10 :                                   AlphArray(7),
    2615             :                                   ErrorsFound,
    2616             :                                   DataLoopNode::ConnectionObjectType::CoilWaterHeatingAirToWaterHeatPumpVariableSpeed,
    2617          10 :                                   AlphArray(1),
    2618             :                                   DataLoopNode::NodeFluidType::Water,
    2619             :                                   DataLoopNode::ConnectionType::Inlet,
    2620             :                                   NodeInputManager::CompFluidStream::Secondary,
    2621             :                                   ObjectIsNotParent);
    2622             : 
    2623          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterOutletNodeNum =
    2624          20 :                 GetOnlySingleNode(state,
    2625          10 :                                   AlphArray(8),
    2626             :                                   ErrorsFound,
    2627             :                                   DataLoopNode::ConnectionObjectType::CoilWaterHeatingAirToWaterHeatPumpVariableSpeed,
    2628          10 :                                   AlphArray(1),
    2629             :                                   DataLoopNode::NodeFluidType::Water,
    2630             :                                   DataLoopNode::ConnectionType::Outlet,
    2631             :                                   NodeInputManager::CompFluidStream::Secondary,
    2632             :                                   ObjectIsNotParent);
    2633             : 
    2634          10 :             TestCompSet(state, CurrentModuleObject, AlphArray(1), AlphArray(7), AlphArray(8), "Water Nodes");
    2635             : 
    2636          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterCapacity = NumArray(10);
    2637          10 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterCapacity < 0.0) {
    2638           0 :                 ShowSevereError(
    2639             :                     state,
    2640           0 :                     format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2641           0 :                 ShowContinueError(state, format("...{} must be >= 0.0  entered value=[{:.1T}].", cNumericFields(10), NumArray(10)));
    2642           0 :                 ErrorsFound = true;
    2643             :             }
    2644             : 
    2645          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MaxOATCrankcaseHeater = NumArray(11);
    2646          10 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MaxOATCrankcaseHeater < 0.0) {
    2647           0 :                 ShowSevereError(
    2648             :                     state,
    2649           0 :                     format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2650           0 :                 ShowContinueError(state, format("...{} must be >= 0 {{C}}.  entered value=[{:.1T}].", cNumericFields(11), NumArray(11)));
    2651           0 :                 ErrorsFound = true;
    2652             :             }
    2653             : 
    2654          10 :             if (!lAlphaBlanks(9)) {
    2655           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterCapacityCurveIndex = Curve::GetCurveIndex(state, AlphArray(9));
    2656           0 :                 ErrorsFound |=
    2657           0 :                     Curve::CheckCurveDims(state,
    2658           0 :                                           state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterCapacityCurveIndex, // Curve index
    2659             :                                           {1},                                                                                     // Valid dimensions
    2660             :                                           RoutineName,                                                                             // Routine name
    2661             :                                           CurrentModuleObject,                                                                     // Object Type
    2662           0 :                                           state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,                              // Object Name
    2663           0 :                                           cAlphaFields(9));                                                                        // Field Name
    2664             :             }
    2665             : 
    2666          10 :             if (Util::SameString(AlphArray(10), "DryBulbTemperature")) {
    2667           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirTemperatureType = HVAC::OATType::DryBulb;
    2668          10 :             } else if (Util::SameString(AlphArray(10), "WetBulbTemperature")) {
    2669          10 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirTemperatureType = HVAC::OATType::WetBulb;
    2670             :             } else {
    2671             :                 //   wrong temperature type selection
    2672           0 :                 ShowSevereError(
    2673             :                     state,
    2674           0 :                     format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2675           0 :                 ShowContinueError(state, format("...{} must be DryBulbTemperature or WetBulbTemperature.", cAlphaFields(10)));
    2676           0 :                 ShowContinueError(state, format("...entered value=\"{}\".", AlphArray(10)));
    2677           0 :                 ErrorsFound = true;
    2678             :             }
    2679             : 
    2680             :             // set rated inlet air temperature for curve object verification
    2681          10 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirTemperatureType == HVAC::OATType::WetBulb) {
    2682          10 :                 WHInletAirTemp = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WHRatedInletWBTemp;
    2683             :             } else {
    2684           0 :                 WHInletAirTemp = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WHRatedInletDBTemp;
    2685             :             }
    2686             :             // set rated water temperature for curve object verification
    2687          10 :             WHInletWaterTemp = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WHRatedInletWaterTemp;
    2688             : 
    2689             :             // part load curve
    2690          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PLFFPLR = GetCurveIndex(state, AlphArray(11)); // convert curve name to number
    2691          10 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PLFFPLR == 0) {
    2692           0 :                 if (lAlphaBlanks(11)) {
    2693           0 :                     ShowSevereError(
    2694             :                         state,
    2695           0 :                         format("{}{}=\"{}\", missing", RoutineName, CurrentModuleObject, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2696           0 :                     ShowContinueError(state, format("...required {} is blank.", cAlphaFields(11)));
    2697             :                 } else {
    2698           0 :                     ShowSevereError(
    2699             :                         state,
    2700           0 :                         format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2701           0 :                     ShowContinueError(state, format("...not found {}=\"{}\".", cAlphaFields(11), AlphArray(11)));
    2702             :                 }
    2703           0 :                 ErrorsFound = true;
    2704             :             } else {
    2705          10 :                 CurveVal = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PLFFPLR, 1.0);
    2706          10 :                 if (CurveVal > 1.10 || CurveVal < 0.90) {
    2707           0 :                     ShowWarningError(state,
    2708           0 :                                      format("{}{}=\"{}\", curve values",
    2709             :                                             RoutineName,
    2710             :                                             CurrentModuleObject,
    2711           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2712           0 :                     ShowContinueError(state, format("...{} output is not equal to 1.0 (+ or - 10%) at rated conditions.", cAlphaFields(11)));
    2713           0 :                     ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    2714             :                 }
    2715             :             }
    2716             : 
    2717         110 :             for (I = 1; I <= state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds; ++I) {
    2718         100 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I) = NumArray(12 + (I - 1) * 6);
    2719         100 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedCOP(I) = NumArray(13 + (I - 1) * 6);
    2720         100 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedSHR(I) = NumArray(14 + (I - 1) * 6);
    2721         100 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowRate(I) = NumArray(15 + (I - 1) * 6);
    2722         100 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterVolFlowRate(I) = NumArray(16 + (I - 1) * 6);
    2723         100 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWHPumpPower(I) = NumArray(17 + (I - 1) * 6);
    2724             : 
    2725         100 :                 AlfaFieldIncre = 12 + (I - 1) * 6;
    2726         100 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(I) =
    2727         100 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
    2728         100 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(I) == 0) {
    2729           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
    2730           0 :                         ShowSevereError(state,
    2731           0 :                                         format("{}{}=\"{}\", missing",
    2732             :                                                RoutineName,
    2733             :                                                CurrentModuleObject,
    2734           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2735           0 :                         ShowContinueError(state, format("...required {} is blank.", cAlphaFields(AlfaFieldIncre)));
    2736             :                     } else {
    2737           0 :                         ShowSevereError(state,
    2738           0 :                                         format("{}{}=\"{}\", invalid",
    2739             :                                                RoutineName,
    2740             :                                                CurrentModuleObject,
    2741           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2742           0 :                         ShowContinueError(state, format("...not found {}=\"{}\".", cAlphaFields(AlfaFieldIncre), AlphArray(AlfaFieldIncre)));
    2743             :                     }
    2744           0 :                     ErrorsFound = true;
    2745             :                 } else {
    2746             :                     // Verify Curve Object, only legal type is BiQuadratic
    2747         200 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    2748         100 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(I), // Curve index
    2749             :                                                          {2},                                                                  // Valid dimensions
    2750             :                                                          RoutineName,                                                          // Routine name
    2751             :                                                          CurrentModuleObject,                                                  // Object Type
    2752         100 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,           // Object Name
    2753         100 :                                                          cAlphaFields(AlfaFieldIncre));                                        // Field Name
    2754             : 
    2755         100 :                     if (!ErrorsFound) {
    2756         100 :                         CurveVal =
    2757         100 :                             CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(I), WHInletAirTemp, WHInletWaterTemp);
    2758         100 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
    2759           0 :                             ShowWarningError(state,
    2760           0 :                                              format("{}{}=\"{}\", curve values",
    2761             :                                                     RoutineName,
    2762             :                                                     CurrentModuleObject,
    2763           0 :                                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2764           0 :                             ShowContinueError(
    2765           0 :                                 state, format("...{} output is not equal to 1.0 (+ or - 10%) at rated conditions.", cAlphaFields(AlfaFieldIncre)));
    2766           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    2767             :                         }
    2768             :                     }
    2769             :                 }
    2770             : 
    2771         100 :                 AlfaFieldIncre = 13 + (I - 1) * 6;
    2772         100 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(I) =
    2773         100 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
    2774         100 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(I) == 0) {
    2775           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
    2776           0 :                         ShowSevereError(state,
    2777           0 :                                         format("{}{}=\"{}\", missing",
    2778             :                                                RoutineName,
    2779             :                                                CurrentModuleObject,
    2780           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2781           0 :                         ShowContinueError(state, format("...required {} is blank.", cAlphaFields(AlfaFieldIncre)));
    2782             :                     } else {
    2783           0 :                         ShowSevereError(state,
    2784           0 :                                         format("{}{}=\"{}\", invalid",
    2785             :                                                RoutineName,
    2786             :                                                CurrentModuleObject,
    2787           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2788           0 :                         ShowContinueError(state, format("...not found {}=\"{}\".", cAlphaFields(AlfaFieldIncre), AlphArray(AlfaFieldIncre)));
    2789             :                     }
    2790           0 :                     ErrorsFound = true;
    2791             :                 } else {
    2792             :                     // Verify Curve Object, only legal type is Quadratic
    2793         200 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    2794         100 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(I), // Curve index
    2795             :                                                          {1},                                                                     // Valid dimensions
    2796             :                                                          RoutineName,                                                             // Routine name
    2797             :                                                          CurrentModuleObject,                                                     // Object Type
    2798         100 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,              // Object Name
    2799         100 :                                                          cAlphaFields(AlfaFieldIncre));                                           // Field Name
    2800             : 
    2801         100 :                     if (!ErrorsFound) {
    2802         100 :                         CurveVal = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(I), 1.0);
    2803         100 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
    2804           0 :                             ShowWarningError(state,
    2805           0 :                                              format("{}{}=\"{}\", curve values",
    2806             :                                                     RoutineName,
    2807             :                                                     CurrentModuleObject,
    2808           0 :                                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2809           0 :                             ShowContinueError(
    2810           0 :                                 state, format("...{} output is not equal to 1.0 (+ or - 10%) at rated conditions.", cAlphaFields(AlfaFieldIncre)));
    2811           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    2812             :                         }
    2813             :                     }
    2814             :                 }
    2815             : 
    2816         100 :                 AlfaFieldIncre = 14 + (I - 1) * 6;
    2817         100 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(I) =
    2818         100 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
    2819         100 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(I) == 0) {
    2820           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
    2821           0 :                         ShowSevereError(state,
    2822           0 :                                         format("{}{}=\"{}\", missing",
    2823             :                                                RoutineName,
    2824             :                                                CurrentModuleObject,
    2825           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2826           0 :                         ShowContinueError(state, format("...required {} is blank.", cAlphaFields(AlfaFieldIncre)));
    2827             :                     } else {
    2828           0 :                         ShowSevereError(state,
    2829           0 :                                         format("{}{}=\"{}\", invalid",
    2830             :                                                RoutineName,
    2831             :                                                CurrentModuleObject,
    2832           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2833           0 :                         ShowContinueError(state, format("...not found {}=\"{}\".", cAlphaFields(AlfaFieldIncre), AlphArray(AlfaFieldIncre)));
    2834             :                     }
    2835           0 :                     ErrorsFound = true;
    2836             :                 } else {
    2837             :                     // Verify Curve Object, only legal type is Quadratic
    2838         200 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    2839         100 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(I), // Curve index
    2840             :                                                          {1},                                                        // Valid dimensions
    2841             :                                                          RoutineName,                                                // Routine name
    2842             :                                                          CurrentModuleObject,                                        // Object Type
    2843         100 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name, // Object Name
    2844         100 :                                                          cAlphaFields(AlfaFieldIncre));                              // Field Name
    2845             : 
    2846         100 :                     if (!ErrorsFound) {
    2847         100 :                         CurveVal = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(I), 1.0);
    2848         100 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
    2849           0 :                             ShowWarningError(state,
    2850           0 :                                              format("{}{}=\"{}\", curve values",
    2851             :                                                     RoutineName,
    2852             :                                                     CurrentModuleObject,
    2853           0 :                                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2854           0 :                             ShowContinueError(
    2855           0 :                                 state, format("...{} output is not equal to 1.0 (+ or - 10%) at rated conditions.", cAlphaFields(AlfaFieldIncre)));
    2856           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    2857             :                         }
    2858             :                     }
    2859             :                 }
    2860             : 
    2861         100 :                 AlfaFieldIncre = 15 + (I - 1) * 6;
    2862         100 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(I) =
    2863         100 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
    2864         100 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(I) == 0) {
    2865           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
    2866           0 :                         ShowSevereError(state,
    2867           0 :                                         format("{}{}=\"{}\", missing",
    2868             :                                                RoutineName,
    2869             :                                                CurrentModuleObject,
    2870           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2871           0 :                         ShowContinueError(state, format("...required {} is blank.", cAlphaFields(AlfaFieldIncre)));
    2872             :                     } else {
    2873           0 :                         ShowSevereError(state,
    2874           0 :                                         format("{}{}=\"{}\", invalid",
    2875             :                                                RoutineName,
    2876             :                                                CurrentModuleObject,
    2877           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2878           0 :                         ShowContinueError(state, format("...not found {}=\"{}\".", cAlphaFields(AlfaFieldIncre), AlphArray(AlfaFieldIncre)));
    2879             :                     }
    2880           0 :                     ErrorsFound = true;
    2881             :                 } else {
    2882             :                     // Verify Curve Object, only legal type is BiQuadratic
    2883         200 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    2884         100 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(I), // Curve index
    2885             :                                                          {2},                                                                 // Valid dimensions
    2886             :                                                          RoutineName,                                                         // Routine name
    2887             :                                                          CurrentModuleObject,                                                 // Object Type
    2888         100 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,          // Object Name
    2889         100 :                                                          cAlphaFields(AlfaFieldIncre));                                       // Field Name
    2890             : 
    2891         100 :                     if (!ErrorsFound) {
    2892         100 :                         CurveVal =
    2893         100 :                             CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(I), WHInletAirTemp, WHInletWaterTemp);
    2894         100 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
    2895           0 :                             ShowWarningError(state,
    2896           0 :                                              format("{}{}=\"{}\", curve values",
    2897             :                                                     RoutineName,
    2898             :                                                     CurrentModuleObject,
    2899           0 :                                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2900           0 :                             ShowContinueError(
    2901           0 :                                 state, format("...{} output is not equal to 1.0 (+ or - 10%) at rated conditions.", cAlphaFields(AlfaFieldIncre)));
    2902           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    2903             :                         }
    2904             :                     }
    2905             :                 }
    2906             : 
    2907         100 :                 AlfaFieldIncre = 16 + (I - 1) * 6;
    2908         100 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(I) =
    2909         100 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
    2910         100 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(I) == 0) {
    2911           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
    2912           0 :                         ShowSevereError(state,
    2913           0 :                                         format("{}{}=\"{}\", missing",
    2914             :                                                RoutineName,
    2915             :                                                CurrentModuleObject,
    2916           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2917           0 :                         ShowContinueError(state, format("...required {} is blank.", cAlphaFields(AlfaFieldIncre)));
    2918             :                     } else {
    2919           0 :                         ShowSevereError(state,
    2920           0 :                                         format("{}{}=\"{}\", invalid",
    2921             :                                                RoutineName,
    2922             :                                                CurrentModuleObject,
    2923           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2924           0 :                         ShowContinueError(state, format("...not found {}=\"{}\".", cAlphaFields(AlfaFieldIncre), AlphArray(AlfaFieldIncre)));
    2925             :                     }
    2926           0 :                     ErrorsFound = true;
    2927             :                 } else {
    2928             :                     // Verify Curve Object, only legal type is Quadratic
    2929         200 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    2930         100 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(I), // Curve index
    2931             :                                                          {1},                                                                    // Valid dimensions
    2932             :                                                          RoutineName,                                                            // Routine name
    2933             :                                                          CurrentModuleObject,                                                    // Object Type
    2934         100 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,             // Object Name
    2935         100 :                                                          cAlphaFields(AlfaFieldIncre));                                          // Field Name
    2936             : 
    2937         100 :                     if (!ErrorsFound) {
    2938         100 :                         CurveVal = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(I), 1.0);
    2939         100 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
    2940           0 :                             ShowWarningError(state,
    2941           0 :                                              format("{}{}=\"{}\", curve values",
    2942             :                                                     RoutineName,
    2943             :                                                     CurrentModuleObject,
    2944           0 :                                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2945           0 :                             ShowContinueError(
    2946           0 :                                 state, format("...{} output is not equal to 1.0 (+ or - 10%) at rated conditions.", cAlphaFields(AlfaFieldIncre)));
    2947           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    2948             :                         }
    2949             :                     }
    2950             :                 }
    2951             : 
    2952         100 :                 AlfaFieldIncre = 17 + (I - 1) * 6;
    2953         100 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRWaterFFlow(I) =
    2954         100 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
    2955         100 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRWaterFFlow(I) == 0) {
    2956           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
    2957           0 :                         ShowSevereError(state,
    2958           0 :                                         format("{}{}=\"{}\", missing",
    2959             :                                                RoutineName,
    2960             :                                                CurrentModuleObject,
    2961           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2962           0 :                         ShowContinueError(state, format("...required {} is blank.", cAlphaFields(AlfaFieldIncre)));
    2963             :                     } else {
    2964           0 :                         ShowSevereError(state,
    2965           0 :                                         format("{}{}=\"{}\", invalid",
    2966             :                                                RoutineName,
    2967             :                                                CurrentModuleObject,
    2968           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2969           0 :                         ShowContinueError(state, format("...not found {}=\"{}\".", cAlphaFields(AlfaFieldIncre), AlphArray(AlfaFieldIncre)));
    2970             :                     }
    2971           0 :                     ErrorsFound = true;
    2972             :                 } else {
    2973             :                     // Verify Curve Object, only legal type is Quadratic
    2974         200 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    2975         100 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRWaterFFlow(I), // Curve index
    2976             :                                                          {1},                                                                      // Valid dimensions
    2977             :                                                          RoutineName,                                                              // Routine name
    2978             :                                                          CurrentModuleObject,                                                      // Object Type
    2979         100 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,               // Object Name
    2980         100 :                                                          cAlphaFields(AlfaFieldIncre));                                            // Field Name
    2981             : 
    2982         100 :                     if (!ErrorsFound) {
    2983         100 :                         CurveVal = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRWaterFFlow(I), 1.0);
    2984         100 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
    2985           0 :                             ShowWarningError(state,
    2986           0 :                                              format("{}{}=\"{}\", curve values",
    2987             :                                                     RoutineName,
    2988             :                                                     CurrentModuleObject,
    2989           0 :                                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
    2990           0 :                             ShowContinueError(
    2991           0 :                                 state, format("...{} output is not equal to 1.0 (+ or - 10%) at rated conditions.", cAlphaFields(AlfaFieldIncre)));
    2992           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    2993             :                         }
    2994             :                     }
    2995             :                 }
    2996             :             }
    2997             : 
    2998             :             // get scale values
    2999         110 :             for (I = 1; I <= state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds; ++I) {
    3000         100 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedPercentTotCap(I) =
    3001         100 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I) /
    3002         200 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(
    3003         100 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds);
    3004         100 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowPerRatedTotCap(I) =
    3005         100 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowRate(I) /
    3006         100 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I);
    3007         100 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterVolFlowPerRatedTotCap(I) =
    3008         100 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterVolFlowRate(I) /
    3009         100 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I);
    3010         100 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWHPumpPowerPerRatedTotCap(I) =
    3011         100 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWHPumpPower(I) /
    3012         100 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I);
    3013             :             }
    3014             : 
    3015             :             // CurrentModuleObject = "Coil:Waterheating:Airtowaterheatpump:Variablespeed"
    3016          20 :             SetupOutputVariable(state,
    3017             :                                 "Cooling Coil Electricity Energy",
    3018             :                                 Constant::Units::J,
    3019          10 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Energy,
    3020             :                                 OutputProcessor::TimeStepType::System,
    3021             :                                 OutputProcessor::StoreType::Sum,
    3022          10 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    3023             :                                 Constant::eResource::Electricity,
    3024             :                                 OutputProcessor::Group::HVAC,
    3025             :                                 OutputProcessor::EndUseCat::Heating);
    3026          20 :             SetupOutputVariable(state,
    3027             :                                 "Cooling Coil Sensible Cooling Energy",
    3028             :                                 Constant::Units::J,
    3029          10 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergySensible,
    3030             :                                 OutputProcessor::TimeStepType::System,
    3031             :                                 OutputProcessor::StoreType::Sum,
    3032          10 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3033          20 :             SetupOutputVariable(state,
    3034             :                                 "Cooling Coil Latent Cooling Energy",
    3035             :                                 Constant::Units::J,
    3036          10 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLatent,
    3037             :                                 OutputProcessor::TimeStepType::System,
    3038             :                                 OutputProcessor::StoreType::Sum,
    3039          10 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3040          20 :             SetupOutputVariable(state,
    3041             :                                 "Cooling Coil Water Side Heat Transfer Energy",
    3042             :                                 Constant::Units::J,
    3043          10 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergySource,
    3044             :                                 OutputProcessor::TimeStepType::System,
    3045             :                                 OutputProcessor::StoreType::Sum,
    3046          10 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    3047             :                                 Constant::eResource::PlantLoopHeatingDemand,
    3048             :                                 OutputProcessor::Group::HVAC,
    3049             :                                 OutputProcessor::EndUseCat::HeatingCoils);
    3050             : 
    3051          10 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).IsDXCoilInZone) {
    3052          20 :                 SetupOutputVariable(state,
    3053             :                                     "Cooling Coil Cooling Energy",
    3054             :                                     Constant::Units::J,
    3055          10 :                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLoadTotal,
    3056             :                                     OutputProcessor::TimeStepType::System,
    3057             :                                     OutputProcessor::StoreType::Sum,
    3058          10 :                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    3059             :                                     Constant::eResource::EnergyTransfer,
    3060             :                                     OutputProcessor::Group::HVAC,
    3061             :                                     OutputProcessor::EndUseCat::CoolingCoils);
    3062             :             } else {
    3063           0 :                 SetupOutputVariable(state,
    3064             :                                     "Cooling Coil Cooling Energy",
    3065             :                                     Constant::Units::J,
    3066           0 :                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLoadTotal,
    3067             :                                     OutputProcessor::TimeStepType::System,
    3068             :                                     OutputProcessor::StoreType::Sum,
    3069           0 :                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3070             :             }
    3071             : 
    3072          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedCapCoolSens =
    3073             :                 AutoSize; // always auto-sized, to be determined in the sizing calculation
    3074             :         }
    3075             :         //---------------------------VARIABLE-SPEED AIR SOURCE HPWH END --------------
    3076             : 
    3077          22 :         AlphArray.deallocate();
    3078          22 :         cAlphaFields.deallocate();
    3079          22 :         lAlphaBlanks.deallocate();
    3080          22 :         cNumericFields.deallocate();
    3081          22 :         lNumericBlanks.deallocate();
    3082          22 :         NumArray.deallocate();
    3083             : 
    3084          22 :         if (ErrorsFound) {
    3085           0 :             ShowFatalError(state, format("{}Errors found getting input. Program terminates.", RoutineName));
    3086             :         }
    3087             : 
    3088          99 :         for (DXCoilNum = 1; DXCoilNum <= state.dataVariableSpeedCoils->NumVarSpeedCoils; ++DXCoilNum) {
    3089         132 :             if ((state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_CoolingAirToAirVariableSpeed) ||
    3090          55 :                 (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_HeatingAirToAirVariableSpeed)) {
    3091             :                 // Setup Report variables for the Heat Pump
    3092             : 
    3093             :                 // cooling and heating coils separately
    3094          31 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_CoolingAirToAirVariableSpeed) {
    3095             :                     // air source cooling coils
    3096          44 :                     SetupOutputVariable(state,
    3097             :                                         "Cooling Coil Air Mass Flow Rate",
    3098             :                                         Constant::Units::kg_s,
    3099          22 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate,
    3100             :                                         OutputProcessor::TimeStepType::System,
    3101             :                                         OutputProcessor::StoreType::Average,
    3102          22 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3103          44 :                     SetupOutputVariable(state,
    3104             :                                         "Cooling Coil Air Inlet Temperature",
    3105             :                                         Constant::Units::C,
    3106          22 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirDBTemp,
    3107             :                                         OutputProcessor::TimeStepType::System,
    3108             :                                         OutputProcessor::StoreType::Average,
    3109          22 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3110          44 :                     SetupOutputVariable(state,
    3111             :                                         "Cooling Coil Air Inlet Humidity Ratio",
    3112             :                                         Constant::Units::kgWater_kgDryAir,
    3113          22 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirHumRat,
    3114             :                                         OutputProcessor::TimeStepType::System,
    3115             :                                         OutputProcessor::StoreType::Average,
    3116          22 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3117          44 :                     SetupOutputVariable(state,
    3118             :                                         "Cooling Coil Latent Cooling Rate",
    3119             :                                         Constant::Units::W,
    3120          22 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLatent,
    3121             :                                         OutputProcessor::TimeStepType::System,
    3122             :                                         OutputProcessor::StoreType::Average,
    3123          22 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3124          44 :                     SetupOutputVariable(state,
    3125             :                                         "Cooling Coil Air Outlet Temperature",
    3126             :                                         Constant::Units::C,
    3127          22 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirDBTemp,
    3128             :                                         OutputProcessor::TimeStepType::System,
    3129             :                                         OutputProcessor::StoreType::Average,
    3130          22 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3131          44 :                     SetupOutputVariable(state,
    3132             :                                         "Cooling Coil Air Outlet Humidity Ratio",
    3133             :                                         Constant::Units::kgWater_kgDryAir,
    3134          22 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirHumRat,
    3135             :                                         OutputProcessor::TimeStepType::System,
    3136             :                                         OutputProcessor::StoreType::Average,
    3137          22 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3138          44 :                     SetupOutputVariable(state,
    3139             :                                         "Cooling Coil Sensible Cooling Rate",
    3140             :                                         Constant::Units::W,
    3141          22 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSensible,
    3142             :                                         OutputProcessor::TimeStepType::System,
    3143             :                                         OutputProcessor::StoreType::Average,
    3144          22 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3145          44 :                     SetupOutputVariable(state,
    3146             :                                         "Cooling Coil Total Cooling Rate",
    3147             :                                         Constant::Units::W,
    3148          22 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLoadTotal,
    3149             :                                         OutputProcessor::TimeStepType::System,
    3150             :                                         OutputProcessor::StoreType::Average,
    3151          22 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3152          44 :                     SetupOutputVariable(state,
    3153             :                                         "Cooling Coil Part Load Ratio",
    3154             :                                         Constant::Units::None,
    3155          22 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PartLoadRatio,
    3156             :                                         OutputProcessor::TimeStepType::System,
    3157             :                                         OutputProcessor::StoreType::Average,
    3158          22 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3159          44 :                     SetupOutputVariable(state,
    3160             :                                         "Cooling Coil Electricity Rate",
    3161             :                                         Constant::Units::W,
    3162          22 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Power,
    3163             :                                         OutputProcessor::TimeStepType::System,
    3164             :                                         OutputProcessor::StoreType::Average,
    3165          22 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3166          44 :                     SetupOutputVariable(state,
    3167             :                                         "Cooling Coil Runtime Fraction",
    3168             :                                         Constant::Units::None,
    3169          22 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac,
    3170             :                                         OutputProcessor::TimeStepType::System,
    3171             :                                         OutputProcessor::StoreType::Average,
    3172          22 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3173          44 :                     SetupOutputVariable(state,
    3174             :                                         "Cooling Coil Source Side Heat Transfer Rate",
    3175             :                                         Constant::Units::W,
    3176          22 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSource,
    3177             :                                         OutputProcessor::TimeStepType::System,
    3178             :                                         OutputProcessor::StoreType::Average,
    3179          22 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3180          44 :                     SetupOutputVariable(state,
    3181             :                                         "Cooling Coil Upper Speed Level",
    3182             :                                         Constant::Units::None,
    3183          22 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SpeedNumReport,
    3184             :                                         OutputProcessor::TimeStepType::System,
    3185             :                                         OutputProcessor::StoreType::Average,
    3186          22 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3187          44 :                     SetupOutputVariable(state,
    3188             :                                         "Cooling Coil Neighboring Speed Levels Ratio",
    3189             :                                         Constant::Units::None,
    3190          22 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SpeedRatioReport,
    3191             :                                         OutputProcessor::TimeStepType::System,
    3192             :                                         OutputProcessor::StoreType::Average,
    3193          22 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3194             : 
    3195          22 :                     if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondensateCollectMode == CondensateToTank) {
    3196           0 :                         SetupOutputVariable(state,
    3197             :                                             "Cooling Coil Condensate Volume Flow Rate",
    3198             :                                             Constant::Units::m3_s,
    3199           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondensateVdot,
    3200             :                                             OutputProcessor::TimeStepType::System,
    3201             :                                             OutputProcessor::StoreType::Average,
    3202           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3203           0 :                         SetupOutputVariable(state,
    3204             :                                             "Cooling Coil Condensate Volume",
    3205             :                                             Constant::Units::m3,
    3206           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondensateVol,
    3207             :                                             OutputProcessor::TimeStepType::System,
    3208             :                                             OutputProcessor::StoreType::Sum,
    3209           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    3210             :                                             Constant::eResource::OnSiteWater,
    3211             :                                             OutputProcessor::Group::HVAC,
    3212             :                                             OutputProcessor::EndUseCat::Condensate);
    3213             :                     }
    3214             : 
    3215          22 :                     if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).ReportEvapCondVars) {
    3216           0 :                         SetupOutputVariable(state,
    3217             :                                             "Cooling Coil Condenser Inlet Temperature",
    3218             :                                             Constant::Units::C,
    3219           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondInletTemp,
    3220             :                                             OutputProcessor::TimeStepType::System,
    3221             :                                             OutputProcessor::StoreType::Average,
    3222           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3223           0 :                         SetupOutputVariable(state,
    3224             :                                             "Cooling Coil Evaporative Condenser Water Volume",
    3225             :                                             Constant::Units::m3,
    3226           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapWaterConsump,
    3227             :                                             OutputProcessor::TimeStepType::System,
    3228             :                                             OutputProcessor::StoreType::Sum,
    3229           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    3230             :                                             Constant::eResource::Water,
    3231             :                                             OutputProcessor::Group::HVAC,
    3232             :                                             OutputProcessor::EndUseCat::Cooling);
    3233           0 :                         SetupOutputVariable(state,
    3234             :                                             "Cooling Coil Evaporative Condenser Mains Water Volume",
    3235             :                                             Constant::Units::m3,
    3236           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapWaterConsump,
    3237             :                                             OutputProcessor::TimeStepType::System,
    3238             :                                             OutputProcessor::StoreType::Sum,
    3239           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    3240             :                                             Constant::eResource::MainsWater,
    3241             :                                             OutputProcessor::Group::HVAC,
    3242             :                                             OutputProcessor::EndUseCat::Cooling);
    3243           0 :                         SetupOutputVariable(state,
    3244             :                                             "Cooling Coil Evaporative Condenser Pump Electricity Rate",
    3245             :                                             Constant::Units::W,
    3246           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondPumpElecPower,
    3247             :                                             OutputProcessor::TimeStepType::System,
    3248             :                                             OutputProcessor::StoreType::Average,
    3249           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3250           0 :                         SetupOutputVariable(state,
    3251             :                                             "Cooling Coil Evaporative Condenser Pump Electricity Energy",
    3252             :                                             Constant::Units::J,
    3253           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondPumpElecConsumption,
    3254             :                                             OutputProcessor::TimeStepType::System,
    3255             :                                             OutputProcessor::StoreType::Sum,
    3256           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    3257             :                                             Constant::eResource::Electricity,
    3258             :                                             OutputProcessor::Group::HVAC,
    3259             :                                             OutputProcessor::EndUseCat::Cooling);
    3260           0 :                         if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterPowerFTempDiff > 0.0) {
    3261           0 :                             SetupOutputVariable(state,
    3262             :                                                 "Cooling Coil Basin Heater Electricity Rate",
    3263             :                                                 Constant::Units::W,
    3264           0 :                                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterPower,
    3265             :                                                 OutputProcessor::TimeStepType::System,
    3266             :                                                 OutputProcessor::StoreType::Average,
    3267           0 :                                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3268           0 :                             SetupOutputVariable(state,
    3269             :                                                 "Cooling Coil Basin Heater Electricity Energy",
    3270             :                                                 Constant::Units::J,
    3271           0 :                                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterConsumption,
    3272             :                                                 OutputProcessor::TimeStepType::System,
    3273             :                                                 OutputProcessor::StoreType::Sum,
    3274           0 :                                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    3275             :                                                 Constant::eResource::Electricity,
    3276             :                                                 OutputProcessor::Group::HVAC,
    3277             :                                                 OutputProcessor::EndUseCat::Cooling);
    3278             :                         }
    3279             :                     }
    3280             : 
    3281          44 :                     SetupOutputVariable(state,
    3282             :                                         "Cooling Coil Crankcase Heater Electricity Rate",
    3283             :                                         Constant::Units::W,
    3284          22 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterPower,
    3285             :                                         OutputProcessor::TimeStepType::System,
    3286             :                                         OutputProcessor::StoreType::Average,
    3287          22 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3288          44 :                     SetupOutputVariable(state,
    3289             :                                         "Cooling Coil Crankcase Heater Electricity Energy",
    3290             :                                         Constant::Units::J,
    3291          22 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterConsumption,
    3292             :                                         OutputProcessor::TimeStepType::System,
    3293             :                                         OutputProcessor::StoreType::Sum,
    3294          22 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    3295             :                                         Constant::eResource::Electricity,
    3296             :                                         OutputProcessor::Group::HVAC,
    3297             :                                         OutputProcessor::EndUseCat::Cooling);
    3298             :                 } else {
    3299             :                     // air source heating coils
    3300          18 :                     SetupOutputVariable(state,
    3301             :                                         "Heating Coil Air Mass Flow Rate",
    3302             :                                         Constant::Units::kg_s,
    3303           9 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate,
    3304             :                                         OutputProcessor::TimeStepType::System,
    3305             :                                         OutputProcessor::StoreType::Average,
    3306           9 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3307          18 :                     SetupOutputVariable(state,
    3308             :                                         "Heating Coil Air Inlet Temperature",
    3309             :                                         Constant::Units::C,
    3310           9 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirDBTemp,
    3311             :                                         OutputProcessor::TimeStepType::System,
    3312             :                                         OutputProcessor::StoreType::Average,
    3313           9 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3314          18 :                     SetupOutputVariable(state,
    3315             :                                         "Heating Coil Air Inlet Humidity Ratio",
    3316             :                                         Constant::Units::kgWater_kgDryAir,
    3317           9 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirHumRat,
    3318             :                                         OutputProcessor::TimeStepType::System,
    3319             :                                         OutputProcessor::StoreType::Average,
    3320           9 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3321          18 :                     SetupOutputVariable(state,
    3322             :                                         "Heating Coil Air Outlet Temperature",
    3323             :                                         Constant::Units::C,
    3324           9 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirDBTemp,
    3325             :                                         OutputProcessor::TimeStepType::System,
    3326             :                                         OutputProcessor::StoreType::Average,
    3327           9 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3328          18 :                     SetupOutputVariable(state,
    3329             :                                         "Heating Coil Air Outlet Humidity Ratio",
    3330             :                                         Constant::Units::kgWater_kgDryAir,
    3331           9 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirHumRat,
    3332             :                                         OutputProcessor::TimeStepType::System,
    3333             :                                         OutputProcessor::StoreType::Average,
    3334           9 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3335          18 :                     SetupOutputVariable(state,
    3336             :                                         "Heating Coil Sensible Heating Rate",
    3337             :                                         Constant::Units::W,
    3338           9 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSensible,
    3339             :                                         OutputProcessor::TimeStepType::System,
    3340             :                                         OutputProcessor::StoreType::Average,
    3341           9 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3342          18 :                     SetupOutputVariable(state,
    3343             :                                         "Heating Coil Heating Rate",
    3344             :                                         Constant::Units::W,
    3345           9 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLoadTotal,
    3346             :                                         OutputProcessor::TimeStepType::System,
    3347             :                                         OutputProcessor::StoreType::Average,
    3348           9 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3349          18 :                     SetupOutputVariable(state,
    3350             :                                         "Heating Coil Part Load Ratio",
    3351             :                                         Constant::Units::None,
    3352           9 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PartLoadRatio,
    3353             :                                         OutputProcessor::TimeStepType::System,
    3354             :                                         OutputProcessor::StoreType::Average,
    3355           9 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3356          18 :                     SetupOutputVariable(state,
    3357             :                                         "Heating Coil Electricity Rate",
    3358             :                                         Constant::Units::W,
    3359           9 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Power,
    3360             :                                         OutputProcessor::TimeStepType::System,
    3361             :                                         OutputProcessor::StoreType::Average,
    3362           9 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3363          18 :                     SetupOutputVariable(state,
    3364             :                                         "Heating Coil Runtime Fraction",
    3365             :                                         Constant::Units::None,
    3366           9 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac,
    3367             :                                         OutputProcessor::TimeStepType::System,
    3368             :                                         OutputProcessor::StoreType::Average,
    3369           9 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3370             : 
    3371          18 :                     SetupOutputVariable(state,
    3372             :                                         "Heating Coil Source Side Heat Transfer Rate",
    3373             :                                         Constant::Units::W,
    3374           9 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSource,
    3375             :                                         OutputProcessor::TimeStepType::System,
    3376             :                                         OutputProcessor::StoreType::Average,
    3377           9 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3378          18 :                     SetupOutputVariable(state,
    3379             :                                         "Heating Coil Upper Speed Level",
    3380             :                                         Constant::Units::None,
    3381           9 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SpeedNumReport,
    3382             :                                         OutputProcessor::TimeStepType::System,
    3383             :                                         OutputProcessor::StoreType::Average,
    3384           9 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3385          18 :                     SetupOutputVariable(state,
    3386             :                                         "Heating Coil Neighboring Speed Levels Ratio",
    3387             :                                         Constant::Units::None,
    3388           9 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SpeedRatioReport,
    3389             :                                         OutputProcessor::TimeStepType::System,
    3390             :                                         OutputProcessor::StoreType::Average,
    3391           9 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3392             : 
    3393          18 :                     SetupOutputVariable(state,
    3394             :                                         "Heating Coil Defrost Electricity Rate",
    3395             :                                         Constant::Units::W,
    3396           9 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostPower,
    3397             :                                         OutputProcessor::TimeStepType::System,
    3398             :                                         OutputProcessor::StoreType::Average,
    3399           9 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3400          18 :                     SetupOutputVariable(state,
    3401             :                                         "Heating Coil Defrost Electricity Energy",
    3402             :                                         Constant::Units::J,
    3403           9 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostConsumption,
    3404             :                                         OutputProcessor::TimeStepType::System,
    3405             :                                         OutputProcessor::StoreType::Sum,
    3406           9 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    3407             :                                         Constant::eResource::Electricity,
    3408             :                                         OutputProcessor::Group::HVAC,
    3409             :                                         OutputProcessor::EndUseCat::Heating);
    3410          18 :                     SetupOutputVariable(state,
    3411             :                                         "Heating Coil Crankcase Heater Electricity Rate",
    3412             :                                         Constant::Units::W,
    3413           9 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterPower,
    3414             :                                         OutputProcessor::TimeStepType::System,
    3415             :                                         OutputProcessor::StoreType::Average,
    3416           9 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3417          18 :                     SetupOutputVariable(state,
    3418             :                                         "Heating Coil Crankcase Heater Electricity Energy",
    3419             :                                         Constant::Units::J,
    3420           9 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterConsumption,
    3421             :                                         OutputProcessor::TimeStepType::System,
    3422             :                                         OutputProcessor::StoreType::Sum,
    3423           9 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    3424             :                                         Constant::eResource::Electricity,
    3425             :                                         OutputProcessor::Group::HVAC,
    3426             :                                         OutputProcessor::EndUseCat::Heating);
    3427             :                 }
    3428             :             } else {
    3429             : 
    3430          46 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType ==
    3431             :                     HVAC::Coil_CoolingWaterToAirHPVSEquationFit) { // fix coil type
    3432             :                     // cooling WAHP coil
    3433             :                     // Setup Report variables for water source Heat Pump
    3434          36 :                     SetupOutputVariable(state,
    3435             :                                         "Cooling Coil Electricity Rate",
    3436             :                                         Constant::Units::W,
    3437          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Power,
    3438             :                                         OutputProcessor::TimeStepType::System,
    3439             :                                         OutputProcessor::StoreType::Average,
    3440          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3441          36 :                     SetupOutputVariable(state,
    3442             :                                         "Cooling Coil Total Cooling Rate",
    3443             :                                         Constant::Units::W,
    3444          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLoadTotal,
    3445             :                                         OutputProcessor::TimeStepType::System,
    3446             :                                         OutputProcessor::StoreType::Average,
    3447          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3448          36 :                     SetupOutputVariable(state,
    3449             :                                         "Cooling Coil Sensible Cooling Rate",
    3450             :                                         Constant::Units::W,
    3451          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSensible,
    3452             :                                         OutputProcessor::TimeStepType::System,
    3453             :                                         OutputProcessor::StoreType::Average,
    3454          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3455          36 :                     SetupOutputVariable(state,
    3456             :                                         "Cooling Coil Latent Cooling Rate",
    3457             :                                         Constant::Units::W,
    3458          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLatent,
    3459             :                                         OutputProcessor::TimeStepType::System,
    3460             :                                         OutputProcessor::StoreType::Average,
    3461          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3462          36 :                     SetupOutputVariable(state,
    3463             :                                         "Cooling Coil Source Side Heat Transfer Rate",
    3464             :                                         Constant::Units::W,
    3465          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSource,
    3466             :                                         OutputProcessor::TimeStepType::System,
    3467             :                                         OutputProcessor::StoreType::Average,
    3468          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3469          36 :                     SetupOutputVariable(state,
    3470             :                                         "Cooling Coil Part Load Ratio",
    3471             :                                         Constant::Units::None,
    3472          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PartLoadRatio,
    3473             :                                         OutputProcessor::TimeStepType::System,
    3474             :                                         OutputProcessor::StoreType::Average,
    3475          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3476          36 :                     SetupOutputVariable(state,
    3477             :                                         "Cooling Coil Runtime Fraction",
    3478             :                                         Constant::Units::None,
    3479          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac,
    3480             :                                         OutputProcessor::TimeStepType::System,
    3481             :                                         OutputProcessor::StoreType::Average,
    3482          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3483             : 
    3484          36 :                     SetupOutputVariable(state,
    3485             :                                         "Cooling Coil Air Mass Flow Rate",
    3486             :                                         Constant::Units::kg_s,
    3487          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate,
    3488             :                                         OutputProcessor::TimeStepType::System,
    3489             :                                         OutputProcessor::StoreType::Average,
    3490          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3491          36 :                     SetupOutputVariable(state,
    3492             :                                         "Cooling Coil Air Inlet Temperature",
    3493             :                                         Constant::Units::C,
    3494          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirDBTemp,
    3495             :                                         OutputProcessor::TimeStepType::System,
    3496             :                                         OutputProcessor::StoreType::Average,
    3497          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3498          36 :                     SetupOutputVariable(state,
    3499             :                                         "Cooling Coil Air Inlet Humidity Ratio",
    3500             :                                         Constant::Units::kgWater_kgDryAir,
    3501          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirHumRat,
    3502             :                                         OutputProcessor::TimeStepType::System,
    3503             :                                         OutputProcessor::StoreType::Average,
    3504          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3505          36 :                     SetupOutputVariable(state,
    3506             :                                         "Cooling Coil Air Outlet Temperature",
    3507             :                                         Constant::Units::C,
    3508          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirDBTemp,
    3509             :                                         OutputProcessor::TimeStepType::System,
    3510             :                                         OutputProcessor::StoreType::Average,
    3511          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3512          36 :                     SetupOutputVariable(state,
    3513             :                                         "Cooling Coil Air Outlet Humidity Ratio",
    3514             :                                         Constant::Units::kgWater_kgDryAir,
    3515          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirHumRat,
    3516             :                                         OutputProcessor::TimeStepType::System,
    3517             :                                         OutputProcessor::StoreType::Average,
    3518          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3519          36 :                     SetupOutputVariable(state,
    3520             :                                         "Cooling Coil Source Side Mass Flow Rate",
    3521             :                                         Constant::Units::kg_s,
    3522          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterMassFlowRate,
    3523             :                                         OutputProcessor::TimeStepType::System,
    3524             :                                         OutputProcessor::StoreType::Average,
    3525          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3526          36 :                     SetupOutputVariable(state,
    3527             :                                         "Cooling Coil Source Side Inlet Temperature",
    3528             :                                         Constant::Units::C,
    3529          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterTemp,
    3530             :                                         OutputProcessor::TimeStepType::System,
    3531             :                                         OutputProcessor::StoreType::Average,
    3532          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3533          36 :                     SetupOutputVariable(state,
    3534             :                                         "Cooling Coil Source Side Outlet Temperature",
    3535             :                                         Constant::Units::C,
    3536          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletWaterTemp,
    3537             :                                         OutputProcessor::TimeStepType::System,
    3538             :                                         OutputProcessor::StoreType::Average,
    3539          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3540             : 
    3541          36 :                     SetupOutputVariable(state,
    3542             :                                         "Cooling Coil Upper Speed Level",
    3543             :                                         Constant::Units::None,
    3544          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SpeedNumReport,
    3545             :                                         OutputProcessor::TimeStepType::System,
    3546             :                                         OutputProcessor::StoreType::Average,
    3547          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3548          36 :                     SetupOutputVariable(state,
    3549             :                                         "Cooling Coil Neighboring Speed Levels Ratio",
    3550             :                                         Constant::Units::None,
    3551          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SpeedRatioReport,
    3552             :                                         OutputProcessor::TimeStepType::System,
    3553             :                                         OutputProcessor::StoreType::Average,
    3554          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3555          36 :                     SetupOutputVariable(state,
    3556             :                                         "Cooling Coil Recoverable Heat Transfer Rate",
    3557             :                                         Constant::Units::W,
    3558          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QWasteHeat,
    3559             :                                         OutputProcessor::TimeStepType::System,
    3560             :                                         OutputProcessor::StoreType::Average,
    3561          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3562          28 :                 } else if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType ==
    3563             :                            HVAC::Coil_HeatingWaterToAirHPVSEquationFit) { // fix coil type
    3564             :                     // heating WAHP coil
    3565             :                     // Setup Report variables for water source Heat Pump
    3566          36 :                     SetupOutputVariable(state,
    3567             :                                         "Heating Coil Electricity Rate",
    3568             :                                         Constant::Units::W,
    3569          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Power,
    3570             :                                         OutputProcessor::TimeStepType::System,
    3571             :                                         OutputProcessor::StoreType::Average,
    3572          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3573          36 :                     SetupOutputVariable(state,
    3574             :                                         "Heating Coil Heating Rate",
    3575             :                                         Constant::Units::W,
    3576          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLoadTotal,
    3577             :                                         OutputProcessor::TimeStepType::System,
    3578             :                                         OutputProcessor::StoreType::Average,
    3579          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3580          36 :                     SetupOutputVariable(state,
    3581             :                                         "Heating Coil Sensible Heating Rate",
    3582             :                                         Constant::Units::W,
    3583          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSensible,
    3584             :                                         OutputProcessor::TimeStepType::System,
    3585             :                                         OutputProcessor::StoreType::Average,
    3586          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3587             : 
    3588          36 :                     SetupOutputVariable(state,
    3589             :                                         "Heating Coil Source Side Heat Transfer Rate",
    3590             :                                         Constant::Units::W,
    3591          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSource,
    3592             :                                         OutputProcessor::TimeStepType::System,
    3593             :                                         OutputProcessor::StoreType::Average,
    3594          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3595          36 :                     SetupOutputVariable(state,
    3596             :                                         "Heating Coil Part Load Ratio",
    3597             :                                         Constant::Units::None,
    3598          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PartLoadRatio,
    3599             :                                         OutputProcessor::TimeStepType::System,
    3600             :                                         OutputProcessor::StoreType::Average,
    3601          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3602          36 :                     SetupOutputVariable(state,
    3603             :                                         "Heating Coil Runtime Fraction",
    3604             :                                         Constant::Units::None,
    3605          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac,
    3606             :                                         OutputProcessor::TimeStepType::System,
    3607             :                                         OutputProcessor::StoreType::Average,
    3608          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3609             : 
    3610          36 :                     SetupOutputVariable(state,
    3611             :                                         "Heating Coil Air Mass Flow Rate",
    3612             :                                         Constant::Units::kg_s,
    3613          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate,
    3614             :                                         OutputProcessor::TimeStepType::System,
    3615             :                                         OutputProcessor::StoreType::Average,
    3616          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3617          36 :                     SetupOutputVariable(state,
    3618             :                                         "Heating Coil Air Inlet Temperature",
    3619             :                                         Constant::Units::C,
    3620          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirDBTemp,
    3621             :                                         OutputProcessor::TimeStepType::System,
    3622             :                                         OutputProcessor::StoreType::Average,
    3623          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3624          36 :                     SetupOutputVariable(state,
    3625             :                                         "Heating Coil Air Inlet Humidity Ratio",
    3626             :                                         Constant::Units::kgWater_kgDryAir,
    3627          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirHumRat,
    3628             :                                         OutputProcessor::TimeStepType::System,
    3629             :                                         OutputProcessor::StoreType::Average,
    3630          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3631          36 :                     SetupOutputVariable(state,
    3632             :                                         "Heating Coil Air Outlet Temperature",
    3633             :                                         Constant::Units::C,
    3634          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirDBTemp,
    3635             :                                         OutputProcessor::TimeStepType::System,
    3636             :                                         OutputProcessor::StoreType::Average,
    3637          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3638          36 :                     SetupOutputVariable(state,
    3639             :                                         "Heating Coil Air Outlet Humidity Ratio",
    3640             :                                         Constant::Units::kgWater_kgDryAir,
    3641          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirHumRat,
    3642             :                                         OutputProcessor::TimeStepType::System,
    3643             :                                         OutputProcessor::StoreType::Average,
    3644          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3645          36 :                     SetupOutputVariable(state,
    3646             :                                         "Heating Coil Source Side Mass Flow Rate",
    3647             :                                         Constant::Units::kg_s,
    3648          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterMassFlowRate,
    3649             :                                         OutputProcessor::TimeStepType::System,
    3650             :                                         OutputProcessor::StoreType::Average,
    3651          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3652          36 :                     SetupOutputVariable(state,
    3653             :                                         "Heating Coil Source Side Inlet Temperature",
    3654             :                                         Constant::Units::C,
    3655          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterTemp,
    3656             :                                         OutputProcessor::TimeStepType::System,
    3657             :                                         OutputProcessor::StoreType::Average,
    3658          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3659          36 :                     SetupOutputVariable(state,
    3660             :                                         "Heating Coil Source Side Outlet Temperature",
    3661             :                                         Constant::Units::C,
    3662          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletWaterTemp,
    3663             :                                         OutputProcessor::TimeStepType::System,
    3664             :                                         OutputProcessor::StoreType::Average,
    3665          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3666             : 
    3667          36 :                     SetupOutputVariable(state,
    3668             :                                         "Heating Coil Upper Speed Level",
    3669             :                                         Constant::Units::None,
    3670          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SpeedNumReport,
    3671             :                                         OutputProcessor::TimeStepType::System,
    3672             :                                         OutputProcessor::StoreType::Average,
    3673          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3674          36 :                     SetupOutputVariable(state,
    3675             :                                         "Heating Coil Neighboring Speed Levels Ratio",
    3676             :                                         Constant::Units::None,
    3677          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SpeedRatioReport,
    3678             :                                         OutputProcessor::TimeStepType::System,
    3679             :                                         OutputProcessor::StoreType::Average,
    3680          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3681          36 :                     SetupOutputVariable(state,
    3682             :                                         "Heating Coil Recoverable Heat Transfer Rate",
    3683             :                                         Constant::Units::W,
    3684          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QWasteHeat,
    3685             :                                         OutputProcessor::TimeStepType::System,
    3686             :                                         OutputProcessor::StoreType::Average,
    3687          18 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3688          10 :                 } else if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::CoilDX_HeatPumpWaterHeaterVariableSpeed) {
    3689             :                     // air source water heating coil
    3690          20 :                     SetupOutputVariable(state,
    3691             :                                         "Cooling Coil Water Heating Electricity Rate",
    3692             :                                         Constant::Units::W,
    3693          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Power,
    3694             :                                         OutputProcessor::TimeStepType::System,
    3695             :                                         OutputProcessor::StoreType::Average,
    3696          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3697          20 :                     SetupOutputVariable(state,
    3698             :                                         "Cooling Coil Total Cooling Rate",
    3699             :                                         Constant::Units::W,
    3700          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLoadTotal,
    3701             :                                         OutputProcessor::TimeStepType::System,
    3702             :                                         OutputProcessor::StoreType::Average,
    3703          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3704          20 :                     SetupOutputVariable(state,
    3705             :                                         "Cooling Coil Sensible Cooling Rate",
    3706             :                                         Constant::Units::W,
    3707          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSensible,
    3708             :                                         OutputProcessor::TimeStepType::System,
    3709             :                                         OutputProcessor::StoreType::Average,
    3710          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3711          20 :                     SetupOutputVariable(state,
    3712             :                                         "Cooling Coil Latent Cooling Rate",
    3713             :                                         Constant::Units::W,
    3714          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLatent,
    3715             :                                         OutputProcessor::TimeStepType::System,
    3716             :                                         OutputProcessor::StoreType::Average,
    3717          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3718          20 :                     SetupOutputVariable(state,
    3719             :                                         "Cooling Coil Total Water Heating Rate",
    3720             :                                         Constant::Units::W,
    3721          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).TotalHeatingEnergyRate,
    3722             :                                         OutputProcessor::TimeStepType::System,
    3723             :                                         OutputProcessor::StoreType::Average,
    3724          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3725          20 :                     SetupOutputVariable(state,
    3726             :                                         "Cooling Coil Part Load Ratio",
    3727             :                                         Constant::Units::None,
    3728          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PartLoadRatio,
    3729             :                                         OutputProcessor::TimeStepType::System,
    3730             :                                         OutputProcessor::StoreType::Average,
    3731          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3732          20 :                     SetupOutputVariable(state,
    3733             :                                         "Cooling Coil Runtime Fraction",
    3734             :                                         Constant::Units::None,
    3735          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac,
    3736             :                                         OutputProcessor::TimeStepType::System,
    3737             :                                         OutputProcessor::StoreType::Average,
    3738          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3739             : 
    3740          20 :                     SetupOutputVariable(state,
    3741             :                                         "Cooling Coil Air Mass Flow Rate",
    3742             :                                         Constant::Units::kg_s,
    3743          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate,
    3744             :                                         OutputProcessor::TimeStepType::System,
    3745             :                                         OutputProcessor::StoreType::Average,
    3746          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3747          20 :                     SetupOutputVariable(state,
    3748             :                                         "Cooling Coil Air Inlet Temperature",
    3749             :                                         Constant::Units::C,
    3750          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirDBTemp,
    3751             :                                         OutputProcessor::TimeStepType::System,
    3752             :                                         OutputProcessor::StoreType::Average,
    3753          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3754          20 :                     SetupOutputVariable(state,
    3755             :                                         "Cooling Coil Air Inlet Humidity Ratio",
    3756             :                                         Constant::Units::kgWater_kgDryAir,
    3757          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirHumRat,
    3758             :                                         OutputProcessor::TimeStepType::System,
    3759             :                                         OutputProcessor::StoreType::Average,
    3760          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3761          20 :                     SetupOutputVariable(state,
    3762             :                                         "Cooling Coil Air Outlet Temperature",
    3763             :                                         Constant::Units::C,
    3764          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirDBTemp,
    3765             :                                         OutputProcessor::TimeStepType::System,
    3766             :                                         OutputProcessor::StoreType::Average,
    3767          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3768          20 :                     SetupOutputVariable(state,
    3769             :                                         "Cooling Coil Air Outlet Humidity Ratio",
    3770             :                                         Constant::Units::kgWater_kgDryAir,
    3771          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirHumRat,
    3772             :                                         OutputProcessor::TimeStepType::System,
    3773             :                                         OutputProcessor::StoreType::Average,
    3774          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3775          20 :                     SetupOutputVariable(state,
    3776             :                                         "Cooling Coil Water Mass Flow Rate",
    3777             :                                         Constant::Units::kg_s,
    3778          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterMassFlowRate,
    3779             :                                         OutputProcessor::TimeStepType::System,
    3780             :                                         OutputProcessor::StoreType::Average,
    3781          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3782          20 :                     SetupOutputVariable(state,
    3783             :                                         "Cooling Coil Water Inlet Temperature",
    3784             :                                         Constant::Units::C,
    3785          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterTemp,
    3786             :                                         OutputProcessor::TimeStepType::System,
    3787             :                                         OutputProcessor::StoreType::Average,
    3788          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3789          20 :                     SetupOutputVariable(state,
    3790             :                                         "Cooling Coil Water Outlet Temperature",
    3791             :                                         Constant::Units::C,
    3792          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletWaterTemp,
    3793             :                                         OutputProcessor::TimeStepType::System,
    3794             :                                         OutputProcessor::StoreType::Average,
    3795          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3796             : 
    3797          20 :                     SetupOutputVariable(state,
    3798             :                                         "Cooling Coil Crankcase Heater Electricity Rate",
    3799             :                                         Constant::Units::W,
    3800          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterPower,
    3801             :                                         OutputProcessor::TimeStepType::System,
    3802             :                                         OutputProcessor::StoreType::Average,
    3803          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3804          20 :                     SetupOutputVariable(state,
    3805             :                                         "Cooling Coil Crankcase Heater Electricity Energy",
    3806             :                                         Constant::Units::J,
    3807          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterConsumption,
    3808             :                                         OutputProcessor::TimeStepType::System,
    3809             :                                         OutputProcessor::StoreType::Sum,
    3810          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    3811             :                                         Constant::eResource::Electricity,
    3812             :                                         OutputProcessor::Group::HVAC,
    3813             :                                         OutputProcessor::EndUseCat::Heating);
    3814             : 
    3815          20 :                     SetupOutputVariable(state,
    3816             :                                         "Cooling Coil Upper Speed Level",
    3817             :                                         Constant::Units::None,
    3818          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SpeedNumReport,
    3819             :                                         OutputProcessor::TimeStepType::System,
    3820             :                                         OutputProcessor::StoreType::Average,
    3821          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3822          20 :                     SetupOutputVariable(state,
    3823             :                                         "Cooling Coil Neighboring Speed Levels Ratio",
    3824             :                                         Constant::Units::None,
    3825          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SpeedRatioReport,
    3826             :                                         OutputProcessor::TimeStepType::System,
    3827             :                                         OutputProcessor::StoreType::Average,
    3828          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3829             : 
    3830          20 :                     SetupOutputVariable(state,
    3831             :                                         "Cooling Coil Water Heating Pump Electricity Rate",
    3832             :                                         Constant::Units::W,
    3833          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower,
    3834             :                                         OutputProcessor::TimeStepType::System,
    3835             :                                         OutputProcessor::StoreType::Average,
    3836          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3837          20 :                     SetupOutputVariable(state,
    3838             :                                         "Cooling Coil Water Heating Pump Electricity Energy",
    3839             :                                         Constant::Units::J,
    3840          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondPumpElecConsumption,
    3841             :                                         OutputProcessor::TimeStepType::System,
    3842             :                                         OutputProcessor::StoreType::Sum,
    3843          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    3844             :                                         Constant::eResource::Electricity,
    3845             :                                         OutputProcessor::Group::HVAC,
    3846             :                                         OutputProcessor::EndUseCat::Heating);
    3847             :                 }
    3848             :             }
    3849             :         }
    3850             : 
    3851          22 :         if (ErrorsFound) {
    3852           0 :             ShowFatalError(
    3853           0 :                 state, format("{}Errors found in getting {} input.  Preceding condition(s) causes termination.", RoutineName, CurrentModuleObject));
    3854             :         }
    3855          22 :     }
    3856             : 
    3857             :     // Beginning Initialization Section of the Module
    3858             :     //******************************************************************************
    3859             : 
    3860    45106592 :     void InitVarSpeedCoil(EnergyPlusData &state,
    3861             :                           int const DXCoilNum,                             // Current DXCoilNum under simulation
    3862             :                           Real64 const SensLoad,                           // Control zone sensible load[W]
    3863             :                           Real64 const LatentLoad,                         // Control zone latent load[W]
    3864             :                           HVAC::FanOp const fanOp,                         // fan operating mode
    3865             :                           [[maybe_unused]] Real64 const OnOffAirFlowRatio, // ratio of compressor on flow to average flow over time step
    3866             :                           Real64 const SpeedRatio,                         // compressor speed ratio
    3867             :                           int const SpeedNum                               // compressor speed number
    3868             :     )
    3869             :     {
    3870             : 
    3871             :         // SUBROUTINE INFORMATION:
    3872             :         //       AUTHOR         Bo Shen, based on  MODULE WaterToAirHeatPumpSimple:InitSimpleWatertoAirHP
    3873             :         //       DATE WRITTEN   March, 2012
    3874             :         //       MODIFIED       Bo Shen, 12/2014, add variable-speed HPWH
    3875             :         //       RE-ENGINEERED  na
    3876             : 
    3877             :         // PURPOSE OF THIS SUBROUTINE:
    3878             :         // This subroutine is for initializations of the variable speed Water to Air HP Components.
    3879             : 
    3880             :         // METHODOLOGY EMPLOYED:
    3881             :         // Uses the status flags to trigger initializations.
    3882             : 
    3883             :         // Using/Aliasing
    3884             :         using FluidProperties::GetDensityGlycol;
    3885             :         using FluidProperties::GetSpecificHeatGlycol;
    3886             : 
    3887             :         using PlantUtilities::InitComponentNodes;
    3888             :         using PlantUtilities::ScanPlantLoopsForObject;
    3889             :         using PlantUtilities::SetComponentFlowRate;
    3890             :         using Psychrometrics::PsyRhoAirFnPbTdbW;
    3891             : 
    3892             :         // Locals
    3893             :         // SUBROUTINE ARGUMENT DEFINITIONS:
    3894             : 
    3895             :         // shut off after compressor cycle off  [s]
    3896             : 
    3897             :         // SUBROUTINE PARAMETER DEFINITIONS:
    3898             :         static constexpr std::string_view RoutineNameSimpleWatertoAirHP("InitSimpleWatertoAirHP");
    3899             : 
    3900             :         // INTERFACE BLOCK SPECIFICATIONS
    3901             :         // na
    3902             : 
    3903             :         // DERIVED TYPE DEFINITIONS
    3904             :         // na
    3905             : 
    3906             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    3907             :         int AirInletNode;                  // Node Number of the air inlet
    3908             :         int WaterInletNode;                // Node Number of the Water inlet
    3909             :         Real64 rho;                        // local fluid density
    3910             :         Real64 Cp;                         // local fluid specific heat
    3911             :         int SpeedCal;                      // calculated speed level
    3912    45106592 :         bool ErrorsFound(false);           // TRUE when errors found, air loop initialization error
    3913             :         Real64 RatedVolFlowPerRatedTotCap; // Rated Air Volume Flow Rate divided by Rated Total Capacity [m3/s-W)
    3914             :         int Mode;                          // Performance mode for MultiMode DX coil; Always 1 for other coil types
    3915             :         Real64 RatedHeatPumpIndoorAirTemp; // Indoor dry-bulb temperature to heat pump evaporator at rated conditions [C]
    3916             :         Real64 RatedHeatPumpIndoorHumRat;  // Inlet humidity ratio to heat pump evaporator at rated conditions [kg/kg]
    3917             :         Real64 WaterFlowScale;             // water flow scaling factor match rated flow rate
    3918             : 
    3919             :         // SUBROUTINE PARAMETER DEFINITIONS:
    3920             :         static constexpr std::string_view RoutineName("InitVarSpeedCoil");
    3921             : 
    3922    45106592 :         if (state.dataVariableSpeedCoils->MyOneTimeFlag) {
    3923             :             // initialize the environment and sizing flags
    3924          22 :             state.dataVariableSpeedCoils->MySizeFlag.allocate(state.dataVariableSpeedCoils->NumVarSpeedCoils);
    3925          22 :             state.dataVariableSpeedCoils->MyEnvrnFlag.allocate(state.dataVariableSpeedCoils->NumVarSpeedCoils);
    3926          22 :             state.dataVariableSpeedCoils->MyPlantScanFlag.allocate(state.dataVariableSpeedCoils->NumVarSpeedCoils);
    3927          22 :             state.dataVariableSpeedCoils->MySizeFlag = true;
    3928          22 :             state.dataVariableSpeedCoils->MyEnvrnFlag = true;
    3929          22 :             state.dataVariableSpeedCoils->MyPlantScanFlag = true;
    3930          22 :             state.dataVariableSpeedCoils->MyOneTimeFlag = false;
    3931             :         }
    3932             : 
    3933    45106592 :         state.dataHVACGlobal->DXCT = HVAC::DXCoilType::Regular; // hard-code to non-DOAS sizing routine for cfm/ton until .ISHundredPercentDOASDXCoil
    3934             :                                                                 // member from DXcoils.cc is added to VarSpeedCoil object
    3935             : 
    3936             :         // variable-speed heat pump water heating, begin
    3937    46793064 :         if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::CoilDX_HeatPumpWaterHeaterVariableSpeed &&
    3938     1686472 :             state.dataVariableSpeedCoils->MySizeFlag(DXCoilNum)) {
    3939             : 
    3940          10 :             ErrorsFound = false;
    3941          10 :             SizeVarSpeedCoil(state, DXCoilNum, ErrorsFound);
    3942          10 :             if (ErrorsFound) {
    3943           0 :                 ShowFatalError(state, format("{}: Failed to size variable speed coil.", RoutineName));
    3944             :             }
    3945             : 
    3946             :             //   get rated coil bypass factor excluding fan heat
    3947             : 
    3948          10 :             state.dataVariableSpeedCoils->MySizeFlag(DXCoilNum) = false;
    3949             :         }
    3950             :         // variable-speed heat pump water heating, end
    3951             : 
    3952             :         // water source
    3953    85691391 :         if ((state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_CoolingWaterToAirHPVSEquationFit) ||
    3954    40584799 :             (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_HeatingWaterToAirHPVSEquationFit)) { // fix coil type
    3955     9043586 :             if (state.dataVariableSpeedCoils->MyPlantScanFlag(DXCoilNum) && allocated(state.dataPlnt->PlantLoop)) {
    3956             :                 // switch from coil type numbers in DataHVACGlobals, to coil type numbers in plant.
    3957          36 :                 DataPlant::PlantEquipmentType CoilVSWAHPType(DataPlant::PlantEquipmentType::Invalid);
    3958          36 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_CoolingWaterToAirHPVSEquationFit) {
    3959          18 :                     CoilVSWAHPType = DataPlant::PlantEquipmentType::CoilVSWAHPCoolingEquationFit;
    3960          18 :                 } else if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_HeatingWaterToAirHPVSEquationFit) {
    3961          18 :                     CoilVSWAHPType = DataPlant::PlantEquipmentType::CoilVSWAHPHeatingEquationFit;
    3962             :                 }
    3963          36 :                 ErrorsFound = false;
    3964          72 :                 ScanPlantLoopsForObject(state,
    3965          36 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    3966             :                                         CoilVSWAHPType,
    3967          36 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).plantLoc,
    3968             :                                         ErrorsFound,
    3969             :                                         _,
    3970             :                                         _,
    3971             :                                         _,
    3972             :                                         _,
    3973             :                                         _);
    3974          36 :                 if (ErrorsFound) {
    3975           0 :                     ShowFatalError(state, "InitVarSpeedCoil: Program terminated for previous conditions.");
    3976             :                 }
    3977          36 :                 state.dataVariableSpeedCoils->MyPlantScanFlag(DXCoilNum) = false;
    3978             :             }
    3979             :         } else {
    3980    36063006 :             state.dataVariableSpeedCoils->MyPlantScanFlag(DXCoilNum) = false;
    3981             :         }
    3982             : 
    3983    45106659 :         if (!state.dataGlobal->SysSizingCalc && state.dataVariableSpeedCoils->MySizeFlag(DXCoilNum) &&
    3984          67 :             !state.dataVariableSpeedCoils->MyPlantScanFlag(DXCoilNum)) {
    3985             :             // for each furnace, do the sizing once.
    3986          67 :             ErrorsFound = false;
    3987          67 :             SizeVarSpeedCoil(state, DXCoilNum, ErrorsFound);
    3988          67 :             if (ErrorsFound) {
    3989           0 :                 ShowFatalError(state, format("{}: Failed to size variable speed coil.", RoutineName));
    3990             :             }
    3991             : 
    3992          67 :             state.dataVariableSpeedCoils->MySizeFlag(DXCoilNum) = false;
    3993             : 
    3994             :             // Multispeed Cooling
    3995         116 :             if ((state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_CoolingWaterToAirHPVSEquationFit) ||
    3996          49 :                 (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_CoolingAirToAirVariableSpeed)) {
    3997         380 :                 for (Mode = 1; Mode <= state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds; ++Mode) {
    3998         340 :                     if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedCapCoolTotal <= 0.0) break;
    3999             :                     // Check for zero capacity or zero max flow rate
    4000         340 :                     if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(Mode) <= 0.0) {
    4001           0 :                         ShowSevereError(state,
    4002           0 :                                         format("Sizing: {} {} has zero rated total capacity at speed {}",
    4003           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VarSpeedCoilType,
    4004           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    4005             :                                                Mode));
    4006           0 :                         ErrorsFound = true;
    4007             :                     }
    4008         340 :                     if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowRate(Mode) <= 0.0) {
    4009           0 :                         ShowSevereError(state,
    4010           0 :                                         format("Sizing: {} {} has zero rated air flow rate at speed {}",
    4011           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VarSpeedCoilType,
    4012           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    4013             :                                                Mode));
    4014           0 :                         ErrorsFound = true;
    4015             :                     }
    4016         340 :                     if (ErrorsFound) {
    4017           0 :                         ShowFatalError(state, "Preceding condition causes termination.");
    4018             :                     }
    4019             :                     // Check for valid range of (Rated Air Volume Flow Rate / Rated Total Capacity)
    4020         340 :                     RatedVolFlowPerRatedTotCap = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowRate(Mode) /
    4021         340 :                                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(Mode);
    4022             :                     // note: variable-speed HP can exceed the flow rate restrictions at low speed levels
    4023             :                     //        IF (((MinRatedAirVolFlowPerRatedTotCap - RatedVolFlowPerRatedTotCap) > SmallDifferenceTest).OR. &
    4024             :                     //           ((RatedVolFlowPerRatedTotCap - MaxRatedAirVolFlowPerRatedTotCap) > SmallDifferenceTest)) THEN
    4025             :                     //          CALL ShowSevereError(state,'Sizing: '//TRIM(VarSpeedCoil(DXCoilNum)%VarSpeedCoilType) &
    4026             :                     //           // ' "'//TRIM(VarSpeedCoil(DXCoilNum)%Name)//  &
    4027             :                     //                '": Rated air volume flow rate per watt of rated total '// &
    4028             :                     //                'cooling capacity is out of range at speed '//TRIM(TrimSigDigits(Mode)))
    4029             :                     //          CALL ShowContinueError &
    4030             :                     //           ('Min Rated Vol Flow Per Watt=['//TRIM(TrimSigDigits(MinRatedAirVolFlowPerRatedTotCap,3))//'], '// &
    4031             :                     //           'Rated Vol Flow Per Watt=['//TRIM(TrimSigDigits(RatedVolFlowPerRatedTotCap,3))//'],  &
    4032             :                     //           Max Rated Vol Flow Per Watt=['// &
    4033             :                     //           TRIM(TrimSigDigits(MaxRatedAirVolFlowPerRatedTotCap,3))//']. See Input-Output Reference Manual for valid range.')
    4034             :                     //        END IF
    4035             :                     //        VarSpeedCoil(DXCoilNum)%MSRatedAirMassFlowRate(Mode) = VarSpeedCoil(DXCoilNum)%MSRatedAirVolFlowRate(Mode)* &
    4036             :                     //          PsyRhoAirFnPbTdbW(state, OutBaroPress,RatedInletAirTemp,RatedInletAirHumRat,RoutineName)
    4037             :                     //        ! get high speed rated coil bypass factor
    4038             :                     //        VarSpeedCoil(DXCoilNum)%MSRatedCBF(Mode) = CalcCBF(VarSpeedCoil(DXCoilNum)%VarSpeedCoilType, &
    4039             :                     //               VarSpeedCoil(DXCoilNum)%Name,&
    4040             :                     //                                           RatedInletAirTemp,RatedInletAirHumRat,VarSpeedCoil(DXCoilNum)%MSRatedTotCap(Mode),&
    4041             :                     //                                           VarSpeedCoil(DXCoilNum)%MSRatedAirMassFlowRate(Mode), &
    4042             :                     //                           VarSpeedCoil(DXCoilNum)%MSRatedSHR(Mode))
    4043             :                 }
    4044             :                 // call coil model with everthing set at rating point
    4045          40 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirDBTemp = RatedInletAirTemp;
    4046          40 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirHumRat =
    4047          40 :                     Psychrometrics::PsyWFnTdbTwbPb(state, RatedInletAirTemp, RatedInletWetBulbTemp, DataEnvironment::StdPressureSeaLevel);
    4048          40 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirEnthalpy =
    4049          40 :                     Psychrometrics::PsyHFnTdbW(RatedInletAirTemp, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirHumRat);
    4050          40 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirPressure = DataEnvironment::StdPressureSeaLevel;
    4051             : 
    4052          40 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate =
    4053          40 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedAirVolFlowRate *
    4054          80 :                     Psychrometrics::PsyRhoAirFnPbTdbW(state,
    4055             :                                                       DataEnvironment::StdPressureSeaLevel,
    4056             :                                                       RatedInletAirTemp,
    4057          40 :                                                       state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirHumRat);
    4058             :                 // store environment data fill back in after rating point calc is over
    4059          40 :                 Real64 holdOutDryBulbTemp = state.dataEnvrn->OutDryBulbTemp;
    4060          40 :                 Real64 holdOutHumRat = state.dataEnvrn->OutHumRat;
    4061          40 :                 Real64 holdOutWetBulb = state.dataEnvrn->OutWetBulbTemp;
    4062          40 :                 Real64 holdOutBaroPress = state.dataEnvrn->OutBaroPress;
    4063          40 :                 Real64 ratedOutdoorAirWetBulb = 23.9; // from I/O ref. more precise value?
    4064             : 
    4065          40 :                 state.dataEnvrn->OutDryBulbTemp = RatedAmbAirTemp;
    4066          40 :                 state.dataEnvrn->OutWetBulbTemp = ratedOutdoorAirWetBulb;
    4067          40 :                 state.dataEnvrn->OutBaroPress = DataEnvironment::StdPressureSeaLevel; // assume rating is for sea level.
    4068          80 :                 state.dataEnvrn->OutHumRat =
    4069          40 :                     Psychrometrics::PsyWFnTdbTwbPb(state, RatedAmbAirTemp, ratedOutdoorAirWetBulb, DataEnvironment::StdPressureSeaLevel, RoutineName);
    4070          40 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum > 0) {
    4071           1 :                     state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum).Temp = RatedAmbAirTemp;
    4072           1 :                     state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum).HumRat =
    4073           1 :                         state.dataEnvrn->OutHumRat;
    4074           1 :                     state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum).Press =
    4075             :                         DataEnvironment::StdPressureSeaLevel;
    4076           1 :                     state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum).OutAirWetBulb =
    4077             :                         ratedOutdoorAirWetBulb;
    4078             :                 }
    4079          40 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType ==
    4080             :                     HVAC::Coil_CoolingWaterToAirHPVSEquationFit) { // need to set water info for WSHP
    4081          18 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterMassFlowRate =
    4082          36 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterMassFlowRate(
    4083          18 :                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds);
    4084          18 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterTemp = RatedInletWaterTemp; // 85 F cooling mode
    4085          18 :                     Real64 CpSource = GetSpecificHeatGlycol(
    4086             :                         state,
    4087          18 :                         state.dataPlnt->PlantLoop(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).plantLoc.loopNum).FluidName,
    4088          18 :                         state.dataVariableSpeedCoils->SourceSideInletTemp,
    4089          18 :                         state.dataPlnt->PlantLoop(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).plantLoc.loopNum).FluidIndex,
    4090             :                         RoutineName);
    4091          18 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterEnthalpy =
    4092          18 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterTemp * CpSource;
    4093             :                 }
    4094             : 
    4095             :                 // calculate coil model at rating point
    4096          40 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac = 1.0;
    4097          40 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignAirMassFlowRate =
    4098          80 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirMassFlowRate(
    4099          40 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds);
    4100          40 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignAirVolFlowRate =
    4101          80 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowRate(
    4102          40 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds);
    4103          40 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignWaterMassFlowRate =
    4104          80 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterMassFlowRate(
    4105          40 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds);
    4106          40 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignWaterVolFlowRate =
    4107          80 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterVolFlowRate(
    4108          40 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds);
    4109             : 
    4110          40 :                 CalcVarSpeedCoilCooling(state,
    4111             :                                         DXCoilNum,
    4112             :                                         HVAC::FanOp::Continuous,
    4113             :                                         SensLoad,
    4114             :                                         LatentLoad,
    4115             :                                         HVAC::CompressorOp::On,
    4116             :                                         1.0,
    4117             :                                         1.0,
    4118             :                                         1.0,
    4119          40 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds);
    4120             :                 // coil outlets
    4121          40 :                 Real64 RatedOutletWetBulb(0.0);
    4122         120 :                 RatedOutletWetBulb = Psychrometrics::PsyTwbFnTdbWPb(state,
    4123          40 :                                                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirDBTemp,
    4124          40 :                                                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirHumRat,
    4125             :                                                                     DataEnvironment::StdPressureSeaLevel,
    4126             :                                                                     RoutineName);
    4127          40 :                 state.dataRptCoilSelection->coilSelectionReportObj->setRatedCoilConditions(
    4128             :                     state,
    4129          40 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    4130          40 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VarSpeedCoilType,
    4131          40 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLoadTotal, // this is the report variable
    4132          40 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSensible,  // this is the report variable
    4133          40 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate,
    4134          40 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirDBTemp,
    4135          40 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirHumRat,
    4136             :                     RatedInletWetBulbTemp,
    4137          40 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirDBTemp,
    4138          40 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirHumRat,
    4139             :                     RatedOutletWetBulb,
    4140             :                     RatedAmbAirTemp,
    4141             :                     ratedOutdoorAirWetBulb,
    4142          80 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedCBF(
    4143          40 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds),
    4144             :                     -999.0); // coil effectiveness not define for DX
    4145             : 
    4146             :                 // now replace the outdoor air conditions set above for one time rating point calc
    4147          40 :                 state.dataEnvrn->OutDryBulbTemp = holdOutDryBulbTemp;
    4148          40 :                 state.dataEnvrn->OutHumRat = holdOutHumRat;
    4149          40 :                 state.dataEnvrn->OutWetBulbTemp = holdOutWetBulb;
    4150          40 :                 state.dataEnvrn->OutBaroPress = holdOutBaroPress;
    4151             :             }
    4152             : 
    4153             :             // Multispeed Heating
    4154         116 :             if ((state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_HeatingWaterToAirHPVSEquationFit) ||
    4155          49 :                 (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_HeatingAirToAirVariableSpeed)) {
    4156          27 :                 RatedHeatPumpIndoorAirTemp = 21.11;  // 21.11C or 70F
    4157          27 :                 RatedHeatPumpIndoorHumRat = 0.00881; // Humidity ratio corresponding to 70F dry bulb/60F wet bulb
    4158         287 :                 for (Mode = 1; Mode <= state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds; ++Mode) {
    4159             : 
    4160         260 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirMassFlowRate(Mode) =
    4161         260 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowRate(Mode) *
    4162         260 :                         PsyRhoAirFnPbTdbW(state, state.dataEnvrn->OutBaroPress, RatedHeatPumpIndoorAirTemp, RatedHeatPumpIndoorHumRat, RoutineName);
    4163             :                     // Check for valid range of (Rated Air Volume Flow Rate / Rated Total Capacity)
    4164         260 :                     RatedVolFlowPerRatedTotCap = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowRate(Mode) /
    4165         260 :                                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(Mode);
    4166             :                     // note: variable-speed HP can exceed the flow rate restrictions at low speed levels
    4167             :                     //        IF (((MinRatedAirVolFlowPerRatedTotCap - RatedVolFlowPerRatedTotCap) > SmallDifferenceTest).OR. &
    4168             :                     //            ((RatedVolFlowperRatedTotCap - MaxRatedAirVolFlowPerRatedTotCap) > SmallDifferenceTest)) THEN
    4169             :                     //          CALL ShowSevereError(state,'Coil:Heating:DX:MultiSpeed '//TRIM(VarSpeedCoil(DXCoilNum)%Name)//  &
    4170             :                     //                              ': Rated air volume flow rate per watt of rated total '// &
    4171             :                     //                'heating capacity is out of range at speed '//TRIM(TrimSigDigits(Mode)))
    4172             :                     //          CALL ShowContinueError(state, 'Min Rated Vol Flow Per Watt=['//TRIM(TrimSigDigits &
    4173             :                     //           (MinRatedAirVolFlowPerRatedTotCap,3))//'], '// &
    4174             :                     //           'Rated Vol Flow Per Watt=['//TRIM(TrimSigDigits(RatedVolFlowPerRatedTotCap,3))//'],  &
    4175             :                     //               Max Rated Vol Flow Per Watt=['// &
    4176             :                     //           TRIM(TrimSigDigits(MaxRatedAirVolFlowPerRatedTotCap,3))//']. See Input-Output Reference  &
    4177             :                     //                Manual for valid range.')
    4178             :                     //        END IF
    4179             :                 }
    4180             :                 // call coil model with everthing set at rating point
    4181          27 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirDBTemp = RatedInletAirTempHeat;
    4182          27 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirHumRat =
    4183          27 :                     Psychrometrics::PsyWFnTdbTwbPb(state, RatedInletAirTempHeat, RatedInletWetBulbTemp, DataEnvironment::StdPressureSeaLevel);
    4184          27 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirEnthalpy =
    4185          27 :                     Psychrometrics::PsyHFnTdbW(RatedInletAirTempHeat, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirHumRat);
    4186          27 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirPressure = DataEnvironment::StdPressureSeaLevel;
    4187             : 
    4188          27 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate =
    4189          27 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedAirVolFlowRate *
    4190          54 :                     Psychrometrics::PsyRhoAirFnPbTdbW(state,
    4191             :                                                       DataEnvironment::StdPressureSeaLevel,
    4192             :                                                       RatedInletAirTempHeat,
    4193          27 :                                                       state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirHumRat);
    4194             :                 // store environment data fill back in after rating point calc is over
    4195          27 :                 Real64 holdOutDryBulbTemp = state.dataEnvrn->OutDryBulbTemp;
    4196          27 :                 Real64 holdOutHumRat = state.dataEnvrn->OutHumRat;
    4197          27 :                 Real64 holdOutWetBulb = state.dataEnvrn->OutWetBulbTemp;
    4198          27 :                 Real64 holdOutBaroPress = state.dataEnvrn->OutBaroPress;
    4199             : 
    4200          27 :                 state.dataEnvrn->OutDryBulbTemp = RatedAmbAirTempHeat;
    4201          27 :                 state.dataEnvrn->OutWetBulbTemp = RatedAmbAirWBHeat;
    4202          27 :                 state.dataEnvrn->OutBaroPress = DataEnvironment::StdPressureSeaLevel; // assume rating is for sea level.
    4203          54 :                 state.dataEnvrn->OutHumRat =
    4204          27 :                     Psychrometrics::PsyWFnTdbTwbPb(state, RatedAmbAirTempHeat, RatedAmbAirWBHeat, DataEnvironment::StdPressureSeaLevel, RoutineName);
    4205          27 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum > 0) {
    4206           0 :                     state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum).Temp = RatedAmbAirTempHeat;
    4207           0 :                     state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum).HumRat =
    4208           0 :                         state.dataEnvrn->OutHumRat;
    4209           0 :                     state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum).Press =
    4210             :                         DataEnvironment::StdPressureSeaLevel;
    4211           0 :                     state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum).OutAirWetBulb =
    4212             :                         RatedAmbAirWBHeat;
    4213             :                 }
    4214             : 
    4215          27 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType ==
    4216             :                     HVAC::Coil_HeatingWaterToAirHPVSEquationFit) { // need to set water info for WSHP
    4217          18 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterMassFlowRate =
    4218          36 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterMassFlowRate(
    4219          18 :                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds);
    4220          18 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterTemp = RatedInletWaterTempHeat; // 21.11C or 70F, heating mode
    4221          18 :                     Real64 CpSource = GetSpecificHeatGlycol(
    4222             :                         state,
    4223          18 :                         state.dataPlnt->PlantLoop(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).plantLoc.loopNum).FluidName,
    4224          18 :                         state.dataVariableSpeedCoils->SourceSideInletTemp,
    4225          18 :                         state.dataPlnt->PlantLoop(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).plantLoc.loopNum).FluidIndex,
    4226             :                         RoutineName);
    4227          18 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterEnthalpy =
    4228          18 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterTemp * CpSource;
    4229             :                 }
    4230             : 
    4231             :                 // calculate coil model at rating point
    4232          27 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac = 1.0;
    4233          27 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignAirMassFlowRate =
    4234          54 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirMassFlowRate(
    4235          27 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds);
    4236          27 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignAirVolFlowRate =
    4237          54 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowRate(
    4238          27 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds);
    4239          27 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignWaterMassFlowRate =
    4240          54 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterMassFlowRate(
    4241          27 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds);
    4242          27 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignWaterVolFlowRate =
    4243          54 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterVolFlowRate(
    4244          27 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds);
    4245          27 :                 CalcVarSpeedCoilHeating(state,
    4246             :                                         DXCoilNum,
    4247             :                                         HVAC::FanOp::Continuous,
    4248             :                                         SensLoad,
    4249             :                                         HVAC::CompressorOp::On,
    4250             :                                         1.0,
    4251             :                                         1.0,
    4252             :                                         1.0,
    4253          27 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds);
    4254             :                 // coil outlets
    4255          27 :                 Real64 RatedOutletWetBulb(0.0);
    4256          81 :                 RatedOutletWetBulb = Psychrometrics::PsyTwbFnTdbWPb(state,
    4257          27 :                                                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirDBTemp,
    4258          27 :                                                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirHumRat,
    4259             :                                                                     DataEnvironment::StdPressureSeaLevel,
    4260             :                                                                     RoutineName);
    4261          27 :                 state.dataRptCoilSelection->coilSelectionReportObj->setRatedCoilConditions(
    4262             :                     state,
    4263          27 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    4264          27 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VarSpeedCoilType,
    4265          27 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLoadTotal, // this is the report variable
    4266          27 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSensible,  // this is the report variable
    4267          27 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate,
    4268          27 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirDBTemp,
    4269          27 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirHumRat,
    4270             :                     RatedInletWetBulbTemp,
    4271          27 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirDBTemp,
    4272          27 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirHumRat,
    4273             :                     RatedOutletWetBulb,
    4274             :                     RatedAmbAirTempHeat,
    4275             :                     RatedAmbAirWBHeat,
    4276          54 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedCBF(
    4277          27 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds),
    4278             :                     -999.0); // coil effectiveness not define for DX
    4279             : 
    4280             :                 // now replace the outdoor air conditions set above for one time rating point calc
    4281          27 :                 state.dataEnvrn->OutDryBulbTemp = holdOutDryBulbTemp;
    4282          27 :                 state.dataEnvrn->OutHumRat = holdOutHumRat;
    4283          27 :                 state.dataEnvrn->OutWetBulbTemp = holdOutWetBulb;
    4284          27 :                 state.dataEnvrn->OutBaroPress = holdOutBaroPress;
    4285             :             }
    4286             : 
    4287             :             // store fan info for coil
    4288          67 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SupplyFanIndex > 0) {
    4289          12 :                 state.dataRptCoilSelection->coilSelectionReportObj->setCoilSupplyFanInfo(
    4290             :                     state,
    4291          12 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    4292          12 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VarSpeedCoilType,
    4293          12 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SupplyFanName,
    4294          12 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).supplyFanType,
    4295          12 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SupplyFanIndex);
    4296             :             }
    4297             :         }
    4298             : 
    4299    45106592 :         if (SpeedNum > state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds) {
    4300           0 :             SpeedCal = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds;
    4301    45106592 :         } else if (SpeedNum < 1) {
    4302           0 :             SpeedCal = 1;
    4303             :         } else {
    4304    45106592 :             SpeedCal = SpeedNum;
    4305             :         }
    4306             : 
    4307    45106592 :         if ((SpeedNum <= 1) || (SpeedNum > state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds)) {
    4308    22500554 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignAirMassFlowRate =
    4309    22500554 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirMassFlowRate(SpeedCal);
    4310    22500554 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignAirVolFlowRate =
    4311    22500554 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowRate(SpeedCal);
    4312    22500554 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignWaterMassFlowRate =
    4313    22500554 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterMassFlowRate(SpeedCal);
    4314    22500554 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignWaterVolFlowRate =
    4315    22500554 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterVolFlowRate(SpeedCal);
    4316             :         } else {
    4317    22606038 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignAirMassFlowRate =
    4318    22606038 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirMassFlowRate(SpeedCal) * SpeedRatio +
    4319    22606038 :                 (1.0 - SpeedRatio) * state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirMassFlowRate(SpeedCal - 1);
    4320    22606038 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignAirVolFlowRate =
    4321    22606038 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowRate(SpeedCal) * SpeedRatio +
    4322    22606038 :                 (1.0 - SpeedRatio) * state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowRate(SpeedCal - 1);
    4323    22606038 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignWaterMassFlowRate =
    4324    22606038 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterMassFlowRate(SpeedCal) * SpeedRatio +
    4325    22606038 :                 (1.0 - SpeedRatio) * state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterMassFlowRate(SpeedCal - 1);
    4326    22606038 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignWaterVolFlowRate =
    4327    22606038 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterVolFlowRate(SpeedCal) * SpeedRatio +
    4328    22606038 :                 (1.0 - SpeedRatio) * state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterVolFlowRate(SpeedCal - 1);
    4329             :         }
    4330             : 
    4331             :         // Do the Begin Environment initializations
    4332    45107041 :         if (state.dataGlobal->BeginEnvrnFlag && state.dataVariableSpeedCoils->MyEnvrnFlag(DXCoilNum) &&
    4333         449 :             !state.dataVariableSpeedCoils->MyPlantScanFlag(DXCoilNum)) {
    4334             :             // Do the initializations to start simulation
    4335             : 
    4336         449 :             AirInletNode = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirInletNodeNum;
    4337             : 
    4338             :             // Initialize all report variables to a known state at beginning of simulation
    4339         449 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirVolFlowRate = 0.0;
    4340         449 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirDBTemp = 0.0;
    4341         449 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirHumRat = 0.0;
    4342         449 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirDBTemp = 0.0;
    4343         449 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirHumRat = 0.0;
    4344         449 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterVolFlowRate = 0.0;
    4345         449 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterMassFlowRate = 0.0;
    4346         449 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterTemp = 0.0;
    4347         449 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterEnthalpy = 0.0;
    4348         449 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletWaterEnthalpy = 0.0;
    4349         449 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletWaterTemp = 0.0;
    4350         449 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Power = 0.0;
    4351         449 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLoadTotal = 0.0;
    4352         449 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSensible = 0.0;
    4353         449 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLatent = 0.0;
    4354         449 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSource = 0.0;
    4355         449 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Energy = 0.0;
    4356         449 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLoadTotal = 0.0;
    4357         449 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergySensible = 0.0;
    4358         449 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLatent = 0.0;
    4359         449 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergySource = 0.0;
    4360         449 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).COP = 0.0;
    4361         449 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac = 0.0;
    4362         449 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PartLoadRatio = 0.0;
    4363             : 
    4364         792 :             if ((state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_HeatingWaterToAirHPVSEquationFit) ||
    4365         343 :                 (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_CoolingWaterToAirHPVSEquationFit)) {
    4366         212 :                 WaterInletNode = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterInletNodeNum;
    4367             : 
    4368         212 :                 rho = GetDensityGlycol(state,
    4369         212 :                                        state.dataPlnt->PlantLoop(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).plantLoc.loopNum).FluidName,
    4370             :                                        Constant::CWInitConvTemp,
    4371         212 :                                        state.dataPlnt->PlantLoop(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).plantLoc.loopNum).FluidIndex,
    4372             :                                        RoutineNameSimpleWatertoAirHP);
    4373         212 :                 Cp = GetSpecificHeatGlycol(
    4374             :                     state,
    4375         212 :                     state.dataPlnt->PlantLoop(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).plantLoc.loopNum).FluidName,
    4376             :                     Constant::CWInitConvTemp,
    4377         212 :                     state.dataPlnt->PlantLoop(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).plantLoc.loopNum).FluidIndex,
    4378             :                     RoutineNameSimpleWatertoAirHP);
    4379             : 
    4380             :                 //    VarSpeedCoil(DXCoilNum)%DesignWaterMassFlowRate= &
    4381             :                 //                             rho * VarSpeedCoil(DXCoilNum)%RatedWaterVolFlowRate
    4382             : 
    4383         636 :                 InitComponentNodes(state,
    4384             :                                    0.0,
    4385         212 :                                    state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignWaterMassFlowRate,
    4386         212 :                                    state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterInletNodeNum,
    4387         212 :                                    state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterOutletNodeNum);
    4388             : 
    4389         212 :                 state.dataLoopNodes->Node(WaterInletNode).Temp = 5.0;
    4390         212 :                 state.dataLoopNodes->Node(WaterInletNode).Enthalpy = Cp * state.dataLoopNodes->Node(WaterInletNode).Temp;
    4391         212 :                 state.dataLoopNodes->Node(WaterInletNode).Quality = 0.0;
    4392         212 :                 state.dataLoopNodes->Node(WaterInletNode).Press = 0.0;
    4393         212 :                 state.dataLoopNodes->Node(WaterInletNode).HumRat = 0.0;
    4394             : 
    4395         212 :                 state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterOutletNodeNum).Temp = 5.0;
    4396         212 :                 state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterOutletNodeNum).Enthalpy =
    4397         212 :                     Cp * state.dataLoopNodes->Node(WaterInletNode).Temp;
    4398         212 :                 state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterOutletNodeNum).Quality = 0.0;
    4399         212 :                 state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterOutletNodeNum).Press = 0.0;
    4400         212 :                 state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterOutletNodeNum).HumRat = 0.0;
    4401             :             }
    4402             : 
    4403         449 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SimFlag = true;
    4404         449 :             state.dataHeatBal->HeatReclaimVS_DXCoil(DXCoilNum).AvailCapacity = 0.0;
    4405             : 
    4406         449 :             state.dataVariableSpeedCoils->MyEnvrnFlag(DXCoilNum) = false;
    4407             : 
    4408             :         } // End If for the Begin Environment initializations
    4409             : 
    4410    45106592 :         if (!state.dataGlobal->BeginEnvrnFlag) {
    4411    45062352 :             state.dataVariableSpeedCoils->MyEnvrnFlag(DXCoilNum) = true;
    4412             :         }
    4413             : 
    4414             :         // Do the following initializations (every time step): This should be the info from
    4415             :         // the previous components outlets or the node data in this section.
    4416             :         // First set the conditions for the air into the heat pump model
    4417             : 
    4418             :         // Set water and air inlet nodes
    4419             : 
    4420    45106592 :         AirInletNode = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirInletNodeNum;
    4421    45106592 :         WaterInletNode = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterInletNodeNum;
    4422             : 
    4423    45106592 :         if ((SensLoad != 0.0 || LatentLoad != 0.0) && (state.dataLoopNodes->Node(AirInletNode).MassFlowRate > 0.0)) {
    4424             : 
    4425    30240509 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterMassFlowRate(
    4426    30240509 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel) > 0.0) {
    4427     3439666 :                 WaterFlowScale = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedWaterMassFlowRate /
    4428     3439666 :                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterMassFlowRate(
    4429     3439666 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel);
    4430     3439666 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterMassFlowRate =
    4431     3439666 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignWaterMassFlowRate * WaterFlowScale;
    4432             :             } else {
    4433    26800843 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterMassFlowRate = 0.0;
    4434             :             }
    4435             : 
    4436    30240509 :             if (fanOp == HVAC::FanOp::Continuous) {
    4437             :                 // continuous fan, cycling compressor
    4438    29590555 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate = state.dataLoopNodes->Node(AirInletNode).MassFlowRate;
    4439             :                 //    VarSpeedCoil(DXCoilNum)%AirMassFlowRate   = VarSpeedCoil(DXCoilNum)%DesignAirVolFlowRate*  &
    4440             :                 //             PsyRhoAirFnPbTdbW(state, OutBaroPress,Node(AirInletNode)%Temp,Node(AirInletNode)%HumRat)
    4441             :                 // If air flow is less than 25% rated flow. Then set air flow to the 25% of rated conditions
    4442    29590555 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate <
    4443    29590555 :                     0.25 * state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignAirVolFlowRate *
    4444    59181110 :                         PsyRhoAirFnPbTdbW(state,
    4445    29590555 :                                           state.dataEnvrn->OutBaroPress,
    4446    29590555 :                                           state.dataLoopNodes->Node(AirInletNode).Temp,
    4447    29590555 :                                           state.dataLoopNodes->Node(AirInletNode).HumRat)) {
    4448      102927 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate =
    4449      102927 :                         0.25 * state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignAirVolFlowRate *
    4450      308781 :                         PsyRhoAirFnPbTdbW(state,
    4451      102927 :                                           state.dataEnvrn->OutBaroPress,
    4452      102927 :                                           state.dataLoopNodes->Node(AirInletNode).Temp,
    4453      102927 :                                           state.dataLoopNodes->Node(AirInletNode).HumRat);
    4454             :                 }
    4455             :             } else { // CYCLIC FAN, NOT CORRECTION, WILL BE PROCESSED IN THE FOLLOWING SUBROUTINES
    4456      649954 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate = state.dataLoopNodes->Node(AirInletNode).MassFlowRate;
    4457             :             }
    4458             : 
    4459             :         } else { // heat pump is off
    4460    14866083 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterMassFlowRate = 0.0;
    4461    14866083 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate = 0.0;
    4462             :         }
    4463             : 
    4464    85691391 :         if ((state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_HeatingWaterToAirHPVSEquationFit) ||
    4465    40584799 :             (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_CoolingWaterToAirHPVSEquationFit)) {
    4466    27130758 :             SetComponentFlowRate(state,
    4467     9043586 :                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterMassFlowRate,
    4468     9043586 :                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterInletNodeNum,
    4469     9043586 :                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterOutletNodeNum,
    4470     9043586 :                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).plantLoc);
    4471             : 
    4472     9043586 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterTemp = state.dataLoopNodes->Node(WaterInletNode).Temp;
    4473     9043586 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterEnthalpy = state.dataLoopNodes->Node(WaterInletNode).Enthalpy;
    4474             :         } else {
    4475    36063006 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterTemp = 0.0;
    4476    36063006 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterEnthalpy = 0.0;
    4477             :         }
    4478             : 
    4479    45106592 :         if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::CoilDX_HeatPumpWaterHeaterVariableSpeed) {
    4480     1686472 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterTemp = state.dataLoopNodes->Node(WaterInletNode).Temp;
    4481     1686472 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterEnthalpy = state.dataLoopNodes->Node(WaterInletNode).Enthalpy;
    4482             :         };
    4483             : 
    4484    45106592 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirDBTemp = state.dataLoopNodes->Node(AirInletNode).Temp;
    4485    45106592 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirHumRat = state.dataLoopNodes->Node(AirInletNode).HumRat;
    4486    45106592 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirEnthalpy = state.dataLoopNodes->Node(AirInletNode).Enthalpy;
    4487             : 
    4488    45106592 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirPressure = state.dataEnvrn->OutBaroPress; // temporary
    4489             :         // Outlet variables
    4490    45106592 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Power = 0.0;
    4491    45106592 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLoadTotal = 0.0;
    4492    45106592 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSensible = 0.0;
    4493    45106592 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLatent = 0.0;
    4494    45106592 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSource = 0.0;
    4495    45106592 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QWasteHeat = 0.0;
    4496    45106592 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Energy = 0.0;
    4497    45106592 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLoadTotal = 0.0;
    4498    45106592 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergySensible = 0.0;
    4499    45106592 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLatent = 0.0;
    4500    45106592 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergySource = 0.0;
    4501    45106592 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).COP = 0.0;
    4502             : 
    4503    45106592 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirDBTemp = 0.0;
    4504    45106592 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletWaterTemp = 0.0;
    4505    45106592 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirHumRat = 0.0;
    4506    45106592 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirEnthalpy = 0.0;
    4507    45106592 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletWaterEnthalpy = 0.0;
    4508             : 
    4509             :         // bug fix, must set zeros to the variables below, otherwise can't pass switch DD test
    4510    45106592 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterConsumption = 0.0;
    4511    45106592 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapWaterConsump = 0.0;
    4512    45106592 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterConsumption = 0.0;
    4513    45106592 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondPumpElecConsumption = 0.0;
    4514    45106592 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterPower = 0.0;
    4515    45106592 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostPower = 0.0;
    4516    45106592 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostConsumption = 0.0;
    4517    45106592 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondensateVdot = 0.0;
    4518    45106592 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondensateVol = 0.0;
    4519    45106592 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QWasteHeat = 0.0;
    4520             : 
    4521             :         // clear zeros to HPWH variables
    4522    45106592 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).ElecWaterHeatingPower =
    4523             :             0.0; // Total electric power consumed by compressor and condenser pump [W]
    4524    45106592 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).ElecWaterHeatingConsumption =
    4525             :             0.0; // Total electric consumption by compressor and condenser pump [J]
    4526    45106592 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).TotalHeatingEnergy = 0.0;       // total water heating energy
    4527    45106592 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).TotalHeatingEnergyRate = 0.0;   // total WH energy rate
    4528    45106592 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower = 0.0; // power power
    4529             : 
    4530    45106592 :         state.dataVariableSpeedCoils->VSHPWHHeatingCapacity = 0.0; // Used by Heat Pump:Water Heater object as total water heating capacity [W]
    4531    45106592 :         state.dataVariableSpeedCoils->VSHPWHHeatingCOP = 0.0;      // Used by Heat Pump:Water Heater object as water heating COP [W/W]
    4532    45106592 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletWaterTemp = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterTemp;
    4533    45106592 :         state.dataHeatBal->HeatReclaimVS_DXCoil(DXCoilNum).AvailCapacity = 0.0;
    4534    45106592 :     }
    4535             : 
    4536          85 :     void SizeVarSpeedCoil(EnergyPlusData &state, int const DXCoilNum, bool &ErrorsFound)
    4537             :     {
    4538             : 
    4539             :         // SUBROUTINE INFORMATION:
    4540             :         //       AUTHOR         Bo Shen, based on WaterToAirHeatPumpSimple:SizeHVACWaterToAir
    4541             :         //       DATE WRITTEN   March, 2012
    4542             :         //       MODIFIED       August 2013 Daeho Kang, add component sizing table entries
    4543             :         //       MODIFIED       Bo Shen, 12/2014, add variable-speed HPWH
    4544             : 
    4545             :         // PURPOSE OF THIS SUBROUTINE:
    4546             :         // This subroutine is for sizing WSHP Components for which nominal capacities
    4547             :         // and flow rates have not been specified in the input
    4548             : 
    4549             :         // METHODOLOGY EMPLOYED:
    4550             :         // Obtains heating capacities and flow rates from the zone or system sizing arrays.
    4551             :         // NOTE: For WSHP's we are sizing the heating capacity to be
    4552             :         // equal to the cooling capacity.  Thus the cooling and
    4553             :         // and heating capacities of a DX heat pump system will be identical. In real life the ARI
    4554             :         // heating and cooling capacities are close but not identical.
    4555             : 
    4556             :         // SUBROUTINE PARAMETER DEFINITIONS:
    4557             :         static constexpr std::string_view RoutineName("SizeVarSpeedCoil");
    4558             :         static constexpr std::string_view RoutineNameAlt("SizeHVACWaterToAir");
    4559             : 
    4560          85 :         auto &ZoneEqSizing(state.dataSize->ZoneEqSizing);
    4561          85 :         auto &varSpeedCoil = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum);
    4562             : 
    4563             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    4564          85 :         Real64 rhoair = state.dataEnvrn->StdRhoAir;
    4565          85 :         Real64 MixTemp = -999.0;
    4566          85 :         Real64 MixHumRat = -999.0;
    4567          85 :         Real64 MixEnth = -999.0;
    4568          85 :         Real64 MixWetBulb = -999.0;
    4569          85 :         Real64 SupTemp = -999.0;
    4570          85 :         Real64 SupHumRat = -999.0;
    4571          85 :         Real64 SupEnth = -999.0;
    4572          85 :         Real64 OutTemp = -999.0;
    4573          85 :         Real64 OutAirFrac = -999.0;
    4574          85 :         Real64 VolFlowRate = -999.0;
    4575          85 :         Real64 CoolCapAtPeak = -999.0;
    4576          85 :         Real64 TotCapTempModFac = -999.0;
    4577             :         int TimeStepNumAtMax;
    4578             :         int DDNum;
    4579             :         bool RatedCapCoolTotalAutoSized;
    4580             :         bool RatedCapCoolSensAutoSized;
    4581             :         Real64 SystemCapacity;
    4582             :         Real64 rho;
    4583             :         Real64 cp;
    4584             :         int Mode;                     // speed level
    4585             :         Real64 rhoW;                  // water density
    4586             :         Real64 SHR;                   // sensible heat transfer ratio
    4587             :         Real64 RatedAirMassFlowRate;  // rated air mass flow rate
    4588             :         Real64 CBFRated;              // bypass factor at the rated condition, considering difference in flow rates
    4589             :         Real64 RatedInletEnth;        // rated inlet air enthalpy
    4590             :         Real64 QLoadTotal1;           // placeholder for calculating SHR
    4591             :         Real64 QLoadTotal2;           // placeholder for calculating SHR
    4592             :         Real64 QLoadTotal;            // placeholder for calculating SHR
    4593             :         Real64 AirMassFlowRatio;      // air mass flow ratio
    4594             :         Real64 WaterMassFlowRatio;    // water mass flow rate
    4595             :         Real64 RatedSourceTempCool;   // rated source temperature, space cooling mode
    4596          85 :         std::string CurrentObjSubfix; // Object subfix type for printing
    4597             :         bool HardSizeNoDesRun;        // Indicator to hardsize withouth sizing runs
    4598             :         bool SizingDesRunThisAirSys;  // true if a particular air system had a Sizing:System object and system sizing done
    4599             :         bool SizingDesRunThisZone;    // true if a particular zone had a Sizing:Zone object and zone sizing was done
    4600             :         Real64 HPInletAirHumRat;      // Rated inlet air humidity ratio for heat pump water heater [kgWater/kgDryAir]
    4601             :         Real64 HPWHCoolCapacity;      // estimate cooling capacity in HPWH
    4602             : 
    4603          85 :         int UpperSpeed = varSpeedCoil.NumOfSpeeds;
    4604          85 :         int NormSpeed = varSpeedCoil.NormSpedLevel;
    4605          85 :         int PltSizNum = 0;
    4606          85 :         bool RatedAirFlowAutoSized = false;
    4607          85 :         bool RatedWaterFlowAutoSized = false;
    4608          85 :         bool RatedCapHeatAutoSized = false;
    4609          85 :         bool IsAutoSize = false;
    4610             : 
    4611          85 :         if (state.dataSize->SysSizingRunDone || state.dataSize->ZoneSizingRunDone) {
    4612          53 :             HardSizeNoDesRun = false;
    4613             :         } else {
    4614          32 :             HardSizeNoDesRun = true;
    4615             :         }
    4616          85 :         if (state.dataSize->CurSysNum > 0) {
    4617          63 :             CheckThisAirSystemForSizing(state, state.dataSize->CurSysNum, SizingDesRunThisAirSys);
    4618             :         } else {
    4619          22 :             SizingDesRunThisAirSys = false;
    4620             :         }
    4621          85 :         if (state.dataSize->CurZoneEqNum > 0) {
    4622          18 :             CheckThisZoneForSizing(state, state.dataSize->CurZoneEqNum, SizingDesRunThisZone);
    4623             :         } else {
    4624          67 :             SizingDesRunThisZone = false;
    4625             :         }
    4626          85 :         bool HardSizeNoDesRunAirFlow = false;
    4627          85 :         Real64 RatedAirVolFlowRateDes = 0.0;
    4628          85 :         Real64 RatedAirVolFlowRateUser = 0.0;
    4629          85 :         Real64 RatedCapCoolTotalDes = 0.0;
    4630          85 :         Real64 RatedCapCoolTotalUser = 0.0;
    4631          85 :         Real64 RatedCapHeatDes = 0.0;
    4632          85 :         Real64 RatedCapHeatUser = 0.0;
    4633          85 :         Real64 RatedWaterVolFlowRateDes = 0.0;
    4634          85 :         Real64 RatedWaterVolFlowRateUser = 0.0;
    4635          85 :         Real64 RatedCapCoolSensDes = 0.0;
    4636          85 :         Real64 EvapCondPumpElecNomPowerDes = 0.0;
    4637          85 :         Real64 EvapCondPumpElecNomPowerUser = 0.0;
    4638          85 :         Real64 DefrostCapacityDes = 0.0;
    4639          85 :         Real64 DefrostCapacityUser = 0.0;
    4640             : 
    4641          85 :         if (varSpeedCoil.VSCoilType == HVAC::Coil_CoolingWaterToAirHPVSEquationFit ||
    4642          67 :             varSpeedCoil.VSCoilType == HVAC::Coil_HeatingWaterToAirHPVSEquationFit) {
    4643          36 :             CurrentObjSubfix = ":WATERTOAIRHEATPUMP:VARIABLESPEEDEQUATIONFIT";
    4644          49 :         } else if (varSpeedCoil.VSCoilType == HVAC::CoilDX_HeatPumpWaterHeaterVariableSpeed) {
    4645          14 :             CurrentObjSubfix = ":WATERHEATING:AIRTOWATERHEATPUMP:VARIABLESPEED";
    4646             :         } else {
    4647          35 :             CurrentObjSubfix = ":DX:VARIABLESPEED";
    4648             :         }
    4649             : 
    4650          85 :         if (varSpeedCoil.VSCoilType == HVAC::CoilDX_HeatPumpWaterHeaterVariableSpeed) {
    4651          14 :             if (varSpeedCoil.RatedAirVolFlowRate == Constant::AutoCalculate) {
    4652           4 :                 varSpeedCoil.RatedAirVolFlowRate =
    4653           4 :                     varSpeedCoil.RatedCapWH * varSpeedCoil.MSRatedAirVolFlowRate(NormSpeed) / varSpeedCoil.MSRatedTotCap(NormSpeed); // 0.00005035;
    4654           4 :                 varSpeedCoil.AirVolFlowAutoSized = true;
    4655             :             }
    4656          14 :             state.dataRptCoilSelection->coilSelectionReportObj->setCoilAirFlow(
    4657          14 :                 state, varSpeedCoil.Name, varSpeedCoil.VarSpeedCoilType, varSpeedCoil.RatedAirVolFlowRate, varSpeedCoil.AirVolFlowAutoSized);
    4658             : 
    4659          14 :             if (varSpeedCoil.RatedWaterVolFlowRate == Constant::AutoCalculate) {
    4660           4 :                 varSpeedCoil.RatedHPWHCondWaterFlow = varSpeedCoil.RatedCapWH * varSpeedCoil.MSRatedWaterVolFlowRate(NormSpeed) /
    4661           4 :                                                       varSpeedCoil.MSRatedTotCap(NormSpeed); // 0.00000004487;
    4662           4 :                 varSpeedCoil.RatedWaterVolFlowRate = varSpeedCoil.RatedHPWHCondWaterFlow;
    4663           4 :                 varSpeedCoil.WaterVolFlowAutoSized = true;
    4664             :             }
    4665          14 :             state.dataRptCoilSelection->coilSelectionReportObj->setCoilWaterFlowPltSizNum(state,
    4666          14 :                                                                                           varSpeedCoil.Name,
    4667          14 :                                                                                           varSpeedCoil.VarSpeedCoilType,
    4668             :                                                                                           varSpeedCoil.RatedWaterVolFlowRate,
    4669          14 :                                                                                           varSpeedCoil.WaterVolFlowAutoSized,
    4670             :                                                                                           -999,
    4671             :                                                                                           varSpeedCoil.plantLoc.loopNum);
    4672             :         }
    4673             : 
    4674          85 :         if (varSpeedCoil.RatedAirVolFlowRate == AutoSize) {
    4675          25 :             RatedAirFlowAutoSized = true;
    4676             :         }
    4677             : 
    4678          85 :         if (state.dataSize->CurSysNum > 0) {
    4679          63 :             if (!RatedAirFlowAutoSized && !SizingDesRunThisAirSys) { // Simulation continue
    4680          51 :                 HardSizeNoDesRunAirFlow = true;
    4681          51 :                 if (varSpeedCoil.RatedAirVolFlowRate > 0.0) {
    4682         153 :                     BaseSizer::reportSizerOutput(state,
    4683         102 :                                                  format("COIL:{}{}", varSpeedCoil.CoolHeatType, CurrentObjSubfix),
    4684             :                                                  varSpeedCoil.Name,
    4685             :                                                  "User-Specified Rated Air Flow Rate [m3/s]",
    4686             :                                                  varSpeedCoil.RatedAirVolFlowRate);
    4687             :                 }
    4688             :             } else {
    4689          12 :                 CheckSysSizing(state, format("COIL:{}{}", varSpeedCoil.CoolHeatType, CurrentObjSubfix), varSpeedCoil.Name);
    4690          12 :                 if (state.dataSize->CurOASysNum > 0 && state.dataAirLoop->OutsideAirSys(state.dataSize->CurOASysNum).AirLoopDOASNum > -1) {
    4691             :                     auto &thisAirloopDOAS =
    4692           0 :                         state.dataAirLoopHVACDOAS->airloopDOAS[state.dataAirLoop->OutsideAirSys(state.dataSize->CurOASysNum).AirLoopDOASNum];
    4693           0 :                     RatedAirVolFlowRateDes = thisAirloopDOAS.SizingMassFlow / state.dataEnvrn->StdRhoAir;
    4694             :                 } else {
    4695          12 :                     if (state.dataSize->FinalSysSizing(state.dataSize->CurSysNum).DesMainVolFlow >= HVAC::SmallAirVolFlow) {
    4696          12 :                         RatedAirVolFlowRateDes = state.dataSize->FinalSysSizing(state.dataSize->CurSysNum).DesMainVolFlow;
    4697             :                     } else {
    4698           0 :                         RatedAirVolFlowRateDes = 0.0;
    4699             :                     }
    4700             :                 }
    4701             :             }
    4702             :         }
    4703             : 
    4704          85 :         if (state.dataSize->CurZoneEqNum > 0) {
    4705          18 :             if (!RatedAirFlowAutoSized && !SizingDesRunThisZone) { // Simulation continue
    4706           0 :                 HardSizeNoDesRunAirFlow = true;
    4707           0 :                 if (varSpeedCoil.RatedAirVolFlowRate > 0.0) {
    4708           0 :                     BaseSizer::reportSizerOutput(state,
    4709           0 :                                                  format("COIL:{}{}", varSpeedCoil.CoolHeatType, CurrentObjSubfix),
    4710             :                                                  varSpeedCoil.Name,
    4711             :                                                  "User-Specified Rated Air Flow Rate [m3/s]",
    4712             :                                                  varSpeedCoil.RatedAirVolFlowRate);
    4713             :                 }
    4714             :             } else {
    4715          18 :                 CheckZoneSizing(state, format("COIL:{}{}", varSpeedCoil.CoolHeatType, CurrentObjSubfix), varSpeedCoil.Name);
    4716          18 :                 RatedAirVolFlowRateDes = max(state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).DesCoolVolFlow,
    4717          18 :                                              state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).DesHeatVolFlow);
    4718          18 :                 if (RatedAirVolFlowRateDes < HVAC::SmallAirVolFlow) {
    4719           0 :                     RatedAirVolFlowRateDes = 0.0;
    4720             :                 }
    4721             :             }
    4722             :         }
    4723             : 
    4724          85 :         if (RatedAirFlowAutoSized) varSpeedCoil.RatedAirVolFlowRate = RatedAirVolFlowRateDes;
    4725             : 
    4726          85 :         RatedCapCoolTotalAutoSized = false;
    4727          85 :         RatedCapCoolSensAutoSized = false;
    4728             : 
    4729             :         // size rated total cooling capacity
    4730          85 :         IsAutoSize = false;
    4731          85 :         if (varSpeedCoil.RatedCapCoolTotal == AutoSize && (varSpeedCoil.VSCoilType == HVAC::Coil_CoolingWaterToAirHPVSEquationFit ||
    4732          52 :                                                            varSpeedCoil.VSCoilType == HVAC::Coil_CoolingAirToAirVariableSpeed)) {
    4733          18 :             RatedCapCoolTotalAutoSized = true;
    4734             :         }
    4735          85 :         if (SizingDesRunThisZone || SizingDesRunThisAirSys) HardSizeNoDesRun = false;
    4736          85 :         if (state.dataSize->CurSysNum > 0) {
    4737          63 :             if (!RatedCapCoolTotalAutoSized && !SizingDesRunThisAirSys) { // Simulation continue
    4738          51 :                 HardSizeNoDesRun = true;
    4739          51 :                 if (varSpeedCoil.RatedCapCoolTotal > 0.0) {
    4740          84 :                     BaseSizer::reportSizerOutput(state,
    4741          56 :                                                  format("COIL:{}{}", varSpeedCoil.CoolHeatType, CurrentObjSubfix),
    4742             :                                                  varSpeedCoil.Name,
    4743             :                                                  "User-Specified Rated Total Cooling Capacity [W]",
    4744             :                                                  varSpeedCoil.RatedCapCoolTotal);
    4745             :                 }
    4746             :             } else {
    4747          12 :                 CheckSysSizing(state, format("COIL:{}{}", varSpeedCoil.CoolHeatType, CurrentObjSubfix), varSpeedCoil.Name);
    4748          12 :                 if (state.dataSize->CurOASysNum > 0 && state.dataAirLoop->OutsideAirSys(state.dataSize->CurOASysNum).AirLoopDOASNum > -1) {
    4749             :                     auto &thisAirloopDOAS =
    4750           0 :                         state.dataAirLoopHVACDOAS->airloopDOAS[state.dataAirLoop->OutsideAirSys(state.dataSize->CurOASysNum).AirLoopDOASNum];
    4751           0 :                     VolFlowRate = varSpeedCoil.RatedAirVolFlowRate;
    4752           0 :                     MixTemp = thisAirloopDOAS.SizingCoolOATemp;
    4753           0 :                     SupTemp = thisAirloopDOAS.PrecoolTemp;
    4754           0 :                     MixHumRat = thisAirloopDOAS.SizingCoolOAHumRat;
    4755           0 :                     SupHumRat = thisAirloopDOAS.PrecoolHumRat;
    4756           0 :                     RatedCapCoolTotalDes = VolFlowRate * state.dataEnvrn->StdRhoAir *
    4757           0 :                                            (Psychrometrics::PsyHFnTdbW(MixTemp, MixHumRat) - Psychrometrics::PsyHFnTdbW(SupTemp, SupHumRat));
    4758           0 :                     if (varSpeedCoil.MSCCapFTemp(varSpeedCoil.NormSpedLevel) > 0) {
    4759           0 :                         MixWetBulb = Psychrometrics::PsyTwbFnTdbWPb(state, MixTemp, MixHumRat, state.dataEnvrn->StdBaroPress, RoutineName);
    4760           0 :                         if (varSpeedCoil.CondenserType == DataHeatBalance::RefrigCondenserType::Air) {
    4761           0 :                             RatedSourceTempCool = thisAirloopDOAS.SizingCoolOATemp;
    4762             :                         } else {
    4763           0 :                             RatedSourceTempCool = GetVSCoilRatedSourceTemp(state, DXCoilNum);
    4764             :                         }
    4765           0 :                         TotCapTempModFac =
    4766           0 :                             Curve::CurveValue(state, varSpeedCoil.MSCCapFTemp(varSpeedCoil.NormSpedLevel), MixWetBulb, RatedSourceTempCool);
    4767           0 :                         RatedCapCoolTotalDes /= TotCapTempModFac;
    4768             :                     }
    4769             :                 } else {
    4770          12 :                     auto &finalSysSizing = state.dataSize->FinalSysSizing(state.dataSize->CurSysNum);
    4771          12 :                     VolFlowRate = varSpeedCoil.RatedAirVolFlowRate;
    4772          12 :                     if (VolFlowRate >= HVAC::SmallAirVolFlow) {
    4773          12 :                         if (state.dataSize->CurOASysNum > 0) { // coil is in the OA stream
    4774           0 :                             MixTemp = finalSysSizing.OutTempAtCoolPeak;
    4775           0 :                             MixHumRat = finalSysSizing.OutHumRatAtCoolPeak;
    4776           0 :                             SupTemp = finalSysSizing.PrecoolTemp;
    4777           0 :                             SupHumRat = finalSysSizing.PrecoolHumRat;
    4778             :                         } else { // coil is on the main air loop
    4779          12 :                             SupTemp = finalSysSizing.CoolSupTemp;
    4780          12 :                             SupHumRat = finalSysSizing.CoolSupHumRat;
    4781          12 :                             if (state.dataAirSystemsData->PrimaryAirSystems(state.dataSize->CurSysNum).NumOACoolCoils ==
    4782             :                                 0) { // there is no precooling of the OA stream
    4783          12 :                                 MixTemp = finalSysSizing.MixTempAtCoolPeak;
    4784          12 :                                 MixHumRat = finalSysSizing.MixHumRatAtCoolPeak;
    4785             :                             } else { // there is precooling of OA stream
    4786           0 :                                 if (VolFlowRate > 0.0) {
    4787           0 :                                     OutAirFrac = finalSysSizing.DesOutAirVolFlow / VolFlowRate;
    4788             :                                 } else {
    4789           0 :                                     OutAirFrac = 1.0;
    4790             :                                 }
    4791           0 :                                 OutAirFrac = min(1.0, max(0.0, OutAirFrac));
    4792           0 :                                 MixTemp = OutAirFrac * finalSysSizing.PrecoolTemp + (1.0 - OutAirFrac) * finalSysSizing.RetTempAtCoolPeak;
    4793           0 :                                 MixHumRat = OutAirFrac * finalSysSizing.PrecoolHumRat + (1.0 - OutAirFrac) * finalSysSizing.RetHumRatAtCoolPeak;
    4794             :                             }
    4795             :                         }
    4796          12 :                         OutTemp = finalSysSizing.OutTempAtCoolPeak;
    4797          12 :                         MixEnth = Psychrometrics::PsyHFnTdbW(MixTemp, MixHumRat);
    4798          12 :                         SupEnth = Psychrometrics::PsyHFnTdbW(SupTemp, SupHumRat);
    4799             : 
    4800             :                         // design fan heat will be added to coil load
    4801          12 :                         Real64 FanCoolLoad = DataAirSystems::calcFanDesignHeatGain(state, state.dataSize->DataFanIndex, VolFlowRate);
    4802             :                         // inlet/outlet temp is adjusted after enthalpy is calculcated so fan heat is not double counted
    4803          12 :                         Real64 CpAir = Psychrometrics::PsyCpAirFnW(MixHumRat);
    4804          12 :                         if (state.dataAirSystemsData->PrimaryAirSystems(state.dataSize->CurSysNum).supFanPlace == HVAC::FanPlace::BlowThru) {
    4805          12 :                             MixTemp += FanCoolLoad / (CpAir * rhoair * VolFlowRate);
    4806           0 :                         } else if (state.dataAirSystemsData->PrimaryAirSystems(state.dataSize->CurSysNum).supFanPlace == HVAC::FanPlace::DrawThru) {
    4807           0 :                             SupTemp -= FanCoolLoad / (CpAir * rhoair * VolFlowRate);
    4808             :                         }
    4809          12 :                         MixWetBulb = Psychrometrics::PsyTwbFnTdbWPb(state, MixTemp, MixHumRat, state.dataEnvrn->StdBaroPress, RoutineName);
    4810          12 :                         if (varSpeedCoil.CondenserType == DataHeatBalance::RefrigCondenserType::Air) {
    4811          12 :                             RatedSourceTempCool = OutTemp;
    4812             :                         } else {
    4813           0 :                             RatedSourceTempCool = GetVSCoilRatedSourceTemp(state, DXCoilNum);
    4814             :                         }
    4815          12 :                         TotCapTempModFac =
    4816          12 :                             Curve::CurveValue(state, varSpeedCoil.MSCCapFTemp(varSpeedCoil.NormSpedLevel), MixWetBulb, RatedSourceTempCool);
    4817             : 
    4818             :                         //       The mixed air temp for zone equipment without an OA mixer is 0.
    4819             :                         //       This test avoids a negative capacity until a solution can be found.
    4820          12 :                         if (MixEnth > SupEnth) {
    4821          12 :                             CoolCapAtPeak = (rhoair * VolFlowRate * (MixEnth - SupEnth)) + FanCoolLoad;
    4822             :                         } else {
    4823           0 :                             CoolCapAtPeak = (rhoair * VolFlowRate * (48000.0 - SupEnth)) + FanCoolLoad;
    4824             :                         }
    4825          12 :                         CoolCapAtPeak = max(0.0, CoolCapAtPeak);
    4826          12 :                         if (TotCapTempModFac > 0.0) {
    4827          12 :                             RatedCapCoolTotalDes = CoolCapAtPeak / TotCapTempModFac;
    4828             :                         } else {
    4829           0 :                             RatedCapCoolTotalDes = CoolCapAtPeak;
    4830             :                         }
    4831             :                     } else {
    4832           0 :                         RatedCapCoolTotalDes = 0.0;
    4833             :                     }
    4834             :                 }
    4835             :             }
    4836             : 
    4837          22 :         } else if (state.dataSize->CurZoneEqNum > 0) {
    4838          18 :             if (!RatedCapCoolTotalAutoSized && !SizingDesRunThisZone) { // Simulation continue
    4839           0 :                 HardSizeNoDesRun = true;
    4840           0 :                 if (varSpeedCoil.RatedCapCoolTotal > 0.0) {
    4841           0 :                     BaseSizer::reportSizerOutput(state,
    4842           0 :                                                  format("COIL:{}{}", varSpeedCoil.CoolHeatType, CurrentObjSubfix),
    4843             :                                                  varSpeedCoil.Name,
    4844             :                                                  "User-Specified Rated Total Cooling Capacity [W]",
    4845             :                                                  varSpeedCoil.RatedCapCoolTotal);
    4846             :                 }
    4847             :             } else {
    4848          18 :                 CheckZoneSizing(state, format("COIL:{}{}", varSpeedCoil.CoolHeatType, CurrentObjSubfix), varSpeedCoil.Name);
    4849          18 :                 auto &finalZoneSizing = state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum);
    4850          18 :                 VolFlowRate = varSpeedCoil.RatedAirVolFlowRate;
    4851          18 :                 if (VolFlowRate >= HVAC::SmallAirVolFlow) {
    4852          18 :                     if (state.dataSize->ZoneEqDXCoil) {
    4853          14 :                         if (ZoneEqSizing(state.dataSize->CurZoneEqNum).OAVolFlow > 0.0) {
    4854          10 :                             MixTemp = finalZoneSizing.DesCoolCoilInTemp;
    4855          10 :                             MixHumRat = finalZoneSizing.DesCoolCoilInHumRat;
    4856             :                         } else {
    4857           4 :                             MixTemp = finalZoneSizing.ZoneTempAtCoolPeak;
    4858           4 :                             MixHumRat = finalZoneSizing.ZoneHumRatAtCoolPeak;
    4859             :                         }
    4860             :                     } else {
    4861           4 :                         MixTemp = finalZoneSizing.DesCoolCoilInTemp;
    4862           4 :                         MixHumRat = finalZoneSizing.DesCoolCoilInHumRat;
    4863             :                     }
    4864          18 :                     SupTemp = finalZoneSizing.CoolDesTemp;
    4865          18 :                     SupHumRat = finalZoneSizing.CoolDesHumRat;
    4866          18 :                     TimeStepNumAtMax = finalZoneSizing.TimeStepNumAtCoolMax;
    4867          18 :                     DDNum = finalZoneSizing.CoolDDNum;
    4868          18 :                     if (DDNum > 0 && TimeStepNumAtMax > 0) {
    4869          18 :                         OutTemp = state.dataSize->DesDayWeath(DDNum).Temp(TimeStepNumAtMax);
    4870             :                     } else {
    4871           0 :                         OutTemp = 0.0;
    4872             :                     }
    4873          18 :                     MixEnth = Psychrometrics::PsyHFnTdbW(MixTemp, MixHumRat);
    4874          18 :                     SupEnth = Psychrometrics::PsyHFnTdbW(SupTemp, SupHumRat);
    4875             : 
    4876             :                     // design fan heat will be added to coil load
    4877          18 :                     Real64 FanCoolLoad = DataAirSystems::calcFanDesignHeatGain(state, state.dataSize->DataFanIndex, VolFlowRate);
    4878             :                     // inlet/outlet temp is adjusted after enthalpy is calculcated so fan heat is not double counted
    4879          18 :                     Real64 CpAir = Psychrometrics::PsyCpAirFnW(MixHumRat);
    4880             : 
    4881          18 :                     if (state.dataSize->DataFanPlacement == HVAC::FanPlace::BlowThru) {
    4882          13 :                         MixTemp += FanCoolLoad / (CpAir * rhoair * VolFlowRate);
    4883             :                     } else {
    4884           5 :                         SupTemp -= FanCoolLoad / (CpAir * rhoair * VolFlowRate);
    4885             :                     }
    4886             : 
    4887          18 :                     MixWetBulb = Psychrometrics::PsyTwbFnTdbWPb(state, MixTemp, MixHumRat, state.dataEnvrn->StdBaroPress, RoutineName);
    4888          18 :                     if (varSpeedCoil.CondenserType == DataHeatBalance::RefrigCondenserType::Air) {
    4889          10 :                         RatedSourceTempCool = OutTemp;
    4890             :                     } else {
    4891           8 :                         RatedSourceTempCool = GetVSCoilRatedSourceTemp(state, DXCoilNum);
    4892             :                     }
    4893          18 :                     TotCapTempModFac =
    4894          18 :                         Curve::CurveValue(state, varSpeedCoil.MSCCapFTemp(varSpeedCoil.NormSpedLevel), MixWetBulb, RatedSourceTempCool);
    4895             : 
    4896             :                     //       The mixed air temp for zone equipment without an OA mixer is 0.
    4897             :                     //       This test avoids a negative capacity until a solution can be found.
    4898          18 :                     if (MixEnth > SupEnth) {
    4899          18 :                         CoolCapAtPeak = (rhoair * VolFlowRate * (MixEnth - SupEnth)) + FanCoolLoad;
    4900             :                     } else {
    4901           0 :                         CoolCapAtPeak = (rhoair * VolFlowRate * (48000.0 - SupEnth)) + FanCoolLoad;
    4902             :                     }
    4903          18 :                     CoolCapAtPeak = max(0.0, CoolCapAtPeak);
    4904          18 :                     if (TotCapTempModFac > 0.0) {
    4905          18 :                         RatedCapCoolTotalDes = CoolCapAtPeak / TotCapTempModFac;
    4906             :                     } else {
    4907           0 :                         RatedCapCoolTotalDes = CoolCapAtPeak;
    4908             :                     }
    4909             :                 } else {
    4910           0 :                     RatedCapCoolTotalDes = 0.0;
    4911             :                 }
    4912             :             }
    4913             :         }
    4914          85 :         if (RatedCapCoolTotalDes < HVAC::SmallLoad) {
    4915          55 :             RatedCapCoolTotalDes = 0.0;
    4916             :         }
    4917          85 :         if (!HardSizeNoDesRun) {
    4918          33 :             if (RatedCapCoolTotalAutoSized) {
    4919          18 :                 varSpeedCoil.RatedCapCoolTotal = RatedCapCoolTotalDes;
    4920          54 :                 BaseSizer::reportSizerOutput(state,
    4921          36 :                                              format("COIL:{}{}", varSpeedCoil.CoolHeatType, CurrentObjSubfix),
    4922             :                                              varSpeedCoil.Name,
    4923             :                                              "Design Size Rated Total Cooling Capacity [W]",
    4924             :                                              varSpeedCoil.RatedCapCoolTotal);
    4925          36 :                 OutputReportPredefined::PreDefTableEntry(
    4926          18 :                     state, state.dataOutRptPredefined->pdchCoolCoilTotCap, varSpeedCoil.Name, varSpeedCoil.RatedCapCoolTotal);
    4927          36 :                 OutputReportPredefined::PreDefTableEntry(state,
    4928          18 :                                                          state.dataOutRptPredefined->pdchCoolCoilLatCap,
    4929             :                                                          varSpeedCoil.Name,
    4930          18 :                                                          varSpeedCoil.RatedCapCoolTotal - varSpeedCoil.RatedCapCoolSens);
    4931          18 :                 if (varSpeedCoil.RatedCapCoolTotal != 0.0) {
    4932          36 :                     OutputReportPredefined::PreDefTableEntry(state,
    4933          18 :                                                              state.dataOutRptPredefined->pdchCoolCoilSHR,
    4934             :                                                              varSpeedCoil.Name,
    4935          18 :                                                              varSpeedCoil.RatedCapCoolSens / varSpeedCoil.RatedCapCoolTotal);
    4936          36 :                     OutputReportPredefined::PreDefTableEntry(
    4937          18 :                         state, state.dataOutRptPredefined->pdchCoolCoilNomEff, varSpeedCoil.Name, varSpeedCoil.MSRatedCOP(NormSpeed));
    4938             :                 } else {
    4939           0 :                     OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoolCoilSHR, varSpeedCoil.Name, 0.0);
    4940           0 :                     OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoolCoilNomEff, varSpeedCoil.Name, 0.0);
    4941             :                 }
    4942          36 :                 OutputReportPredefined::addFootNoteSubTable(
    4943             :                     state,
    4944          18 :                     state.dataOutRptPredefined->pdstCoolCoil,
    4945             :                     "Nominal values are gross at rated conditions, i.e., the supply air fan heat and electric power NOT accounted for.");
    4946             :             } else {
    4947          15 :                 if (varSpeedCoil.RatedCapCoolTotal > 0.0 && RatedCapCoolTotalDes > 0.0) {
    4948           2 :                     RatedCapCoolTotalUser = varSpeedCoil.RatedCapCoolTotal;
    4949           6 :                     BaseSizer::reportSizerOutput(state,
    4950           4 :                                                  format("COIL:{}{}", varSpeedCoil.CoolHeatType, CurrentObjSubfix),
    4951             :                                                  varSpeedCoil.Name,
    4952             :                                                  "Design Size Rated Total Cooling Capacity [W]",
    4953             :                                                  RatedCapCoolTotalDes,
    4954             :                                                  "User-Specified Rated Total Cooling Capacity [W]",
    4955             :                                                  RatedCapCoolTotalUser);
    4956           2 :                     if (state.dataGlobal->DisplayExtraWarnings) {
    4957           0 :                         if ((std::abs(RatedCapCoolTotalDes - RatedCapCoolTotalUser) / RatedCapCoolTotalUser) >
    4958           0 :                             state.dataSize->AutoVsHardSizingThreshold) {
    4959           0 :                             ShowMessage(state,
    4960           0 :                                         format("SizeVarSpeedCoil: Potential issue with equipment sizing for {} {}",
    4961           0 :                                                varSpeedCoil.CoolHeatType,
    4962             :                                                CurrentObjSubfix));
    4963           0 :                             ShowContinueError(state, format("Coil Name = {}", varSpeedCoil.Name));
    4964           0 :                             ShowContinueError(state, format("User-Specified Rated Total Cooling Capacity of {:.2R} [W]", RatedCapCoolTotalUser));
    4965           0 :                             ShowContinueError(state,
    4966           0 :                                               format("differs from Design Size Rated Total Cooling Capacity of {:.2R} [W]", RatedCapCoolTotalDes));
    4967           0 :                             ShowContinueError(state, "This may, or may not, indicate mismatched component sizes.");
    4968           0 :                             ShowContinueError(state, "Verify that the value entered is intended and is consistent with other components.");
    4969             :                         }
    4970             :                     }
    4971             :                 }
    4972             :             }
    4973             : 
    4974          33 :             state.dataRptCoilSelection->coilSelectionReportObj->setCoilEntAirTemp(
    4975          33 :                 state, varSpeedCoil.Name, varSpeedCoil.VarSpeedCoilType, MixTemp, state.dataSize->CurSysNum, state.dataSize->CurZoneEqNum);
    4976          33 :             state.dataRptCoilSelection->coilSelectionReportObj->setCoilEntAirHumRat(
    4977          33 :                 state, varSpeedCoil.Name, varSpeedCoil.VarSpeedCoilType, MixHumRat);
    4978          33 :             state.dataRptCoilSelection->coilSelectionReportObj->setCoilLvgAirTemp(state, varSpeedCoil.Name, varSpeedCoil.VarSpeedCoilType, SupTemp);
    4979          33 :             state.dataRptCoilSelection->coilSelectionReportObj->setCoilLvgAirHumRat(
    4980          33 :                 state, varSpeedCoil.Name, varSpeedCoil.VarSpeedCoilType, SupHumRat);
    4981          33 :             state.dataRptCoilSelection->coilSelectionReportObj->setCoilAirFlow(
    4982          33 :                 state, varSpeedCoil.Name, varSpeedCoil.VarSpeedCoilType, varSpeedCoil.RatedAirVolFlowRate, RatedAirFlowAutoSized);
    4983          33 :             state.dataRptCoilSelection->coilSelectionReportObj->setCoilCoolingCapacity(state,
    4984          33 :                                                                                        varSpeedCoil.Name,
    4985          33 :                                                                                        varSpeedCoil.VarSpeedCoilType,
    4986             :                                                                                        RatedCapCoolTotalDes,
    4987             :                                                                                        RatedCapCoolTotalAutoSized,
    4988          33 :                                                                                        state.dataSize->CurSysNum,
    4989          33 :                                                                                        state.dataSize->CurZoneEqNum,
    4990          33 :                                                                                        state.dataSize->CurOASysNum,
    4991             :                                                                                        0.0, // no fan load included in sizing
    4992             :                                                                                        TotCapTempModFac,
    4993             :                                                                                        -999.0,
    4994             :                                                                                        -999.0); // VS model doesn't limit, double check
    4995             :         }
    4996             : 
    4997             :         // Set the global DX cooling coil capacity variable for use by other objects
    4998          85 :         if (varSpeedCoil.VSCoilType == HVAC::Coil_CoolingWaterToAirHPVSEquationFit ||
    4999          67 :             varSpeedCoil.VSCoilType == HVAC::Coil_CoolingAirToAirVariableSpeed) {
    5000          42 :             state.dataSize->DXCoolCap = varSpeedCoil.RatedCapCoolTotal;
    5001             :         }
    5002             : 
    5003             :         // size rated heating capacity
    5004          85 :         if (varSpeedCoil.RatedCapHeat == AutoSize && (varSpeedCoil.VSCoilType == HVAC::Coil_HeatingWaterToAirHPVSEquationFit ||
    5005          60 :                                                       varSpeedCoil.VSCoilType == HVAC::Coil_HeatingAirToAirVariableSpeed)) {
    5006           7 :             RatedCapHeatAutoSized = true;
    5007             :         }
    5008             :         //   simply set heating capacity equal to the cooling capacity
    5009             :         // VarSpeedCoil(DXCoilNum)%RatedCapHeat = DXCoolCap
    5010          85 :         if (varSpeedCoil.VSCoilType == HVAC::Coil_HeatingWaterToAirHPVSEquationFit ||
    5011          67 :             varSpeedCoil.VSCoilType == HVAC::Coil_HeatingAirToAirVariableSpeed) {
    5012          29 :             if (varSpeedCoil.CompanionCoolingCoilNum > 0) {
    5013          24 :                 RatedCapHeatDes = state.dataVariableSpeedCoils->VarSpeedCoil(varSpeedCoil.CompanionCoolingCoilNum).RatedCapCoolTotal;
    5014          24 :                 varSpeedCoil.RatedCapCoolTotal = RatedCapHeatDes; // AVOID BEING ZERO
    5015             :             } else {
    5016           5 :                 RatedCapHeatDes = state.dataSize->DXCoolCap; // previous code, can be risky
    5017             :             }
    5018             :             // END IF
    5019          29 :             if (RatedCapHeatAutoSized) {
    5020           7 :                 if (RatedCapHeatDes == AutoSize) {
    5021           0 :                     ShowWarningError(
    5022           0 :                         state, format("COIL:{}:WATERTOAIRHEATPUMP:VARIABLESPEEDEQUATIONFIT \"{}\"", varSpeedCoil.CoolHeatType, varSpeedCoil.Name));
    5023           0 :                     ShowContinueError(state,
    5024           0 :                                       format("{}: Heating coil could not be autosized since cooling coil was not previously sized.", RoutineName));
    5025           0 :                     ShowContinueError(state, "... Cooling coil must be upstream of heating coil.");
    5026           0 :                     ShowContinueError(state, "... Manually sizing this heating coil will be required.");
    5027             :                 }
    5028             :             }
    5029          29 :             if (RatedCapHeatDes < HVAC::SmallLoad) {
    5030           0 :                 RatedCapHeatDes = 0.0;
    5031             :             }
    5032          29 :             state.dataRptCoilSelection->coilSelectionReportObj->setCoilHeatingCapacity(state,
    5033          29 :                                                                                        varSpeedCoil.Name,
    5034          29 :                                                                                        varSpeedCoil.VarSpeedCoilType,
    5035             :                                                                                        RatedCapHeatDes,
    5036             :                                                                                        RatedCapHeatAutoSized,
    5037          29 :                                                                                        state.dataSize->CurSysNum,
    5038          29 :                                                                                        state.dataSize->CurZoneEqNum,
    5039          29 :                                                                                        state.dataSize->CurOASysNum,
    5040             :                                                                                        0.0,
    5041             :                                                                                        1.0,
    5042             :                                                                                        -999.0,
    5043             :                                                                                        -999.0);
    5044             :         }
    5045          85 :         if (RatedCapHeatAutoSized) {
    5046           7 :             varSpeedCoil.RatedCapHeat = RatedCapHeatDes;
    5047          21 :             BaseSizer::reportSizerOutput(state,
    5048          14 :                                          format("COIL:{}{}", varSpeedCoil.CoolHeatType, CurrentObjSubfix),
    5049             :                                          varSpeedCoil.Name,
    5050             :                                          "Design Size Nominal Heating Capacity [W]",
    5051             :                                          RatedCapHeatDes);
    5052          14 :             OutputReportPredefined::PreDefTableEntry(
    5053           7 :                 state, state.dataOutRptPredefined->pdchHeatCoilNomCap, varSpeedCoil.Name, varSpeedCoil.RatedCapHeat);
    5054           7 :             if (varSpeedCoil.RatedCapHeat != 0.0) {
    5055          14 :                 OutputReportPredefined::PreDefTableEntry(
    5056           7 :                     state, state.dataOutRptPredefined->pdchHeatCoilNomEff, varSpeedCoil.Name, varSpeedCoil.MSRatedCOP(NormSpeed));
    5057             :             } else {
    5058           0 :                 OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchHeatCoilNomEff, varSpeedCoil.Name, 0.0);
    5059             :             }
    5060          14 :             OutputReportPredefined::addFootNoteSubTable(
    5061             :                 state,
    5062           7 :                 state.dataOutRptPredefined->pdstHeatCoil,
    5063             :                 "Nominal values are gross at rated conditions, i.e., the supply air fan heat and electric power NOT accounted for.");
    5064             :         } else {
    5065          78 :             if (varSpeedCoil.RatedCapHeat > 0.0 && RatedCapHeatDes > 0.0) {
    5066          22 :                 RatedCapHeatUser = varSpeedCoil.RatedCapHeat;
    5067          66 :                 BaseSizer::reportSizerOutput(state,
    5068          44 :                                              format("COIL:{}{}", varSpeedCoil.CoolHeatType, CurrentObjSubfix),
    5069             :                                              varSpeedCoil.Name,
    5070             :                                              "Design Size Nominal Heating Capacity [W]",
    5071             :                                              RatedCapHeatDes,
    5072             :                                              "User-Specified Nominal Heating Capacity [W]",
    5073             :                                              RatedCapHeatUser);
    5074          22 :                 if (state.dataGlobal->DisplayExtraWarnings) {
    5075           4 :                     if ((std::abs(RatedCapHeatDes - RatedCapHeatUser) / RatedCapHeatUser) > state.dataSize->AutoVsHardSizingThreshold) {
    5076           0 :                         ShowMessage(
    5077             :                             state,
    5078           0 :                             format("SizeVarSpeedCoil: Potential issue with equipment sizing for {} {}", varSpeedCoil.CoolHeatType, CurrentObjSubfix));
    5079           0 :                         ShowContinueError(state, format("Coil Name = {}", varSpeedCoil.Name));
    5080           0 :                         ShowContinueError(state, format("User-Specified Rated Total Heating Capacity of {:.2R} [W]", RatedCapHeatUser));
    5081           0 :                         ShowContinueError(state, format("differs from Design Size Rated Total Heating Capacity of {:.2R} [W]", RatedCapHeatDes));
    5082           0 :                         ShowContinueError(state, "This may, or may not, indicate mismatched component sizes.");
    5083           0 :                         ShowContinueError(state, "Verify that the value entered is intended and is consistent with other components.");
    5084             :                     }
    5085             :                 }
    5086             :             }
    5087             :         }
    5088             : 
    5089             :         // FORCE BACK TO THE RATED AIR FLOW RATE WITH THE SAME RATIO DEFINED BY THE CATALOG DATA
    5090          85 :         if (!HardSizeNoDesRunAirFlow) {
    5091          34 :             if ((RatedCapCoolTotalAutoSized) && (RatedAirFlowAutoSized)) {
    5092          18 :                 RatedAirVolFlowRateDes = varSpeedCoil.RatedCapCoolTotal * varSpeedCoil.MSRatedAirVolFlowPerRatedTotCap(NormSpeed);
    5093          16 :             } else if ((RatedCapHeatAutoSized) && (RatedAirFlowAutoSized)) {
    5094           7 :                 RatedAirVolFlowRateDes = varSpeedCoil.RatedCapHeat * varSpeedCoil.MSRatedAirVolFlowPerRatedTotCap(NormSpeed);
    5095             :             }
    5096             : 
    5097             :             // write the air flow sizing output
    5098          34 :             if (RatedAirFlowAutoSized) {
    5099          25 :                 varSpeedCoil.RatedAirVolFlowRate = RatedAirVolFlowRateDes;
    5100          75 :                 BaseSizer::reportSizerOutput(state,
    5101          50 :                                              format("COIL:{}{}", varSpeedCoil.CoolHeatType, CurrentObjSubfix),
    5102             :                                              varSpeedCoil.Name,
    5103             :                                              "Design Size Rated Air Flow Rate [m3/s]",
    5104             :                                              RatedAirVolFlowRateDes);
    5105             :             } else {
    5106           9 :                 if (varSpeedCoil.RatedAirVolFlowRate > 0.0 && RatedAirVolFlowRateDes > 0.0) {
    5107           5 :                     RatedAirVolFlowRateUser = varSpeedCoil.RatedAirVolFlowRate;
    5108          15 :                     BaseSizer::reportSizerOutput(state,
    5109          10 :                                                  format("COIL:{}{}", varSpeedCoil.CoolHeatType, CurrentObjSubfix),
    5110             :                                                  varSpeedCoil.Name,
    5111             :                                                  "Design Size Rated Air Flow Rate [m3/s]",
    5112             :                                                  RatedAirVolFlowRateDes,
    5113             :                                                  "User-Specified Rated Air Flow Rate [m3/s]",
    5114             :                                                  RatedAirVolFlowRateUser);
    5115           5 :                     if (state.dataGlobal->DisplayExtraWarnings) {
    5116           0 :                         if ((std::abs(RatedAirVolFlowRateDes - RatedAirVolFlowRateUser) / RatedAirVolFlowRateUser) >
    5117           0 :                             state.dataSize->AutoVsHardSizingThreshold) {
    5118           0 :                             ShowMessage(state,
    5119           0 :                                         format("SizeVarSpeedCoil: Potential issue with equipment sizing for {} {}",
    5120           0 :                                                varSpeedCoil.CoolHeatType,
    5121             :                                                CurrentObjSubfix));
    5122           0 :                             ShowContinueError(state, format("Coil Name = {}", varSpeedCoil.Name));
    5123           0 :                             ShowContinueError(state, format("User-Specified Rated Air Flow Rate of {:.5R} [m3/s]", RatedAirVolFlowRateUser));
    5124           0 :                             ShowContinueError(state, format("differs from Design Size Rated Air Flow Rate of {:.5R} [m3/s]", RatedAirVolFlowRateDes));
    5125           0 :                             ShowContinueError(state, "This may, or may not, indicate mismatched component sizes.");
    5126           0 :                             ShowContinueError(state, "Verify that the value entered is intended and is consistent with other components.");
    5127             :                         }
    5128             :                     }
    5129             :                 }
    5130             :             }
    5131          34 :             state.dataRptCoilSelection->coilSelectionReportObj->setCoilAirFlow(
    5132          34 :                 state, varSpeedCoil.Name, varSpeedCoil.VarSpeedCoilType, RatedAirVolFlowRateDes, RatedAirFlowAutoSized);
    5133             :         }
    5134             : 
    5135             :         // Check that heat pump heating capacity is within 20% of cooling capacity. Check only for heating coil and report both.
    5136          85 :         if ((varSpeedCoil.VSCoilType == HVAC::Coil_HeatingWaterToAirHPVSEquationFit ||
    5137          67 :              varSpeedCoil.VSCoilType == HVAC::Coil_HeatingAirToAirVariableSpeed) &&
    5138          29 :             varSpeedCoil.CompanionCoolingCoilNum > 0) {
    5139             : 
    5140          24 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(varSpeedCoil.CompanionCoolingCoilNum).RatedCapCoolTotal > 0.0) {
    5141             : 
    5142          24 :                 if (std::abs(state.dataVariableSpeedCoils->VarSpeedCoil(varSpeedCoil.CompanionCoolingCoilNum).RatedCapCoolTotal -
    5143          24 :                              varSpeedCoil.RatedCapHeat) /
    5144          24 :                         state.dataVariableSpeedCoils->VarSpeedCoil(varSpeedCoil.CompanionCoolingCoilNum).RatedCapCoolTotal >
    5145             :                     0.2) {
    5146             : 
    5147           0 :                     ShowWarningError(
    5148           0 :                         state, format("COIL:{}:WATERTOAIRHEATPUMP:VARIABLESPEEDEQUATIONFIT \"{}\"", varSpeedCoil.CoolHeatType, varSpeedCoil.Name));
    5149           0 :                     ShowContinueError(state,
    5150           0 :                                       format("...used with COIL:{}:WATERTOAIRHEATPUMP:VARIABLESPEEDEQUATIONFIT \"{}\"",
    5151           0 :                                              state.dataVariableSpeedCoils->VarSpeedCoil(varSpeedCoil.CompanionCoolingCoilNum).CoolHeatType,
    5152           0 :                                              state.dataVariableSpeedCoils->VarSpeedCoil(varSpeedCoil.CompanionCoolingCoilNum).Name));
    5153           0 :                     ShowContinueError(state, "...heating capacity is disproportionate (> 20% different) to total cooling capacity");
    5154           0 :                     ShowContinueError(state, format("...heating capacity = {:.3T} W", varSpeedCoil.RatedCapHeat));
    5155           0 :                     ShowContinueError(state,
    5156           0 :                                       format("...cooling capacity = {:.3T} W",
    5157           0 :                                              state.dataVariableSpeedCoils->VarSpeedCoil(varSpeedCoil.CompanionCoolingCoilNum).RatedCapCoolTotal));
    5158             :                 }
    5159             :             }
    5160             :         }
    5161             : 
    5162             :         // ASSIGN CAPACITY
    5163          85 :         switch (varSpeedCoil.VSCoilType) {
    5164          42 :         case HVAC::Coil_CoolingWaterToAirHPVSEquationFit:
    5165             :         case HVAC::Coil_CoolingAirToAirVariableSpeed: {
    5166          42 :             varSpeedCoil.MSRatedTotCap(UpperSpeed) = varSpeedCoil.RatedCapCoolTotal / varSpeedCoil.MSRatedPercentTotCap(NormSpeed);
    5167          42 :         } break;
    5168          29 :         case HVAC::Coil_HeatingWaterToAirHPVSEquationFit:
    5169             :         case HVAC::Coil_HeatingAirToAirVariableSpeed: {
    5170          29 :             varSpeedCoil.MSRatedTotCap(UpperSpeed) = varSpeedCoil.RatedCapHeat / varSpeedCoil.MSRatedPercentTotCap(NormSpeed);
    5171          29 :         } break;
    5172          14 :         case HVAC::CoilDX_HeatPumpWaterHeaterVariableSpeed: {
    5173          14 :             varSpeedCoil.MSRatedTotCap(UpperSpeed) = varSpeedCoil.RatedCapWH / varSpeedCoil.MSRatedPercentTotCap(NormSpeed);
    5174          14 :         } break;
    5175             :         }
    5176             : 
    5177          85 :         if (varSpeedCoil.VSCoilType == HVAC::CoilDX_HeatPumpWaterHeaterVariableSpeed) {
    5178          14 :             HPInletAirHumRat = Psychrometrics::PsyWFnTdbTwbPb(
    5179          14 :                 state, varSpeedCoil.WHRatedInletDBTemp, varSpeedCoil.WHRatedInletWBTemp, state.dataEnvrn->StdBaroPress, RoutineName);
    5180             : 
    5181         154 :             for (Mode = varSpeedCoil.NumOfSpeeds; Mode >= 1; --Mode) {
    5182         140 :                 varSpeedCoil.MSRatedTotCap(Mode) = varSpeedCoil.MSRatedTotCap(UpperSpeed) * varSpeedCoil.MSRatedPercentTotCap(Mode);
    5183         140 :                 varSpeedCoil.MSRatedAirVolFlowRate(Mode) = varSpeedCoil.MSRatedTotCap(Mode) * varSpeedCoil.MSRatedAirVolFlowPerRatedTotCap(Mode);
    5184         140 :                 varSpeedCoil.MSRatedAirMassFlowRate(Mode) = varSpeedCoil.MSRatedAirVolFlowRate(Mode) * rhoair;
    5185             :                 // EVAPORATIVE PRECOOLING CONDENSER AIR FLOW RATE
    5186         140 :                 varSpeedCoil.EvapCondAirFlow(Mode) = 0.0;
    5187             :             }
    5188             :         } else {
    5189             :             // HPWH, the mass flow rate will be updated by a revised entering air density
    5190             : 
    5191          71 :             if (varSpeedCoil.MSHPDesignSpecIndex > -1 && state.dataUnitarySystems->designSpecMSHP.size() > 0) {
    5192           1 :                 if (varSpeedCoil.VSCoilType == HVAC::Coil_CoolingWaterToAirHPVSEquationFit ||
    5193           1 :                     varSpeedCoil.VSCoilType == HVAC::Coil_CoolingAirToAirVariableSpeed) {
    5194           1 :                     if (state.dataUnitarySystems->designSpecMSHP[varSpeedCoil.MSHPDesignSpecIndex].numOfSpeedCooling != varSpeedCoil.NumOfSpeeds) {
    5195           0 :                         ShowFatalError(state,
    5196           0 :                                        format("COIL:{} = {}{} number of speeds not equal to number of speed specified in "
    5197             :                                               "UnitarySystemPerformance:Multispeed object.",
    5198           0 :                                               varSpeedCoil.CoolHeatType,
    5199             :                                               CurrentObjSubfix,
    5200           0 :                                               varSpeedCoil.Name));
    5201             :                     } else {
    5202           5 :                         for (Mode = varSpeedCoil.NumOfSpeeds; Mode >= 1; --Mode) {
    5203           8 :                             varSpeedCoil.MSRatedAirVolFlowRate(Mode) =
    5204           4 :                                 varSpeedCoil.RatedAirVolFlowRate *
    5205           4 :                                 state.dataUnitarySystems->designSpecMSHP[varSpeedCoil.MSHPDesignSpecIndex].coolingVolFlowRatio[Mode - 1];
    5206           8 :                             varSpeedCoil.MSRatedTotCap(Mode) =
    5207           4 :                                 varSpeedCoil.MSRatedAirVolFlowRate(Mode) / varSpeedCoil.MSRatedAirVolFlowPerRatedTotCap(Mode);
    5208           4 :                             varSpeedCoil.MSRatedAirMassFlowRate(Mode) = varSpeedCoil.MSRatedAirVolFlowRate(Mode) * rhoair;
    5209             :                             // EVAPORATIVE PRECOOLING CONDENSER AIR FLOW RATE
    5210           4 :                             varSpeedCoil.EvapCondAirFlow(Mode) =
    5211           4 :                                 varSpeedCoil.MSRatedTotCap(Mode) * varSpeedCoil.MSRatedEvapCondVolFlowPerRatedTotCap(Mode);
    5212             :                         }
    5213             :                     }
    5214           0 :                 } else if (varSpeedCoil.VSCoilType == HVAC::Coil_HeatingWaterToAirHPVSEquationFit ||
    5215           0 :                            varSpeedCoil.VSCoilType == HVAC::Coil_HeatingAirToAirVariableSpeed) {
    5216           0 :                     if (state.dataUnitarySystems->designSpecMSHP[varSpeedCoil.MSHPDesignSpecIndex].numOfSpeedHeating != varSpeedCoil.NumOfSpeeds) {
    5217           0 :                         ShowFatalError(state,
    5218           0 :                                        format("COIL:{}{} = \"{}\" number of speeds not equal to number of speed specified in "
    5219             :                                               "UnitarySystemPerformance:Multispeed object.",
    5220           0 :                                               varSpeedCoil.CoolHeatType,
    5221             :                                               CurrentObjSubfix,
    5222           0 :                                               varSpeedCoil.Name));
    5223             :                     } else {
    5224           0 :                         for (Mode = varSpeedCoil.NumOfSpeeds; Mode >= 1; --Mode) {
    5225           0 :                             varSpeedCoil.MSRatedAirVolFlowRate(Mode) =
    5226           0 :                                 varSpeedCoil.RatedAirVolFlowRate *
    5227           0 :                                 state.dataUnitarySystems->designSpecMSHP[varSpeedCoil.MSHPDesignSpecIndex].heatingVolFlowRatio[Mode - 1];
    5228           0 :                             varSpeedCoil.MSRatedTotCap(Mode) =
    5229           0 :                                 varSpeedCoil.MSRatedAirVolFlowRate(Mode) / varSpeedCoil.MSRatedAirVolFlowPerRatedTotCap(Mode);
    5230           0 :                             varSpeedCoil.MSRatedAirMassFlowRate(Mode) = varSpeedCoil.MSRatedAirVolFlowRate(Mode) * rhoair;
    5231             :                             // EVAPORATIVE PRECOOLING CONDENSER AIR FLOW RATE
    5232           0 :                             varSpeedCoil.EvapCondAirFlow(Mode) =
    5233           0 :                                 varSpeedCoil.MSRatedTotCap(Mode) * varSpeedCoil.MSRatedEvapCondVolFlowPerRatedTotCap(Mode);
    5234             :                         }
    5235             :                     }
    5236             :                 }
    5237             :             } else {
    5238         706 :                 for (Mode = varSpeedCoil.NumOfSpeeds; Mode >= 1; --Mode) {
    5239         636 :                     varSpeedCoil.MSRatedTotCap(Mode) = varSpeedCoil.MSRatedTotCap(UpperSpeed) * varSpeedCoil.MSRatedPercentTotCap(Mode);
    5240         636 :                     varSpeedCoil.MSRatedAirVolFlowRate(Mode) = varSpeedCoil.MSRatedTotCap(Mode) * varSpeedCoil.MSRatedAirVolFlowPerRatedTotCap(Mode);
    5241         636 :                     varSpeedCoil.MSRatedAirMassFlowRate(Mode) = varSpeedCoil.MSRatedAirVolFlowRate(Mode) * rhoair;
    5242             :                     // EVAPORATIVE PRECOOLING CONDENSER AIR FLOW RATE
    5243         636 :                     varSpeedCoil.EvapCondAirFlow(Mode) = varSpeedCoil.MSRatedTotCap(Mode) * varSpeedCoil.MSRatedEvapCondVolFlowPerRatedTotCap(Mode);
    5244             :                 }
    5245             :             }
    5246             :         }
    5247             : 
    5248             :         // size rated power
    5249          85 :         switch (varSpeedCoil.VSCoilType) {
    5250          42 :         case HVAC::Coil_CoolingWaterToAirHPVSEquationFit:
    5251             :         case HVAC::Coil_CoolingAirToAirVariableSpeed: {
    5252          42 :             varSpeedCoil.RatedCOPCool = varSpeedCoil.MSRatedCOP(varSpeedCoil.NormSpedLevel);
    5253          42 :             varSpeedCoil.RatedPowerCool = varSpeedCoil.RatedCapCoolTotal / varSpeedCoil.RatedCOPCool;
    5254          42 :         } break;
    5255          29 :         case HVAC::Coil_HeatingWaterToAirHPVSEquationFit:
    5256             :         case HVAC::Coil_HeatingAirToAirVariableSpeed: {
    5257          29 :             varSpeedCoil.RatedCOPHeat = varSpeedCoil.MSRatedCOP(varSpeedCoil.NormSpedLevel);
    5258          29 :             varSpeedCoil.RatedPowerHeat = varSpeedCoil.RatedCapHeat / varSpeedCoil.RatedCOPHeat;
    5259          29 :             varSpeedCoil.RatedCapCoolTotal = varSpeedCoil.RatedCapHeat;
    5260          29 :         } break;
    5261          14 :         case HVAC::CoilDX_HeatPumpWaterHeaterVariableSpeed: {
    5262          14 :             varSpeedCoil.RatedCOPHeat = varSpeedCoil.MSRatedCOP(varSpeedCoil.NormSpedLevel);
    5263          14 :             varSpeedCoil.RatedPowerHeat = varSpeedCoil.RatedCapWH / varSpeedCoil.RatedCOPHeat;
    5264          14 :             varSpeedCoil.RatedCapCoolTotal = varSpeedCoil.RatedCapWH * (1.0 - 1.0 / varSpeedCoil.RatedCOPHeat);
    5265          14 :         } break;
    5266             :         }
    5267             : 
    5268             :         // Size water volumetric flow rate
    5269          85 :         if ((varSpeedCoil.RatedWaterVolFlowRate == AutoSize) && (varSpeedCoil.VSCoilType == HVAC::Coil_CoolingWaterToAirHPVSEquationFit ||
    5270          38 :                                                                  varSpeedCoil.VSCoilType == HVAC::Coil_HeatingWaterToAirHPVSEquationFit)) {
    5271           6 :             RatedWaterFlowAutoSized = true;
    5272             :         }
    5273             : 
    5274             :         //   WSHP condenser can be on either a plant loop or condenser loop. Test each to find plant sizing number.
    5275             :         //   first check to see if coil is connected to a plant loop, no warning on this CALL
    5276          85 :         if (RatedWaterFlowAutoSized) {
    5277           6 :             if (varSpeedCoil.CondenserType == DataHeatBalance::RefrigCondenserType::Water)
    5278          12 :                 PltSizNum = PlantUtilities::MyPlantSizingIndex(state,
    5279          12 :                                                                format("COIL:{}{}", varSpeedCoil.CoolHeatType, CurrentObjSubfix),
    5280             :                                                                varSpeedCoil.Name,
    5281             :                                                                varSpeedCoil.WaterInletNodeNum,
    5282             :                                                                varSpeedCoil.WaterOutletNodeNum,
    5283             :                                                                ErrorsFound,
    5284             :                                                                false);
    5285             : 
    5286           6 :             if (PltSizNum > 0) {
    5287           6 :                 rho = FluidProperties::GetDensityGlycol(state,
    5288           6 :                                                         state.dataPlnt->PlantLoop(varSpeedCoil.plantLoc.loopNum).FluidName,
    5289           6 :                                                         state.dataSize->PlantSizData(PltSizNum).ExitTemp,
    5290           6 :                                                         state.dataPlnt->PlantLoop(varSpeedCoil.plantLoc.loopNum).FluidIndex,
    5291             :                                                         RoutineNameAlt);
    5292           6 :                 cp = FluidProperties::GetSpecificHeatGlycol(state,
    5293           6 :                                                             state.dataPlnt->PlantLoop(varSpeedCoil.plantLoc.loopNum).FluidName,
    5294           6 :                                                             state.dataSize->PlantSizData(PltSizNum).ExitTemp,
    5295           6 :                                                             state.dataPlnt->PlantLoop(varSpeedCoil.plantLoc.loopNum).FluidIndex,
    5296             :                                                             RoutineNameAlt);
    5297             : 
    5298           6 :                 if (varSpeedCoil.VSCoilType == HVAC::Coil_HeatingWaterToAirHPVSEquationFit ||
    5299           3 :                     varSpeedCoil.VSCoilType == HVAC::Coil_HeatingAirToAirVariableSpeed) {
    5300             : 
    5301           3 :                     RatedWaterVolFlowRateDes = varSpeedCoil.RatedCapHeat / (state.dataSize->PlantSizData(PltSizNum).DeltaT * cp * rho);
    5302             : 
    5303           3 :                     state.dataRptCoilSelection->coilSelectionReportObj->setCoilLvgWaterTemp(
    5304             :                         state,
    5305           3 :                         varSpeedCoil.Name,
    5306           3 :                         varSpeedCoil.VarSpeedCoilType,
    5307           3 :                         state.dataSize->PlantSizData(PltSizNum).ExitTemp +
    5308           3 :                             state.dataSize->PlantSizData(PltSizNum).DeltaT); // TRACE 3D Plus coil selection report
    5309             : 
    5310           3 :                 } else if (varSpeedCoil.VSCoilType == HVAC::Coil_CoolingWaterToAirHPVSEquationFit ||
    5311           0 :                            varSpeedCoil.VSCoilType == HVAC::Coil_CoolingAirToAirVariableSpeed) {
    5312             : 
    5313             :                     //       use companion heating coil capacity to calculate volumetric flow rate
    5314           3 :                     if (varSpeedCoil.CompanionCoolingCoilNum > 0) {
    5315           0 :                         SystemCapacity = state.dataVariableSpeedCoils->VarSpeedCoil(varSpeedCoil.CompanionCoolingCoilNum).RatedCapHeat;
    5316             :                     } else {
    5317           3 :                         SystemCapacity = varSpeedCoil.RatedCapCoolTotal;
    5318             :                     }
    5319             : 
    5320           3 :                     RatedWaterVolFlowRateDes = SystemCapacity / (state.dataSize->PlantSizData(PltSizNum).DeltaT * cp * rho);
    5321             : 
    5322           3 :                     state.dataRptCoilSelection->coilSelectionReportObj->setCoilLvgWaterTemp(
    5323             :                         state,
    5324           3 :                         varSpeedCoil.Name,
    5325           3 :                         varSpeedCoil.VarSpeedCoilType,
    5326           3 :                         state.dataSize->PlantSizData(PltSizNum).ExitTemp -
    5327           3 :                             state.dataSize->PlantSizData(PltSizNum).DeltaT); // TRACE 3D Plus coil selection report
    5328             :                 }
    5329             : 
    5330           6 :                 state.dataRptCoilSelection->coilSelectionReportObj->setCoilEntWaterTemp(
    5331             :                     state,
    5332           6 :                     varSpeedCoil.Name,
    5333           6 :                     varSpeedCoil.VarSpeedCoilType,
    5334           6 :                     state.dataSize->PlantSizData(PltSizNum).ExitTemp); // TRACE 3D Plus coil selection report
    5335             : 
    5336           6 :                 state.dataRptCoilSelection->coilSelectionReportObj->setCoilWaterDeltaT(
    5337             :                     state,
    5338           6 :                     varSpeedCoil.Name,
    5339           6 :                     varSpeedCoil.VarSpeedCoilType,
    5340           6 :                     state.dataSize->PlantSizData(PltSizNum).DeltaT); // TRACE 3D Plus coil selection report
    5341             :             } else {
    5342           0 :                 ShowSevereError(state, "Autosizing of water flow requires a loop Sizing:Plant object");
    5343           0 :                 ShowContinueError(state, "Autosizing also requires physical connection to a plant or condenser loop.");
    5344           0 :                 ShowContinueError(state, format("Occurs in COIL:{}{}  Object = {}", varSpeedCoil.CoolHeatType, CurrentObjSubfix, varSpeedCoil.Name));
    5345           0 :                 ErrorsFound = true;
    5346             :             }
    5347             :         }
    5348             : 
    5349             :         // WRITE THE WATER SIZING OUTPUT
    5350          85 :         if (RatedWaterFlowAutoSized) {
    5351             :             // FORCE BACK TO THE RATED WATER FLOW RATE WITH THE SAME RATIO DEFINED BY THE CATLOG DATA
    5352           6 :             if (RatedCapCoolTotalAutoSized) {
    5353           3 :                 RatedWaterVolFlowRateDes = varSpeedCoil.RatedCapCoolTotal * varSpeedCoil.MSRatedWaterVolFlowPerRatedTotCap(NormSpeed);
    5354           3 :             } else if (RatedCapHeatAutoSized) {
    5355           3 :                 RatedWaterVolFlowRateDes = varSpeedCoil.RatedCapHeat * varSpeedCoil.MSRatedWaterVolFlowPerRatedTotCap(NormSpeed);
    5356             :             }
    5357           6 :             state.dataRptCoilSelection->coilSelectionReportObj->setCoilWaterFlowNodeNums(state,
    5358           6 :                                                                                          varSpeedCoil.Name,
    5359           6 :                                                                                          varSpeedCoil.VarSpeedCoilType,
    5360             :                                                                                          RatedWaterVolFlowRateDes,
    5361             :                                                                                          RatedWaterFlowAutoSized,
    5362             :                                                                                          varSpeedCoil.WaterInletNodeNum,
    5363             :                                                                                          varSpeedCoil.WaterOutletNodeNum,
    5364             :                                                                                          varSpeedCoil.plantLoc.loopNum);
    5365           6 :             varSpeedCoil.RatedWaterVolFlowRate = RatedWaterVolFlowRateDes;
    5366          18 :             BaseSizer::reportSizerOutput(state,
    5367          12 :                                          format("COIL:{}{}", varSpeedCoil.CoolHeatType, CurrentObjSubfix),
    5368             :                                          varSpeedCoil.Name,
    5369             :                                          "Design Size Rated Water Flow Rate [m3/s]",
    5370             :                                          RatedWaterVolFlowRateDes);
    5371             :             // Ensure water flow rate at lower speed must be lower or
    5372             :             // equal to the flow rate at higher speed. Otherwise, a severe error is isssued.
    5373          60 :             for (Mode = 1; Mode <= varSpeedCoil.NumOfSpeeds - 1; ++Mode) {
    5374          54 :                 if (varSpeedCoil.MSRatedWaterVolFlowRate(Mode) > varSpeedCoil.MSRatedWaterVolFlowRate(Mode + 1) * 1.05) {
    5375           0 :                     ShowWarningError(
    5376             :                         state,
    5377           0 :                         format("SizeDXCoil: {} {}, Speed {} Rated Air Flow Rate must be less than or equal to Speed {} Rated Air Flow Rate.",
    5378           0 :                                varSpeedCoil.VarSpeedCoilType,
    5379           0 :                                varSpeedCoil.Name,
    5380             :                                Mode,
    5381           0 :                                Mode + 1));
    5382           0 :                     ShowContinueError(
    5383             :                         state,
    5384           0 :                         format("Instead, {:.2R} > {:.2R}", varSpeedCoil.MSRatedAirVolFlowRate(Mode), varSpeedCoil.MSRatedAirVolFlowRate(Mode + 1)));
    5385           0 :                     ShowFatalError(state, "Preceding conditions cause termination.");
    5386             :                 }
    5387             :             }
    5388             :         } else {
    5389          79 :             if (varSpeedCoil.RatedWaterVolFlowRate > 0.0 && RatedWaterVolFlowRateDes > 0.0) {
    5390           0 :                 RatedWaterVolFlowRateUser = varSpeedCoil.RatedWaterVolFlowRate;
    5391           0 :                 BaseSizer::reportSizerOutput(state,
    5392           0 :                                              format("COIL:{}{}", varSpeedCoil.CoolHeatType, CurrentObjSubfix),
    5393             :                                              varSpeedCoil.Name,
    5394             :                                              "Design Size Rated Water Flow Rate [m3/s]",
    5395             :                                              RatedWaterVolFlowRateDes,
    5396             :                                              "User-Specified Rated Water Flow Rate [m3/s]",
    5397             :                                              RatedWaterVolFlowRateUser);
    5398           0 :                 if (state.dataGlobal->DisplayExtraWarnings) {
    5399           0 :                     if ((std::abs(RatedWaterVolFlowRateDes - RatedWaterVolFlowRateUser) / RatedWaterVolFlowRateUser) >
    5400           0 :                         state.dataSize->AutoVsHardSizingThreshold) {
    5401           0 :                         ShowMessage(
    5402             :                             state,
    5403           0 :                             format("SizeVarSpeedCoil: Potential issue with equipment sizing for {} {}", varSpeedCoil.CoolHeatType, CurrentObjSubfix));
    5404           0 :                         ShowContinueError(state, format("Coil Name = {}", varSpeedCoil.Name));
    5405           0 :                         ShowContinueError(state, format("User-Specified Rated Water Flow Rate of {:.5R} [m3/s]", RatedWaterVolFlowRateUser));
    5406           0 :                         ShowContinueError(state, format("differs from Design Size Rated Water Flow Rate of {:.5R} [m3/s]", RatedWaterVolFlowRateDes));
    5407           0 :                         ShowContinueError(state, "This may, or may not, indicate mismatched component sizes.");
    5408           0 :                         ShowContinueError(state, "Verify that the value entered is intended and is consistent with other components.");
    5409             :                     }
    5410             :                 }
    5411             :             }
    5412             :         }
    5413             : 
    5414             :         // Save component design water volumetric flow rate.
    5415          85 :         if (varSpeedCoil.RatedWaterVolFlowRate > 0.0 && varSpeedCoil.VSCoilType == HVAC::CoilDX_HeatPumpWaterHeaterVariableSpeed) {
    5416          14 :             PlantUtilities::RegisterPlantCompDesignFlow(state, varSpeedCoil.WaterInletNodeNum, varSpeedCoil.RatedWaterVolFlowRate);
    5417             :         }
    5418             :         // Use 1/2 flow since both cooling and heating coil will save flow yet only 1 will operate at a time
    5419          71 :         else if (varSpeedCoil.RatedWaterVolFlowRate > 0.0) {
    5420          36 :             PlantUtilities::RegisterPlantCompDesignFlow(state, varSpeedCoil.WaterInletNodeNum, 0.5 * varSpeedCoil.RatedWaterVolFlowRate);
    5421             :         }
    5422             : 
    5423          85 :         RatedSourceTempCool = GetVSCoilRatedSourceTemp(state, DXCoilNum);
    5424          85 :         if (varSpeedCoil.VSCoilType == HVAC::Coil_CoolingWaterToAirHPVSEquationFit ||
    5425          67 :             varSpeedCoil.VSCoilType == HVAC::Coil_HeatingWaterToAirHPVSEquationFit) {
    5426             : 
    5427          36 :             if (PltSizNum > 0) {
    5428           6 :                 rhoW = rho;
    5429             :             } else {
    5430          30 :                 rhoW = FluidProperties::GetDensityGlycol(state,
    5431          30 :                                                          state.dataPlnt->PlantLoop(varSpeedCoil.plantLoc.loopNum).FluidName,
    5432             :                                                          RatedSourceTempCool,
    5433          30 :                                                          state.dataPlnt->PlantLoop(varSpeedCoil.plantLoc.loopNum).FluidIndex,
    5434             :                                                          RoutineName);
    5435             :             }
    5436             : 
    5437          36 :             varSpeedCoil.RatedWaterMassFlowRate = varSpeedCoil.RatedWaterVolFlowRate * rhoW;
    5438         396 :             for (Mode = varSpeedCoil.NumOfSpeeds; Mode >= 1; --Mode) {
    5439         360 :                 varSpeedCoil.MSRatedWaterVolFlowRate(Mode) = varSpeedCoil.MSRatedTotCap(Mode) * varSpeedCoil.MSRatedWaterVolFlowPerRatedTotCap(Mode);
    5440         360 :                 varSpeedCoil.MSRatedWaterMassFlowRate(Mode) = varSpeedCoil.MSRatedWaterVolFlowRate(Mode) * rhoW;
    5441             :             }
    5442          49 :         } else if (varSpeedCoil.VSCoilType == HVAC::CoilDX_HeatPumpWaterHeaterVariableSpeed) {
    5443          14 :             rhoW = RhoH2O(RatedSourceTempCool);
    5444          14 :             varSpeedCoil.RatedWaterMassFlowRate = varSpeedCoil.RatedWaterVolFlowRate * rhoW;
    5445         154 :             for (Mode = varSpeedCoil.NumOfSpeeds; Mode >= 1; --Mode) {
    5446         140 :                 varSpeedCoil.MSRatedWaterVolFlowRate(Mode) = varSpeedCoil.MSRatedTotCap(Mode) * varSpeedCoil.MSRatedWaterVolFlowPerRatedTotCap(Mode);
    5447         140 :                 varSpeedCoil.MSWHPumpPower(Mode) = varSpeedCoil.MSRatedTotCap(Mode) * varSpeedCoil.MSWHPumpPowerPerRatedTotCap(Mode);
    5448         140 :                 varSpeedCoil.MSRatedWaterMassFlowRate(Mode) = varSpeedCoil.MSRatedWaterVolFlowRate(Mode) * rhoW;
    5449             :             }
    5450             :         }
    5451             : 
    5452             :         // Ensure air flow rate at lower speed must be lower or
    5453             :         // equal to the flow rate at higher speed. Otherwise, a severe error is issued.
    5454         780 :         for (Mode = 1; Mode <= varSpeedCoil.NumOfSpeeds - 1; ++Mode) {
    5455         695 :             if (varSpeedCoil.MSRatedAirVolFlowRate(Mode) > varSpeedCoil.MSRatedAirVolFlowRate(Mode + 1)) {
    5456           0 :                 ShowWarningError(state,
    5457           0 :                                  format("SizeDXCoil: {} {}, Speed {} Rated Air Flow Rate must be less than or equal to Speed {} Rated Air Flow Rate.",
    5458           0 :                                         varSpeedCoil.VarSpeedCoilType,
    5459           0 :                                         varSpeedCoil.Name,
    5460             :                                         Mode,
    5461           0 :                                         Mode + 1));
    5462           0 :                 ShowContinueError(
    5463             :                     state,
    5464           0 :                     format("Instead, {:.2R} > {:.2R}", varSpeedCoil.MSRatedAirVolFlowRate(Mode), varSpeedCoil.MSRatedAirVolFlowRate(Mode + 1)));
    5465           0 :                 ShowFatalError(state, "Preceding conditions cause termination.");
    5466             :             }
    5467             :         }
    5468             : 
    5469             :         // Ensure capacity at lower speed must be lower or equal to the capacity at higher speed.
    5470         780 :         for (Mode = 1; Mode <= varSpeedCoil.NumOfSpeeds - 1; ++Mode) {
    5471         695 :             if (varSpeedCoil.MSRatedTotCap(Mode) > varSpeedCoil.MSRatedTotCap(Mode + 1)) {
    5472           0 :                 ShowWarningError(state,
    5473           0 :                                  format("SizeDXCoil: {} {}, Speed {} Rated Total Cooling Capacity must be less than or equal to Speed {} Rated Total "
    5474             :                                         "Cooling Capacity.",
    5475           0 :                                         varSpeedCoil.VarSpeedCoilType,
    5476           0 :                                         varSpeedCoil.Name,
    5477             :                                         Mode,
    5478           0 :                                         Mode + 1));
    5479           0 :                 ShowContinueError(state, format("Instead, {:.2R} > {:.2R}", varSpeedCoil.MSRatedTotCap(Mode), varSpeedCoil.MSRatedTotCap(Mode + 1)));
    5480           0 :                 ShowFatalError(state, "Preceding conditions cause termination.");
    5481             :             }
    5482             :         }
    5483             : 
    5484             :         // convert SHR to rated Bypass factor and effective air side surface area
    5485          85 :         if (varSpeedCoil.VSCoilType == HVAC::Coil_CoolingWaterToAirHPVSEquationFit ||
    5486          67 :             varSpeedCoil.VSCoilType == HVAC::Coil_CoolingAirToAirVariableSpeed) {
    5487         402 :             for (Mode = 1; Mode <= varSpeedCoil.NumOfSpeeds; ++Mode) {
    5488         360 :                 varSpeedCoil.MSRatedCBF(Mode) = CalcCBF(state,
    5489         360 :                                                         varSpeedCoil.VarSpeedCoilType,
    5490         360 :                                                         varSpeedCoil.Name,
    5491             :                                                         RatedInletAirTemp,
    5492             :                                                         RatedInletAirHumRat,
    5493         360 :                                                         varSpeedCoil.MSRatedTotCap(Mode),
    5494         360 :                                                         varSpeedCoil.MSRatedAirVolFlowRate(Mode),
    5495         360 :                                                         varSpeedCoil.MSRatedSHR(Mode),
    5496             :                                                         true);
    5497         360 :                 if (varSpeedCoil.MSRatedCBF(Mode) > 0.0) {
    5498         360 :                     varSpeedCoil.MSEffectiveAo(Mode) = -std::log(varSpeedCoil.MSRatedCBF(Mode)) * varSpeedCoil.MSRatedAirMassFlowRate(Mode);
    5499             :                 } else {
    5500           0 :                     varSpeedCoil.MSEffectiveAo(Mode) = 0.0;
    5501             :                 }
    5502             :             }
    5503          43 :         } else if (varSpeedCoil.VSCoilType == HVAC::CoilDX_HeatPumpWaterHeaterVariableSpeed) {
    5504          14 :             state.dataHVACGlobal->HPWHInletDBTemp = varSpeedCoil.WHRatedInletDBTemp;
    5505          14 :             state.dataHVACGlobal->HPWHInletWBTemp = varSpeedCoil.WHRatedInletWBTemp;
    5506             : 
    5507         154 :             for (Mode = 1; Mode <= varSpeedCoil.NumOfSpeeds; ++Mode) {
    5508         140 :                 varSpeedCoil.MSRatedAirMassFlowRate(Mode) = varSpeedCoil.MSRatedAirVolFlowRate(Mode) * rhoair;
    5509             :             }
    5510             : 
    5511         154 :             for (Mode = 1; Mode <= varSpeedCoil.NumOfSpeeds; ++Mode) {
    5512             :                 // get cooling capacity, without fan power, i.e. total coil cooling
    5513         140 :                 if (varSpeedCoil.CondPumpPowerInCOP)
    5514           0 :                     HPWHCoolCapacity = varSpeedCoil.MSRatedTotCap(Mode) * (1.0 - 1.0 / varSpeedCoil.MSRatedCOP(Mode)) +
    5515           0 :                                        varSpeedCoil.MSWHPumpPower(Mode) - varSpeedCoil.MSWHPumpPower(Mode) * varSpeedCoil.HPWHCondPumpFracToWater;
    5516             :                 else
    5517         140 :                     HPWHCoolCapacity = varSpeedCoil.MSRatedTotCap(Mode) * (1.0 - 1.0 / varSpeedCoil.MSRatedCOP(Mode)) -
    5518         140 :                                        varSpeedCoil.MSWHPumpPower(Mode) * varSpeedCoil.HPWHCondPumpFracToWater;
    5519             : 
    5520         140 :                 varSpeedCoil.MSRatedCBF(Mode) = CalcCBF(state,
    5521         140 :                                                         varSpeedCoil.VarSpeedCoilType,
    5522         140 :                                                         varSpeedCoil.Name,
    5523         140 :                                                         state.dataHVACGlobal->HPWHInletDBTemp,
    5524             :                                                         HPInletAirHumRat,
    5525             :                                                         HPWHCoolCapacity,
    5526         140 :                                                         varSpeedCoil.MSRatedAirVolFlowRate(Mode),
    5527         140 :                                                         varSpeedCoil.MSRatedSHR(Mode),
    5528             :                                                         true);
    5529         140 :                 if (varSpeedCoil.MSRatedCBF(Mode) > 0.0) {
    5530         140 :                     varSpeedCoil.MSEffectiveAo(Mode) = -std::log(varSpeedCoil.MSRatedCBF(Mode)) * varSpeedCoil.MSRatedAirMassFlowRate(Mode);
    5531             :                 } else {
    5532           0 :                     varSpeedCoil.MSEffectiveAo(Mode) = 0.0;
    5533             :                 }
    5534             :             }
    5535             : 
    5536             :             // update VarSpeedCoil(DXCoilNum).RatedCapCoolTotal
    5537          14 :             Mode = varSpeedCoil.NormSpedLevel;
    5538          14 :             if (varSpeedCoil.CondPumpPowerInCOP) {
    5539           0 :                 varSpeedCoil.RatedCapCoolTotal = varSpeedCoil.MSRatedTotCap(Mode) * (1.0 - 1.0 / varSpeedCoil.MSRatedCOP(Mode)) +
    5540           0 :                                                  varSpeedCoil.MSWHPumpPower(Mode) -
    5541           0 :                                                  varSpeedCoil.MSWHPumpPower(Mode) * varSpeedCoil.HPWHCondPumpFracToWater;
    5542             :             } else {
    5543          14 :                 varSpeedCoil.RatedCapCoolTotal = varSpeedCoil.MSRatedTotCap(Mode) * (1.0 - 1.0 / varSpeedCoil.MSRatedCOP(Mode)) -
    5544          14 :                                                  varSpeedCoil.MSWHPumpPower(Mode) * varSpeedCoil.HPWHCondPumpFracToWater;
    5545             :             }
    5546             :         }
    5547             : 
    5548             :         // size rated sensible cooling capacity
    5549          85 :         RatedCapCoolSensAutoSized = true; // always do that
    5550             : 
    5551          85 :         if (varSpeedCoil.RatedAirVolFlowRate >= HVAC::SmallAirVolFlow && (varSpeedCoil.VSCoilType == HVAC::Coil_CoolingWaterToAirHPVSEquationFit ||
    5552          67 :                                                                           varSpeedCoil.VSCoilType == HVAC::Coil_CoolingAirToAirVariableSpeed)) {
    5553          42 :             RatedAirMassFlowRate =
    5554          42 :                 varSpeedCoil.RatedAirVolFlowRate *
    5555          42 :                 Psychrometrics::PsyRhoAirFnPbTdbW(state, state.dataEnvrn->StdBaroPress, RatedInletAirTemp, RatedInletAirHumRat, RoutineName);
    5556          42 :             RatedInletEnth = Psychrometrics::PsyHFnTdbW(RatedInletAirTemp, RatedInletAirHumRat);
    5557          42 :             CBFRated = AdjustCBF(varSpeedCoil.MSRatedCBF(NormSpeed), varSpeedCoil.MSRatedAirMassFlowRate(NormSpeed), RatedAirMassFlowRate);
    5558          42 :             if (CBFRated > 0.999) CBFRated = 0.999;
    5559          42 :             if (varSpeedCoil.MSRatedAirMassFlowRate(NormSpeed) > 1.0e-10) {
    5560          42 :                 AirMassFlowRatio = RatedAirMassFlowRate / varSpeedCoil.MSRatedAirMassFlowRate(NormSpeed);
    5561             :             } else {
    5562           0 :                 AirMassFlowRatio = 1.0;
    5563             :             }
    5564             : 
    5565          42 :             if (varSpeedCoil.MSRatedWaterVolFlowRate(NormSpeed) > 1.0e-10) {
    5566          18 :                 WaterMassFlowRatio = varSpeedCoil.RatedWaterVolFlowRate / varSpeedCoil.MSRatedWaterVolFlowRate(NormSpeed);
    5567             :             } else {
    5568          24 :                 WaterMassFlowRatio = 1.0;
    5569             :             }
    5570             : 
    5571          42 :             Real64 TempInletWetBulb = RatedInletWetBulbTemp;
    5572         210 :             CalcTotCapSHR_VSWSHP(state,
    5573             :                                  RatedInletAirTemp,
    5574             :                                  RatedInletAirHumRat,
    5575             :                                  RatedInletEnth,
    5576             :                                  TempInletWetBulb,
    5577             :                                  AirMassFlowRatio,
    5578             :                                  WaterMassFlowRatio,
    5579             :                                  RatedAirMassFlowRate,
    5580             :                                  CBFRated,
    5581          42 :                                  varSpeedCoil.MSRatedTotCap(NormSpeed),
    5582          42 :                                  varSpeedCoil.MSCCapFTemp(NormSpeed),
    5583          42 :                                  varSpeedCoil.MSCCapAirFFlow(NormSpeed),
    5584          42 :                                  varSpeedCoil.MSCCapWaterFFlow(NormSpeed),
    5585             :                                  0.0,
    5586             :                                  0,
    5587             :                                  0,
    5588             :                                  0,
    5589             :                                  QLoadTotal1,
    5590             :                                  QLoadTotal2,
    5591             :                                  QLoadTotal,
    5592             :                                  SHR,
    5593             :                                  RatedSourceTempCool,
    5594          42 :                                  state.dataEnvrn->StdBaroPress,
    5595             :                                  0.0,
    5596             :                                  1,
    5597          42 :                                  varSpeedCoil.capModFacTotal);
    5598             : 
    5599          42 :             RatedCapCoolSensDes = varSpeedCoil.RatedCapCoolTotal * SHR;
    5600          85 :         } else if (varSpeedCoil.RatedAirVolFlowRate >= HVAC::SmallAirVolFlow &&
    5601          43 :                    varSpeedCoil.VSCoilType == HVAC::CoilDX_HeatPumpWaterHeaterVariableSpeed) {
    5602          14 :             SHR = varSpeedCoil.MSRatedSHR(NormSpeed);
    5603          14 :             RatedCapCoolSensDes = varSpeedCoil.RatedCapCoolTotal * SHR;
    5604             :         } else {
    5605          29 :             RatedCapCoolSensDes = 0.0;
    5606             :         }
    5607             : 
    5608          85 :         if (RatedCapCoolSensDes < HVAC::SmallLoad) {
    5609          29 :             RatedCapCoolSensDes = 0.0;
    5610             :         }
    5611             : 
    5612          85 :         if (varSpeedCoil.VSCoilType == HVAC::Coil_CoolingWaterToAirHPVSEquationFit ||
    5613          67 :             varSpeedCoil.VSCoilType == HVAC::Coil_CoolingAirToAirVariableSpeed) { // always report for cooling mode
    5614          42 :             if (RatedCapCoolTotalAutoSized) {
    5615          18 :                 varSpeedCoil.RatedCapCoolSens = RatedCapCoolSensDes;
    5616          54 :                 BaseSizer::reportSizerOutput(state,
    5617          36 :                                              format("COIL:{}{}", varSpeedCoil.CoolHeatType, CurrentObjSubfix),
    5618             :                                              varSpeedCoil.Name,
    5619             :                                              "Design Size Rated Sensible Cooling Capacity [W]",
    5620             :                                              varSpeedCoil.RatedCapCoolSens);
    5621             : 
    5622             :             } else {
    5623             :                 // sensible capacity does not have an input field
    5624          24 :                 if (RatedCapCoolSensDes > 0.0) {
    5625          24 :                     varSpeedCoil.RatedCapCoolSens = RatedCapCoolSensDes;
    5626          72 :                     BaseSizer::reportSizerOutput(state,
    5627          48 :                                                  format("COIL:{}{}", varSpeedCoil.CoolHeatType, CurrentObjSubfix),
    5628             :                                                  varSpeedCoil.Name,
    5629             :                                                  "Design Size Rated Sensible Cooling Capacity [W]",
    5630             :                                                  RatedCapCoolSensDes); //, &
    5631             :                 }
    5632             :             }
    5633          84 :             OutputReportPredefined::PreDefTableEntry(
    5634          42 :                 state, state.dataOutRptPredefined->pdchCoolCoilTotCap, varSpeedCoil.Name, varSpeedCoil.RatedCapCoolTotal);
    5635          84 :             OutputReportPredefined::PreDefTableEntry(
    5636          42 :                 state, state.dataOutRptPredefined->pdchCoolCoilSensCap, varSpeedCoil.Name, varSpeedCoil.RatedCapCoolSens);
    5637          84 :             OutputReportPredefined::PreDefTableEntry(state,
    5638          42 :                                                      state.dataOutRptPredefined->pdchCoolCoilLatCap,
    5639             :                                                      varSpeedCoil.Name,
    5640          42 :                                                      varSpeedCoil.RatedCapCoolTotal - varSpeedCoil.RatedCapCoolSens);
    5641          42 :             if (varSpeedCoil.RatedCapCoolTotal != 0.0) {
    5642          84 :                 OutputReportPredefined::PreDefTableEntry(state,
    5643          42 :                                                          state.dataOutRptPredefined->pdchCoolCoilSHR,
    5644             :                                                          varSpeedCoil.Name,
    5645          42 :                                                          varSpeedCoil.RatedCapCoolSens / varSpeedCoil.RatedCapCoolTotal);
    5646             :             } else {
    5647           0 :                 OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoolCoilSHR, varSpeedCoil.Name, 0.0);
    5648             :             }
    5649          84 :             OutputReportPredefined::PreDefTableEntry(
    5650          42 :                 state, state.dataOutRptPredefined->pdchCoolCoilNomEff, varSpeedCoil.Name, varSpeedCoil.MSRatedCOP(varSpeedCoil.NormSpedLevel));
    5651          84 :             OutputReportPredefined::addFootNoteSubTable(
    5652             :                 state,
    5653          42 :                 state.dataOutRptPredefined->pdstCoolCoil,
    5654             :                 "Nominal values are gross at rated conditions, i.e., the supply air fan heat and electric power NOT accounted for.");
    5655             :         }
    5656             : 
    5657             :         // START SIZING EVAP PRECOOLING PUMP POWER
    5658          85 :         IsAutoSize = false;
    5659          85 :         if (varSpeedCoil.VSCoilType == HVAC::Coil_CoolingAirToAirVariableSpeed) {
    5660          24 :             if (varSpeedCoil.EvapCondPumpElecNomPower == AutoSize) {
    5661           0 :                 IsAutoSize = true;
    5662             :             }
    5663             :             //     Auto size high speed evap condenser pump power to Total Capacity * 0.004266 w/w (15 w/ton)
    5664          24 :             EvapCondPumpElecNomPowerDes = varSpeedCoil.RatedCapCoolTotal * 0.004266;
    5665          24 :             if (IsAutoSize) {
    5666           0 :                 varSpeedCoil.EvapCondPumpElecNomPower = EvapCondPumpElecNomPowerDes;
    5667           0 :                 BaseSizer::reportSizerOutput(state,
    5668             :                                              "AS VS COOLING COIL",
    5669             :                                              varSpeedCoil.Name,
    5670             :                                              "Design Size Evaporative Condenser Pump Rated Power Consumption [W]",
    5671             :                                              EvapCondPumpElecNomPowerDes);
    5672             :             } else {
    5673          24 :                 if (varSpeedCoil.EvapCondPumpElecNomPower > 0.0 && EvapCondPumpElecNomPowerDes > 0.0) {
    5674           0 :                     EvapCondPumpElecNomPowerUser = varSpeedCoil.EvapCondPumpElecNomPower;
    5675           0 :                     BaseSizer::reportSizerOutput(state,
    5676             :                                                  "AS VS COOLING COIL",
    5677             :                                                  varSpeedCoil.Name,
    5678             :                                                  "Design Size Evaporative Condenser Pump Rated Power Consumption [W]",
    5679             :                                                  EvapCondPumpElecNomPowerDes,
    5680             :                                                  "User-Specified Evaporative Condenser Pump Rated Power Consumption [W]",
    5681             :                                                  EvapCondPumpElecNomPowerUser);
    5682           0 :                     if (state.dataGlobal->DisplayExtraWarnings) {
    5683           0 :                         if ((std::abs(EvapCondPumpElecNomPowerDes - EvapCondPumpElecNomPowerUser) / EvapCondPumpElecNomPowerUser) >
    5684           0 :                             state.dataSize->AutoVsHardSizingThreshold) {
    5685           0 :                             ShowMessage(state,
    5686           0 :                                         format("SizeVarSpeedCoil: Potential issue with equipment sizing for {} {}",
    5687           0 :                                                varSpeedCoil.CoolHeatType,
    5688             :                                                CurrentObjSubfix));
    5689           0 :                             ShowContinueError(state, format("Coil Name = {}", varSpeedCoil.Name));
    5690           0 :                             ShowContinueError(state,
    5691           0 :                                               format("User-Specified Evaporative Condenser Pump Rated Power Consumption of {:.2R} [W]",
    5692             :                                                      EvapCondPumpElecNomPowerUser));
    5693           0 :                             ShowContinueError(state,
    5694           0 :                                               format("differs from Design Size Evaporative Condenser Pump Rated Power Consumption of {:.2R} [W]",
    5695             :                                                      EvapCondPumpElecNomPowerDes));
    5696           0 :                             ShowContinueError(state, "This may, or may not, indicate mismatched component sizes.");
    5697           0 :                             ShowContinueError(state, "Verify that the value entered is intended and is consistent with other components.");
    5698             :                         }
    5699             :                     }
    5700             :                 }
    5701             :             }
    5702             :         }
    5703             :         // END SIZING EVAP PRE-COOLING PUMP POWER
    5704             : 
    5705             :         // SIZE DEFROST HEATER
    5706             : 
    5707             :         // Resistive Defrost Heater Capacity = capacity at the first stage
    5708          85 :         IsAutoSize = false;
    5709          85 :         if (varSpeedCoil.VSCoilType == HVAC::Coil_HeatingAirToAirVariableSpeed) {
    5710          11 :             if (varSpeedCoil.DefrostCapacity == AutoSize) {
    5711           2 :                 IsAutoSize = true;
    5712             :             }
    5713          11 :             if (varSpeedCoil.DefrostStrategy == Resistive) {
    5714          11 :                 DefrostCapacityDes = varSpeedCoil.RatedCapHeat;
    5715             :             } else {
    5716           0 :                 DefrostCapacityDes = 0.0;
    5717             :             }
    5718          11 :             if (IsAutoSize) {
    5719           2 :                 varSpeedCoil.DefrostCapacity = DefrostCapacityDes;
    5720           2 :                 BaseSizer::reportSizerOutput(
    5721             :                     state, "AS VS HEATING COIL", varSpeedCoil.Name, "Design Size Resistive Defrost Heater Capacity [W]", DefrostCapacityDes);
    5722             :             } else {
    5723           9 :                 if (varSpeedCoil.DefrostCapacity > 0.0 && DefrostCapacityDes > 0.0 && !HardSizeNoDesRun) {
    5724           3 :                     DefrostCapacityUser = varSpeedCoil.DefrostCapacity;
    5725           3 :                     BaseSizer::reportSizerOutput(state,
    5726             :                                                  "AS VS HEATING COIL",
    5727             :                                                  varSpeedCoil.Name,
    5728             :                                                  "Design Size Resistive Defrost Heater Capacity [W]",
    5729             :                                                  DefrostCapacityDes,
    5730             :                                                  "User-Specified Resistive Defrost Heater Capacity [W]",
    5731             :                                                  DefrostCapacityUser);
    5732           3 :                     if (state.dataGlobal->DisplayExtraWarnings) {
    5733           0 :                         if ((std::abs(DefrostCapacityDes - DefrostCapacityUser) / DefrostCapacityUser) > state.dataSize->AutoVsHardSizingThreshold) {
    5734           0 :                             ShowMessage(state,
    5735           0 :                                         format("SizeVarSpeedCoil: Potential issue with equipment sizing for {} {}",
    5736           0 :                                                varSpeedCoil.CoolHeatType,
    5737             :                                                CurrentObjSubfix));
    5738           0 :                             ShowContinueError(state, format("Coil Name = {}", varSpeedCoil.Name));
    5739           0 :                             ShowContinueError(state, format("User-Specified Resistive Defrost Heater Capacity of {:.2R} [W]", DefrostCapacityUser));
    5740           0 :                             ShowContinueError(state,
    5741           0 :                                               format("differs from Design Size Resistive Defrost Heater Capacity of {:.2R} [W]", DefrostCapacityDes));
    5742           0 :                             ShowContinueError(state, "This may, or may not, indicate mismatched component sizes.");
    5743           0 :                             ShowContinueError(state, "Verify that the value entered is intended and is consistent with other components.");
    5744             :                         }
    5745             :                     }
    5746             :                 }
    5747             :             }
    5748             :         }
    5749             :         // END SIZING DEFROST HEATER
    5750             : 
    5751             :         // test autosized sensible and total cooling capacity for total > sensible
    5752          85 :         if (RatedCapCoolSensAutoSized && RatedCapCoolTotalAutoSized) {
    5753          18 :             if (varSpeedCoil.RatedCapCoolSens > varSpeedCoil.RatedCapCoolTotal) {
    5754           0 :                 ShowWarningError(state,
    5755           0 :                                  format("COIL:{}:WATERTOAIRHEATPUMP:VARIABLESPEEDEQUATIONFIT \"{}\"", varSpeedCoil.CoolHeatType, varSpeedCoil.Name));
    5756           0 :                 ShowContinueError(state, format("{}: Rated Sensible Cooling Capacity > Rated Total Cooling Capacity", RoutineName));
    5757           0 :                 ShowContinueError(state, "Each of these capacity inputs have been autosized.");
    5758           0 :                 ShowContinueError(state, format("Rated Sensible Cooling Capacity = {:.2T} W", varSpeedCoil.RatedCapCoolSens));
    5759           0 :                 ShowContinueError(state, format("Rated Total Cooling Capacity    = {:.2T} W", varSpeedCoil.RatedCapCoolTotal));
    5760           0 :                 ShowContinueError(state, "See eio file for further details.");
    5761           0 :                 ShowContinueError(state, "Check Total and Sensible Cooling Capacity Coefficients to ensure they are accurate.");
    5762           0 :                 ShowContinueError(state, "Check Zone and System Sizing objects to verify sizing inputs.");
    5763           0 :                 ShowContinueError(state, "Sizing statistics:");
    5764           0 :                 ShowContinueError(state, format("Entering Air Dry-Bulb Temperature = {:.3T} C", MixTemp));
    5765           0 :                 ShowContinueError(state, format("Entering Air Wet-Bulb Temperature = {:.3T} C", MixWetBulb));
    5766           0 :                 ShowContinueError(state, "Entering Condenser Water Temperature used = 24.4444 C");
    5767           0 :                 ShowContinueError(state, "Used design air and water flow rates (i.e., used 1 for ratioVL and ratioVS)");
    5768           0 :                 ShowContinueError(state, format("ratioTDB = {:.3T}", ((MixTemp + 283.15) / 273.15)));
    5769           0 :                 ShowContinueError(state, format("ratioTWB = {:.3T}", ((MixWetBulb + 283.15) / 273.15)));
    5770           0 :                 ShowContinueError(state, format("ratioTS  = {:.3T}", ((85.0 + 283.15) / 273.15)));
    5771           0 :                 ShowContinueError(state, "Rated Sensible Cooling Capacity = Rated Total Cooling Capacity * Sensible Heat Ratio");
    5772           0 :                 ShowContinueError(state, format("Total Cooling Capacity Modifier = {:.5T}", TotCapTempModFac));
    5773           0 :                 ShowContinueError(state, "...Rated Total Cooling Capacity = Total Design Load / Total Cooling Capacity Modifier");
    5774           0 :                 ShowContinueError(state, "Carefully review the Load Side Total, Sensible, and Latent heat transfer rates");
    5775           0 :                 ShowContinueError(state, "... to ensure they meet the expected manufacturers performance specifications.");
    5776             :             }
    5777          67 :         } else if (RatedCapCoolTotalAutoSized) {
    5778           0 :             if (varSpeedCoil.RatedCapCoolSens > varSpeedCoil.RatedCapCoolTotal) {
    5779           0 :                 ShowWarningError(state,
    5780           0 :                                  format("COIL:{}:WATERTOAIRHEATPUMP:VARIABLESPEEDEQUATIONFIT \"{}\"", varSpeedCoil.CoolHeatType, varSpeedCoil.Name));
    5781           0 :                 ShowContinueError(state, format("{}: Rated Sensible Cooling Capacity > Rated Total Cooling Capacity", RoutineName));
    5782           0 :                 ShowContinueError(state, "Only the rated total capacity input is autosized, consider autosizing both inputs.");
    5783           0 :                 ShowContinueError(state, format("Rated Sensible Cooling Capacity = {:.2T} W", varSpeedCoil.RatedCapCoolSens));
    5784           0 :                 ShowContinueError(state, format("Rated Total Cooling Capacity    = {:.2T} W", varSpeedCoil.RatedCapCoolTotal));
    5785           0 :                 ShowContinueError(state, "See eio file for further details.");
    5786           0 :                 ShowContinueError(state, "Check Total and Sensible Cooling Capacity Coefficients to ensure they are accurate.");
    5787           0 :                 ShowContinueError(state, "Check Zone and System Sizing objects to verify sizing inputs.");
    5788           0 :                 ShowContinueError(state, "Sizing statistics for Total Cooling Capacity:");
    5789           0 :                 ShowContinueError(state, format("Entering Air Wet-Bulb Temperature = {:.3T} C", MixWetBulb));
    5790           0 :                 ShowContinueError(state, "Entering Condenser Water Temperature used = 24.4444 C");
    5791           0 :                 ShowContinueError(state, "Used design air and water flow rates (i.e., used 1 for ratioVL and ratioVS)");
    5792           0 :                 ShowContinueError(state, format("ratioTWB = {:.3T}", ((MixWetBulb + 283.15) / 273.15)));
    5793           0 :                 ShowContinueError(state, format("ratioTS  = {:.3T}", ((85.0 + 283.15) / 273.15)));
    5794           0 :                 ShowContinueError(state, "Rated Sensible Cooling Capacity = Rated Total Cooling Capacity * Sensible Heat Ratio");
    5795           0 :                 ShowContinueError(state, "Carefully review the Load Side Total, Sensible, and Latent heat transfer rates");
    5796           0 :                 ShowContinueError(state, "... to ensure they meet the expected manufacturers performance specifications.");
    5797             :             }
    5798             :         }
    5799             : 
    5800         170 :         Array1D<DataHeatBalance::RefrigCondenserType> CondenserType;
    5801             :         StandardRatings::HPdefrostControl DefrostControl;
    5802          85 :         switch (varSpeedCoil.VSCoilType) {
    5803          24 :         case HVAC::Coil_CoolingAirToAirVariableSpeed:
    5804          24 :             CondenserType.push_back(varSpeedCoil.CondenserType);
    5805          24 :             switch (varSpeedCoil.DefrostControl) // defrost control; 1=timed, 2=on-demand
    5806             :             {
    5807           0 :             case 2:
    5808           0 :                 DefrostControl = StandardRatings::HPdefrostControl::OnDemand;
    5809           0 :                 break;
    5810          24 :             case 1:
    5811             :             default:
    5812          24 :                 DefrostControl = StandardRatings::HPdefrostControl::Timed;
    5813          24 :                 break;
    5814             :             }
    5815          24 :             if (varSpeedCoil.RatedCapCoolTotal > 0.0) {
    5816         144 :                 StandardRatings::CalcDXCoilStandardRating(state,
    5817          24 :                                                           varSpeedCoil.Name,
    5818          24 :                                                           varSpeedCoil.VarSpeedCoilType,
    5819             :                                                           varSpeedCoil.VSCoilType,
    5820             :                                                           varSpeedCoil.NumOfSpeeds,
    5821             :                                                           varSpeedCoil.MSRatedTotCap,
    5822             :                                                           varSpeedCoil.MSRatedCOP,
    5823             :                                                           varSpeedCoil.MSCCapAirFFlow,
    5824             :                                                           varSpeedCoil.MSCCapFTemp,
    5825             :                                                           varSpeedCoil.MSEIRAirFFlow,
    5826             :                                                           varSpeedCoil.MSEIRFTemp,
    5827          24 :                                                           varSpeedCoil.PLFFPLR,
    5828             :                                                           varSpeedCoil.MSRatedAirVolFlowRate,
    5829             :                                                           varSpeedCoil.MSRatedEvaporatorFanPowerPerVolumeFlowRate2017,
    5830             :                                                           varSpeedCoil.MSRatedEvaporatorFanPowerPerVolumeFlowRate2023,
    5831             :                                                           CondenserType,
    5832          48 :                                                           0, // varSpeedCoil.RegionNum, // ??
    5833          24 :                                                           varSpeedCoil.MinOATCompressor,
    5834          24 :                                                           varSpeedCoil.OATempCompressorOn,
    5835          48 :                                                           false, // varSpeedCoil.OATempCompressorOnOffBlank, // ??
    5836             :                                                           DefrostControl,
    5837          48 :                                                           ObjexxFCL::Optional_bool_const(),
    5838          24 :                                                           varSpeedCoil.RatedCapCoolTotal,
    5839          24 :                                                           varSpeedCoil.RatedAirVolFlowRate);
    5840             :             }
    5841          24 :             break;
    5842          61 :         default:
    5843          61 :             break;
    5844             :         }
    5845          85 :     }
    5846             : 
    5847    37957081 :     void CalcVarSpeedCoilCooling(EnergyPlusData &state,
    5848             :                                  int const DXCoilNum,                             // Heat Pump Number
    5849             :                                  HVAC::FanOp const fanOp,                         // Fan/Compressor cycling scheme indicator
    5850             :                                  [[maybe_unused]] Real64 const SensDemand,        // Cooling Sensible Demand [W] !unused1208
    5851             :                                  [[maybe_unused]] Real64 const LatentDemand,      // Cooling Latent Demand [W]
    5852             :                                  HVAC::CompressorOp const compressorOp,           // compressor operation flag
    5853             :                                  Real64 const PartLoadRatio,                      // compressor part load ratio
    5854             :                                  [[maybe_unused]] Real64 const OnOffAirFlowRatio, // ratio of compressor on flow to average flow over time step
    5855             :                                  Real64 const SpeedRatio, // SpeedRatio varies between 1.0 (higher speed) and 0.0 (lower speed)
    5856             :                                  int const SpeedNum       // Speed number, high bound
    5857             :     )
    5858             :     {
    5859             : 
    5860             :         //       AUTHOR         Bo Shen, based on WaterToAirHeatPumpSimple:CalcHPCoolingSimple
    5861             :         //       DATE WRITTEN   March 2012
    5862             :         //       MODIFIED       na
    5863             :         //       RE-ENGINEERED  na
    5864             : 
    5865             :         // PURPOSE OF THIS SUBROUTINE:
    5866             :         // This subroutine is for simulating the cooling mode of the Variable-Speed Water to Air HP Simple
    5867             : 
    5868             :         // METHODOLOGY EMPLOYED:
    5869             :         // Simulate the heat pump performance using the coefficients and rated conditions, interpolating between speed levels
    5870             :         // If the LatDegradModelSimFlag is enabled, the coil will be simulated twice:
    5871             :         // (1)first simulation at the rated conditions (2) second simulation at the
    5872             :         // actual operating conditions. Then call CalcEffectiveSHR and the effective SHR
    5873             :         // is adjusted.
    5874             :         // If the LatDegradModelSimFlag is disabled, the cooling coil is only simulated
    5875             :         // once at the actual operating conditions.
    5876             :         // Finally, adjust the heat pump outlet conditions based on the PartLoadRatio
    5877             :         // and RuntimeFrac.
    5878             : 
    5879             :         // Using/Aliasing
    5880             :         using Curve::CurveValue;
    5881    37957081 :         Real64 TimeStepSysSec = state.dataHVACGlobal->TimeStepSysSec;
    5882             :         using FluidProperties::GetSpecificHeatGlycol;
    5883             :         using Psychrometrics::PsyCpAirFnW;
    5884             :         using Psychrometrics::PsyHFnTdbW;
    5885             :         using Psychrometrics::PsyRhoAirFnPbTdbW;
    5886             :         using Psychrometrics::PsyTdbFnHW;
    5887             :         using Psychrometrics::PsyTwbFnTdbWPb;
    5888             :         using Psychrometrics::PsyWFnTdbH;
    5889             :         using Psychrometrics::PsyWFnTdbTwbPb;
    5890             : 
    5891             :         // Locals
    5892             :         // SUBROUTINE ARGUMENT DEFINITIONS:
    5893             : 
    5894             :         // SUBROUTINE PARAMETER DEFINITIONS:
    5895             :         static constexpr std::string_view RoutineName("CalcVarSpeedCoilCooling");
    5896             :         static constexpr std::string_view RoutineNameSourceSideInletTemp("CalcVarSpeedCoilCooling:SourceSideInletTemp");
    5897             : 
    5898             :         // INTERFACE BLOCK SPECIFICATIONS
    5899             :         // na
    5900             : 
    5901             :         // DERIVED TYPE DEFINITIONS
    5902             :         // na
    5903             : 
    5904             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    5905             : 
    5906             :         Real64 Twet_Rated;  // Twet at rated conditions (coil air flow rate and air temperatures), sec
    5907             :         Real64 Gamma_Rated; // Gamma at rated conditions (coil air flow rate and air temperatures)
    5908             : 
    5909             :         Real64 SHRss;    // Sensible heat ratio at steady state
    5910             :         Real64 SHReff;   // Effective sensible heat ratio at part-load condition
    5911             :         Real64 CpSource; // Specific heat of water [J/kg_C]
    5912             :         Real64 CpAir;    // Specific heat of air [J/kg_C]
    5913             : 
    5914             :         bool LatDegradModelSimFlag;      // Latent degradation model simulation flag
    5915             :         int NumIteration;                // Iteration Counter
    5916             :         Real64 LoadSideInletDBTemp_Unit; // calc conditions for unit
    5917             :         Real64 LoadSideInletWBTemp_Unit; // calc conditions for unit
    5918             :         Real64 LoadSideInletHumRat_Unit; // calc conditions for unit
    5919             :         Real64 LoadSideInletEnth_Unit;   // calc conditions for unit
    5920             :         Real64 CpAir_Unit;               // calc conditions for unit
    5921             :         Real64 AirMassFlowRatio;         // airflow ratio at low speed
    5922             :         Real64 WaterMassFlowRatio;       // airflow ratio at high speed
    5923             :         Real64 EIRAirFFModFac;           // air flow fraction modification
    5924             :         Real64 EIRWaterFFModFac;         // water flow fraction modification
    5925             :         Real64 EIRTempModFac;            // total capacity temperature correctio fraction
    5926             :         Real64 CBFSpeed;                 // total capacity temperature correctio fraction
    5927             :         Real64 SHR;                      // total capacity temperature correctio fraction
    5928             :         Real64 EIR;                      // total capacity temperature correctio fraction
    5929             :         int MaxSpeed;                    // maximum speed level
    5930             :         int SpeedCal;                    // calculated speed level
    5931             :         Real64 AoEff;                    // effective air side surface area
    5932             :         Real64 QLoadTotal1;              // total capacity at low speed
    5933             :         Real64 QLoadTotal2;              // total capacity at high speed
    5934             :         Real64 Winput1;                  // power consumption at low speed
    5935             :         Real64 Winput2;                  // power consumption at high speed
    5936             :         Real64 QWasteHeat;               // recoverable waste heat
    5937             :         Real64 QWasteHeat1;              // recoverable waste heat at low speed
    5938             :         Real64 QWasteHeat2;              // recoverable waste heat at high speed
    5939             :         Real64 PLF;                      // part-load function
    5940             :         Real64 MaxHumRat;                // max possible humidity
    5941             :         Real64 MaxOutletEnth;            // max possible outlet enthalpy
    5942             : 
    5943             :         // ADDED VARIABLES FOR air source coil
    5944             :         Real64 CondInletTemp; // Condenser inlet temperature (C). Outdoor dry-bulb temp for air-cooled condenser.
    5945             :         // Outdoor Wetbulb +(1 - effectiveness)*(outdoor drybulb - outdoor wetbulb) for evap condenser.
    5946             :         Real64 CondInletHumRat; // Condenser inlet humidity ratio (kg/kg). Zero for air-cooled condenser.
    5947             :         // For evap condenser, its the humidity ratio of the air leaving the evap cooling pads.
    5948             :         Real64 CondAirMassFlow;    // Condenser air mass flow rate [kg/s]
    5949             :         Real64 RhoSourceAir;       // Density of air [kg/m3]
    5950             :         Real64 RhoEvapCondWater;   // Density of water used for evaporative condenser [kg/m3]
    5951             :         Real64 EvapCondEffectSped; // condenser evaporative effectiveness at the speed level
    5952             :         Real64 RhoWater;           // condensed water density
    5953             :         Real64 SpecHumIn;          // inlet air specific humidity
    5954             :         Real64 SpecHumOut;         // outlet air specific humidity
    5955    37957081 :         Real64 rhoair(0);          // entering air density
    5956             : 
    5957    37957081 :         if (state.dataVariableSpeedCoils->firstTime) {
    5958             :             // Set indoor air conditions to the rated condition
    5959          20 :             state.dataVariableSpeedCoils->LoadSideInletDBTemp_Init = 26.7;
    5960          20 :             state.dataVariableSpeedCoils->LoadSideInletHumRat_Init = 0.0111;
    5961          20 :             state.dataVariableSpeedCoils->LoadSideInletEnth_Init =
    5962          20 :                 PsyHFnTdbW(state.dataVariableSpeedCoils->LoadSideInletDBTemp_Init, state.dataVariableSpeedCoils->LoadSideInletHumRat_Init);
    5963          20 :             state.dataVariableSpeedCoils->CpAir_Init = PsyCpAirFnW(state.dataVariableSpeedCoils->LoadSideInletHumRat_Init);
    5964          20 :             state.dataVariableSpeedCoils->firstTime = false;
    5965             :         }
    5966             : 
    5967    37957081 :         state.dataVariableSpeedCoils->LoadSideInletWBTemp_Init = PsyTwbFnTdbWPb(state,
    5968    37957081 :                                                                                 state.dataVariableSpeedCoils->LoadSideInletDBTemp_Init,
    5969    37957081 :                                                                                 state.dataVariableSpeedCoils->LoadSideInletHumRat_Init,
    5970    37957081 :                                                                                 state.dataEnvrn->OutBaroPress,
    5971             :                                                                                 RoutineName);
    5972             : 
    5973    37957081 :         MaxSpeed = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds;
    5974             : 
    5975             :         // must be placed inside the loop, otherwise cause bug in release mode, need to be present at two places
    5976    37957081 :         if (SpeedNum > MaxSpeed) {
    5977           0 :             SpeedCal = MaxSpeed;
    5978             :         } else {
    5979    37957081 :             SpeedCal = SpeedNum;
    5980             :         }
    5981             : 
    5982             :         //  LOAD LOCAL VARIABLES FROM DATA STRUCTURE (for code readability)
    5983    37957081 :         if (!(fanOp == HVAC::FanOp::Continuous) && PartLoadRatio > 0.0) {
    5984      372475 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate =
    5985      372475 :                 state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirInletNodeNum).MassFlowRate / PartLoadRatio;
    5986             :         }
    5987             : 
    5988    37957081 :         Twet_Rated = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Twet_Rated;
    5989    37957081 :         Gamma_Rated = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Gamma_Rated;
    5990             : 
    5991    37957081 :         state.dataVariableSpeedCoils->LoadSideMassFlowRate = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate;
    5992             : 
    5993    37957081 :         if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_CoolingAirToAirVariableSpeed) {
    5994             :             // Get condenser outdoor node info from DX COOLING Coil
    5995    33435270 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum != 0) {
    5996       52990 :                 state.dataVariableSpeedCoils->OutdoorDryBulb_CalcVarSpeedCoilCooling =
    5997       26495 :                     state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum).Temp;
    5998       52990 :                 state.dataVariableSpeedCoils->OutdoorHumRat_CalcVarSpeedCoilCooling =
    5999       26495 :                     state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum).HumRat;
    6000       52990 :                 state.dataVariableSpeedCoils->OutdoorPressure_CalcVarSpeedCoilCooling =
    6001       26495 :                     state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum).Press;
    6002       26495 :                 state.dataVariableSpeedCoils->OutdoorWetBulb_CalcVarSpeedCoilCooling =
    6003       26495 :                     state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum).OutAirWetBulb;
    6004             :             } else {
    6005    33408775 :                 state.dataVariableSpeedCoils->OutdoorDryBulb_CalcVarSpeedCoilCooling = state.dataEnvrn->OutDryBulbTemp;
    6006    33408775 :                 state.dataVariableSpeedCoils->OutdoorHumRat_CalcVarSpeedCoilCooling = state.dataEnvrn->OutHumRat;
    6007    33408775 :                 state.dataVariableSpeedCoils->OutdoorPressure_CalcVarSpeedCoilCooling = state.dataEnvrn->OutBaroPress;
    6008    33408775 :                 state.dataVariableSpeedCoils->OutdoorWetBulb_CalcVarSpeedCoilCooling = state.dataEnvrn->OutWetBulbTemp;
    6009             :             }
    6010             : 
    6011    66870540 :             RhoSourceAir = PsyRhoAirFnPbTdbW(state,
    6012    33435270 :                                              state.dataVariableSpeedCoils->OutdoorPressure_CalcVarSpeedCoilCooling,
    6013    33435270 :                                              state.dataVariableSpeedCoils->OutdoorDryBulb_CalcVarSpeedCoilCooling,
    6014    33435270 :                                              state.dataVariableSpeedCoils->OutdoorHumRat_CalcVarSpeedCoilCooling);
    6015             : 
    6016    33435270 :             if ((SpeedNum == 1) || (SpeedNum > MaxSpeed) || (SpeedRatio == 1.0)) {
    6017    26720281 :                 CondAirMassFlow = RhoSourceAir * state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondAirFlow(SpeedCal);
    6018             :             } else {
    6019     6714989 :                 CondAirMassFlow =
    6020     6714989 :                     RhoSourceAir * (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondAirFlow(SpeedCal) * SpeedRatio +
    6021     6714989 :                                     (1.0 - SpeedRatio) * state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondAirFlow(SpeedCal - 1));
    6022             :             }
    6023             : 
    6024             :             // AIR COOL OR EVAP COOLED CONDENSER
    6025    33435270 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
    6026           0 :                 if ((SpeedNum == 1) || (SpeedNum > MaxSpeed) || (SpeedRatio == 1.0)) {
    6027           0 :                     EvapCondEffectSped = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondEffect(SpeedCal);
    6028             :                 } else {
    6029           0 :                     EvapCondEffectSped = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondEffect(SpeedCal) * SpeedRatio +
    6030           0 :                                          (1.0 - SpeedRatio) * state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondEffect(SpeedCal - 1);
    6031             :                 }
    6032             :                 // (Outdoor wet-bulb temp from DataEnvironment) + (1.0-EvapCondEffectiveness) * (drybulb - wetbulb)
    6033           0 :                 CondInletTemp = state.dataVariableSpeedCoils->OutdoorWetBulb_CalcVarSpeedCoilCooling +
    6034           0 :                                 (state.dataVariableSpeedCoils->OutdoorDryBulb_CalcVarSpeedCoilCooling -
    6035           0 :                                  state.dataVariableSpeedCoils->OutdoorWetBulb_CalcVarSpeedCoilCooling) *
    6036           0 :                                     (1.0 - EvapCondEffectSped);
    6037           0 :                 CondInletHumRat = PsyWFnTdbTwbPb(state,
    6038             :                                                  CondInletTemp,
    6039           0 :                                                  state.dataVariableSpeedCoils->OutdoorWetBulb_CalcVarSpeedCoilCooling,
    6040           0 :                                                  state.dataVariableSpeedCoils->OutdoorPressure_CalcVarSpeedCoilCooling);
    6041           0 :                 state.dataVariableSpeedCoils->CompAmbTemp_CalcVarSpeedCoilCooling = CondInletTemp;
    6042             :             } else {                                                                                  // AIR COOLED CONDENSER
    6043    33435270 :                 CondInletTemp = state.dataVariableSpeedCoils->OutdoorDryBulb_CalcVarSpeedCoilCooling; // Outdoor dry-bulb temp
    6044    66870540 :                 state.dataVariableSpeedCoils->CompAmbTemp_CalcVarSpeedCoilCooling =
    6045    33435270 :                     state.dataVariableSpeedCoils->OutdoorDryBulb_CalcVarSpeedCoilCooling;
    6046    33435270 :                 CondInletHumRat = state.dataEnvrn->OutHumRat;
    6047             :             }
    6048             : 
    6049    33435270 :             state.dataVariableSpeedCoils->SourceSideMassFlowRate = CondAirMassFlow;
    6050    33435270 :             state.dataVariableSpeedCoils->SourceSideInletTemp = CondInletTemp;
    6051    33435270 :             state.dataVariableSpeedCoils->SourceSideInletEnth = PsyHFnTdbW(CondInletTemp, CondInletHumRat);
    6052    33435270 :             CpSource = PsyCpAirFnW(CondInletHumRat);
    6053    33435270 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondInletTemp = CondInletTemp;
    6054             : 
    6055             :             // If used in a heat pump, the value of MaxOAT in the heating coil overrides that in the cooling coil (in GetInput)
    6056             :             // Initialize crankcase heater, operates below OAT defined in input deck for HP DX heating coil
    6057    33435270 :             if (state.dataVariableSpeedCoils->OutdoorDryBulb_CalcVarSpeedCoilCooling <
    6058    33435270 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MaxOATCrankcaseHeater) {
    6059     2750480 :                 state.dataVariableSpeedCoils->CrankcaseHeatingPower_CalcVarSpeedCoilCooling =
    6060     1375240 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterCapacity;
    6061     1375240 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterCapacityCurveIndex > 0) {
    6062      125599 :                     state.dataVariableSpeedCoils->CrankcaseHeatingPower_CalcVarSpeedCoilCooling *=
    6063      125599 :                         Curve::CurveValue(state,
    6064      125599 :                                           state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterCapacityCurveIndex,
    6065      125599 :                                           state.dataEnvrn->OutDryBulbTemp);
    6066             :                 }
    6067             :             } else {
    6068    32060030 :                 state.dataVariableSpeedCoils->CrankcaseHeatingPower_CalcVarSpeedCoilCooling = 0.0;
    6069             :             }
    6070             :         } else {
    6071     4521811 :             state.dataVariableSpeedCoils->SourceSideMassFlowRate = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterMassFlowRate;
    6072     4521811 :             state.dataVariableSpeedCoils->SourceSideInletTemp = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterTemp;
    6073     4521811 :             state.dataVariableSpeedCoils->SourceSideInletEnth = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterEnthalpy;
    6074             :             CpSource =
    6075     4521811 :                 GetSpecificHeatGlycol(state,
    6076     4521811 :                                       state.dataPlnt->PlantLoop(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).plantLoc.loopNum).FluidName,
    6077     4521811 :                                       state.dataVariableSpeedCoils->SourceSideInletTemp,
    6078     4521811 :                                       state.dataPlnt->PlantLoop(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).plantLoc.loopNum).FluidIndex,
    6079             :                                       RoutineNameSourceSideInletTemp);
    6080             :         }
    6081             : 
    6082             :         // Check for flows, do not perform simulation if no flow in load side or source side.
    6083    37957081 :         if (state.dataVariableSpeedCoils->SourceSideMassFlowRate <= 0.0 || state.dataVariableSpeedCoils->LoadSideMassFlowRate <= 0.0) {
    6084             : 
    6085     9532936 :             if ((state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_CoolingAirToAirVariableSpeed) &&
    6086    16659810 :                 (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserType == DataHeatBalance::RefrigCondenserType::Air) &&
    6087     7126874 :                 (state.dataVariableSpeedCoils->LoadSideMassFlowRate > 0.0)) {
    6088             :                 // ALLOW SIMULATION IF AIR-COOLED CONDENSER COIL
    6089      308249 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SimFlag = true;
    6090             :             } else {
    6091     9224687 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SimFlag = false;
    6092     9283552 :                 return;
    6093             :             }
    6094             :         } else {
    6095    28424145 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SimFlag = true;
    6096             :         }
    6097             : 
    6098    28732394 :         if (compressorOp == HVAC::CompressorOp::Off || state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedCapCoolTotal <= 0.0) {
    6099       58865 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SimFlag = false;
    6100       58865 :             return;
    6101             :         }
    6102             : 
    6103    55232843 :         if ((state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_CoolingAirToAirVariableSpeed) &&
    6104    26559314 :             (CondInletTemp < state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MinOATCompressor)) {
    6105           0 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SimFlag = false;
    6106           0 :             return;
    6107             :         }
    6108             : 
    6109             :         // Loop the calculation at least once depending whether the latent degradation model
    6110             :         // is enabled. 1st iteration to calculate the QLatent(rated) at (TDB,TWB)indoorair=(26.7C,19.4C)
    6111             :         // and 2nd iteration to calculate the  QLatent(actual)
    6112    28673529 :         if ((PartLoadRatio < 1e-10) || (Twet_Rated <= 0.0) || (Gamma_Rated <= 0.0) || (SpeedNum > 1.0)) {
    6113    28656447 :             LatDegradModelSimFlag = false;
    6114             :             // Set NumIteration=1 so that latent model would quit after 1 simulation with the actual condition
    6115    28656447 :             NumIteration = 1;
    6116             :         } else {
    6117       17082 :             LatDegradModelSimFlag = true;
    6118             :             // Set NumIteration=0 so that latent model would simulate twice with rated and actual condition
    6119       17082 :             NumIteration = 0;
    6120             :         }
    6121             : 
    6122             :         // Set indoor air conditions to the actual condition
    6123    28673529 :         LoadSideInletDBTemp_Unit = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirDBTemp;
    6124    28673529 :         LoadSideInletHumRat_Unit = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirHumRat;
    6125             :         LoadSideInletWBTemp_Unit =
    6126    28673529 :             PsyTwbFnTdbWPb(state, LoadSideInletDBTemp_Unit, LoadSideInletHumRat_Unit, state.dataEnvrn->OutBaroPress, RoutineName);
    6127    28673529 :         LoadSideInletEnth_Unit = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirEnthalpy;
    6128    28673529 :         CpAir_Unit = PsyCpAirFnW(LoadSideInletHumRat_Unit);
    6129             : 
    6130    28673529 :         state.dataHVACGlobal->OnOffFanPartLoadFraction = 1.0;
    6131    28673529 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac = 1.0;
    6132    28673529 :         if ((SpeedNum == 1) && (PartLoadRatio < 1.0)) {
    6133     4074674 :             PLF = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PLFFPLR, PartLoadRatio);
    6134     4074674 :             if (PLF < 0.7) {
    6135           0 :                 PLF = 0.7;
    6136             :             }
    6137     4074674 :             if (fanOp == HVAC::FanOp::Cycling)
    6138       59408 :                 state.dataHVACGlobal->OnOffFanPartLoadFraction =
    6139             :                     PLF; // save PLF for fan model, don't change fan power for constant fan mode if coil is off
    6140             :             // calculate the run time fraction
    6141     4074674 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac = PartLoadRatio / PLF;
    6142     4074674 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PartLoadRatio = PartLoadRatio;
    6143             : 
    6144     4074674 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac > 1.0) {
    6145           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac = 1.0; // Reset coil runtime fraction to 1.0
    6146     4074674 :             } else if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac < 0.0) {
    6147           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac = 0.0;
    6148             :             }
    6149             :         }
    6150             : 
    6151             :         while (true) {
    6152    28690611 :             ++NumIteration;
    6153    28690611 :             if (NumIteration == 1) {
    6154             :                 // Set indoor air conditions to the rated conditions
    6155       17082 :                 state.dataVariableSpeedCoils->LoadSideInletDBTemp = state.dataVariableSpeedCoils->LoadSideInletDBTemp_Init;
    6156       17082 :                 state.dataVariableSpeedCoils->LoadSideInletHumRat = state.dataVariableSpeedCoils->LoadSideInletHumRat_Init;
    6157       17082 :                 state.dataVariableSpeedCoils->LoadSideInletWBTemp = state.dataVariableSpeedCoils->LoadSideInletWBTemp_Init;
    6158       17082 :                 state.dataVariableSpeedCoils->LoadSideInletEnth = state.dataVariableSpeedCoils->LoadSideInletEnth_Init;
    6159       17082 :                 CpAir = state.dataVariableSpeedCoils->CpAir_Init;
    6160             :             } else {
    6161             :                 // Set indoor air conditions to the actual condition
    6162    28673529 :                 state.dataVariableSpeedCoils->LoadSideInletDBTemp = LoadSideInletDBTemp_Unit;
    6163    28673529 :                 state.dataVariableSpeedCoils->LoadSideInletHumRat = LoadSideInletHumRat_Unit;
    6164    28673529 :                 state.dataVariableSpeedCoils->LoadSideInletWBTemp = LoadSideInletWBTemp_Unit;
    6165    28673529 :                 state.dataVariableSpeedCoils->LoadSideInletEnth = LoadSideInletEnth_Unit;
    6166    28673529 :                 CpAir = CpAir_Unit;
    6167             :             }
    6168             : 
    6169             :             // must be placed inside the loop, otherwise cause bug in release mode
    6170    28690611 :             if (SpeedNum > MaxSpeed) {
    6171           0 :                 SpeedCal = MaxSpeed;
    6172             :             } else {
    6173    28690611 :                 SpeedCal = SpeedNum;
    6174             :             }
    6175             : 
    6176    28690611 :             if ((SpeedNum == 1) || (SpeedNum > MaxSpeed) || (SpeedRatio == 1.0)) {
    6177    21633676 :                 AirMassFlowRatio =
    6178    21633676 :                     state.dataVariableSpeedCoils->LoadSideMassFlowRate / state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignAirMassFlowRate;
    6179             : 
    6180    21633676 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_CoolingAirToAirVariableSpeed) {
    6181    19861419 :                     WaterMassFlowRatio = 1.0;
    6182             :                 } else {
    6183     1772257 :                     WaterMassFlowRatio = state.dataVariableSpeedCoils->SourceSideMassFlowRate /
    6184     1772257 :                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignWaterMassFlowRate;
    6185             :                 }
    6186             : 
    6187    21633676 :                 CBFSpeed = AdjustCBF(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedCBF(SpeedCal),
    6188    21633676 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirMassFlowRate(SpeedCal),
    6189    21633676 :                                      state.dataVariableSpeedCoils->LoadSideMassFlowRate);
    6190             : 
    6191    21633676 :                 if (CBFSpeed > 0.999) CBFSpeed = 0.999;
    6192             : 
    6193    21633676 :                 CalcTotCapSHR_VSWSHP(state,
    6194    21633676 :                                      state.dataVariableSpeedCoils->LoadSideInletDBTemp,
    6195    21633676 :                                      state.dataVariableSpeedCoils->LoadSideInletHumRat,
    6196    21633676 :                                      state.dataVariableSpeedCoils->LoadSideInletEnth,
    6197    21633676 :                                      state.dataVariableSpeedCoils->LoadSideInletWBTemp,
    6198             :                                      AirMassFlowRatio,
    6199             :                                      WaterMassFlowRatio,
    6200    21633676 :                                      state.dataVariableSpeedCoils->LoadSideMassFlowRate,
    6201             :                                      CBFSpeed,
    6202    21633676 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(SpeedCal),
    6203    21633676 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(SpeedCal),
    6204    21633676 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(SpeedCal),
    6205    21633676 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(SpeedCal),
    6206             :                                      0.0,
    6207             :                                      0,
    6208             :                                      0,
    6209             :                                      0,
    6210             :                                      QLoadTotal1,
    6211             :                                      QLoadTotal2,
    6212    21633676 :                                      state.dataVariableSpeedCoils->QLoadTotal,
    6213             :                                      SHR,
    6214    21633676 :                                      state.dataVariableSpeedCoils->SourceSideInletTemp,
    6215    21633676 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirPressure,
    6216             :                                      0.0,
    6217             :                                      1,
    6218    21633676 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).capModFacTotal);
    6219             : 
    6220    86534704 :                 EIRTempModFac = CurveValue(state,
    6221    21633676 :                                            state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(SpeedCal),
    6222    21633676 :                                            state.dataVariableSpeedCoils->LoadSideInletWBTemp,
    6223    21633676 :                                            state.dataVariableSpeedCoils->SourceSideInletTemp);
    6224    21633676 :                 EIRAirFFModFac = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(SpeedCal), AirMassFlowRatio);
    6225             : 
    6226    21633676 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_CoolingAirToAirVariableSpeed) {
    6227    19861419 :                     EIRWaterFFModFac = 1.0;
    6228             :                 } else {
    6229             :                     EIRWaterFFModFac =
    6230     1772257 :                         CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRWaterFFlow(SpeedCal), WaterMassFlowRatio);
    6231             :                 }
    6232             : 
    6233    21633676 :                 EIR = (1.0 / state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedCOP(SpeedCal)) * EIRTempModFac * EIRAirFFModFac *
    6234             :                       EIRWaterFFModFac;
    6235             : 
    6236    21633676 :                 CBFSpeed = AdjustCBF(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedCBF(SpeedCal),
    6237    21633676 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirMassFlowRate(SpeedCal),
    6238    21633676 :                                      state.dataVariableSpeedCoils->LoadSideMassFlowRate);
    6239             : 
    6240    21633676 :                 if (CBFSpeed > 0.999) CBFSpeed = 0.999;
    6241             : 
    6242    21633676 :                 CalcTotCapSHR_VSWSHP(state,
    6243    21633676 :                                      state.dataVariableSpeedCoils->LoadSideInletDBTemp,
    6244    21633676 :                                      state.dataVariableSpeedCoils->LoadSideInletHumRat,
    6245    21633676 :                                      state.dataVariableSpeedCoils->LoadSideInletEnth,
    6246    21633676 :                                      state.dataVariableSpeedCoils->LoadSideInletWBTemp,
    6247             :                                      AirMassFlowRatio,
    6248             :                                      WaterMassFlowRatio,
    6249    21633676 :                                      state.dataVariableSpeedCoils->LoadSideMassFlowRate,
    6250             :                                      CBFSpeed,
    6251    21633676 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(SpeedCal),
    6252    21633676 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(SpeedCal),
    6253    21633676 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(SpeedCal),
    6254    21633676 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(SpeedCal),
    6255             :                                      0.0,
    6256             :                                      0,
    6257             :                                      0,
    6258             :                                      0,
    6259             :                                      QLoadTotal1,
    6260             :                                      QLoadTotal2,
    6261    21633676 :                                      state.dataVariableSpeedCoils->QLoadTotal,
    6262             :                                      SHR,
    6263    21633676 :                                      state.dataVariableSpeedCoils->SourceSideInletTemp,
    6264    21633676 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirPressure,
    6265             :                                      0.0,
    6266             :                                      1,
    6267    21633676 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).capModFacTotal);
    6268             : 
    6269    21633676 :                 state.dataVariableSpeedCoils->Winput = state.dataVariableSpeedCoils->QLoadTotal * EIR;
    6270             : 
    6271    21633676 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_CoolingAirToAirVariableSpeed) {
    6272    19861419 :                     QWasteHeat = 0.0;
    6273             :                 } else {
    6274     1772257 :                     QWasteHeat =
    6275     1772257 :                         state.dataVariableSpeedCoils->Winput * state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeatFrac(SpeedCal);
    6276     1772257 :                     QWasteHeat *= CurveValue(state,
    6277     1772257 :                                              state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeat(SpeedCal),
    6278     1772257 :                                              state.dataVariableSpeedCoils->LoadSideInletWBTemp,
    6279     1772257 :                                              state.dataVariableSpeedCoils->SourceSideInletTemp);
    6280             :                 }
    6281             :             } else {
    6282     7056935 :                 AirMassFlowRatio =
    6283     7056935 :                     state.dataVariableSpeedCoils->LoadSideMassFlowRate / state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignAirMassFlowRate;
    6284             : 
    6285     7056935 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_CoolingAirToAirVariableSpeed) {
    6286     6714977 :                     WaterMassFlowRatio = 1.0;
    6287             :                 } else {
    6288      341958 :                     WaterMassFlowRatio = state.dataVariableSpeedCoils->SourceSideMassFlowRate /
    6289      341958 :                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignWaterMassFlowRate;
    6290             :                 }
    6291             : 
    6292     7056935 :                 AoEff = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEffectiveAo(SpeedCal) * SpeedRatio +
    6293     7056935 :                         (1.0 - SpeedRatio) * state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEffectiveAo(SpeedCal - 1);
    6294             : 
    6295     7056935 :                 CBFSpeed = std::exp(-AoEff / state.dataVariableSpeedCoils->LoadSideMassFlowRate);
    6296             : 
    6297     7056935 :                 if (CBFSpeed > 0.999) CBFSpeed = 0.999;
    6298             : 
    6299     7056935 :                 CalcTotCapSHR_VSWSHP(state,
    6300     7056935 :                                      state.dataVariableSpeedCoils->LoadSideInletDBTemp,
    6301     7056935 :                                      state.dataVariableSpeedCoils->LoadSideInletHumRat,
    6302     7056935 :                                      state.dataVariableSpeedCoils->LoadSideInletEnth,
    6303     7056935 :                                      state.dataVariableSpeedCoils->LoadSideInletWBTemp,
    6304             :                                      AirMassFlowRatio,
    6305             :                                      WaterMassFlowRatio,
    6306     7056935 :                                      state.dataVariableSpeedCoils->LoadSideMassFlowRate,
    6307             :                                      CBFSpeed,
    6308     7056935 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(SpeedCal - 1),
    6309     7056935 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(SpeedCal - 1),
    6310     7056935 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(SpeedCal - 1),
    6311     7056935 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(SpeedCal - 1),
    6312     7056935 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(SpeedCal),
    6313     7056935 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(SpeedCal),
    6314     7056935 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(SpeedCal),
    6315     7056935 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(SpeedCal),
    6316             :                                      QLoadTotal1,
    6317             :                                      QLoadTotal2,
    6318     7056935 :                                      state.dataVariableSpeedCoils->QLoadTotal,
    6319             :                                      SHR,
    6320     7056935 :                                      state.dataVariableSpeedCoils->SourceSideInletTemp,
    6321     7056935 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirPressure,
    6322             :                                      SpeedRatio,
    6323             :                                      2,
    6324     7056935 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).capModFacTotal);
    6325             : 
    6326     7056935 :                 SpeedCal = SpeedNum - 1;
    6327    28227740 :                 EIRTempModFac = CurveValue(state,
    6328     7056935 :                                            state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(SpeedCal),
    6329     7056935 :                                            state.dataVariableSpeedCoils->LoadSideInletWBTemp,
    6330     7056935 :                                            state.dataVariableSpeedCoils->SourceSideInletTemp);
    6331     7056935 :                 EIRAirFFModFac = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(SpeedCal), AirMassFlowRatio);
    6332             : 
    6333     7056935 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_CoolingAirToAirVariableSpeed) {
    6334     6714977 :                     EIRWaterFFModFac = 1.0;
    6335             :                 } else {
    6336             :                     EIRWaterFFModFac =
    6337      341958 :                         CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRWaterFFlow(SpeedCal), WaterMassFlowRatio);
    6338             :                 }
    6339             : 
    6340     7056935 :                 EIR = (1.0 / state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedCOP(SpeedCal)) * EIRTempModFac * EIRAirFFModFac *
    6341             :                       EIRWaterFFModFac;
    6342     7056935 :                 Winput1 = QLoadTotal1 * EIR;
    6343             : 
    6344     7056935 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_CoolingAirToAirVariableSpeed) {
    6345     6714977 :                     QWasteHeat1 = 0.0;
    6346             :                 } else {
    6347      341958 :                     QWasteHeat1 = Winput1 * state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeatFrac(SpeedCal);
    6348      341958 :                     QWasteHeat1 *= CurveValue(state,
    6349      341958 :                                               state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeat(SpeedCal),
    6350      341958 :                                               state.dataVariableSpeedCoils->LoadSideInletWBTemp,
    6351      341958 :                                               state.dataVariableSpeedCoils->SourceSideInletTemp);
    6352             :                 }
    6353             : 
    6354     7056935 :                 SpeedCal = SpeedNum;
    6355    28227740 :                 EIRTempModFac = CurveValue(state,
    6356     7056935 :                                            state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(SpeedCal),
    6357     7056935 :                                            state.dataVariableSpeedCoils->LoadSideInletWBTemp,
    6358     7056935 :                                            state.dataVariableSpeedCoils->SourceSideInletTemp);
    6359     7056935 :                 EIRAirFFModFac = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(SpeedCal), AirMassFlowRatio);
    6360             : 
    6361     7056935 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_CoolingAirToAirVariableSpeed) {
    6362     6714977 :                     EIRWaterFFModFac = 1.0;
    6363             :                 } else {
    6364             :                     EIRWaterFFModFac =
    6365      341958 :                         CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRWaterFFlow(SpeedCal), WaterMassFlowRatio);
    6366             :                 }
    6367             : 
    6368     7056935 :                 EIR = (1.0 / state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedCOP(SpeedCal)) * EIRTempModFac * EIRAirFFModFac *
    6369             :                       EIRWaterFFModFac;
    6370     7056935 :                 Winput2 = QLoadTotal2 * EIR;
    6371             : 
    6372     7056935 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_CoolingAirToAirVariableSpeed) {
    6373     6714977 :                     QWasteHeat2 = 0.0;
    6374             :                 } else {
    6375      341958 :                     QWasteHeat2 = Winput2 * state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeatFrac(SpeedCal);
    6376      341958 :                     QWasteHeat2 *= CurveValue(state,
    6377      341958 :                                               state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeat(SpeedCal),
    6378      341958 :                                               state.dataVariableSpeedCoils->LoadSideInletWBTemp,
    6379      341958 :                                               state.dataVariableSpeedCoils->SourceSideInletTemp);
    6380             :                 }
    6381             : 
    6382     7056935 :                 state.dataVariableSpeedCoils->Winput = Winput2 * SpeedRatio + (1.0 - SpeedRatio) * Winput1;
    6383     7056935 :                 QWasteHeat = QWasteHeat2 * SpeedRatio + (1.0 - SpeedRatio) * QWasteHeat1;
    6384             :             }
    6385             : 
    6386    28690611 :             state.dataVariableSpeedCoils->QSensible = state.dataVariableSpeedCoils->QLoadTotal * SHR;
    6387             : 
    6388    28690611 :             state.dataVariableSpeedCoils->QSource = state.dataVariableSpeedCoils->QLoadTotal + state.dataVariableSpeedCoils->Winput - QWasteHeat;
    6389             : 
    6390    28690611 :             if (state.dataVariableSpeedCoils->QSource < 0) {
    6391           0 :                 state.dataVariableSpeedCoils->QSource = 0.0;
    6392           0 :                 QWasteHeat = state.dataVariableSpeedCoils->QLoadTotal + state.dataVariableSpeedCoils->Winput;
    6393             :             }
    6394             : 
    6395             :             // Check if the Sensible Load is greater than the Total Cooling Load
    6396    28690611 :             if (state.dataVariableSpeedCoils->QSensible > state.dataVariableSpeedCoils->QLoadTotal) {
    6397           0 :                 state.dataVariableSpeedCoils->QSensible = state.dataVariableSpeedCoils->QLoadTotal;
    6398             :             }
    6399             : 
    6400    28690611 :             if (LatDegradModelSimFlag) {
    6401             :                 // Calculate for SHReff using the Latent Degradation Model
    6402       34164 :                 if (NumIteration == 1) {
    6403       17082 :                     state.dataVariableSpeedCoils->QLatRated = state.dataVariableSpeedCoils->QLoadTotal - state.dataVariableSpeedCoils->QSensible;
    6404       17082 :                 } else if (NumIteration == 2) {
    6405       17082 :                     state.dataVariableSpeedCoils->QLatActual = state.dataVariableSpeedCoils->QLoadTotal - state.dataVariableSpeedCoils->QSensible;
    6406       17082 :                     SHRss = state.dataVariableSpeedCoils->QSensible / state.dataVariableSpeedCoils->QLoadTotal;
    6407      102492 :                     SHReff = CalcEffectiveSHR(state,
    6408             :                                               DXCoilNum,
    6409             :                                               SHRss,
    6410             :                                               fanOp,
    6411       17082 :                                               state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac,
    6412       17082 :                                               state.dataVariableSpeedCoils->QLatRated,
    6413       17082 :                                               state.dataVariableSpeedCoils->QLatActual,
    6414       17082 :                                               state.dataVariableSpeedCoils->LoadSideInletDBTemp,
    6415       17082 :                                               state.dataVariableSpeedCoils->LoadSideInletWBTemp);
    6416             :                     //       Update sensible capacity based on effective SHR
    6417       17082 :                     state.dataVariableSpeedCoils->QSensible = state.dataVariableSpeedCoils->QLoadTotal * SHReff;
    6418       17082 :                     goto LOOP_exit;
    6419             :                 }
    6420             :             } else {
    6421             :                 // Assume SHReff=SHRss
    6422    28656447 :                 SHReff = state.dataVariableSpeedCoils->QSensible / state.dataVariableSpeedCoils->QLoadTotal;
    6423    28656447 :                 goto LOOP_exit;
    6424             :             }
    6425             :         }
    6426    28673529 :     LOOP_exit:;
    6427             : 
    6428             :         // considering hot gas reheat here
    6429    28673529 :         if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HOTGASREHEATFLG > 0) {
    6430     1619941 :             state.dataVariableSpeedCoils->QLoadTotal -= QWasteHeat;
    6431     1619941 :             state.dataVariableSpeedCoils->QSensible -= QWasteHeat;
    6432     1619941 :             SHReff = state.dataVariableSpeedCoils->QSensible / state.dataVariableSpeedCoils->QLoadTotal;
    6433             :         }
    6434             : 
    6435    28673529 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterPower = 0.0;
    6436    28673529 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterPower = 0.0;
    6437             : 
    6438    28673529 :         if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_CoolingAirToAirVariableSpeed) {
    6439    26559314 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
    6440             :                 //******************
    6441             :                 //             WATER CONSUMPTION IN m3 OF WATER FOR DIRECT
    6442             :                 //             H2O [m3/s] = Delta W[kgWater/kgDryAir]*Mass Flow Air[kgDryAir/s]
    6443             :                 //                                /RhoWater [kgWater/m3]
    6444             :                 //******************
    6445           0 :                 RhoEvapCondWater = RhoH2O(state.dataVariableSpeedCoils->OutdoorDryBulb_CalcVarSpeedCoilCooling);
    6446           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapWaterConsumpRate =
    6447           0 :                     (CondInletHumRat - state.dataVariableSpeedCoils->OutdoorHumRat_CalcVarSpeedCoilCooling) * CondAirMassFlow / RhoEvapCondWater *
    6448           0 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac;
    6449           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondPumpElecPower =
    6450           0 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondPumpElecNomPower *
    6451           0 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac;
    6452             :                 // Calculate basin heater power
    6453           0 :                 CalcBasinHeaterPower(state,
    6454           0 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterPowerFTempDiff,
    6455           0 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterSchedulePtr,
    6456           0 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterSetPointTemp,
    6457           0 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterPower);
    6458           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterPower *=
    6459           0 :                     (1.0 - state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac);
    6460             :             }
    6461             : 
    6462    26559314 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterPower =
    6463    26559314 :                 state.dataVariableSpeedCoils->CrankcaseHeatingPower_CalcVarSpeedCoilCooling *
    6464    26559314 :                 (1.0 - state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac);
    6465             : 
    6466             :             // set water system demand request (if needed)
    6467    26559314 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapWaterSupplyMode == WaterSupplyFromTank) {
    6468           0 :                 state.dataWaterData->WaterStorage(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapWaterSupTankID)
    6469           0 :                     .VdotRequestDemand(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapWaterTankDemandARRID) =
    6470           0 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapWaterConsumpRate;
    6471             :             }
    6472             :         }
    6473             : 
    6474    28673529 :         if ((PartLoadRatio > 0.0 && fanOp == HVAC::FanOp::Continuous) || (fanOp == HVAC::FanOp::Cycling)) {
    6475             :             // calculate coil outlet state variables
    6476    55903534 :             state.dataVariableSpeedCoils->LoadSideOutletEnth =
    6477    27951767 :                 state.dataVariableSpeedCoils->LoadSideInletEnth -
    6478    27951767 :                 state.dataVariableSpeedCoils->QLoadTotal / state.dataVariableSpeedCoils->LoadSideMassFlowRate;
    6479    55903534 :             state.dataVariableSpeedCoils->LoadSideOutletDBTemp =
    6480    27951767 :                 state.dataVariableSpeedCoils->LoadSideInletDBTemp -
    6481    27951767 :                 state.dataVariableSpeedCoils->QSensible / (state.dataVariableSpeedCoils->LoadSideMassFlowRate * CpAir);
    6482             : 
    6483    27951767 :             MaxHumRat = PsyWFnTdbRhPb(state,
    6484    27951767 :                                       state.dataVariableSpeedCoils->LoadSideOutletDBTemp,
    6485             :                                       0.9999,
    6486    27951767 :                                       state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirPressure,
    6487             :                                       RoutineName);
    6488    27951767 :             MaxOutletEnth = PsyHFnTdbW(state.dataVariableSpeedCoils->LoadSideOutletDBTemp, MaxHumRat);
    6489    27951767 :             if (state.dataVariableSpeedCoils->LoadSideOutletEnth > MaxOutletEnth) {
    6490      153073 :                 state.dataVariableSpeedCoils->LoadSideOutletEnth = MaxOutletEnth;
    6491             :                 // QLoadTotal = LoadSideMassFlowRate * (LoadSideInletEnth - LoadSideOutletEnth)
    6492             :             }
    6493    55903534 :             state.dataVariableSpeedCoils->LoadSideOutletHumRat =
    6494    27951767 :                 PsyWFnTdbH(state, state.dataVariableSpeedCoils->LoadSideOutletDBTemp, state.dataVariableSpeedCoils->LoadSideOutletEnth, RoutineName);
    6495    27951767 :             if (state.dataVariableSpeedCoils->LoadSideOutletHumRat > MaxHumRat) {
    6496       16933 :                 state.dataVariableSpeedCoils->LoadSideOutletHumRat = MaxHumRat;
    6497             :             }
    6498             :         }
    6499             : 
    6500             :         // Actual outlet conditions are "average" for time step
    6501    28673529 :         if (fanOp == HVAC::FanOp::Continuous) {
    6502             :             // continuous fan, cycling compressor
    6503    28301060 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirEnthalpy =
    6504    28301060 :                 PartLoadRatio * state.dataVariableSpeedCoils->LoadSideOutletEnth +
    6505    28301060 :                 (1.0 - PartLoadRatio) * state.dataVariableSpeedCoils->LoadSideInletEnth;
    6506    28301060 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirHumRat =
    6507    28301060 :                 PartLoadRatio * state.dataVariableSpeedCoils->LoadSideOutletHumRat +
    6508    28301060 :                 (1.0 - PartLoadRatio) * state.dataVariableSpeedCoils->LoadSideInletHumRat;
    6509    28301060 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirDBTemp =
    6510    28301060 :                 PsyTdbFnHW(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirEnthalpy,
    6511    28301060 :                            state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirHumRat);
    6512    28301060 :             state.dataVariableSpeedCoils->PLRCorrLoadSideMdot = state.dataVariableSpeedCoils->LoadSideMassFlowRate;
    6513             :         } else {
    6514             :             // default to cycling fan, cycling compressor
    6515      372469 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirEnthalpy = state.dataVariableSpeedCoils->LoadSideOutletEnth;
    6516      372469 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirHumRat = state.dataVariableSpeedCoils->LoadSideOutletHumRat;
    6517      372469 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirDBTemp = state.dataVariableSpeedCoils->LoadSideOutletDBTemp;
    6518      372469 :             state.dataVariableSpeedCoils->PLRCorrLoadSideMdot = state.dataVariableSpeedCoils->LoadSideMassFlowRate * PartLoadRatio;
    6519             :         }
    6520             : 
    6521             :         // scale heat transfer rates to PLR and power to RTF
    6522    28673529 :         state.dataVariableSpeedCoils->QLoadTotal *= PartLoadRatio;
    6523    28673529 :         state.dataVariableSpeedCoils->QSensible *= PartLoadRatio;
    6524             :         // count the powr separately
    6525    28673529 :         state.dataVariableSpeedCoils->Winput *= state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac;
    6526    28673529 :         state.dataVariableSpeedCoils->QSource *= PartLoadRatio;
    6527    28673529 :         QWasteHeat *= PartLoadRatio;
    6528             : 
    6529             :         // Update heat pump data structure
    6530    28673529 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Power = state.dataVariableSpeedCoils->Winput;
    6531    28673529 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLoadTotal = state.dataVariableSpeedCoils->QLoadTotal;
    6532    28673529 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSensible = state.dataVariableSpeedCoils->QSensible;
    6533    28673529 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLatent =
    6534    28673529 :             state.dataVariableSpeedCoils->QLoadTotal - state.dataVariableSpeedCoils->QSensible;
    6535    28673529 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSource = state.dataVariableSpeedCoils->QSource;
    6536    28673529 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Energy = state.dataVariableSpeedCoils->Winput * TimeStepSysSec;
    6537    28673529 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLoadTotal = state.dataVariableSpeedCoils->QLoadTotal * TimeStepSysSec;
    6538    28673529 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergySensible = state.dataVariableSpeedCoils->QSensible * TimeStepSysSec;
    6539    28673529 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLatent =
    6540    28673529 :             (state.dataVariableSpeedCoils->QLoadTotal - state.dataVariableSpeedCoils->QSensible) * TimeStepSysSec;
    6541    28673529 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergySource = state.dataVariableSpeedCoils->QSource * TimeStepSysSec;
    6542    28673529 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterConsumption =
    6543    28673529 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterPower * TimeStepSysSec;
    6544    28673529 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapWaterConsump =
    6545    28673529 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapWaterConsumpRate * TimeStepSysSec;
    6546    28673529 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterConsumption =
    6547    28673529 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterPower * TimeStepSysSec;
    6548    28673529 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondPumpElecConsumption =
    6549    28673529 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondPumpElecPower * TimeStepSysSec;
    6550    28673529 :         if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac == 0.0) {
    6551      721762 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).COP = 0.0;
    6552             :         } else {
    6553    27951767 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).COP =
    6554    27951767 :                 state.dataVariableSpeedCoils->QLoadTotal / state.dataVariableSpeedCoils->Winput;
    6555             :         }
    6556    28673529 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PartLoadRatio = PartLoadRatio;
    6557    28673529 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate = state.dataVariableSpeedCoils->PLRCorrLoadSideMdot;
    6558    28673529 :         rhoair = PsyRhoAirFnPbTdbW(state,
    6559    28673529 :                                    state.dataEnvrn->OutBaroPress,
    6560    28673529 :                                    state.dataVariableSpeedCoils->LoadSideInletDBTemp,
    6561    28673529 :                                    state.dataVariableSpeedCoils->LoadSideInletHumRat,
    6562             :                                    RoutineName);
    6563             :         // This seems wrong, initializing mass flow rate to StdRhoAir or actual air density,
    6564             :         // then using that mass flow rate, then back calculating volume using inlet conditions.
    6565             :         // Volume should be constant through a fan and air mass flow rate should vary based on inlet conditions.
    6566    28673529 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirVolFlowRate =
    6567    28673529 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate / rhoair;
    6568             : 
    6569    28673529 :         if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_CoolingAirToAirVariableSpeed) {
    6570    26559314 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterMassFlowRate = 0.0;
    6571    26559314 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletWaterTemp = 0.0;
    6572    26559314 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletWaterEnthalpy = 0.0;
    6573    26559314 :             state.dataHeatBal->HeatReclaimVS_DXCoil(DXCoilNum).AvailCapacity = state.dataVariableSpeedCoils->QSource;
    6574             :         } else {
    6575     2114215 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterMassFlowRate = state.dataVariableSpeedCoils->SourceSideMassFlowRate;
    6576     2114215 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletWaterTemp =
    6577     2114215 :                 state.dataVariableSpeedCoils->SourceSideInletTemp +
    6578     2114215 :                 state.dataVariableSpeedCoils->QSource / (state.dataVariableSpeedCoils->SourceSideMassFlowRate * CpSource);
    6579     2114215 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletWaterEnthalpy =
    6580     2114215 :                 state.dataVariableSpeedCoils->SourceSideInletEnth +
    6581     2114215 :                 state.dataVariableSpeedCoils->QSource / state.dataVariableSpeedCoils->SourceSideMassFlowRate;
    6582             :         }
    6583             : 
    6584    28673529 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QWasteHeat = QWasteHeat;
    6585             : 
    6586    28673529 :         if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondensateCollectMode == CondensateToTank) {
    6587             :             // calculate and report condensation rates  (how much water extracted from the air stream)
    6588             :             // water flow of water in m3/s for water system interactions
    6589           0 :             RhoWater = RhoH2O((state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirDBTemp +
    6590           0 :                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirDBTemp) /
    6591             :                               2.0);
    6592             :             //     CR9155 Remove specific humidity calculations
    6593           0 :             SpecHumIn = state.dataVariableSpeedCoils->LoadSideInletHumRat;
    6594           0 :             SpecHumOut = state.dataVariableSpeedCoils->LoadSideOutletHumRat;
    6595             :             //  mdot * del HumRat / rho water
    6596           0 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondensateVdot =
    6597           0 :                 max(0.0, (state.dataVariableSpeedCoils->LoadSideMassFlowRate * (SpecHumIn - SpecHumOut) / RhoWater));
    6598           0 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondensateVol =
    6599           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondensateVdot * TimeStepSysSec;
    6600             :         }
    6601             :     }
    6602             : 
    6603     1686472 :     void CalcVarSpeedHPWH(EnergyPlusData &state,
    6604             :                           int const DXCoilNum,        // the number of the DX coil to be simulated
    6605             :                           Real64 const PartLoadRatio, // sensible water heating load / full load sensible water heating capacity
    6606             :                           Real64 const SpeedRatio,    // SpeedRatio varies between 1.0 (higher speed) and 0.0 (lower speed)
    6607             :                           int const SpeedNum,         // Speed number, high bound
    6608             :                           HVAC::FanOp const fanOp     // Continuous fan OR cycling compressor
    6609             :     )
    6610             :     {
    6611             : 
    6612             :         // SUBROUTINE INFORMATION:
    6613             :         //       AUTHOR         Bo Shen, ORNL
    6614             :         //       DATE WRITTEN   12/2014
    6615             : 
    6616             :         // PURPOSE OF THIS SUBROUTINE:
    6617             :         // Calculates the gross cooling capacity of a variable-speed heat pump water heater evaporator and
    6618             :         // heating capacity of the condenser coil given the rated heating capacity and COP.
    6619             : 
    6620             :         // METHODOLOGY EMPLOYED:
    6621             :         // The routine requires the user to enter the total heating capacity and COP for the
    6622             :         // heat pump water heater along with logicals defining if fan and condenser pump are included at numerous speed levels.
    6623             :         // Since manufacturer's can rate their HPWH equipment with or without including condenser
    6624             :         // pump heat, this information is required to accurately determine the condenser's leaving
    6625             :         // water temperature. In addition, knowledge of the fan heat is required to back into
    6626             :         // a compressor COP.
    6627             : 
    6628             :         // Using/Aliasing
    6629             :         using Curve::CurveValue;
    6630     1686472 :         Real64 TimeStepSysSec = state.dataHVACGlobal->TimeStepSysSec;
    6631             : 
    6632             :         // SUBROUTINE PARAMETER DEFINITIONS:
    6633             :         static constexpr std::string_view RoutineName("CalcVarSpeedHPWH");
    6634             : 
    6635             :         // INTERFACE BLOCK SPECIFICATIONS
    6636             :         // na
    6637             : 
    6638             :         // DERIVED TYPE DEFINITIONS
    6639             :         // na
    6640             : 
    6641             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    6642             :         Real64 OperatingHeatingCapacity; // Water heating operating capacity including the impact of capacity and COP curves (W)
    6643             :         Real64 OperatingHeatingCOP;      // Water heating operating COP including the impact of capacity and COP curves (W/W)
    6644             :         Real64 OperatingHeatingPower;    // Water heating operating Power (W)
    6645             :         Real64 CompressorPower;          // Power consumed by compressor only (W)
    6646             : 
    6647             :         Real64 TotalTankHeatingCapacity; // Water heating capacity corrected for condenser water pump heat (W)
    6648             :         Real64 TankHeatingCOP;           // Water heating COP corrected for fan and condenser water pump power (W/W)
    6649             :         // (these previous 2 variables also include the impact of capacity and COP curves)
    6650             :         Real64 EvapCoolingCapacity;   // Air cooling capacity corrected for evap fan and cond water pump heat (W)
    6651             :         Real64 InletWaterTemp;        // Condenser water inlet temperature (C)
    6652             :         Real64 OutletWaterTemp;       // Condenser water outlet temperature (C)
    6653             :         Real64 EvapInletMassFlowRate; // Evaporator air inlet mass flow rate (m3/s)
    6654             :         Real64 CondInletMassFlowRate; // Condenser water inlet mass flow rate (m3/s)
    6655             :         Real64 CpWater;               // Specific heat of condenser inlet water (J/Kg/k)
    6656             :         Real64 InletAirTemp;          // HPWH inlet air temperature (dry-bulb or wet-bulb) (C)
    6657             :         Real64 AirMassFlowRatio;      // Ratio of evaporator inlet air mass flow rate to rated mass flow rate
    6658             :         Real64 WaterMassFlowRatio;    // Ratio of evaporator inlet water mass flow rate to rated mass flow rate
    6659             :         Real64 PumpHeatToWater;       // Amount of pump heat attributed to heating water
    6660             :         Real64 PLF;                   // part-load function
    6661             :         Real64 CBFSpeed;              // bypass factor as individual speed level
    6662             :         Real64 COPAirFFModFac;        // air flow fraction modification
    6663             :         Real64 COPWaterFFModFac;      // water flow fraction modification
    6664             :         Real64 COPTempModFac;         // total capacity temperature correctio fraction
    6665             :         Real64 TOTCAPAirFFModFac;     // air flow fraction modification
    6666             :         Real64 TOTCAPWaterFFModFac;   // water flow fraction modification
    6667             :         Real64 TOTCAPTempModFac;      // total capacity temperature correctio fraction
    6668             :         Real64 SHR;                   // total capacity temperature correctio fraction
    6669             :         Real64 COP;                   // total capacity temperature correctio fraction
    6670             :         Real64 AoEff;                 // effective air side surface area
    6671             :         Real64 Winput1;               // power consumption at low speed
    6672             :         Real64 Winput2;               // power consumption at high speed
    6673             :         Real64 LoadPressure;          // evaporator inlet pressure
    6674             :         Real64 CrankcaseHeatingPower; // power due to crankcase heater
    6675             :         Real64 hDelta;                // Change in air enthalpy across the cooling coil [J/kg]
    6676             :         Real64 hADP;                  // Apparatus dew point enthalpy [J/kg]
    6677             :         Real64 tADP;                  // Apparatus dew point temperature [C]
    6678             :         Real64 wADP;                  // Apparatus dew point humidity ratio [kg/kg]
    6679             :         Real64 hTinwADP;              // Enthalpy at inlet dry-bulb and wADP [J/kg]
    6680             :         Real64 WHCAP1;                // total heating capacity at low speed [W]
    6681             :         Real64 WHCAP2;                // total heating capacity at high speed [W]
    6682             :         Real64 CpAir;                 // Specific heat of air [J/kg_C]
    6683             :         Real64 MaxHumRat;             // max possible humidity
    6684             :         Real64 MaxOutletEnth;         // max possible outlet enthalpy
    6685             :         int EvapInletNode;            // Evaporator air inlet node number
    6686             :         int EvapOutletNode;           // Evaporator air outlet node number
    6687             :         int CondInletNode;            // Condenser water inlet node number
    6688             :         int CondOutletNode;           // Condenser water outlet node number
    6689             :         int MaxSpeed;                 // maximum speed level
    6690             :         int SpeedCal;                 // calculated speed level
    6691     1686472 :         Real64 rhoair(0.0);           // entering air density
    6692     1686472 :         Real64 RhoWater(0.0);         // water density
    6693             : 
    6694             :         // note: load side is the evaporator side, and source side is the condenser side
    6695             : 
    6696     1686472 :         CondInletNode = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterInletNodeNum;
    6697     1686472 :         CondOutletNode = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterOutletNodeNum;
    6698             :         // If heat pump water heater is OFF, set outlet to inlet and RETURN
    6699     1686472 :         if (PartLoadRatio == 0.0) {
    6700     1070009 :             state.dataLoopNodes->Node(CondOutletNode) = state.dataLoopNodes->Node(CondInletNode);
    6701     1070009 :             return;
    6702             :         } else {
    6703      616463 :             EvapInletNode = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirInletNodeNum;
    6704      616463 :             EvapOutletNode = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirOutletNodeNum;
    6705      616463 :             InletWaterTemp = state.dataLoopNodes->Node(CondInletNode).Temp;
    6706      616463 :             CondInletMassFlowRate = state.dataLoopNodes->Node(CondInletNode).MassFlowRate;
    6707      616463 :             EvapInletMassFlowRate = state.dataLoopNodes->Node(EvapInletNode).MassFlowRate;
    6708      616463 :             CpWater = CPHW(InletWaterTemp);
    6709      616463 :             CompressorPower = 0.0;
    6710      616463 :             OperatingHeatingPower = 0.0;
    6711      616463 :             TankHeatingCOP = 0.0;
    6712             :         }
    6713             : 
    6714             :         //  LOAD LOCAL VARIABLES FROM DATA STRUCTURE (for code readability)
    6715      616463 :         if (!(fanOp == HVAC::FanOp::Continuous) && PartLoadRatio > 0.0) {
    6716      616463 :             CondInletMassFlowRate = CondInletMassFlowRate / PartLoadRatio;
    6717      616463 :             EvapInletMassFlowRate = EvapInletMassFlowRate / PartLoadRatio;
    6718             :         }
    6719             : 
    6720      616463 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate = EvapInletMassFlowRate;
    6721      616463 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterMassFlowRate = CondInletMassFlowRate;
    6722             : 
    6723             :         // determine inlet air temperature type for curve objects
    6724      616463 :         if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirTemperatureType == HVAC::OATType::WetBulb) {
    6725      616463 :             InletAirTemp = state.dataHVACGlobal->HPWHInletWBTemp;
    6726             :         } else {
    6727           0 :             InletAirTemp = state.dataHVACGlobal->HPWHInletDBTemp;
    6728             :         }
    6729             : 
    6730             :         // check if indoor evaporator or outdoor evaporator
    6731      616463 :         CrankcaseHeatingPower = 0.0;
    6732      616463 :         if (EvapInletNode != 0) {
    6733      616463 :             state.dataVariableSpeedCoils->LoadSideInletDBTemp = state.dataLoopNodes->Node(EvapInletNode).Temp;
    6734      616463 :             state.dataVariableSpeedCoils->LoadSideInletHumRat = state.dataLoopNodes->Node(EvapInletNode).HumRat;
    6735      616463 :             LoadPressure = state.dataLoopNodes->Node(EvapInletNode).Press;
    6736             :             // prevent the air pressure not given
    6737      616463 :             if (LoadPressure < 10.0) LoadPressure = state.dataEnvrn->OutBaroPress;
    6738             : 
    6739      616463 :             state.dataVariableSpeedCoils->LoadSideInletWBTemp = state.dataLoopNodes->Node(EvapInletNode).OutAirWetBulb;
    6740      616463 :             state.dataVariableSpeedCoils->LoadSideInletEnth = state.dataLoopNodes->Node(EvapInletNode).Enthalpy;
    6741             :         } else {
    6742           0 :             state.dataVariableSpeedCoils->LoadSideInletDBTemp = state.dataEnvrn->OutDryBulbTemp;
    6743           0 :             state.dataVariableSpeedCoils->LoadSideInletHumRat = state.dataEnvrn->OutHumRat;
    6744           0 :             LoadPressure = state.dataEnvrn->OutBaroPress;
    6745           0 :             state.dataVariableSpeedCoils->LoadSideInletWBTemp = state.dataEnvrn->OutWetBulbTemp;
    6746           0 :             state.dataVariableSpeedCoils->LoadSideInletEnth = state.dataEnvrn->OutEnthalpy;
    6747             : 
    6748             :             // Initialize crankcase heater, operates below OAT defined in input deck for HP DX heating coil
    6749           0 :             if (state.dataEnvrn->OutDryBulbTemp < state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MaxOATCrankcaseHeater) {
    6750           0 :                 CrankcaseHeatingPower = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterCapacity;
    6751           0 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterCapacityCurveIndex > 0) {
    6752           0 :                     CrankcaseHeatingPower *=
    6753           0 :                         Curve::CurveValue(state,
    6754           0 :                                           state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterCapacityCurveIndex,
    6755           0 :                                           state.dataEnvrn->OutDryBulbTemp);
    6756             :                 }
    6757             :             };
    6758             :         }
    6759             : 
    6760      616463 :         state.dataVariableSpeedCoils->LoadSideMassFlowRate = EvapInletMassFlowRate;
    6761      616463 :         state.dataVariableSpeedCoils->SourceSideMassFlowRate = CondInletMassFlowRate;
    6762      616463 :         state.dataVariableSpeedCoils->SourceSideInletTemp = InletWaterTemp;
    6763      616463 :         state.dataVariableSpeedCoils->SourceSideInletEnth = state.dataLoopNodes->Node(CondInletNode).Enthalpy;
    6764      616463 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterEnthalpy = state.dataVariableSpeedCoils->SourceSideInletEnth;
    6765             : 
    6766             :         // Check for flows, do not perform simulation if no flow in load side or source side.
    6767      616463 :         if ((state.dataVariableSpeedCoils->SourceSideMassFlowRate <= 0.0) || (state.dataVariableSpeedCoils->LoadSideMassFlowRate <= 0.0)) {
    6768         548 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SimFlag = false;
    6769         548 :             return;
    6770             :         } else {
    6771      615915 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SimFlag = true;
    6772             :         }
    6773             : 
    6774      615915 :         MaxSpeed = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds;
    6775             : 
    6776             :         // must be placed inside the loop, otherwise cause bug in release mode, need to be present at two places
    6777      615915 :         if (SpeedNum > MaxSpeed) {
    6778           0 :             SpeedCal = MaxSpeed;
    6779             :         } else {
    6780      615915 :             SpeedCal = SpeedNum;
    6781             :         }
    6782             : 
    6783             :         // part-load calculation
    6784      615915 :         state.dataHVACGlobal->OnOffFanPartLoadFraction = 1.0;
    6785      615915 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac = 1.0;
    6786      615915 :         if ((SpeedNum == 1) && (PartLoadRatio < 1.0)) {
    6787       15520 :             PLF = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PLFFPLR, PartLoadRatio);
    6788       15520 :             if (PLF < 0.7) {
    6789           0 :                 PLF = 0.7;
    6790             :             }
    6791       15520 :             if (fanOp == HVAC::FanOp::Cycling)
    6792       15520 :                 state.dataHVACGlobal->OnOffFanPartLoadFraction =
    6793             :                     PLF; // save PLF for fan model, don't change fan power for constant fan mode if coil is off
    6794             :             // calculate the run time fraction
    6795       15520 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac = PartLoadRatio / PLF;
    6796       15520 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PartLoadRatio = PartLoadRatio;
    6797             : 
    6798       15520 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac > 1.0) {
    6799           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac = 1.0; // Reset coil runtime fraction to 1.0
    6800       15520 :             } else if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac < 0.0) {
    6801           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac = 0.0;
    6802             :             }
    6803             :         }
    6804             : 
    6805             :         // interpolate between speeds
    6806             :         // must be placed inside the loop, otherwise cause bug in release mode
    6807      615915 :         if (SpeedNum > MaxSpeed) {
    6808           0 :             SpeedCal = MaxSpeed;
    6809             :         } else {
    6810      615915 :             SpeedCal = SpeedNum;
    6811             :         }
    6812             : 
    6813      615915 :         Real64 locFanElecPower = 0.0; // local for fan electric power
    6814      615915 :         if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SupplyFanIndex > 0) {
    6815      528541 :             locFanElecPower = state.dataFans->fans(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SupplyFanIndex)->totalPower;
    6816             :         }
    6817      615915 :         if ((SpeedNum == 1) || (SpeedNum > MaxSpeed) || (SpeedRatio == 1.0)) {
    6818      506291 :             AirMassFlowRatio =
    6819      506291 :                 state.dataVariableSpeedCoils->LoadSideMassFlowRate / state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignAirMassFlowRate;
    6820      506291 :             WaterMassFlowRatio =
    6821      506291 :                 state.dataVariableSpeedCoils->SourceSideMassFlowRate / state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignWaterMassFlowRate;
    6822      506291 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower =
    6823      506291 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWHPumpPower(SpeedCal);
    6824             : 
    6825     1518873 :             COPTempModFac = CurveValue(state,
    6826      506291 :                                        state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(SpeedCal),
    6827             :                                        InletAirTemp,
    6828      506291 :                                        state.dataVariableSpeedCoils->SourceSideInletTemp);
    6829      506291 :             COPAirFFModFac = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(SpeedCal), AirMassFlowRatio);
    6830      506291 :             COPWaterFFModFac = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRWaterFFlow(SpeedCal), WaterMassFlowRatio);
    6831             : 
    6832      506291 :             COP = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedCOP(SpeedCal) * COPTempModFac * COPAirFFModFac * COPWaterFFModFac;
    6833             : 
    6834     1518873 :             TOTCAPTempModFac = CurveValue(state,
    6835      506291 :                                           state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(SpeedCal),
    6836             :                                           InletAirTemp,
    6837      506291 :                                           state.dataVariableSpeedCoils->SourceSideInletTemp);
    6838             :             //   Get capacity modifying factor (function of mass flow) for off-rated conditions
    6839      506291 :             TOTCAPAirFFModFac = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(SpeedCal), AirMassFlowRatio);
    6840             :             // Get capacity modifying factor (function of mass flow) for off-rated conditions
    6841             :             TOTCAPWaterFFModFac =
    6842      506291 :                 CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(SpeedCal), WaterMassFlowRatio);
    6843             : 
    6844      506291 :             OperatingHeatingCapacity = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(SpeedCal) * TOTCAPTempModFac *
    6845             :                                        TOTCAPAirFFModFac * TOTCAPWaterFFModFac;
    6846             : 
    6847      506291 :             state.dataVariableSpeedCoils->Winput = OperatingHeatingCapacity / COP;
    6848      506291 :             OperatingHeatingPower = state.dataVariableSpeedCoils->Winput;
    6849             : 
    6850      506291 :             OperatingHeatingCOP = COP;
    6851      506291 :             PumpHeatToWater = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower *
    6852      506291 :                               state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpFracToWater;
    6853      506291 :             TankHeatingCOP = OperatingHeatingCOP;
    6854             : 
    6855             :             // account for pump heat if not included in total water heating capacity
    6856      506291 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondPumpHeatInCapacity) {
    6857           0 :                 TotalTankHeatingCapacity = OperatingHeatingCapacity;
    6858             :             } else {
    6859      506291 :                 TotalTankHeatingCapacity = OperatingHeatingCapacity + PumpHeatToWater;
    6860             :             }
    6861             : 
    6862             :             // calculate evaporator total cooling capacity
    6863      506291 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).FanPowerIncludedInCOP) {
    6864       16799 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondPumpPowerInCOP) {
    6865             :                     //       make sure fan power is full load fan power, it isn't though,
    6866           0 :                     CompressorPower = OperatingHeatingPower - locFanElecPower / state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac -
    6867           0 :                                       state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower;
    6868           0 :                     if (OperatingHeatingPower > 0.0) TankHeatingCOP = TotalTankHeatingCapacity / OperatingHeatingPower;
    6869             :                 } else {
    6870       16799 :                     CompressorPower = OperatingHeatingPower - locFanElecPower / state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac;
    6871       16799 :                     if ((OperatingHeatingPower + state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower) > 0.0)
    6872       16799 :                         TankHeatingCOP = TotalTankHeatingCapacity /
    6873       16799 :                                          (OperatingHeatingPower + state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower);
    6874             :                 }
    6875             :             } else {
    6876      489492 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondPumpPowerInCOP) {
    6877             :                     //       make sure fan power is full load fan power
    6878           0 :                     CompressorPower = OperatingHeatingPower - state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower;
    6879           0 :                     if ((OperatingHeatingPower + locFanElecPower / state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac) > 0.0)
    6880           0 :                         TankHeatingCOP = TotalTankHeatingCapacity /
    6881           0 :                                          (OperatingHeatingPower + locFanElecPower / state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac);
    6882             :                 } else {
    6883      489492 :                     CompressorPower = OperatingHeatingPower;
    6884      489492 :                     if ((OperatingHeatingPower + locFanElecPower / state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac +
    6885      489492 :                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower) > 0.0)
    6886      489492 :                         TankHeatingCOP = TotalTankHeatingCapacity /
    6887      489492 :                                          (OperatingHeatingPower + locFanElecPower / state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac +
    6888      489492 :                                           state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower);
    6889             :                 }
    6890             :             }
    6891             : 
    6892      506291 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondPumpHeatInCapacity) {
    6893           0 :                 EvapCoolingCapacity = TotalTankHeatingCapacity - PumpHeatToWater - CompressorPower;
    6894             :             } else {
    6895      506291 :                 EvapCoolingCapacity = TotalTankHeatingCapacity - CompressorPower;
    6896             :             }
    6897             : 
    6898      506291 :             CBFSpeed = AdjustCBF(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedCBF(SpeedCal),
    6899      506291 :                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirMassFlowRate(SpeedCal),
    6900      506291 :                                  state.dataVariableSpeedCoils->LoadSideMassFlowRate);
    6901             : 
    6902             :         } else {
    6903      109624 :             AirMassFlowRatio =
    6904      109624 :                 state.dataVariableSpeedCoils->LoadSideMassFlowRate / state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignAirMassFlowRate;
    6905      109624 :             WaterMassFlowRatio =
    6906      109624 :                 state.dataVariableSpeedCoils->SourceSideMassFlowRate / state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignWaterMassFlowRate;
    6907      109624 :             AoEff = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEffectiveAo(SpeedCal) * SpeedRatio +
    6908      109624 :                     (1.0 - SpeedRatio) * state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEffectiveAo(SpeedCal - 1);
    6909      109624 :             CBFSpeed = std::exp(-AoEff / state.dataVariableSpeedCoils->LoadSideMassFlowRate);
    6910             : 
    6911             :             // calculate low speed
    6912      109624 :             SpeedCal = SpeedNum - 1;
    6913             : 
    6914      109624 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower =
    6915      109624 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWHPumpPower(SpeedCal);
    6916      328872 :             COPTempModFac = CurveValue(state,
    6917      109624 :                                        state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(SpeedCal),
    6918             :                                        InletAirTemp,
    6919      109624 :                                        state.dataVariableSpeedCoils->SourceSideInletTemp);
    6920      109624 :             COPAirFFModFac = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(SpeedCal), AirMassFlowRatio);
    6921      109624 :             COPWaterFFModFac = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRWaterFFlow(SpeedCal), WaterMassFlowRatio);
    6922             : 
    6923      109624 :             COP = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedCOP(SpeedCal) * COPTempModFac * COPAirFFModFac * COPWaterFFModFac;
    6924             : 
    6925      328872 :             TOTCAPTempModFac = CurveValue(state,
    6926      109624 :                                           state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(SpeedCal),
    6927             :                                           InletAirTemp,
    6928      109624 :                                           state.dataVariableSpeedCoils->SourceSideInletTemp);
    6929             :             //   Get capacity modifying factor (function of mass flow) for off-rated conditions
    6930      109624 :             TOTCAPAirFFModFac = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(SpeedCal), AirMassFlowRatio);
    6931             :             // Get capacity modifying factor (function of mass flow) for off-rated conditions
    6932             :             TOTCAPWaterFFModFac =
    6933      109624 :                 CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(SpeedCal), WaterMassFlowRatio);
    6934             : 
    6935      109624 :             OperatingHeatingCapacity = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(SpeedCal) * TOTCAPTempModFac *
    6936             :                                        TOTCAPAirFFModFac * TOTCAPWaterFFModFac;
    6937             : 
    6938      109624 :             state.dataVariableSpeedCoils->Winput = OperatingHeatingCapacity / COP;
    6939      109624 :             OperatingHeatingPower = state.dataVariableSpeedCoils->Winput;
    6940      109624 :             Winput1 = state.dataVariableSpeedCoils->Winput;
    6941      109624 :             WHCAP1 = OperatingHeatingCapacity;
    6942             : 
    6943             :             // calculate upper speed
    6944      109624 :             SpeedCal = SpeedNum;
    6945             : 
    6946      109624 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower =
    6947      109624 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWHPumpPower(SpeedCal);
    6948      328872 :             COPTempModFac = CurveValue(state,
    6949      109624 :                                        state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(SpeedCal),
    6950             :                                        InletAirTemp,
    6951      109624 :                                        state.dataVariableSpeedCoils->SourceSideInletTemp);
    6952      109624 :             COPAirFFModFac = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(SpeedCal), AirMassFlowRatio);
    6953      109624 :             COPWaterFFModFac = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRWaterFFlow(SpeedCal), WaterMassFlowRatio);
    6954             : 
    6955      109624 :             COP = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedCOP(SpeedCal) * COPTempModFac * COPAirFFModFac * COPWaterFFModFac;
    6956             : 
    6957      328872 :             TOTCAPTempModFac = CurveValue(state,
    6958      109624 :                                           state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(SpeedCal),
    6959             :                                           InletAirTemp,
    6960      109624 :                                           state.dataVariableSpeedCoils->SourceSideInletTemp);
    6961             :             //   Get capacity modifying factor (function of mass flow) for off-rated conditions
    6962      109624 :             TOTCAPAirFFModFac = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(SpeedCal), AirMassFlowRatio);
    6963             :             // Get capacity modifying factor (function of mass flow) for off-rated conditions
    6964             :             TOTCAPWaterFFModFac =
    6965      109624 :                 CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(SpeedCal), WaterMassFlowRatio);
    6966             : 
    6967      109624 :             OperatingHeatingCapacity = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(SpeedCal) * TOTCAPTempModFac *
    6968             :                                        TOTCAPAirFFModFac * TOTCAPWaterFFModFac;
    6969             : 
    6970      109624 :             state.dataVariableSpeedCoils->Winput = OperatingHeatingCapacity / COP;
    6971      109624 :             OperatingHeatingPower = state.dataVariableSpeedCoils->Winput;
    6972             : 
    6973      109624 :             Winput2 = state.dataVariableSpeedCoils->Winput;
    6974      109624 :             WHCAP2 = OperatingHeatingCapacity;
    6975             : 
    6976             :             // interpolation
    6977      109624 :             state.dataVariableSpeedCoils->Winput = Winput2 * SpeedRatio + (1.0 - SpeedRatio) * Winput1;
    6978      109624 :             OperatingHeatingPower = state.dataVariableSpeedCoils->Winput;
    6979      109624 :             OperatingHeatingCapacity = WHCAP2 * SpeedRatio + (1.0 - SpeedRatio) * WHCAP1;
    6980      109624 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower =
    6981      109624 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWHPumpPower(SpeedNum) * SpeedRatio +
    6982      109624 :                 (1.0 - SpeedRatio) * state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWHPumpPower(SpeedNum - 1);
    6983             : 
    6984      109624 :             OperatingHeatingCOP = OperatingHeatingCapacity / OperatingHeatingPower;
    6985      109624 :             TankHeatingCOP = OperatingHeatingCOP;
    6986             : 
    6987      109624 :             PumpHeatToWater = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower *
    6988      109624 :                               state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpFracToWater;
    6989             : 
    6990             :             // account for pump heat if not included in total water heating capacity
    6991      109624 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondPumpHeatInCapacity) {
    6992           0 :                 TotalTankHeatingCapacity = OperatingHeatingCapacity;
    6993             :             } else {
    6994      109624 :                 TotalTankHeatingCapacity = OperatingHeatingCapacity + PumpHeatToWater;
    6995             :             }
    6996             : 
    6997      109624 :             Real64 HPRTF = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac;
    6998             :             // calculate evaporator total cooling capacity
    6999      109624 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).FanPowerIncludedInCOP) {
    7000        3074 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondPumpPowerInCOP) {
    7001             :                     //       make sure fan power is full load fan power
    7002           0 :                     CompressorPower = OperatingHeatingPower - locFanElecPower / HPRTF -
    7003           0 :                                       state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower;
    7004           0 :                     if (OperatingHeatingPower > 0.0) TankHeatingCOP = TotalTankHeatingCapacity / OperatingHeatingPower;
    7005             :                 } else {
    7006        3074 :                     CompressorPower = OperatingHeatingPower - locFanElecPower / HPRTF;
    7007        3074 :                     if ((OperatingHeatingPower + state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower) > 0.0)
    7008        3074 :                         TankHeatingCOP = TotalTankHeatingCapacity /
    7009        3074 :                                          (OperatingHeatingPower + state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower);
    7010             :                 }
    7011             :             } else {
    7012      106550 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondPumpPowerInCOP) {
    7013             :                     //       make sure fan power is full load fan power
    7014           0 :                     CompressorPower = OperatingHeatingPower - state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower;
    7015           0 :                     if ((OperatingHeatingPower + locFanElecPower / HPRTF) > 0.0)
    7016           0 :                         TankHeatingCOP = TotalTankHeatingCapacity / (OperatingHeatingPower + locFanElecPower / HPRTF);
    7017             :                 } else {
    7018      106550 :                     CompressorPower = OperatingHeatingPower;
    7019      213100 :                     if ((OperatingHeatingPower + locFanElecPower / HPRTF +
    7020      106550 :                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower) > 0.0)
    7021      213100 :                         TankHeatingCOP = TotalTankHeatingCapacity / (OperatingHeatingPower + locFanElecPower / HPRTF +
    7022      106550 :                                                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower);
    7023             :                 }
    7024             :             }
    7025             : 
    7026      109624 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondPumpHeatInCapacity) {
    7027           0 :                 EvapCoolingCapacity = TotalTankHeatingCapacity - PumpHeatToWater - CompressorPower;
    7028             :             } else {
    7029      109624 :                 EvapCoolingCapacity = TotalTankHeatingCapacity - CompressorPower;
    7030             :             }
    7031             :         }
    7032             : 
    7033      615915 :         state.dataVariableSpeedCoils->QSource = TotalTankHeatingCapacity;
    7034      615915 :         state.dataVariableSpeedCoils->QLoadTotal = EvapCoolingCapacity;
    7035      615915 :         state.dataHVACGlobal->DXCoilTotalCapacity = EvapCoolingCapacity; // for standard rating calculation
    7036      615915 :         SHR = 1.0;
    7037             :         // if indoor, calculate SHR
    7038      615915 :         if (EvapInletNode != 0) {
    7039      615915 :             if (CBFSpeed > 0.999) CBFSpeed = 0.999;
    7040             : 
    7041      615915 :             if (CBFSpeed < 0.001) {
    7042         682 :                 SHR = 1.0;
    7043             :             } else {
    7044      615233 :                 hDelta = state.dataVariableSpeedCoils->QLoadTotal / state.dataVariableSpeedCoils->LoadSideMassFlowRate;
    7045      615233 :                 hADP = state.dataVariableSpeedCoils->LoadSideInletEnth - hDelta / (1.0 - CBFSpeed);
    7046      615233 :                 tADP = PsyTsatFnHPb(state, hADP, LoadPressure, RoutineName);
    7047      615233 :                 wADP = PsyWFnTdbH(state, tADP, hADP, RoutineName);
    7048      615233 :                 hTinwADP = PsyHFnTdbW(state.dataVariableSpeedCoils->LoadSideInletDBTemp, wADP);
    7049      615233 :                 if ((state.dataVariableSpeedCoils->LoadSideInletEnth - hADP) > 1.e-10) {
    7050      615233 :                     SHR = min((hTinwADP - hADP) / (state.dataVariableSpeedCoils->LoadSideInletEnth - hADP), 1.0);
    7051             :                 } else {
    7052           0 :                     SHR = 1.0;
    7053             :                 }
    7054             :             }
    7055             :         }
    7056             : 
    7057      615915 :         state.dataVariableSpeedCoils->QSensible = state.dataVariableSpeedCoils->QLoadTotal * SHR;
    7058             : 
    7059             :         // determine condenser water inlet/outlet condition at full capacity
    7060      615915 :         if (CondInletMassFlowRate == 0.0) {
    7061           0 :             OutletWaterTemp = InletWaterTemp;
    7062             :         } else {
    7063      615915 :             OutletWaterTemp = InletWaterTemp + TotalTankHeatingCapacity / (CpWater * CondInletMassFlowRate);
    7064             :         }
    7065             : 
    7066      615915 :         state.dataLoopNodes->Node(CondOutletNode).Temp = OutletWaterTemp;
    7067             : 
    7068      615915 :         state.dataLoopNodes->Node(CondOutletNode).MassFlowRate = state.dataLoopNodes->Node(CondInletNode).MassFlowRate;
    7069             : 
    7070             :         // send heating capacity and COP to water heater module for standards rating calculation
    7071             :         // total heating capacity including condenser pump
    7072      615915 :         state.dataVariableSpeedCoils->VSHPWHHeatingCapacity = TotalTankHeatingCapacity;
    7073             :         // total heating COP including compressor, fan, and condenser pump
    7074      615915 :         state.dataVariableSpeedCoils->VSHPWHHeatingCOP = TankHeatingCOP;
    7075             : 
    7076      615915 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).TotalHeatingEnergyRate = TotalTankHeatingCapacity * PartLoadRatio;
    7077             :         // calculate total compressor plus condenser pump power, fan power reported in fan module
    7078      615915 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).ElecWaterHeatingPower =
    7079      615915 :             (CompressorPower + state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower) *
    7080      615915 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac;
    7081             : 
    7082             :         // pass the outputs for the cooling coil section
    7083      615915 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterPower = 0.0;
    7084      615915 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterPower =
    7085      615915 :             CrankcaseHeatingPower * (1.0 - state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac);
    7086             : 
    7087             :         // calculate coil outlet state variables
    7088     1231830 :         state.dataVariableSpeedCoils->LoadSideOutletEnth =
    7089      615915 :             state.dataVariableSpeedCoils->LoadSideInletEnth -
    7090      615915 :             state.dataVariableSpeedCoils->QLoadTotal / state.dataVariableSpeedCoils->LoadSideMassFlowRate;
    7091      615915 :         CpAir = PsyCpAirFnW(state.dataVariableSpeedCoils->LoadSideInletHumRat);
    7092     1231830 :         state.dataVariableSpeedCoils->LoadSideOutletDBTemp =
    7093      615915 :             state.dataVariableSpeedCoils->LoadSideInletDBTemp -
    7094      615915 :             state.dataVariableSpeedCoils->QSensible / (state.dataVariableSpeedCoils->LoadSideMassFlowRate * CpAir);
    7095             : 
    7096      615915 :         MaxHumRat = PsyWFnTdbRhPb(state,
    7097      615915 :                                   state.dataVariableSpeedCoils->LoadSideOutletDBTemp,
    7098             :                                   0.9999,
    7099      615915 :                                   state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirPressure,
    7100             :                                   RoutineName);
    7101      615915 :         MaxOutletEnth = PsyHFnTdbW(state.dataVariableSpeedCoils->LoadSideOutletDBTemp, MaxHumRat);
    7102      615915 :         if (state.dataVariableSpeedCoils->LoadSideOutletEnth > MaxOutletEnth) {
    7103         682 :             state.dataVariableSpeedCoils->LoadSideOutletEnth = MaxOutletEnth;
    7104             :         }
    7105     1231830 :         state.dataVariableSpeedCoils->LoadSideOutletHumRat =
    7106      615915 :             PsyWFnTdbH(state, state.dataVariableSpeedCoils->LoadSideOutletDBTemp, state.dataVariableSpeedCoils->LoadSideOutletEnth, RoutineName);
    7107      615915 :         if (state.dataVariableSpeedCoils->LoadSideOutletHumRat > MaxHumRat) {
    7108         283 :             state.dataVariableSpeedCoils->LoadSideOutletHumRat = MaxHumRat;
    7109             :         }
    7110             : 
    7111             :         // Actual outlet conditions are "average" for time step
    7112      615915 :         if (fanOp == HVAC::FanOp::Continuous) {
    7113             :             // continuous fan, cycling compressor
    7114           0 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirEnthalpy =
    7115           0 :                 PartLoadRatio * state.dataVariableSpeedCoils->LoadSideOutletEnth +
    7116           0 :                 (1.0 - PartLoadRatio) * state.dataVariableSpeedCoils->LoadSideInletEnth;
    7117           0 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirHumRat =
    7118           0 :                 PartLoadRatio * state.dataVariableSpeedCoils->LoadSideOutletHumRat +
    7119           0 :                 (1.0 - PartLoadRatio) * state.dataVariableSpeedCoils->LoadSideInletHumRat;
    7120           0 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirDBTemp =
    7121           0 :                 PsyTdbFnHW(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirEnthalpy,
    7122           0 :                            state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirHumRat);
    7123           0 :             state.dataVariableSpeedCoils->PLRCorrLoadSideMdot = state.dataVariableSpeedCoils->LoadSideMassFlowRate;
    7124             :         } else {
    7125      615915 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirEnthalpy = state.dataVariableSpeedCoils->LoadSideOutletEnth;
    7126      615915 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirHumRat = state.dataVariableSpeedCoils->LoadSideOutletHumRat;
    7127      615915 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirDBTemp = state.dataVariableSpeedCoils->LoadSideOutletDBTemp;
    7128      615915 :             state.dataVariableSpeedCoils->PLRCorrLoadSideMdot = state.dataVariableSpeedCoils->LoadSideMassFlowRate * PartLoadRatio;
    7129             :         }
    7130             : 
    7131             :         // scale heat transfer rates to PLR and power to RTF
    7132      615915 :         state.dataVariableSpeedCoils->QLoadTotal *= PartLoadRatio;
    7133      615915 :         state.dataVariableSpeedCoils->QSensible *= PartLoadRatio;
    7134             :         // count the powr separately
    7135     1231830 :         state.dataVariableSpeedCoils->Winput *=
    7136      615915 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac; //+ VarSpeedCoil(DXCoilNum)%CrankcaseHeaterPower &
    7137             :         //+ VarSpeedCoil(DXCoilNum)%BasinHeaterPower + VarSpeedCoil(DXCoilNum)%EvapCondPumpElecPower
    7138      615915 :         state.dataVariableSpeedCoils->QSource *= PartLoadRatio;
    7139             : 
    7140             :         // Update heat pump data structure
    7141      615915 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower =
    7142      615915 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower *
    7143      615915 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac; // water heating pump power
    7144      615915 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Power = state.dataVariableSpeedCoils->Winput;
    7145      615915 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLoadTotal = state.dataVariableSpeedCoils->QLoadTotal;
    7146      615915 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSensible = state.dataVariableSpeedCoils->QSensible;
    7147      615915 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLatent =
    7148      615915 :             state.dataVariableSpeedCoils->QLoadTotal - state.dataVariableSpeedCoils->QSensible;
    7149      615915 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSource = state.dataVariableSpeedCoils->QSource;
    7150      615915 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Energy = state.dataVariableSpeedCoils->Winput * TimeStepSysSec;
    7151      615915 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLoadTotal = state.dataVariableSpeedCoils->QLoadTotal * TimeStepSysSec;
    7152      615915 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergySensible = state.dataVariableSpeedCoils->QSensible * TimeStepSysSec;
    7153      615915 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLatent =
    7154      615915 :             (state.dataVariableSpeedCoils->QLoadTotal - state.dataVariableSpeedCoils->QSensible) * TimeStepSysSec;
    7155      615915 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergySource = state.dataVariableSpeedCoils->QSource * TimeStepSysSec;
    7156      615915 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterConsumption =
    7157      615915 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterPower * TimeStepSysSec;
    7158      615915 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapWaterConsump = 0.0;
    7159      615915 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterConsumption = 0.0;
    7160             :         // re-use EvapCondPumpElecConsumption to store WH pump energy consumption
    7161      615915 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondPumpElecConsumption =
    7162      615915 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower * TimeStepSysSec;
    7163      615915 :         if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac == 0.0) {
    7164           0 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).COP = 0.0;
    7165             :         } else {
    7166      615915 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).COP =
    7167      615915 :                 state.dataVariableSpeedCoils->QLoadTotal / state.dataVariableSpeedCoils->Winput;
    7168             :         }
    7169      615915 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PartLoadRatio = PartLoadRatio;
    7170      615915 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate = state.dataVariableSpeedCoils->PLRCorrLoadSideMdot;
    7171      615915 :         rhoair = PsyRhoAirFnPbTdbW(state,
    7172      615915 :                                    state.dataEnvrn->OutBaroPress,
    7173      615915 :                                    state.dataVariableSpeedCoils->LoadSideInletDBTemp,
    7174      615915 :                                    state.dataVariableSpeedCoils->LoadSideInletHumRat,
    7175             :                                    RoutineName);
    7176      615915 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirVolFlowRate =
    7177      615915 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate / rhoair;
    7178      615915 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterMassFlowRate = state.dataVariableSpeedCoils->SourceSideMassFlowRate;
    7179      615915 :         RhoWater = RhoH2O(InletWaterTemp); // initialize
    7180      615915 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterVolFlowRate =
    7181      615915 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterMassFlowRate / RhoWater;
    7182             : 
    7183      615915 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletWaterTemp =
    7184      615915 :             state.dataVariableSpeedCoils->SourceSideInletTemp +
    7185      615915 :             state.dataVariableSpeedCoils->QSource / (state.dataVariableSpeedCoils->SourceSideMassFlowRate * CpWater);
    7186      615915 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletWaterEnthalpy =
    7187      615915 :             state.dataVariableSpeedCoils->SourceSideInletEnth +
    7188      615915 :             state.dataVariableSpeedCoils->QSource / state.dataVariableSpeedCoils->SourceSideMassFlowRate;
    7189      615915 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QWasteHeat = 0.0;
    7190             : 
    7191      615915 :         if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).bIsDesuperheater) // desuperheater doesn't save power and cooling energy variables
    7192             :         {
    7193             :             // source side is the water side; load side is the air side
    7194       82596 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Power = 0.0;
    7195       82596 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLoadTotal = 0.0;
    7196       82596 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSensible = 0.0;
    7197       82596 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLatent = 0.0;
    7198       82596 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Energy = 0.0;
    7199       82596 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLoadTotal = 0.0;
    7200       82596 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergySensible = 0.0;
    7201       82596 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLatent = 0.0;
    7202       82596 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterConsumption = 0.0;
    7203             :         }
    7204             :     }
    7205             : 
    7206           7 :     void setVarSpeedHPWHFanType(EnergyPlusData &state, int const dXCoilNum, HVAC::FanType fanType)
    7207             :     {
    7208           7 :         state.dataVariableSpeedCoils->VarSpeedCoil(dXCoilNum).supplyFanType = fanType;
    7209           7 :     }
    7210             : 
    7211           7 :     void setVarSpeedHPWHFanIndex(EnergyPlusData &state, int const dXCoilNum, int const fanIndex)
    7212             :     {
    7213           7 :         state.dataVariableSpeedCoils->VarSpeedCoil(dXCoilNum).SupplyFanIndex = fanIndex;
    7214           7 :     }
    7215             : 
    7216     5463106 :     void CalcVarSpeedCoilHeating(EnergyPlusData &state,
    7217             :                                  int const DXCoilNum,                             // Heat Pump Number
    7218             :                                  HVAC::FanOp const fanOp,                         // Fan/Compressor cycling scheme indicator
    7219             :                                  [[maybe_unused]] Real64 const SensDemand,        // Cooling Sensible Demand [W] !unused1208
    7220             :                                  HVAC::CompressorOp const compressorOp,           // compressor operation flag
    7221             :                                  Real64 const PartLoadRatio,                      // compressor part load ratio
    7222             :                                  [[maybe_unused]] Real64 const OnOffAirFlowRatio, // ratio of compressor on flow to average flow over time step
    7223             :                                  Real64 const SpeedRatio, // SpeedRatio varies between 1.0 (higher speed) and 0.0 (lower speed)
    7224             :                                  int const SpeedNum       // Speed number, high bound, i.e. SpeedNum - 1 is the other side
    7225             :     )
    7226             :     {
    7227             : 
    7228             :         //       AUTHOR         Bo Shen, based on WaterToAirHeatPumpSimple:CalcHPHeatingSimple
    7229             :         //       DATE WRITTEN   March 2012
    7230             :         //       MODIFIED       na
    7231             :         //       RE-ENGINEERED  na
    7232             : 
    7233             :         // PURPOSE OF THIS SUBROUTINE:
    7234             :         // This subroutine is for simulating the heating mode of the Variable Speed Water to Air HP Simple
    7235             : 
    7236             :         // METHODOLOGY EMPLOYED:
    7237             :         // Simulate the heat pump performance using the coefficients and rated conditions
    7238             :         // Finally, adjust the heat pump outlet conditions based on the PartLoadRatio
    7239             :         // and RuntimeFrac.
    7240             : 
    7241             :         // Using/Aliasing
    7242             :         using Curve::CurveValue;
    7243     5463106 :         Real64 TimeStepSysSec = state.dataHVACGlobal->TimeStepSysSec;
    7244             :         using FluidProperties::GetSpecificHeatGlycol;
    7245             :         using Psychrometrics::PsyCpAirFnW;
    7246             :         using Psychrometrics::PsyHFnTdbW;
    7247             :         using Psychrometrics::PsyRhoAirFnPbTdbW;
    7248             :         using Psychrometrics::PsyTdbFnHW;
    7249             :         using Psychrometrics::PsyTwbFnTdbWPb;
    7250             :         using Psychrometrics::PsyWFnTdbH;
    7251             :         using Psychrometrics::PsyWFnTdbTwbPb;
    7252             : 
    7253             :         // Locals
    7254             :         // SUBROUTINE ARGUMENT DEFINITIONS:
    7255             : 
    7256             :         // SUBROUTINE PARAMETER DEFINITIONS:
    7257             :         static constexpr std::string_view RoutineName("CalcVarSpeedCoilHeating");
    7258             :         static constexpr std::string_view RoutineNameSourceSideInletTemp("CalcVarSpeedCoilHeating:SourceSideInletTemp");
    7259             : 
    7260             :         // INTERFACE BLOCK SPECIFICATIONS
    7261             :         // na
    7262             : 
    7263             :         // DERIVED TYPE DEFINITIONS
    7264             :         // na
    7265             : 
    7266             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    7267             :         Real64 CpSource;            // Specific heat of water [J/kg_C]
    7268             :         Real64 CpAir;               // Specific heat of air [J/kg_C]
    7269             :         Real64 AirMassFlowRatio;    // airflow ratio at low speed
    7270             :         Real64 WaterMassFlowRatio;  // airflow ratio at high speed
    7271             :         Real64 TotCapAirFFModFac;   // air flow fraction modification
    7272             :         Real64 TotCapWaterFFModFac; // water flow fraction modification
    7273             :         Real64 TotCapTempModFac;    // total capacity temperature correction fraction
    7274             :         Real64 EIRAirFFModFac;      // air flow fraction modification
    7275             :         Real64 EIRWaterFFModFac;    // water flow fraction modification
    7276             :         Real64 EIRTempModFac;       // total capacity temperature correction fraction
    7277             :         Real64 EIR;                 // total capacity temperature correction fraction
    7278             :         int MaxSpeed;               // maximum speed level
    7279             :         int SpeedCal;               // calculated speed level
    7280             :         Real64 QLoadTotal1;         // heating capacity at low speed
    7281             :         Real64 QLoadTotal2;         // heating capacity at high speed
    7282             :         Real64 Winput1;             // power consumption at low speed
    7283             :         Real64 Winput2;             // power consumption at high speed
    7284             :         Real64 QWasteHeat;          // recoverable waste heat
    7285             :         Real64 QWasteHeat1;         // recoverable waste heat at low speed
    7286             :         Real64 QWasteHeat2;         // recoverable waste heat at high speed
    7287             :         Real64 PLF;                 // part-load function
    7288     5463106 :         Real64 rhoair(0.0);         // entering air density
    7289             : 
    7290             :         // ADDED VARIABLES FOR air source coil
    7291     5463106 :         MaxSpeed = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds;
    7292             : 
    7293             :         //  LOAD LOCAL VARIABLES FROM DATA STRUCTURE (for code readability)
    7294     5463106 :         if (!(fanOp == HVAC::FanOp::Continuous) && PartLoadRatio > 0.0) {
    7295      190375 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate =
    7296      190375 :                 state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirInletNodeNum).MassFlowRate / PartLoadRatio;
    7297             :         }
    7298             : 
    7299     5463106 :         state.dataVariableSpeedCoils->LoadSideMassFlowRate = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate;
    7300     5463106 :         state.dataVariableSpeedCoils->LoadSideInletDBTemp = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirDBTemp;
    7301     5463106 :         state.dataVariableSpeedCoils->LoadSideInletHumRat = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirHumRat;
    7302             : 
    7303     5463106 :         state.dataVariableSpeedCoils->LoadSideInletWBTemp = PsyTwbFnTdbWPb(state,
    7304     5463106 :                                                                            state.dataVariableSpeedCoils->LoadSideInletDBTemp,
    7305     5463106 :                                                                            state.dataVariableSpeedCoils->LoadSideInletHumRat,
    7306     5463106 :                                                                            state.dataEnvrn->OutBaroPress,
    7307             :                                                                            RoutineName);
    7308     5463106 :         state.dataVariableSpeedCoils->LoadSideInletEnth = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirEnthalpy;
    7309     5463106 :         CpAir = PsyCpAirFnW(state.dataVariableSpeedCoils->LoadSideInletHumRat);
    7310             : 
    7311     5463106 :         if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_HeatingAirToAirVariableSpeed) {
    7312             :             // Get condenser outdoor node info from DX Heating Coil
    7313      941295 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum != 0) {
    7314           0 :                 state.dataVariableSpeedCoils->OutdoorDryBulb =
    7315           0 :                     state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum).Temp;
    7316           0 :                 state.dataVariableSpeedCoils->OutdoorHumRat =
    7317           0 :                     state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum).HumRat;
    7318           0 :                 state.dataVariableSpeedCoils->OutdoorPressure =
    7319           0 :                     state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum).Press;
    7320           0 :                 state.dataVariableSpeedCoils->OutdoorWetBulb =
    7321           0 :                     state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum).OutAirWetBulb;
    7322             :             } else {
    7323      941295 :                 state.dataVariableSpeedCoils->OutdoorDryBulb = state.dataEnvrn->OutDryBulbTemp;
    7324      941295 :                 state.dataVariableSpeedCoils->OutdoorHumRat = state.dataEnvrn->OutHumRat;
    7325      941295 :                 state.dataVariableSpeedCoils->OutdoorPressure = state.dataEnvrn->OutBaroPress;
    7326      941295 :                 state.dataVariableSpeedCoils->OutdoorWetBulb = state.dataEnvrn->OutWetBulbTemp;
    7327             :             }
    7328      941295 :             state.dataVariableSpeedCoils->SourceSideMassFlowRate = 1.0; // not used and avoid divided by zero
    7329      941295 :             state.dataVariableSpeedCoils->SourceSideInletTemp = state.dataVariableSpeedCoils->OutdoorDryBulb;
    7330      941295 :             state.dataVariableSpeedCoils->SourceSideInletEnth =
    7331      941295 :                 PsyHFnTdbW(state.dataVariableSpeedCoils->OutdoorDryBulb, state.dataVariableSpeedCoils->OutdoorHumRat);
    7332      941295 :             CpSource = PsyCpAirFnW(state.dataEnvrn->OutHumRat);
    7333             : 
    7334             :             // Initialize crankcase heater, operates below OAT defined in input deck for HP DX heating coil
    7335      941295 :             if (state.dataVariableSpeedCoils->OutdoorDryBulb < state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MaxOATCrankcaseHeater) {
    7336      408681 :                 state.dataVariableSpeedCoils->CrankcaseHeatingPower = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterCapacity;
    7337      408681 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterCapacityCurveIndex > 0) {
    7338      125600 :                     state.dataVariableSpeedCoils->CrankcaseHeatingPower *=
    7339      125600 :                         Curve::CurveValue(state,
    7340      125600 :                                           state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterCapacityCurveIndex,
    7341      125600 :                                           state.dataEnvrn->OutDryBulbTemp);
    7342             :                 }
    7343             :             } else {
    7344      532614 :                 state.dataVariableSpeedCoils->CrankcaseHeatingPower = 0.0;
    7345             :             }
    7346             :         } else {
    7347     4521811 :             state.dataVariableSpeedCoils->SourceSideMassFlowRate = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterMassFlowRate;
    7348     4521811 :             state.dataVariableSpeedCoils->SourceSideInletTemp = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterTemp;
    7349     4521811 :             state.dataVariableSpeedCoils->SourceSideInletEnth = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterEnthalpy;
    7350             :             CpSource =
    7351     4521811 :                 GetSpecificHeatGlycol(state,
    7352     4521811 :                                       state.dataPlnt->PlantLoop(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).plantLoc.loopNum).FluidName,
    7353     4521811 :                                       state.dataVariableSpeedCoils->SourceSideInletTemp,
    7354     4521811 :                                       state.dataPlnt->PlantLoop(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).plantLoc.loopNum).FluidIndex,
    7355             :                                       RoutineNameSourceSideInletTemp);
    7356             :         }
    7357             : 
    7358             :         // Check for flows, do not perform simulation if no flow in load side or source side.
    7359     5463106 :         if ((state.dataVariableSpeedCoils->SourceSideMassFlowRate <= 0.0) || (state.dataVariableSpeedCoils->LoadSideMassFlowRate <= 0.0)) {
    7360     4042268 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SimFlag = false;
    7361     4042268 :             return;
    7362             :         } else {
    7363     1420838 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SimFlag = true;
    7364             :         }
    7365             : 
    7366     1605067 :         if ((state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_HeatingAirToAirVariableSpeed) &&
    7367      184229 :             (state.dataVariableSpeedCoils->OutdoorDryBulb < state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MinOATCompressor)) {
    7368      116357 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SimFlag = false;
    7369      116357 :             return;
    7370             :         }
    7371             : 
    7372     1304481 :         if (compressorOp == HVAC::CompressorOp::Off) {
    7373        2071 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SimFlag = false;
    7374        2071 :             return;
    7375             :         }
    7376             : 
    7377     1302410 :         if (SpeedNum > MaxSpeed) {
    7378           0 :             SpeedCal = MaxSpeed;
    7379             :         } else {
    7380     1302410 :             SpeedCal = SpeedNum;
    7381             :         }
    7382             : 
    7383     1302410 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac = 1.0;
    7384     1302410 :         state.dataHVACGlobal->OnOffFanPartLoadFraction = 1.0;
    7385     1302410 :         if ((SpeedNum == 1) && (PartLoadRatio < 1.0)) {
    7386      135369 :             PLF = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PLFFPLR, PartLoadRatio);
    7387      135369 :             if (PLF < 0.7) {
    7388           0 :                 PLF = 0.7;
    7389             :             }
    7390      135369 :             if (fanOp == HVAC::FanOp::Cycling)
    7391       20142 :                 state.dataHVACGlobal->OnOffFanPartLoadFraction =
    7392             :                     PLF; // save PLF for fan model, don't change fan power for constant fan mode if coil is off
    7393             :             // calculate the run time fraction
    7394      135369 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac = PartLoadRatio / PLF;
    7395      135369 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PartLoadRatio = PartLoadRatio;
    7396             : 
    7397      135369 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac > 1.0) {
    7398           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac = 1.0; // Reset coil runtime fraction to 1.0
    7399      135369 :             } else if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac < 0.0) {
    7400           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac = 0.0;
    7401             :             }
    7402             :         }
    7403             : 
    7404     1302410 :         if ((SpeedNum == 1) || (SpeedNum > MaxSpeed) || (SpeedRatio == 1.0)) {
    7405     1024211 :             AirMassFlowRatio =
    7406     1024211 :                 state.dataVariableSpeedCoils->LoadSideMassFlowRate / state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignAirMassFlowRate;
    7407             : 
    7408     1024211 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_HeatingAirToAirVariableSpeed) {
    7409       58819 :                 WaterMassFlowRatio = 1.0;
    7410             :             } else {
    7411      965392 :                 WaterMassFlowRatio = state.dataVariableSpeedCoils->SourceSideMassFlowRate /
    7412      965392 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignWaterMassFlowRate;
    7413             :             }
    7414             : 
    7415     4096844 :             TotCapTempModFac = CurveValue(state,
    7416     1024211 :                                           state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(SpeedCal),
    7417     1024211 :                                           state.dataVariableSpeedCoils->LoadSideInletDBTemp,
    7418     1024211 :                                           state.dataVariableSpeedCoils->SourceSideInletTemp);
    7419     1024211 :             TotCapAirFFModFac = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(SpeedCal), AirMassFlowRatio);
    7420             : 
    7421     1024211 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_HeatingAirToAirVariableSpeed) {
    7422       58819 :                 TotCapWaterFFModFac = 1.0;
    7423             :             } else {
    7424             :                 TotCapWaterFFModFac =
    7425      965392 :                     CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(SpeedCal), WaterMassFlowRatio);
    7426             :             }
    7427             : 
    7428     1024211 :             state.dataVariableSpeedCoils->QLoadTotal = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(SpeedCal) *
    7429     1024211 :                                                        TotCapTempModFac * TotCapAirFFModFac * TotCapWaterFFModFac;
    7430     1024211 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).capModFacTotal = TotCapTempModFac * TotCapAirFFModFac * TotCapWaterFFModFac;
    7431     2048422 :             state.dataVariableSpeedCoils->TotRatedCapacity =
    7432     1024211 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(SpeedCal); // for defrosting power cal
    7433             : 
    7434     4096844 :             EIRTempModFac = CurveValue(state,
    7435     1024211 :                                        state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(SpeedCal),
    7436     1024211 :                                        state.dataVariableSpeedCoils->LoadSideInletDBTemp,
    7437     1024211 :                                        state.dataVariableSpeedCoils->SourceSideInletTemp);
    7438     1024211 :             EIRAirFFModFac = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(SpeedCal), AirMassFlowRatio);
    7439             : 
    7440     1024211 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_HeatingAirToAirVariableSpeed) {
    7441       58819 :                 EIRWaterFFModFac = 1.0;
    7442             :             } else {
    7443             :                 EIRWaterFFModFac =
    7444      965392 :                     CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRWaterFFlow(SpeedCal), WaterMassFlowRatio);
    7445             :             }
    7446             : 
    7447     1024211 :             EIR = (1.0 / state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedCOP(SpeedCal)) * EIRTempModFac * EIRAirFFModFac *
    7448             :                   EIRWaterFFModFac;
    7449     1024211 :             state.dataVariableSpeedCoils->Winput = state.dataVariableSpeedCoils->QLoadTotal * EIR;
    7450             : 
    7451     1024211 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_HeatingAirToAirVariableSpeed) {
    7452       58819 :                 QWasteHeat = 0.0;
    7453             :             } else {
    7454      965392 :                 QWasteHeat = state.dataVariableSpeedCoils->Winput * state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeatFrac(SpeedCal);
    7455      965392 :                 QWasteHeat *= CurveValue(state,
    7456      965392 :                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeat(SpeedCal),
    7457      965392 :                                          state.dataVariableSpeedCoils->LoadSideInletDBTemp,
    7458      965392 :                                          state.dataVariableSpeedCoils->SourceSideInletTemp);
    7459             :             }
    7460             : 
    7461             :         } else {
    7462      278199 :             AirMassFlowRatio =
    7463      278199 :                 state.dataVariableSpeedCoils->LoadSideMassFlowRate / state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignAirMassFlowRate;
    7464             : 
    7465      278199 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_HeatingAirToAirVariableSpeed) {
    7466        8139 :                 WaterMassFlowRatio = 1.0;
    7467             :             } else {
    7468      270060 :                 WaterMassFlowRatio = state.dataVariableSpeedCoils->SourceSideMassFlowRate /
    7469      270060 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignWaterMassFlowRate;
    7470             :             }
    7471             : 
    7472      278199 :             SpeedCal = SpeedNum - 1;
    7473     1112796 :             TotCapTempModFac = CurveValue(state,
    7474      278199 :                                           state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(SpeedCal),
    7475      278199 :                                           state.dataVariableSpeedCoils->LoadSideInletDBTemp,
    7476      278199 :                                           state.dataVariableSpeedCoils->SourceSideInletTemp);
    7477      278199 :             TotCapAirFFModFac = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(SpeedCal), AirMassFlowRatio);
    7478             : 
    7479      278199 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_HeatingAirToAirVariableSpeed) {
    7480        8139 :                 TotCapWaterFFModFac = 1.0;
    7481             :             } else {
    7482             :                 TotCapWaterFFModFac =
    7483      270060 :                     CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(SpeedCal), WaterMassFlowRatio);
    7484             :             }
    7485             : 
    7486      278199 :             QLoadTotal1 = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(SpeedCal) * TotCapTempModFac * TotCapAirFFModFac *
    7487             :                           TotCapWaterFFModFac;
    7488             : 
    7489     1112796 :             EIRTempModFac = CurveValue(state,
    7490      278199 :                                        state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(SpeedCal),
    7491      278199 :                                        state.dataVariableSpeedCoils->LoadSideInletDBTemp,
    7492      278199 :                                        state.dataVariableSpeedCoils->SourceSideInletTemp);
    7493      278199 :             EIRAirFFModFac = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(SpeedCal), AirMassFlowRatio);
    7494             : 
    7495      278199 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_HeatingAirToAirVariableSpeed) {
    7496        8139 :                 EIRWaterFFModFac = 1.0;
    7497             :             } else {
    7498             :                 EIRWaterFFModFac =
    7499      270060 :                     CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRWaterFFlow(SpeedCal), WaterMassFlowRatio);
    7500             :             }
    7501             : 
    7502      278199 :             EIR = (1.0 / state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedCOP(SpeedCal)) * EIRTempModFac * EIRAirFFModFac *
    7503             :                   EIRWaterFFModFac;
    7504      278199 :             Winput1 = QLoadTotal1 * EIR;
    7505             : 
    7506      278199 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_HeatingAirToAirVariableSpeed) {
    7507        8139 :                 QWasteHeat1 = 0.0;
    7508             :             } else {
    7509      270060 :                 QWasteHeat1 = Winput1 * state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeatFrac(SpeedCal);
    7510      270060 :                 QWasteHeat1 *= CurveValue(state,
    7511      270060 :                                           state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeat(SpeedCal),
    7512      270060 :                                           state.dataVariableSpeedCoils->LoadSideInletDBTemp,
    7513      270060 :                                           state.dataVariableSpeedCoils->SourceSideInletTemp);
    7514             :             }
    7515             : 
    7516      278199 :             SpeedCal = SpeedNum;
    7517     1112796 :             TotCapTempModFac = CurveValue(state,
    7518      278199 :                                           state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(SpeedCal),
    7519      278199 :                                           state.dataVariableSpeedCoils->LoadSideInletDBTemp,
    7520      278199 :                                           state.dataVariableSpeedCoils->SourceSideInletTemp);
    7521      278199 :             TotCapAirFFModFac = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(SpeedCal), AirMassFlowRatio);
    7522             : 
    7523      278199 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_HeatingAirToAirVariableSpeed) {
    7524        8139 :                 TotCapWaterFFModFac = 1.0;
    7525             :             } else {
    7526             :                 TotCapWaterFFModFac =
    7527      270060 :                     CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(SpeedCal), WaterMassFlowRatio);
    7528             :             }
    7529             : 
    7530      278199 :             QLoadTotal2 = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(SpeedCal) * TotCapTempModFac * TotCapAirFFModFac *
    7531             :                           TotCapWaterFFModFac;
    7532             : 
    7533     1112796 :             EIRTempModFac = CurveValue(state,
    7534      278199 :                                        state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(SpeedCal),
    7535      278199 :                                        state.dataVariableSpeedCoils->LoadSideInletDBTemp,
    7536      278199 :                                        state.dataVariableSpeedCoils->SourceSideInletTemp);
    7537      278199 :             EIRAirFFModFac = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(SpeedCal), AirMassFlowRatio);
    7538             : 
    7539      278199 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_HeatingAirToAirVariableSpeed) {
    7540        8139 :                 EIRWaterFFModFac = 1.0;
    7541             :             } else {
    7542             :                 EIRWaterFFModFac =
    7543      270060 :                     CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRWaterFFlow(SpeedCal), WaterMassFlowRatio);
    7544             :             }
    7545             : 
    7546      278199 :             EIR = (1.0 / state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedCOP(SpeedCal)) * EIRTempModFac * EIRAirFFModFac *
    7547             :                   EIRWaterFFModFac;
    7548      278199 :             Winput2 = QLoadTotal2 * EIR;
    7549             : 
    7550      278199 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_HeatingAirToAirVariableSpeed) {
    7551        8139 :                 QWasteHeat2 = 0.0;
    7552             :             } else {
    7553      270060 :                 QWasteHeat2 = Winput2 * state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeatFrac(SpeedCal);
    7554      270060 :                 QWasteHeat2 *= CurveValue(state,
    7555      270060 :                                           state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeat(SpeedCal),
    7556      270060 :                                           state.dataVariableSpeedCoils->LoadSideInletDBTemp,
    7557      270060 :                                           state.dataVariableSpeedCoils->SourceSideInletTemp);
    7558             :             }
    7559             : 
    7560      278199 :             state.dataVariableSpeedCoils->QLoadTotal = QLoadTotal2 * SpeedRatio + (1.0 - SpeedRatio) * QLoadTotal1;
    7561      278199 :             state.dataVariableSpeedCoils->Winput = Winput2 * SpeedRatio + (1.0 - SpeedRatio) * Winput1;
    7562      278199 :             QWasteHeat = QWasteHeat2 * SpeedRatio + (1.0 - SpeedRatio) * QWasteHeat1;
    7563      278199 :             state.dataVariableSpeedCoils->TotRatedCapacity =
    7564      278199 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(SpeedCal) * SpeedRatio +
    7565      278199 :                 (1.0 - SpeedRatio) * state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(SpeedCal - 1);
    7566             :         }
    7567             : 
    7568     1302410 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterPower = 0.0; // necessary to clear zero for water source coils
    7569     1302410 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostPower = 0.0;         // clear the defrost power
    7570     1302410 :         if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_HeatingAirToAirVariableSpeed) {
    7571             :             // Calculating adjustment factors for defrost
    7572             :             // Calculate delta w through outdoor coil by assuming a coil temp of 0.82*DBT-9.7(F) per DOE2.1E
    7573       66958 :             state.dataVariableSpeedCoils->OutdoorCoilT = 0.82 * state.dataVariableSpeedCoils->OutdoorDryBulb - 8.589;
    7574       66958 :             state.dataVariableSpeedCoils->OutdoorCoildw =
    7575       66958 :                 max(1.0e-6,
    7576       66958 :                     (state.dataVariableSpeedCoils->OutdoorHumRat -
    7577       66958 :                      PsyWFnTdpPb(state, state.dataVariableSpeedCoils->OutdoorCoilT, state.dataVariableSpeedCoils->OutdoorPressure)));
    7578             : 
    7579             :             // Initializing defrost adjustment factors
    7580       66958 :             state.dataVariableSpeedCoils->LoadDueToDefrost = 0.0;
    7581       66958 :             state.dataVariableSpeedCoils->HeatingCapacityMultiplier = 1.0;
    7582       66958 :             state.dataVariableSpeedCoils->FractionalDefrostTime = 0.0;
    7583       66958 :             state.dataVariableSpeedCoils->InputPowerMultiplier = 1.0;
    7584             :             // Check outdoor temperature to determine of defrost is active
    7585       66958 :             if (state.dataVariableSpeedCoils->OutdoorDryBulb <= state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MaxOATDefrost) {
    7586             :                 // Calculate defrost adjustment factors depending on defrost control type
    7587           0 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostControl == Timed) {
    7588           0 :                     state.dataVariableSpeedCoils->FractionalDefrostTime = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostTime;
    7589           0 :                     if (state.dataVariableSpeedCoils->FractionalDefrostTime > 0.0) {
    7590           0 :                         state.dataVariableSpeedCoils->HeatingCapacityMultiplier = 0.909 - 107.33 * state.dataVariableSpeedCoils->OutdoorCoildw;
    7591           0 :                         state.dataVariableSpeedCoils->InputPowerMultiplier = 0.90 - 36.45 * state.dataVariableSpeedCoils->OutdoorCoildw;
    7592             :                     }
    7593             :                 } else { // else defrost control is on-demand
    7594           0 :                     state.dataVariableSpeedCoils->FractionalDefrostTime = 1.0 / (1.0 + 0.01446 / state.dataVariableSpeedCoils->OutdoorCoildw);
    7595           0 :                     state.dataVariableSpeedCoils->HeatingCapacityMultiplier = 0.875 * (1.0 - state.dataVariableSpeedCoils->FractionalDefrostTime);
    7596           0 :                     state.dataVariableSpeedCoils->InputPowerMultiplier = 0.954 * (1.0 - state.dataVariableSpeedCoils->FractionalDefrostTime);
    7597             :                 }
    7598             :                 // correction fractional defrost time shorten by runtime fraction
    7599           0 :                 state.dataVariableSpeedCoils->FractionalDefrostTime *= state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac;
    7600             : 
    7601           0 :                 if (state.dataVariableSpeedCoils->FractionalDefrostTime > 0.0) {
    7602             :                     // Calculate defrost adjustment factors depending on defrost control strategy
    7603           0 :                     if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostStrategy == ReverseCycle) {
    7604           0 :                         state.dataVariableSpeedCoils->LoadDueToDefrost = (0.01 * state.dataVariableSpeedCoils->FractionalDefrostTime) *
    7605           0 :                                                                          (7.222 - state.dataVariableSpeedCoils->OutdoorDryBulb) *
    7606           0 :                                                                          (state.dataVariableSpeedCoils->TotRatedCapacity / 1.01667);
    7607           0 :                         state.dataVariableSpeedCoils->DefrostEIRTempModFac =
    7608           0 :                             CurveValue(state,
    7609           0 :                                        state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostEIRFT,
    7610           0 :                                        max(15.555, state.dataVariableSpeedCoils->LoadSideInletWBTemp),
    7611           0 :                                        max(15.555, state.dataVariableSpeedCoils->OutdoorDryBulb));
    7612           0 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostPower =
    7613           0 :                             state.dataVariableSpeedCoils->DefrostEIRTempModFac * (state.dataVariableSpeedCoils->TotRatedCapacity / 1.01667) *
    7614           0 :                             state.dataVariableSpeedCoils->FractionalDefrostTime;
    7615             :                     } else { // Defrost strategy is resistive
    7616           0 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostPower =
    7617           0 :                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostCapacity *
    7618           0 :                             state.dataVariableSpeedCoils->FractionalDefrostTime;
    7619             :                     }
    7620             :                 } else { // Defrost is not active because (OutDryBulbTemp > VarSpeedCoil(DXCoilNum).MaxOATDefrost)
    7621           0 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostPower = 0.0;
    7622             :                 }
    7623             :             }
    7624             : 
    7625       66958 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterPower =
    7626       66958 :                 state.dataVariableSpeedCoils->CrankcaseHeatingPower * (1.0 - state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac);
    7627             :             //! Modify total heating capacity based on defrost heating capacity multiplier
    7628             :             //! MaxHeatCap passed from parent object VRF Condenser and is used to limit capacity of TU's to that available from condenser
    7629             :             //  IF(PRESENT(MaxHeatCap))THEN
    7630             :             //    TotCap = MIN(MaxHeatCap,TotCap * HeatingCapacityMultiplier)
    7631             :             //  ELSE
    7632             :             //    TotCap = TotCap * HeatingCapacityMultiplier
    7633             :             //  END IF
    7634      133916 :             state.dataVariableSpeedCoils->QLoadTotal =
    7635       66958 :                 state.dataVariableSpeedCoils->QLoadTotal * state.dataVariableSpeedCoils->HeatingCapacityMultiplier -
    7636       66958 :                 state.dataVariableSpeedCoils->LoadDueToDefrost;
    7637             :             // count the powr separately
    7638       66958 :             state.dataVariableSpeedCoils->Winput *= state.dataVariableSpeedCoils->InputPowerMultiplier; //+ VarSpeedCoil(DXCoilNum)%DefrostPower
    7639             :         }
    7640             : 
    7641     1302410 :         state.dataVariableSpeedCoils->QSource = state.dataVariableSpeedCoils->QLoadTotal + QWasteHeat - state.dataVariableSpeedCoils->Winput;
    7642     1302410 :         state.dataVariableSpeedCoils->QSensible = state.dataVariableSpeedCoils->QLoadTotal;
    7643             : 
    7644     1302410 :         if (state.dataVariableSpeedCoils->QSource < 0) {
    7645           0 :             state.dataVariableSpeedCoils->QSource = 0.0;
    7646           0 :             QWasteHeat = state.dataVariableSpeedCoils->Winput - state.dataVariableSpeedCoils->QLoadTotal;
    7647             :         }
    7648             : 
    7649             :         // calculate coil outlet state variables
    7650     2604820 :         state.dataVariableSpeedCoils->LoadSideOutletEnth =
    7651     1302410 :             state.dataVariableSpeedCoils->LoadSideInletEnth +
    7652     1302410 :             state.dataVariableSpeedCoils->QLoadTotal / state.dataVariableSpeedCoils->LoadSideMassFlowRate;
    7653     2604820 :         state.dataVariableSpeedCoils->LoadSideOutletDBTemp =
    7654     1302410 :             state.dataVariableSpeedCoils->LoadSideInletDBTemp +
    7655     1302410 :             state.dataVariableSpeedCoils->QSensible / (state.dataVariableSpeedCoils->LoadSideMassFlowRate * CpAir);
    7656     2604820 :         state.dataVariableSpeedCoils->LoadSideOutletHumRat =
    7657     1302410 :             PsyWFnTdbH(state, state.dataVariableSpeedCoils->LoadSideOutletDBTemp, state.dataVariableSpeedCoils->LoadSideOutletEnth, RoutineName);
    7658             : 
    7659             :         // Actual outlet conditions are "average" for time step
    7660     1302410 :         if (fanOp == HVAC::FanOp::Continuous) {
    7661             :             // continuous fan, cycling compressor
    7662     1224367 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirEnthalpy =
    7663     1224367 :                 PartLoadRatio * state.dataVariableSpeedCoils->LoadSideOutletEnth +
    7664     1224367 :                 (1.0 - PartLoadRatio) * state.dataVariableSpeedCoils->LoadSideInletEnth;
    7665     1224367 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirHumRat =
    7666     1224367 :                 PartLoadRatio * state.dataVariableSpeedCoils->LoadSideOutletHumRat +
    7667     1224367 :                 (1.0 - PartLoadRatio) * state.dataVariableSpeedCoils->LoadSideInletHumRat;
    7668     1224367 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirDBTemp =
    7669     1224367 :                 PsyTdbFnHW(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirEnthalpy,
    7670     1224367 :                            state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirHumRat);
    7671     1224367 :             state.dataVariableSpeedCoils->PLRCorrLoadSideMdot = state.dataVariableSpeedCoils->LoadSideMassFlowRate;
    7672             :         } else {
    7673             :             // default to cycling fan, cycling compressor
    7674       78043 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirEnthalpy = state.dataVariableSpeedCoils->LoadSideOutletEnth;
    7675       78043 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirHumRat = state.dataVariableSpeedCoils->LoadSideOutletHumRat;
    7676       78043 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirDBTemp = state.dataVariableSpeedCoils->LoadSideOutletDBTemp;
    7677       78043 :             state.dataVariableSpeedCoils->PLRCorrLoadSideMdot = state.dataVariableSpeedCoils->LoadSideMassFlowRate * PartLoadRatio;
    7678             :         }
    7679             : 
    7680             :         // scale heat transfer rates to PLR and power to RTF
    7681     1302410 :         state.dataVariableSpeedCoils->QLoadTotal *= PartLoadRatio;
    7682     1302410 :         state.dataVariableSpeedCoils->QSensible *= PartLoadRatio;
    7683             :         // count the powr separately
    7684     2604820 :         state.dataVariableSpeedCoils->Winput *=
    7685     1302410 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac; //+ VarSpeedCoil(DXCoilNum)%CrankcaseHeaterPower
    7686     1302410 :         state.dataVariableSpeedCoils->QSource *= PartLoadRatio;
    7687     1302410 :         QWasteHeat *= PartLoadRatio;
    7688             : 
    7689             :         // Update heat pump data structure
    7690     1302410 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Power = state.dataVariableSpeedCoils->Winput;
    7691     1302410 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLoadTotal = state.dataVariableSpeedCoils->QLoadTotal;
    7692     1302410 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSensible = state.dataVariableSpeedCoils->QSensible;
    7693     1302410 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSource = state.dataVariableSpeedCoils->QSource;
    7694     1302410 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Energy = state.dataVariableSpeedCoils->Winput * TimeStepSysSec;
    7695     1302410 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLoadTotal = state.dataVariableSpeedCoils->QLoadTotal * TimeStepSysSec;
    7696     1302410 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergySensible = state.dataVariableSpeedCoils->QSensible * TimeStepSysSec;
    7697     1302410 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLatent = 0.0;
    7698     1302410 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergySource = state.dataVariableSpeedCoils->QSource * TimeStepSysSec;
    7699     1302410 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterConsumption =
    7700     1302410 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterPower * TimeStepSysSec;
    7701     1302410 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostConsumption =
    7702     1302410 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostPower * TimeStepSysSec;
    7703     1302410 :         if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac == 0.0) {
    7704       32032 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).COP = 0.0;
    7705             :         } else {
    7706     1270378 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).COP =
    7707     1270378 :                 state.dataVariableSpeedCoils->QLoadTotal / state.dataVariableSpeedCoils->Winput;
    7708             :         }
    7709     1302410 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PartLoadRatio = PartLoadRatio;
    7710     1302410 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate = state.dataVariableSpeedCoils->PLRCorrLoadSideMdot;
    7711     1302410 :         rhoair = PsyRhoAirFnPbTdbW(state,
    7712     1302410 :                                    state.dataEnvrn->OutBaroPress,
    7713     1302410 :                                    state.dataVariableSpeedCoils->LoadSideInletDBTemp,
    7714     1302410 :                                    state.dataVariableSpeedCoils->LoadSideInletHumRat,
    7715             :                                    RoutineName);
    7716     1302410 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirVolFlowRate =
    7717     1302410 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate / rhoair;
    7718             : 
    7719     1302410 :         if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == HVAC::Coil_HeatingAirToAirVariableSpeed) {
    7720       66958 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterMassFlowRate = 0.0;
    7721       66958 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletWaterTemp = 0.0;
    7722       66958 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletWaterEnthalpy = 0.0;
    7723             :         } else {
    7724     1235452 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterMassFlowRate = state.dataVariableSpeedCoils->SourceSideMassFlowRate;
    7725     1235452 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletWaterTemp =
    7726     1235452 :                 state.dataVariableSpeedCoils->SourceSideInletTemp -
    7727     1235452 :                 state.dataVariableSpeedCoils->QSource / (state.dataVariableSpeedCoils->SourceSideMassFlowRate * CpSource);
    7728     1235452 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletWaterEnthalpy =
    7729     1235452 :                 state.dataVariableSpeedCoils->SourceSideInletEnth -
    7730     1235452 :                 state.dataVariableSpeedCoils->QSource / state.dataVariableSpeedCoils->SourceSideMassFlowRate;
    7731             :         }
    7732             : 
    7733     1302410 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QWasteHeat = QWasteHeat;
    7734             :     }
    7735             : 
    7736          61 :     Real64 GetCoilCapacityVariableSpeed(EnergyPlusData &state,
    7737             :                                         std::string const &CoilType, // must match coil types in this module
    7738             :                                         std::string const &CoilName, // must match coil names for the coil type
    7739             :                                         bool &ErrorsFound            // set to true if problem
    7740             :     )
    7741             :     {
    7742             : 
    7743             :         // FUNCTION INFORMATION:
    7744             :         //       AUTHOR         Bo Shen, based on WaterToAirHeatPumpSimple:GetCoilCapacity
    7745             :         //       DATE WRITTEN   March 2012
    7746             :         //       MODIFIED       na
    7747             :         //       RE-ENGINEERED  na
    7748             : 
    7749             :         // PURPOSE OF THIS FUNCTION:
    7750             :         // This function looks up the rated coil capacity at the nominal speed level for the given coil and returns it.  If
    7751             :         // incorrect coil type or name is given, ErrorsFound is returned as true and capacity is returned
    7752             :         // as negative.
    7753             : 
    7754             :         // Using/Aliasing
    7755             : 
    7756             :         // Return value
    7757             :         Real64 CoilCapacity; // returned capacity of matched coil
    7758             : 
    7759             :         // FUNCTION LOCAL VARIABLE DECLARATIONS:
    7760             :         int WhichCoil;
    7761             : 
    7762             :         // Obtains and Allocates WatertoAirHP related parameters from input file
    7763          61 :         if (state.dataVariableSpeedCoils->GetCoilsInputFlag) { // First time subroutine has been entered
    7764           0 :             GetVarSpeedCoilInput(state);
    7765             :             //    WaterIndex=FindGlycol('WATER') !Initialize the WaterIndex once
    7766           0 :             state.dataVariableSpeedCoils->GetCoilsInputFlag = false;
    7767             :         }
    7768             : 
    7769         104 :         if (Util::SameString(CoilType, "COIL:COOLING:WATERTOAIRHEATPUMP:VARIABLESPEEDEQUATIONFIT") ||
    7770          72 :             Util::SameString(CoilType, "COIL:HEATING:WATERTOAIRHEATPUMP:VARIABLESPEEDEQUATIONFIT") ||
    7771         140 :             Util::SameString(CoilType, "COIL:COOLING:DX:VARIABLESPEED") || Util::SameString(CoilType, "COIL:HEATING:DX:VARIABLESPEED") ||
    7772          68 :             Util::SameString(CoilType, "COIL:WATERHEATING:AIRTOWATERHEATPUMP:VARIABLESPEED")) {
    7773          61 :             WhichCoil = Util::FindItemInList(CoilName, state.dataVariableSpeedCoils->VarSpeedCoil);
    7774          61 :             if (WhichCoil != 0) {
    7775         108 :                 if (Util::SameString(CoilType, "COIL:HEATING:WATERTOAIRHEATPUMP:VARIABLESPEEDEQUATIONFIT") ||
    7776         108 :                     Util::SameString(CoilType, "COIL:HEATING:DX:VARIABLESPEED")) {
    7777          17 :                     CoilCapacity = state.dataVariableSpeedCoils->VarSpeedCoil(WhichCoil).RatedCapHeat;
    7778          44 :                 } else if (Util::SameString(CoilType, "COIL:WATERHEATING:AIRTOWATERHEATPUMP:VARIABLESPEED")) {
    7779           7 :                     CoilCapacity = state.dataVariableSpeedCoils->VarSpeedCoil(WhichCoil).RatedCapWH;
    7780             :                 } else {
    7781          37 :                     CoilCapacity = state.dataVariableSpeedCoils->VarSpeedCoil(WhichCoil).RatedCapCoolTotal;
    7782             :                 }
    7783             :             }
    7784             :         } else {
    7785           0 :             WhichCoil = 0;
    7786             :         }
    7787             : 
    7788          61 :         if (WhichCoil == 0) {
    7789           0 :             ShowSevereError(state, format("GetCoilCapacityVariableSpeed: Could not find CoilType=\"{}\" with Name=\"{}\"", CoilType, CoilName));
    7790           0 :             ErrorsFound = true;
    7791           0 :             CoilCapacity = -1000.0;
    7792             :         }
    7793             : 
    7794          61 :         return CoilCapacity;
    7795             :     }
    7796             : 
    7797          78 :     int GetCoilIndexVariableSpeed(EnergyPlusData &state,
    7798             :                                   std::string const &CoilType, // must match coil types in this module
    7799             :                                   std::string const &CoilName, // must match coil names for the coil type
    7800             :                                   bool &ErrorsFound            // set to true if problem
    7801             :     )
    7802             :     {
    7803             : 
    7804             :         // FUNCTION INFORMATION:
    7805             :         //       AUTHOR         Bo Shen, based on WaterToAirHeatPumpSimple:GetCoilIndex
    7806             :         //       DATE WRITTEN   March 2012
    7807             :         //       MODIFIED       na
    7808             :         //       RE-ENGINEERED  na
    7809             : 
    7810             :         // PURPOSE OF THIS FUNCTION:
    7811             :         // This function looks up the coil index for the given coil and returns it.  If
    7812             :         // incorrect coil type or name is given, ErrorsFound is returned as true and index is returned
    7813             :         // as zero.
    7814             : 
    7815             :         // Return value
    7816             :         int IndexNum; // returned index of matched coil
    7817             : 
    7818             :         // Obtains and Allocates WatertoAirHP related parameters from input file
    7819          78 :         if (state.dataVariableSpeedCoils->GetCoilsInputFlag) { // First time subroutine has been entered
    7820          20 :             GetVarSpeedCoilInput(state);
    7821             :             //    WaterIndex=FindGlycol('WATER') !Initialize the WaterIndex once
    7822          20 :             state.dataVariableSpeedCoils->GetCoilsInputFlag = false;
    7823             :         }
    7824             : 
    7825          78 :         IndexNum = Util::FindItemInList(CoilName, state.dataVariableSpeedCoils->VarSpeedCoil);
    7826             : 
    7827          78 :         if (IndexNum == 0) {
    7828           0 :             ShowSevereError(state, format("GetCoilIndexVariableSpeed: Could not find CoilType=\"{}\" with Name=\"{}\"", CoilType, CoilName));
    7829           0 :             ErrorsFound = true;
    7830             :         }
    7831             : 
    7832          78 :         return IndexNum;
    7833             :     }
    7834             : 
    7835          39 :     Real64 GetCoilAirFlowRateVariableSpeed(EnergyPlusData &state,
    7836             :                                            std::string const &CoilType, // must match coil types in this module
    7837             :                                            std::string const &CoilName, // must match coil names for the coil type
    7838             :                                            bool &ErrorsFound            // set to true if problem
    7839             :     )
    7840             :     {
    7841             : 
    7842             :         // FUNCTION INFORMATION:
    7843             :         //       AUTHOR         Bo Shen, based on WaterToAirHeatPumpSimple:GetCoilAirFlowRate
    7844             :         //       DATE WRITTEN   March 2012
    7845             :         //       MODIFIED       na
    7846             :         //       RE-ENGINEERED  na
    7847             : 
    7848             :         // PURPOSE OF THIS FUNCTION:
    7849             :         // This function looks up the max coil air flow rate for the given coil and returns it.  If
    7850             :         // incorrect coil type or name is given, ErrorsFound is returned as true and capacity is returned
    7851             :         // as negative.
    7852             : 
    7853             :         // Return value
    7854             :         Real64 CoilAirFlowRate; // returned air volume flow rate of matched coil
    7855             : 
    7856             :         // FUNCTION LOCAL VARIABLE DECLARATIONS:
    7857             :         int WhichCoil;
    7858             : 
    7859             :         // Obtains and Allocates WatertoAirHP related parameters from input file
    7860          39 :         if (state.dataVariableSpeedCoils->GetCoilsInputFlag) { // First time subroutine has been entered
    7861           0 :             GetVarSpeedCoilInput(state);
    7862             :             //    WaterIndex=FindGlycol('WATER') !Initialize the WaterIndex once
    7863           0 :             state.dataVariableSpeedCoils->GetCoilsInputFlag = false;
    7864             :         }
    7865             : 
    7866          64 :         if (Util::SameString(CoilType, "COIL:COOLING:WATERTOAIRHEATPUMP:VARIABLESPEEDEQUATIONFIT") ||
    7867          36 :             Util::SameString(CoilType, "COIL:HEATING:WATERTOAIRHEATPUMP:VARIABLESPEEDEQUATIONFIT") ||
    7868          75 :             Util::SameString(CoilType, "COIL:COOLING:DX:VARIABLESPEED") || Util::SameString(CoilType, "COIL:HEATING:DX:VARIABLESPEED") ||
    7869          39 :             Util::SameString(CoilType, "COIL:WATERHEATING:AIRTOWATERHEATPUMP:VARIABLESPEED")) {
    7870          39 :             WhichCoil = Util::FindItemInList(CoilName, state.dataVariableSpeedCoils->VarSpeedCoil);
    7871          39 :             if (WhichCoil != 0) {
    7872             :                 // CoilAirFlowRate=VarSpeedCoil(WhichCoil)%RatedAirVolFlowRate
    7873          39 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(WhichCoil).RatedAirVolFlowRate == AutoSize) { // means autosize
    7874           5 :                     CoilAirFlowRate = state.dataVariableSpeedCoils->VarSpeedCoil(WhichCoil).RatedAirVolFlowRate;
    7875             :                 } else {
    7876          34 :                     CoilAirFlowRate = state.dataVariableSpeedCoils->VarSpeedCoil(WhichCoil).MSRatedAirVolFlowRate(
    7877          34 :                                           state.dataVariableSpeedCoils->VarSpeedCoil(WhichCoil).NumOfSpeeds) /
    7878          34 :                                       state.dataVariableSpeedCoils->VarSpeedCoil(WhichCoil).MSRatedAirVolFlowRate(
    7879          34 :                                           state.dataVariableSpeedCoils->VarSpeedCoil(WhichCoil).NormSpedLevel) *
    7880          34 :                                       state.dataVariableSpeedCoils->VarSpeedCoil(WhichCoil).RatedAirVolFlowRate;
    7881             :                 } // use largest air flow rate
    7882             :             }
    7883             :         } else {
    7884           0 :             WhichCoil = 0;
    7885             :         }
    7886             : 
    7887          39 :         if (WhichCoil == 0) {
    7888           0 :             ShowSevereError(state, format("GetCoilAirFlowRateVariableSpeed: Could not find CoilType=\"{}\" with Name=\"{}\"", CoilType, CoilName));
    7889           0 :             ErrorsFound = true;
    7890           0 :             CoilAirFlowRate = -1000.0;
    7891             :         }
    7892             : 
    7893          39 :         return CoilAirFlowRate;
    7894             :     }
    7895             : 
    7896           7 :     int GetVSCoilPLFFPLR(EnergyPlusData &state,
    7897             :                          std::string const &CoilType, // must match coil types in this module
    7898             :                          std::string const &CoilName, // must match coil names for the coil type
    7899             :                          bool &ErrorsFound            // set to true if problem
    7900             :     )
    7901             :     {
    7902             : 
    7903             :         // FUNCTION INFORMATION:
    7904             :         //       AUTHOR         Bo Shen
    7905             :         //       DATE WRITTEN   12/2014
    7906             :         //       MODIFIED       na
    7907             :         //       RE-ENGINEERED  na
    7908             : 
    7909             :         // PURPOSE OF THIS FUNCTION:
    7910             :         // This function looks up the given coil and returns PLR curve index.  If
    7911             :         // incorrect coil type or name is given, ErrorsFound is returned as true and value is returned
    7912             :         // as zero.
    7913             : 
    7914             :         // Return value
    7915             :         int PLRNumber; // returned outlet node of matched coil
    7916             : 
    7917             :         // FUNCTION LOCAL VARIABLE DECLARATIONS:
    7918             :         int WhichCoil;
    7919             : 
    7920             :         // Obtains and Allocates WatertoAirHP related parameters from input file
    7921           7 :         if (state.dataVariableSpeedCoils->GetCoilsInputFlag) { // First time subroutine has been entered
    7922           0 :             GetVarSpeedCoilInput(state);
    7923             :             //    WaterIndex=FindGlycol('WATER') !Initialize the WaterIndex once
    7924           0 :             state.dataVariableSpeedCoils->GetCoilsInputFlag = false;
    7925             :         }
    7926             : 
    7927           7 :         WhichCoil = Util::FindItemInList(CoilName, state.dataVariableSpeedCoils->VarSpeedCoil);
    7928           7 :         if (WhichCoil != 0) {
    7929           7 :             PLRNumber = state.dataVariableSpeedCoils->VarSpeedCoil(WhichCoil).PLFFPLR;
    7930             :         }
    7931             : 
    7932           7 :         if (WhichCoil == 0) {
    7933           0 :             ShowSevereError(state, format("GetVSCoilPLFFPLR: Could not find CoilType=\"{}\" with Name=\"{}\"", CoilType, CoilName));
    7934           0 :             ErrorsFound = true;
    7935           0 :             PLRNumber = 0;
    7936             :         }
    7937             : 
    7938           7 :         return PLRNumber;
    7939             :     }
    7940             : 
    7941          14 :     int GetVSCoilCapFTCurveIndex(EnergyPlusData &state,
    7942             :                                  int const CoilIndex, // must match coil names for the coil type
    7943             :                                  bool &ErrorsFound    // set to true if problem
    7944             :     )
    7945             :     {
    7946             : 
    7947             :         // FUNCTION INFORMATION:
    7948             :         //       AUTHOR         Richard Raustad
    7949             :         //       DATE WRITTEN   7/2017
    7950             : 
    7951             :         // PURPOSE OF THIS FUNCTION:
    7952             :         // This function looks up the given coil and returns CapFT curve index.  If
    7953             :         // incorrect coil index is given, ErrorsFound is returned as true and value is returned
    7954             :         // as zero.
    7955             : 
    7956             :         // Return value
    7957             :         int CapFTIndex; // returned CapFT curve index of matched coil
    7958             : 
    7959             :         // Obtains and Allocates WatertoAirHP related parameters from input file
    7960          14 :         if (state.dataVariableSpeedCoils->GetCoilsInputFlag) { // First time subroutine has been entered
    7961           0 :             GetVarSpeedCoilInput(state);
    7962           0 :             state.dataVariableSpeedCoils->GetCoilsInputFlag = false;
    7963             :         }
    7964             : 
    7965          14 :         if (CoilIndex == 0) {
    7966           0 :             ShowSevereError(state, "GetVSCoilCapFTCurveIndex: Could not find Coil");
    7967           0 :             ErrorsFound = true;
    7968           0 :             CapFTIndex = 0;
    7969             :         } else {
    7970          14 :             CapFTIndex =
    7971          14 :                 state.dataVariableSpeedCoils->VarSpeedCoil(CoilIndex).MSCCapFTemp(state.dataVariableSpeedCoils->VarSpeedCoil(CoilIndex).NumOfSpeeds);
    7972             :         }
    7973             : 
    7974          14 :         return CapFTIndex;
    7975             :     }
    7976             : 
    7977        2453 :     int GetCoilInletNodeVariableSpeed(EnergyPlusData &state,
    7978             :                                       std::string const &CoilType, // must match coil types in this module
    7979             :                                       std::string const &CoilName, // must match coil names for the coil type
    7980             :                                       bool &ErrorsFound            // set to true if problem
    7981             :     )
    7982             :     {
    7983             : 
    7984             :         // FUNCTION INFORMATION:
    7985             :         //       AUTHOR         Bo Shen, based on WaterToAirHeatPumpSimple:GetCoilInletNode
    7986             :         //       DATE WRITTEN   March 2012
    7987             :         //       MODIFIED       na
    7988             :         //       RE-ENGINEERED  na
    7989             : 
    7990             :         // PURPOSE OF THIS FUNCTION:
    7991             :         // This function looks up the given coil and returns the inlet node.  If
    7992             :         // incorrect coil type or name is given, ErrorsFound is returned as true and value is returned
    7993             :         // as zero.
    7994             : 
    7995             :         // Return value
    7996             :         int NodeNumber; // returned outlet node of matched coil
    7997             : 
    7998             :         // FUNCTION LOCAL VARIABLE DECLARATIONS:
    7999             :         int WhichCoil;
    8000             : 
    8001             :         // Obtains and Allocates WatertoAirHP related parameters from input file
    8002        2453 :         if (state.dataVariableSpeedCoils->GetCoilsInputFlag) { // First time subroutine has been entered
    8003           0 :             GetVarSpeedCoilInput(state);
    8004             :             //    WaterIndex=FindGlycol('WATER') !Initialize the WaterIndex once
    8005           0 :             state.dataVariableSpeedCoils->GetCoilsInputFlag = false;
    8006             :         }
    8007             : 
    8008        2453 :         WhichCoil = Util::FindItemInList(CoilName, state.dataVariableSpeedCoils->VarSpeedCoil);
    8009        2453 :         if (WhichCoil != 0) {
    8010        2453 :             NodeNumber = state.dataVariableSpeedCoils->VarSpeedCoil(WhichCoil).AirInletNodeNum;
    8011             :         }
    8012             : 
    8013        2453 :         if (WhichCoil == 0) {
    8014           0 :             ShowSevereError(state, format("GetCoilInletNodeVariableSpeed: Could not find CoilType=\"{}\" with Name=\"{}\"", CoilType, CoilName));
    8015           0 :             ErrorsFound = true;
    8016           0 :             NodeNumber = 0;
    8017             :         }
    8018             : 
    8019        2453 :         return NodeNumber;
    8020             :     }
    8021             : 
    8022        2451 :     int GetCoilOutletNodeVariableSpeed(EnergyPlusData &state,
    8023             :                                        std::string const &CoilType, // must match coil types in this module
    8024             :                                        std::string const &CoilName, // must match coil names for the coil type
    8025             :                                        bool &ErrorsFound            // set to true if problem
    8026             :     )
    8027             :     {
    8028             : 
    8029             :         // FUNCTION INFORMATION:
    8030             :         //       AUTHOR         Bo Shen, based on WaterToAirHeatPumpSimple:GetCoilOutletNode
    8031             :         //       DATE WRITTEN   March 2012
    8032             :         //       MODIFIED       na
    8033             :         //       RE-ENGINEERED  na
    8034             : 
    8035             :         // PURPOSE OF THIS FUNCTION:
    8036             :         // This function looks up the given coil and returns the outlet node.  If
    8037             :         // incorrect coil type or name is given, ErrorsFound is returned as true and value is returned
    8038             :         // as zero.
    8039             : 
    8040             :         // Return value
    8041             :         int NodeNumber; // returned outlet node of matched coil
    8042             : 
    8043             :         // FUNCTION LOCAL VARIABLE DECLARATIONS:
    8044             :         int WhichCoil;
    8045             : 
    8046             :         // Obtains and Allocates WatertoAirHP related parameters from input file
    8047        2451 :         if (state.dataVariableSpeedCoils->GetCoilsInputFlag) { // First time subroutine has been entered
    8048           2 :             GetVarSpeedCoilInput(state);
    8049             :             //    WaterIndex=FindGlycol('WATER') !Initialize the WaterIndex once
    8050           2 :             state.dataVariableSpeedCoils->GetCoilsInputFlag = false;
    8051             :         }
    8052             : 
    8053        2451 :         WhichCoil = Util::FindItemInList(CoilName, state.dataVariableSpeedCoils->VarSpeedCoil);
    8054        2451 :         if (WhichCoil != 0) {
    8055        2451 :             NodeNumber = state.dataVariableSpeedCoils->VarSpeedCoil(WhichCoil).AirOutletNodeNum;
    8056             :         }
    8057             : 
    8058        2451 :         if (WhichCoil == 0) {
    8059           0 :             ShowSevereError(state, format("GetCoilOutletNodeVariableSpeed: Could not find CoilType=\"{}\" with Name=\"{}\"", CoilType, CoilName));
    8060           0 :             ErrorsFound = true;
    8061           0 :             NodeNumber = 0;
    8062             :         }
    8063             : 
    8064        2451 :         return NodeNumber;
    8065             :     }
    8066             : 
    8067          22 :     int GetVSCoilCondenserInletNode(EnergyPlusData &state,
    8068             :                                     std::string const &CoilName, // must match coil names for the coil type
    8069             :                                     bool &ErrorsFound            // set to true if problem
    8070             :     )
    8071             :     {
    8072             : 
    8073             :         // FUNCTION INFORMATION:
    8074             :         //       AUTHOR         Bo Shen, based on DXCoil:GetCoilCondenserInletNode
    8075             :         //       DATE WRITTEN   July 2012
    8076             :         //       MODIFIED       na
    8077             :         //       RE-ENGINEERED  na
    8078             : 
    8079             :         // PURPOSE OF THIS FUNCTION:
    8080             :         // This function looks up the given coil and returns the condenser inlet node.  If
    8081             :         // incorrect coil  name is given, ErrorsFound is returned as true.
    8082             : 
    8083             :         // Return value
    8084             :         int CondNode; // returned condenser node number of matched coil
    8085             : 
    8086             :         // FUNCTION LOCAL VARIABLE DECLARATIONS:
    8087             :         int WhichCoil;
    8088             : 
    8089             :         // Obtains and Allocates WatertoAirHP related parameters from input file
    8090          22 :         if (state.dataVariableSpeedCoils->GetCoilsInputFlag) { // First time subroutine has been entered
    8091           0 :             GetVarSpeedCoilInput(state);
    8092             :             //    WaterIndex=FindGlycol('WATER') !Initialize the WaterIndex once
    8093           0 :             state.dataVariableSpeedCoils->GetCoilsInputFlag = false;
    8094             :         }
    8095             : 
    8096          22 :         WhichCoil = Util::FindItemInList(CoilName, state.dataVariableSpeedCoils->VarSpeedCoil);
    8097          22 :         if (WhichCoil != 0) {
    8098          22 :             CondNode = state.dataVariableSpeedCoils->VarSpeedCoil(WhichCoil).CondenserInletNodeNum;
    8099             :         } else {
    8100           0 :             ShowSevereError(state, format("GetCoilCondenserInletNode: Invalid VS DX Coil, Type= VS DX Cooling Name=\"{}\"", CoilName));
    8101           0 :             ErrorsFound = true;
    8102           0 :             CondNode = 0;
    8103             :         }
    8104             : 
    8105          22 :         return CondNode;
    8106             :     }
    8107             : 
    8108          23 :     Real64 GetVSCoilMinOATCompressor(EnergyPlusData &state,
    8109             :                                      int const CoilIndex, // index to cooling coil
    8110             :                                      bool &ErrorsFound    // set to true if problem
    8111             :     )
    8112             :     {
    8113             :         // Obtains and Allocates WatertoAirHP related parameters from input file
    8114          23 :         if (state.dataVariableSpeedCoils->GetCoilsInputFlag) { // First time subroutine has been entered
    8115           0 :             GetVarSpeedCoilInput(state);
    8116           0 :             state.dataVariableSpeedCoils->GetCoilsInputFlag = false;
    8117             :         }
    8118             : 
    8119          23 :         if (CoilIndex == 0) {
    8120           0 :             ShowSevereError(state, "GetVSCoilMinOATCompressor: Index passed = 0");
    8121           0 :             ShowContinueError(state, "... returning Min OAT as -1000.");
    8122           0 :             ErrorsFound = true;
    8123           0 :             return -1000.0;
    8124             :         } else {
    8125          23 :             return state.dataVariableSpeedCoils->VarSpeedCoil(CoilIndex).MinOATCompressor;
    8126             :         }
    8127             :     }
    8128             : 
    8129       20930 :     int GetVSCoilNumOfSpeeds(EnergyPlusData &state,
    8130             :                              std::string const &CoilName, // must match coil names for the coil type
    8131             :                              bool &ErrorsFound            // set to true if problem
    8132             :     )
    8133             :     {
    8134             : 
    8135             :         // FUNCTION INFORMATION:
    8136             :         //       AUTHOR         Richard Raustad, FSEC
    8137             :         //       DATE WRITTEN   March 2013
    8138             :         //       MODIFIED       na
    8139             :         //       RE-ENGINEERED  na
    8140             : 
    8141             :         // PURPOSE OF THIS FUNCTION:
    8142             :         // This function looks up the given coil and returns number of speeds.  If
    8143             :         // incorrect coil name is given, ErrorsFound is returned as true.
    8144             : 
    8145             :         // Return value
    8146             :         int Speeds; // returned number of speeds
    8147             : 
    8148             :         // FUNCTION LOCAL VARIABLE DECLARATIONS:
    8149             :         int WhichCoil;
    8150             : 
    8151             :         // Obtains and Allocates WatertoAirHP related parameters from input file
    8152       20930 :         if (state.dataVariableSpeedCoils->GetCoilsInputFlag) { // First time subroutine has been entered
    8153           0 :             GetVarSpeedCoilInput(state);
    8154           0 :             state.dataVariableSpeedCoils->GetCoilsInputFlag = false;
    8155             :         }
    8156             : 
    8157       20930 :         WhichCoil = Util::FindItemInList(CoilName, state.dataVariableSpeedCoils->VarSpeedCoil);
    8158       20930 :         if (WhichCoil != 0) {
    8159       20930 :             Speeds = state.dataVariableSpeedCoils->VarSpeedCoil(WhichCoil).NumOfSpeeds;
    8160             :         } else {
    8161           0 :             ShowSevereError(state, format("GetVSCoilNumOfSpeeds: Invalid VS DX Coil, Type= VS DX Coil Name=\"{}\"", CoilName));
    8162           0 :             ErrorsFound = true;
    8163           0 :             Speeds = 0;
    8164             :         }
    8165             : 
    8166       20930 :         return Speeds;
    8167             :     }
    8168             : 
    8169          96 :     Real64 GetVSCoilRatedSourceTemp(EnergyPlusData &state, int const CoilIndex)
    8170             :     {
    8171          96 :         Real64 RatedSourceTemp = 0.0;
    8172          96 :         switch (state.dataVariableSpeedCoils->VarSpeedCoil(CoilIndex).VSCoilType) {
    8173          24 :         case HVAC::Coil_CoolingWaterToAirHPVSEquationFit: {
    8174          24 :             RatedSourceTemp = RatedInletWaterTemp;
    8175          24 :         } break;
    8176          21 :         case HVAC::Coil_HeatingWaterToAirHPVSEquationFit: {
    8177          21 :             RatedSourceTemp = RatedInletWaterTempHeat;
    8178          21 :         } break;
    8179          16 :         case HVAC::CoilDX_HeatPumpWaterHeaterVariableSpeed: {
    8180          16 :             RatedSourceTemp = state.dataVariableSpeedCoils->VarSpeedCoil(CoilIndex).WHRatedInletWaterTemp;
    8181          16 :         } break;
    8182          24 :         case HVAC::Coil_CoolingAirToAirVariableSpeed: {
    8183          24 :             RatedSourceTemp = RatedAmbAirTemp;
    8184          24 :         } break;
    8185          11 :         case HVAC::Coil_HeatingAirToAirVariableSpeed: {
    8186          11 :             RatedSourceTemp = RatedAmbAirTempHeat;
    8187          11 :         } break;
    8188           0 :         default: {
    8189           0 :             assert(false);
    8190             :         } break;
    8191             :         }
    8192          96 :         return RatedSourceTemp;
    8193             :     }
    8194             : 
    8195          36 :     void SetVarSpeedCoilData(EnergyPlusData &state,
    8196             :                              int const WSHPNum,                               // Number of OA Controller
    8197             :                              bool &ErrorsFound,                               // Set to true if certain errors found
    8198             :                              ObjexxFCL::Optional_int CompanionCoolingCoilNum, // Index to cooling coil for heating coil = SimpleWSHPNum
    8199             :                              ObjexxFCL::Optional_int CompanionHeatingCoilNum, // Index to heating coil for cooling coil = SimpleWSHPNum
    8200             :                              ObjexxFCL::Optional_int MSHPDesignSpecIndex      // index to UnitarySystemPerformance:Multispeed object
    8201             :     )
    8202             :     {
    8203             : 
    8204             :         // SUBROUTINE INFORMATION:
    8205             :         //       AUTHOR         Bo Shen, based on WaterToAirHeatPumpSimple:SetWSHPData
    8206             :         //       DATE WRITTEN   March 2012
    8207             :         //       MODIFIED       na
    8208             :         //       RE-ENGINEERED  na
    8209             : 
    8210             :         // PURPOSE OF THIS SUBROUTINE:
    8211             :         // This routine was designed to "push" information from a parent object to
    8212             :         // this WSHP coil object.
    8213             : 
    8214             :         // Obtains and Allocates WatertoAirHP related parameters from input file
    8215          36 :         if (state.dataVariableSpeedCoils->GetCoilsInputFlag) { // First time subroutine has been entered
    8216           0 :             GetVarSpeedCoilInput(state);
    8217             :             //    WaterIndex=FindGlycol('WATER') !Initialize the WaterIndex once
    8218           0 :             state.dataVariableSpeedCoils->GetCoilsInputFlag = false;
    8219             :         }
    8220             : 
    8221          36 :         if (WSHPNum <= 0 || WSHPNum > state.dataVariableSpeedCoils->NumVarSpeedCoils) {
    8222           0 :             ShowSevereError(state,
    8223           0 :                             format("SetVarSpeedCoilData: called with VS WSHP Coil Number out of range={} should be >0 and <{}",
    8224             :                                    WSHPNum,
    8225           0 :                                    state.dataVariableSpeedCoils->NumVarSpeedCoils));
    8226           0 :             ErrorsFound = true;
    8227           0 :             return;
    8228             :         }
    8229             : 
    8230          36 :         if (present(CompanionCoolingCoilNum)) {
    8231           0 :             state.dataVariableSpeedCoils->VarSpeedCoil(WSHPNum).CompanionCoolingCoilNum = CompanionCoolingCoilNum;
    8232           0 :             state.dataVariableSpeedCoils->VarSpeedCoil(WSHPNum).FindCompanionUpStreamCoil = true;
    8233           0 :             state.dataVariableSpeedCoils->VarSpeedCoil(CompanionCoolingCoilNum).CompanionHeatingCoilNum = WSHPNum;
    8234             :         }
    8235             : 
    8236          36 :         if (present(CompanionHeatingCoilNum)) {
    8237          23 :             state.dataVariableSpeedCoils->VarSpeedCoil(WSHPNum).CompanionHeatingCoilNum = CompanionHeatingCoilNum;
    8238          23 :             state.dataVariableSpeedCoils->VarSpeedCoil(CompanionHeatingCoilNum).CompanionCoolingCoilNum = WSHPNum;
    8239             :         }
    8240             : 
    8241          36 :         if (present(MSHPDesignSpecIndex)) {
    8242          13 :             state.dataVariableSpeedCoils->VarSpeedCoil(WSHPNum).MSHPDesignSpecIndex = MSHPDesignSpecIndex;
    8243             :         }
    8244             :     }
    8245             : 
    8246    45106592 :     void UpdateVarSpeedCoil(EnergyPlusData &state, int const DXCoilNum)
    8247             :     {
    8248             :         // SUBROUTINE INFORMATION:
    8249             :         //       AUTHOR         Bo Shen, based on WaterToAirHeatPumpSimple:UpdateSimpleWSHP
    8250             :         //       DATE WRITTEN   March 2012
    8251             :         //       MODIFIED       na
    8252             :         //       RE-ENGINEERED  na
    8253             : 
    8254             :         // PURPOSE OF THIS SUBROUTINE:
    8255             :         // This subroutine updates the Water to Air Heat Pump outlet nodes.
    8256             : 
    8257             :         // METHODOLOGY EMPLOYED:
    8258             :         // Data is moved from the HP data structure to the HP outlet nodes.
    8259             : 
    8260             :         // Using/Aliasing
    8261    45106592 :         Real64 TimeStepSysSec = state.dataHVACGlobal->TimeStepSysSec;
    8262             :         using PlantUtilities::SafeCopyPlantNode;
    8263             : 
    8264             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    8265             :         int AirInletNode;
    8266             :         int WaterInletNode;
    8267             :         int AirOutletNode;
    8268             :         int WaterOutletNode;
    8269             : 
    8270    45106592 :         auto &varSpeedCoil = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum);
    8271             : 
    8272             :         // WatertoAirHP(DXCoilNum)%SimFlag=.FALSE.
    8273    45106592 :         if (!varSpeedCoil.SimFlag) {
    8274             :             // Heatpump is off; just pass through conditions
    8275    13444957 :             varSpeedCoil.Power = 0.0;
    8276    13444957 :             varSpeedCoil.QLoadTotal = 0.0;
    8277    13444957 :             varSpeedCoil.QSensible = 0.0;
    8278    13444957 :             varSpeedCoil.QLatent = 0.0;
    8279    13444957 :             varSpeedCoil.QSource = 0.0;
    8280    13444957 :             varSpeedCoil.Energy = 0.0;
    8281    13444957 :             varSpeedCoil.EnergyLoadTotal = 0.0;
    8282    13444957 :             varSpeedCoil.EnergySensible = 0.0;
    8283    13444957 :             varSpeedCoil.EnergyLatent = 0.0;
    8284    13444957 :             varSpeedCoil.EnergySource = 0.0;
    8285    13444957 :             varSpeedCoil.COP = 0.0;
    8286    13444957 :             varSpeedCoil.RunFrac = 0.0;
    8287    13444957 :             varSpeedCoil.PartLoadRatio = 0.0;
    8288             : 
    8289    13444957 :             varSpeedCoil.OutletAirDBTemp = varSpeedCoil.InletAirDBTemp;
    8290    13444957 :             varSpeedCoil.OutletAirHumRat = varSpeedCoil.InletAirHumRat;
    8291    13444957 :             varSpeedCoil.OutletAirEnthalpy = varSpeedCoil.InletAirEnthalpy;
    8292    13444957 :             varSpeedCoil.OutletWaterTemp = varSpeedCoil.InletWaterTemp;
    8293    13444957 :             varSpeedCoil.OutletWaterEnthalpy = varSpeedCoil.InletWaterEnthalpy;
    8294             :         }
    8295             : 
    8296    45106592 :         AirInletNode = varSpeedCoil.AirInletNodeNum;
    8297    45106592 :         WaterInletNode = varSpeedCoil.WaterInletNodeNum;
    8298    45106592 :         AirOutletNode = varSpeedCoil.AirOutletNodeNum;
    8299    45106592 :         WaterOutletNode = varSpeedCoil.WaterOutletNodeNum;
    8300             : 
    8301             :         // Set the air outlet  nodes of the WatertoAirHPSimple
    8302    45106592 :         state.dataLoopNodes->Node(AirOutletNode).MassFlowRate = state.dataLoopNodes->Node(AirInletNode).MassFlowRate; // LoadSideMassFlowRate
    8303    45106592 :         state.dataLoopNodes->Node(AirOutletNode).Temp = varSpeedCoil.OutletAirDBTemp;
    8304    45106592 :         state.dataLoopNodes->Node(AirOutletNode).HumRat = varSpeedCoil.OutletAirHumRat;
    8305    45106592 :         state.dataLoopNodes->Node(AirOutletNode).Enthalpy = varSpeedCoil.OutletAirEnthalpy;
    8306             : 
    8307             :         // Set the air outlet nodes for properties that just pass through & not used
    8308    45106592 :         state.dataLoopNodes->Node(AirOutletNode).Quality = state.dataLoopNodes->Node(AirInletNode).Quality;
    8309    45106592 :         state.dataLoopNodes->Node(AirOutletNode).Press = state.dataLoopNodes->Node(AirInletNode).Press;
    8310    45106592 :         state.dataLoopNodes->Node(AirOutletNode).MassFlowRateMin = state.dataLoopNodes->Node(AirInletNode).MassFlowRateMin;
    8311    45106592 :         state.dataLoopNodes->Node(AirOutletNode).MassFlowRateMax = state.dataLoopNodes->Node(AirInletNode).MassFlowRateMax; // LoadSideMassFlowRate
    8312    45106592 :         state.dataLoopNodes->Node(AirOutletNode).MassFlowRateMinAvail = state.dataLoopNodes->Node(AirInletNode).MassFlowRateMinAvail;
    8313    45106592 :         state.dataLoopNodes->Node(AirOutletNode).MassFlowRateMaxAvail =
    8314    45106592 :             state.dataLoopNodes->Node(AirInletNode).MassFlowRateMaxAvail; // LoadSideMassFlowRate
    8315             : 
    8316             :         // Set the water outlet node of the WatertoAirHPSimple
    8317             :         // Set the water outlet nodes for properties that just pass through & not used
    8318    45106592 :         if (WaterInletNode != 0 && WaterOutletNode != 0) {
    8319    10730058 :             SafeCopyPlantNode(state, WaterInletNode, WaterOutletNode);
    8320    10730058 :             state.dataLoopNodes->Node(WaterOutletNode).Temp = varSpeedCoil.OutletWaterTemp;
    8321    10730058 :             state.dataLoopNodes->Node(WaterOutletNode).Enthalpy = varSpeedCoil.OutletWaterEnthalpy;
    8322             :         }
    8323             : 
    8324    45106592 :         varSpeedCoil.Energy = varSpeedCoil.Power * TimeStepSysSec;
    8325    45106592 :         varSpeedCoil.EnergyLoadTotal = varSpeedCoil.QLoadTotal * TimeStepSysSec;
    8326    45106592 :         varSpeedCoil.EnergySensible = varSpeedCoil.QSensible * TimeStepSysSec;
    8327    45106592 :         varSpeedCoil.EnergyLatent = varSpeedCoil.QLatent * TimeStepSysSec;
    8328    45106592 :         varSpeedCoil.EnergySource = varSpeedCoil.QSource * TimeStepSysSec;
    8329             : 
    8330    45106592 :         if (state.dataContaminantBalance->Contaminant.CO2Simulation) {
    8331           0 :             state.dataLoopNodes->Node(AirOutletNode).CO2 = state.dataLoopNodes->Node(AirInletNode).CO2;
    8332             :         }
    8333             : 
    8334    45106592 :         if (state.dataContaminantBalance->Contaminant.GenericContamSimulation) {
    8335           0 :             state.dataLoopNodes->Node(AirOutletNode).GenContam = state.dataLoopNodes->Node(AirInletNode).GenContam;
    8336             :         }
    8337             : 
    8338    45106592 :         if (varSpeedCoil.reportCoilFinalSizes) {
    8339     4764391 :             if (!state.dataGlobal->WarmupFlag && !state.dataGlobal->DoingHVACSizingSimulations && !state.dataGlobal->DoingSizing) {
    8340          77 :                 if (varSpeedCoil.VSCoilType == HVAC::Coil_CoolingWaterToAirHPVSEquationFit ||
    8341          59 :                     varSpeedCoil.VSCoilType == HVAC::Coil_CoolingAirToAirVariableSpeed) { // cooling coil
    8342          40 :                     state.dataRptCoilSelection->coilSelectionReportObj->setCoilFinalSizes(state,
    8343          40 :                                                                                           varSpeedCoil.Name,
    8344          40 :                                                                                           varSpeedCoil.VarSpeedCoilType,
    8345             :                                                                                           varSpeedCoil.RatedCapCoolTotal,
    8346             :                                                                                           varSpeedCoil.RatedCapCoolSens,
    8347             :                                                                                           varSpeedCoil.RatedAirVolFlowRate,
    8348             :                                                                                           varSpeedCoil.RatedWaterMassFlowRate);
    8349          37 :                 } else if (varSpeedCoil.VSCoilType == HVAC::Coil_HeatingWaterToAirHPVSEquationFit ||
    8350          19 :                            varSpeedCoil.VSCoilType == HVAC::Coil_HeatingAirToAirVariableSpeed) { // heating coil
    8351          27 :                     state.dataRptCoilSelection->coilSelectionReportObj->setCoilFinalSizes(state,
    8352          27 :                                                                                           varSpeedCoil.Name,
    8353          27 :                                                                                           varSpeedCoil.VarSpeedCoilType,
    8354             :                                                                                           varSpeedCoil.RatedCapHeat,
    8355             :                                                                                           varSpeedCoil.RatedCapHeat,
    8356             :                                                                                           varSpeedCoil.RatedAirVolFlowRate,
    8357             :                                                                                           varSpeedCoil.RatedWaterMassFlowRate);
    8358             :                 }
    8359          77 :                 varSpeedCoil.reportCoilFinalSizes = false;
    8360             :             }
    8361             :         }
    8362    45106592 :         if (varSpeedCoil.VSCoilType == HVAC::Coil_CoolingWaterToAirHPVSEquationFit ||
    8363    40584799 :             varSpeedCoil.VSCoilType == HVAC::Coil_CoolingAirToAirVariableSpeed) {
    8364             :             //  Add power to global variable so power can be summed by parent object
    8365    37957041 :             state.dataHVACGlobal->DXElecCoolingPower = varSpeedCoil.Power;
    8366     7149551 :         } else if (varSpeedCoil.VSCoilType == HVAC::Coil_HeatingWaterToAirHPVSEquationFit) {
    8367             :             //  Add power to global variable so power can be summed by parent object
    8368     4521793 :             state.dataHVACGlobal->DXElecHeatingPower = varSpeedCoil.Power;
    8369     2627758 :         } else if (varSpeedCoil.VSCoilType == HVAC::Coil_HeatingAirToAirVariableSpeed) {
    8370             :             //  Add power to global variable so power can be summed by parent object
    8371      941286 :             state.dataHVACGlobal->DXElecHeatingPower = varSpeedCoil.Power + varSpeedCoil.CrankcaseHeaterPower;
    8372      941286 :             state.dataHVACGlobal->DefrostElecPower = varSpeedCoil.DefrostPower;
    8373             :         }
    8374    45106592 :     }
    8375             : 
    8376       17082 :     Real64 CalcEffectiveSHR(EnergyPlusData &state,
    8377             :                             int const DXCoilNum,     // Index number for cooling coil
    8378             :                             Real64 const SHRss,      // Steady-state sensible heat ratio
    8379             :                             HVAC::FanOp const fanOp, // Fan/compressor cycling scheme indicator
    8380             :                             Real64 const RTF,        // Compressor run-time fraction
    8381             :                             Real64 const QLatRated,  // Rated latent capacity
    8382             :                             Real64 const QLatActual, // Actual latent capacity
    8383             :                             Real64 const EnteringDB, // Entering air dry-bulb temperature
    8384             :                             Real64 const EnteringWB  // Entering air wet-bulb temperature
    8385             :     )
    8386             :     {
    8387             : 
    8388             :         // FUNCTION INFORMATION:
    8389             :         //    AUTHOR         Bo Shen, based on WaterToAirHeatPumpSimple:CalcEffectiveSHR
    8390             :         //    DATE WRITTEN   March 2012
    8391             : 
    8392             :         // PURPOSE OF THIS FUNCTION:
    8393             :         //    Adjust sensible heat ratio to account for degradation of DX coil latent
    8394             :         //    capacity at part-load (cycling) conditions.
    8395             : 
    8396             :         // METHODOLOGY EMPLOYED:
    8397             :         //    With model parameters entered by the user, the part-load latent performance
    8398             :         //    of a DX cooling coil is determined for a constant air flow system with
    8399             :         //    a cooling coil that cycles on/off. The model calculates the time
    8400             :         //    required for condensate to begin falling from the cooling coil.
    8401             :         //    Runtimes greater than this are integrated to a "part-load" latent
    8402             :         //    capacity which is used to determine the "part-load" sensible heat ratio.
    8403             :         //    See reference below for additional details (linear decay model, Eq. 8b).
    8404             : 
    8405             :         //    For cycling fan operation, a modified version of Henderson and Rengarajan (1996)
    8406             :         //    model is used by ultilizing the fan delay time as the time-off (or time duration
    8407             :         //    for the re-evaporation of moisture from time coil). Refer to Tang, C.C. (2005)
    8408             : 
    8409             :         // REFERENCES:
    8410             :         // na
    8411             : 
    8412             :         // Return value
    8413             :         Real64 SHReff; // Effective sensible heat ratio, includes degradation due to cycling effects
    8414             : 
    8415             :         // FUNCTION LOCAL VARIABLE DECLARATIONS:
    8416             :         Real64 Twet; // Nominal time for condensate to begin leaving the coil's condensate drain line
    8417             :         // at the current operating conditions (sec)
    8418             :         Real64 Gamma; // Initial moisture evaporation rate divided by steady-state AC latent capacity
    8419             :         // at the current operating conditions
    8420             :         Real64 Twet_Rated;                 // Twet at rated conditions (coil air flow rate and air temperatures), sec
    8421             :         Real64 Gamma_Rated;                // Gamma at rated conditions (coil air flow rate and air temperatures)
    8422             :         Real64 Twet_max;                   // Maximum allowed value for Twet
    8423             :         Real64 MaxONOFFCyclesperHour;      // Maximum cycling rate of heat pump [cycles/hr]
    8424             :         Real64 LatentCapacityTimeConstant; // Latent capacity time constant [s]
    8425             :         Real64 FanDelayTime;               // Fan delay time, time delay for the HP's fan to
    8426             :         // shut off after compressor cycle off  [s]
    8427             :         Real64 Ton;     // Coil on time (sec)
    8428             :         Real64 Toff;    // Coil off time (sec)
    8429             :         Real64 Toffa;   // Actual coil off time (sec). Equations valid for Toff <= (2.0 * Twet/Gamma)
    8430             :         Real64 aa;      // Intermediate variable
    8431             :         Real64 To1;     // Intermediate variable (first guess at To). To = time to the start of moisture removal
    8432             :         Real64 To2;     // Intermediate variable (second guess at To). To = time to the start of moisture removal
    8433             :         Real64 Error;   // Error for iteration (DO) loop
    8434             :         Real64 LHRmult; // Latent Heat Ratio (LHR) multiplier. The effective latent heat ratio LHR = (1-SHRss)*LHRmult
    8435             : 
    8436       17082 :         Twet_Rated = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Twet_Rated;
    8437       17082 :         Gamma_Rated = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Gamma_Rated;
    8438       17082 :         MaxONOFFCyclesperHour = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MaxONOFFCyclesperHour;
    8439       17082 :         LatentCapacityTimeConstant = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).LatentCapacityTimeConstant;
    8440       17082 :         FanDelayTime = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).FanDelayTime;
    8441             : 
    8442             :         //  No moisture evaporation (latent degradation) occurs for runtime fraction of 1.0
    8443             :         //  All latent degradation model parameters cause divide by 0.0 if not greater than 0.0
    8444             :         //  Latent degradation model parameters initialize to 0.0 meaning no evaporation model used.
    8445       17082 :         if ((RTF >= 1.0) || (QLatRated == 0.0) || (QLatActual == 0.0) || (Twet_Rated <= 0.0) || (Gamma_Rated <= 0.0) ||
    8446       11521 :             (MaxONOFFCyclesperHour <= 0.0) || (LatentCapacityTimeConstant <= 0.0) || (RTF <= 0.0)) {
    8447        5561 :             SHReff = SHRss;
    8448        5561 :             return SHReff;
    8449             :         }
    8450             : 
    8451       11521 :         Twet_max = 9999.0; // high limit for Twet
    8452             : 
    8453             :         //  Calculate the model parameters at the actual operating conditions
    8454       11521 :         Twet = min(Twet_Rated * QLatRated / (QLatActual + 1.e-10), Twet_max);
    8455       11521 :         Gamma = Gamma_Rated * QLatRated * (EnteringDB - EnteringWB) / ((26.7 - 19.4) * QLatActual + 1.e-10);
    8456             : 
    8457             :         //  Calculate the compressor on and off times using a converntional thermostat curve
    8458       11521 :         Ton = 3600.0 / (4.0 * MaxONOFFCyclesperHour * (1.0 - RTF)); // duration of cooling coil on-cycle (sec)
    8459             : 
    8460       11521 :         if ((fanOp == HVAC::FanOp::Cycling) && (FanDelayTime != 0.0)) {
    8461             :             // For FanOp::Cycling, moisture is evaporated from the cooling coil back to the air stream
    8462             :             // until the fan cycle off. Assume no evaporation from the coil after the fan shuts off.
    8463           0 :             Toff = FanDelayTime;
    8464             :         } else {
    8465             :             // For FanOp::Continuous, moisture is evaporated from the cooling coil back to the air stream
    8466             :             // for the entire heat pump off-cycle.
    8467       11521 :             Toff = 3600.0 / (4.0 * MaxONOFFCyclesperHour * RTF); // duration of cooling coil off-cycle (sec)
    8468             :         }
    8469             : 
    8470             :         //  Cap Toff to meet the equation restriction
    8471       11521 :         if (Gamma > 0.0) {
    8472       11521 :             Toffa = min(Toff, 2.0 * Twet / Gamma);
    8473             :         } else {
    8474           0 :             Toffa = Toff;
    8475             :         }
    8476             : 
    8477             :         //  Use sucessive substitution to solve for To
    8478       11521 :         aa = (Gamma * Toffa) - (0.25 / Twet) * pow_2(Gamma) * pow_2(Toffa);
    8479             : 
    8480       11521 :         To1 = aa + LatentCapacityTimeConstant;
    8481       11521 :         Error = 1.0;
    8482       23624 :         while (Error > 0.001) {
    8483       12103 :             To2 = aa - LatentCapacityTimeConstant * (std::exp(-To1 / LatentCapacityTimeConstant) - 1.0);
    8484       12103 :             Error = std::abs((To2 - To1) / To1);
    8485       12103 :             To1 = To2;
    8486             :         }
    8487             : 
    8488             :         //  Adjust Sensible Heat Ratio (SHR) using Latent Heat Ratio (LHR) multiplier
    8489             :         //  Floating underflow errors occur when -Ton/LatentCapacityTimeConstant is a large negative number.
    8490             :         //  Cap lower limit at -700 to avoid the underflow errors.
    8491       11521 :         aa = std::exp(max(-700.0, -Ton / LatentCapacityTimeConstant));
    8492             :         //  Calculate latent heat ratio multiplier
    8493       11521 :         LHRmult = max(((Ton - To2) / (Ton + LatentCapacityTimeConstant * (aa - 1.0))), 0.0);
    8494             : 
    8495             :         //  Calculate part-load or "effective" sensible heat ratio
    8496       11521 :         SHReff = 1.0 - (1.0 - SHRss) * LHRmult;
    8497             : 
    8498       11521 :         if (SHReff < SHRss) SHReff = SHRss; // Effective SHR can be less than the steady-state SHR
    8499       11521 :         if (SHReff > 1.0) SHReff = 1.0;     // Effective sensible heat ratio can't be greater than 1.0
    8500             : 
    8501       11521 :         return SHReff;
    8502             :     }
    8503             : 
    8504    50324329 :     void CalcTotCapSHR_VSWSHP(EnergyPlusData &state,
    8505             :                               Real64 const InletDryBulb,       // inlet air dry bulb temperature [C]
    8506             :                               Real64 const InletHumRat,        // inlet air humidity ratio [kg water / kg dry air]
    8507             :                               Real64 const InletEnthalpy,      // inlet air specific enthalpy [J/kg]
    8508             :                               Real64 &InletWetBulb,            // inlet air wet bulb temperature [C]
    8509             :                               Real64 const AirMassFlowRatio,   // Ratio of actual air mass flow to nominal air mass flow
    8510             :                               Real64 const WaterMassFlowRatio, // Ratio of actual water mass flow to nominal water mass flow
    8511             :                               Real64 const AirMassFlow,        // actual mass flow for capacity and SHR calculation
    8512             :                               Real64 const CBF,                // coil bypass factor
    8513             :                               Real64 const TotCapNom1,         // nominal total capacity at low speed [W]
    8514             :                               int const CCapFTemp1,            // capacity modifier curve index, function of entering wetbulb at low speed
    8515             :                               int const CCapAirFFlow1,         // capacity modifier curve, function of actual air flow vs rated flow at low speed
    8516             :                               int const CCapWaterFFlow1,       // capacity modifier curve, function of actual water flow vs rated flow at low speed
    8517             :                               Real64 const TotCapNom2,         // nominal total capacity at high speed [W]
    8518             :                               int const CCapFTemp2,            // capacity modifier curve index, function of entering wetbulb at high speed
    8519             :                               int const CCapAirFFlow2,         // capacity modifier curve, function of actual air flow vs rated flow at high speed
    8520             :                               int const CCapWaterFFlow2,       // capacity modifier curve, function of actual water flow vs rated flow at high speed
    8521             :                               Real64 &TotCap1,                 // total capacity at the given conditions [W] at low speed
    8522             :                               Real64 &TotCap2,                 // total capacity at the given conditions [W] at high speed
    8523             :                               Real64 &TotCapSpeed,             // integrated total capacity corresponding to the speed ratio
    8524             :                               Real64 &SHR,                     // sensible heat ratio at the given conditions
    8525             :                               Real64 const CondInletTemp,      // Condenser inlet temperature [C]
    8526             :                               Real64 const Pressure,           // air pressure [Pa]
    8527             :                               Real64 const SpeedRatio,         // from 0.0 to 1.0
    8528             :                               int const NumSpeeds,             // number of speeds for input
    8529             :                               Real64 &TotCapModFac             // capacity modification factor, func of temp and func of flow
    8530             :     )
    8531             :     {
    8532             : 
    8533             :         // SUBROUTINE INFORMATION:
    8534             :         //       AUTHOR         Bo Shen, , based on DX:CalcTotCapSHR, introducing two speed levels
    8535             :         //       DATE WRITTEN   March 2012
    8536             : 
    8537             :         // PURPOSE OF THIS SUBROUTINE:
    8538             :         // Calculates total capacity and sensible heat ratio of a DX coil at the specified conditions
    8539             : 
    8540             :         // METHODOLOGY EMPLOYED:
    8541             :         // With the rated performance data entered by the user, the model employs some of the
    8542             :         // DOE-2.1E curve fits to adjust the capacity and SHR of the unit as a function
    8543             :         // of entering air temperatures and supply air flow rate (actual vs rated flow). The model
    8544             :         // does NOT employ the exact same methodology to calculate performance as DOE-2, although
    8545             :         // some of the DOE-2 curve fits are employed by this model.
    8546             : 
    8547             :         // The model checks for coil dryout conditions, and adjusts the calculated performance
    8548             :         // appropriately.
    8549             : 
    8550             :         // REFERENCES:
    8551             :         // ASHRAE HVAC 2 Toolkit page 4-81.
    8552             :         // Henderson, H.I. Jr., K. Rengarajan and D.B. Shirey, III. 1992.The impact of comfort
    8553             :         // control on air conditioner energy use in humid climates. ASHRAE Transactions 98(2):
    8554             :         // 104-113.
    8555             :         // Henderson, H.I. Jr., Danny Parker and Y.J. Huang. 2000.Improving DOE-2's RESYS routine:
    8556             :         // User Defined Functions to Provide More Accurate Part Load Energy Use and Humidity
    8557             :         // Predictions. Proceedings of ACEEE Conference.
    8558             : 
    8559             :         // Using/Aliasing
    8560             :         using Curve::CurveValue;
    8561             : 
    8562             :         // SUBROUTINE PARAMETER DEFINITIONS:
    8563             :         static constexpr std::string_view RoutineName("CalcTotCapSHR_VSWSHP");
    8564    50324329 :         constexpr int MaxIter(30);        // Maximum number of iterations for dry evaporator calculations
    8565    50324329 :         constexpr Real64 Tolerance(0.01); // Error tolerance for dry evaporator iterations
    8566             : 
    8567             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    8568             :         Real64 TotCapWaterFlowModFac1; // Total capacity modifier (function of actual supply water flow vs nominal flow) at low speed
    8569             :         Real64 TotCapTempModFac2;      // Total capacity modifier (function of entering wetbulb, outside water inlet temp) at high speed
    8570             :         Real64 TotCapAirFlowModFac2;   // Total capacity modifier (function of actual supply air flow vs nominal flow) at high speed
    8571             :         Real64 TotCapWaterFlowModFac2; // Total capacity modifier (function of actual supply water flow vs nominal flow) at high speed
    8572             :         Real64 TotCapCalc;             // temporary calculated value of total capacity [W]
    8573             :         Real64 TotCapCalc1;            // temporary calculated value of total capacity [W] at low speed
    8574             :         Real64 TotCapCalc2;            // temporary calculated value of total capacity [W] at high speed
    8575             : 
    8576    50324329 :         int Counter = 0;                        // Error tolerance for dry evaporator iterations
    8577    50324329 :         Real64 RF = 0.4;                        // Relaxation factor for dry evaporator iterations
    8578    50324329 :         Real64 werror = 0.0;                    // Deviation of humidity ratio in dry evaporator iteration loop
    8579    50324329 :         Real64 SHRCalc = SHR;                   // initialize temporary calculated value of SHR
    8580    50324329 :         Real64 InletWetBulbCalc = InletWetBulb; // calculated inlet wetbulb temperature used for finding dry coil point [C]
    8581    50324329 :         Real64 InletHumRatCalc = InletHumRat;   // calculated inlet humidity ratio used for finding dry coil point [kg water / kg dry air]
    8582    50324329 :         bool LoopOn = true;                     // flag to control the loop iteration
    8583             : 
    8584             :         //  LOOP WHILE (ABS(werror) .gt. Tolerance .OR. Counter == 0)
    8585   100743469 :         while (LoopOn) {
    8586             :             //   Get capacity modifying factor (function of inlet wetbulb & condenser inlet temp) for off-rated conditions
    8587    50419140 :             Real64 TotCapTempModFac1 = CurveValue(state, CCapFTemp1, InletWetBulbCalc, CondInletTemp);
    8588             :             //   Get capacity modifying factor (function of mass flow) for off-rated conditions
    8589    50419140 :             Real64 TotCapAirFlowModFac1 = CurveValue(state, CCapAirFFlow1, AirMassFlowRatio);
    8590             :             // Get capacity modifying factor (function of mass flow) for off-rated conditions
    8591    50419140 :             if (CCapWaterFFlow1 == 0) {
    8592    46525390 :                 TotCapWaterFlowModFac1 = 1.0;
    8593             :             } else {
    8594     3893750 :                 TotCapWaterFlowModFac1 = CurveValue(state, CCapWaterFFlow1, WaterMassFlowRatio);
    8595             :             }
    8596             : 
    8597             :             //   Get total capacity
    8598    50419140 :             if (NumSpeeds < 2) { // ONLY ONE SPEED
    8599    43355849 :                 TotCapCalc = TotCapNom1 * TotCapAirFlowModFac1 * TotCapWaterFlowModFac1 * TotCapTempModFac1;
    8600    43355849 :                 TotCapCalc1 = TotCapCalc;
    8601    43355849 :                 TotCapCalc2 = 0.0;
    8602    43355849 :                 TotCapModFac = TotCapAirFlowModFac1 * TotCapWaterFlowModFac1 * TotCapTempModFac1;
    8603             :             } else {
    8604     7063291 :                 TotCapTempModFac2 = CurveValue(state, CCapFTemp2, InletWetBulbCalc, CondInletTemp);
    8605     7063291 :                 TotCapAirFlowModFac2 = CurveValue(state, CCapAirFFlow2, AirMassFlowRatio);
    8606             : 
    8607     7063291 :                 if (CCapWaterFFlow2 == 0) {
    8608     6721333 :                     TotCapWaterFlowModFac2 = 1.0;
    8609             :                 } else {
    8610      341958 :                     TotCapWaterFlowModFac2 = CurveValue(state, CCapWaterFFlow2, WaterMassFlowRatio);
    8611             :                 }
    8612             : 
    8613     7063291 :                 TotCapCalc1 = TotCapNom1 * TotCapAirFlowModFac1 * TotCapWaterFlowModFac1 * TotCapTempModFac1;
    8614     7063291 :                 TotCapCalc2 = TotCapNom2 * TotCapAirFlowModFac2 * TotCapWaterFlowModFac2 * TotCapTempModFac2;
    8615             : 
    8616     7063291 :                 TotCapCalc = TotCapCalc2 * SpeedRatio + (1.0 - SpeedRatio) * TotCapCalc1;
    8617     7063291 :                 TotCapModFac = (TotCapAirFlowModFac2 * TotCapWaterFlowModFac2 * TotCapTempModFac2) * SpeedRatio +
    8618     7063291 :                                (1.0 - SpeedRatio) * (TotCapAirFlowModFac1 * TotCapWaterFlowModFac1 * TotCapTempModFac1);
    8619             :             }
    8620             : 
    8621    50419140 :             Real64 localCBF = max(0.0, CBF); // negative coil bypass factor is physically impossible
    8622             : 
    8623             :             //   Calculate apparatus dew point conditions using TotCap and CBF
    8624    50419140 :             Real64 hDelta = TotCapCalc / AirMassFlow;                       // Change in air enthalpy across the cooling coil [J/kg]
    8625    50419140 :             Real64 hADP = InletEnthalpy - hDelta / (1.0 - localCBF);        // Apparatus dew point enthalpy [J/kg]
    8626    50419140 :             Real64 tADP = PsyTsatFnHPb(state, hADP, Pressure, RoutineName); // Apparatus dew point temperature [C]
    8627    50419140 :             Real64 wADP = PsyWFnTdbH(state, tADP, hADP, RoutineName);       // Apparatus dew point humidity ratio [kg/kg]
    8628    50419140 :             Real64 hTinwADP = PsyHFnTdbW(InletDryBulb, wADP);               // Enthalpy at inlet dry-bulb and wADP [J/kg]
    8629    50419140 :             if (TotCapCalc > 1.0e-10) {
    8630    50419140 :                 SHRCalc = min((hTinwADP - hADP) / (InletEnthalpy - hADP), 1.0); // temporary calculated value of SHR
    8631             :             } else {
    8632           0 :                 SHRCalc = 1.0;
    8633             :             }
    8634             : 
    8635             :             //   Check for dry evaporator conditions (win < wadp)
    8636    50419140 :             if (wADP > InletHumRatCalc || (Counter >= 1 && Counter < MaxIter)) {
    8637      121166 :                 if (InletHumRatCalc == 0.0) InletHumRatCalc = 0.00001;
    8638      121166 :                 werror = (InletHumRatCalc - wADP) / InletHumRatCalc;
    8639             :                 //     Increase InletHumRatCalc at constant inlet air temp to find coil dry-out point. Then use the
    8640             :                 //     capacity at the dry-out point to determine exiting conditions from coil. This is required
    8641             :                 //     since the TotCapTempModFac doesn't work properly with dry-coil conditions.
    8642      121166 :                 InletHumRatCalc = RF * wADP + (1.0 - RF) * InletHumRatCalc;
    8643      121166 :                 InletWetBulbCalc = PsyTwbFnTdbWPb(state, InletDryBulb, InletHumRatCalc, Pressure);
    8644      121166 :                 ++Counter;
    8645      121166 :                 if (std::abs(werror) > Tolerance) {
    8646       94811 :                     LoopOn = true; // Recalculate with modified inlet conditions
    8647             :                 } else {
    8648       26355 :                     LoopOn = false;
    8649             :                 }
    8650             :             } else {
    8651    50297974 :                 LoopOn = false;
    8652             :             }
    8653             :         } // END LOOP
    8654             : 
    8655             :         //  Calculate full load output conditions
    8656    50324329 :         if (SHRCalc > 1.0 || Counter > 0) SHRCalc = 1.0; // if Counter > 0 means a dry coil so SHR = 1
    8657             : 
    8658    50324329 :         SHR = SHRCalc;
    8659    50324329 :         TotCap1 = TotCapCalc1;
    8660    50324329 :         TotCap2 = TotCapCalc2;
    8661    50324329 :         TotCapSpeed = TotCapCalc;
    8662    50324329 :         InletWetBulb = InletWetBulbCalc;
    8663    50324329 :     }
    8664             : 
    8665       20926 :     Real64 getVarSpeedPartLoadRatio(EnergyPlusData &state, int const DXCoilNum)
    8666             :     {
    8667       20926 :         return state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PartLoadRatio;
    8668             :     }
    8669             : 
    8670             : } // namespace VariableSpeedCoils
    8671             : 
    8672             : } // namespace EnergyPlus

Generated by: LCOV version 1.14