LCOV - code coverage report
Current view: top level - EnergyPlus - VariableSpeedCoils.cc (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 3267 4507 72.5 %
Date: 2023-01-17 19:17:23 Functions: 27 29 93.1 %

          Line data    Source code
       1             : // EnergyPlus, Copyright (c) 1996-2023, The Board of Trustees of the University of Illinois,
       2             : // The Regents of the University of California, through Lawrence Berkeley National Laboratory
       3             : // (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge
       4             : // National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other
       5             : // contributors. All rights reserved.
       6             : //
       7             : // NOTICE: This Software was developed under funding from the U.S. Department of Energy and the
       8             : // U.S. Government consequently retains certain rights. As such, the U.S. Government has been
       9             : // granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable,
      10             : // worldwide license in the Software to reproduce, distribute copies to the public, prepare
      11             : // derivative works, and perform publicly and display publicly, and to permit others to do so.
      12             : //
      13             : // Redistribution and use in source and binary forms, with or without modification, are permitted
      14             : // provided that the following conditions are met:
      15             : //
      16             : // (1) Redistributions of source code must retain the above copyright notice, this list of
      17             : //     conditions and the following disclaimer.
      18             : //
      19             : // (2) Redistributions in binary form must reproduce the above copyright notice, this list of
      20             : //     conditions and the following disclaimer in the documentation and/or other materials
      21             : //     provided with the distribution.
      22             : //
      23             : // (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory,
      24             : //     the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be
      25             : //     used to endorse or promote products derived from this software without specific prior
      26             : //     written permission.
      27             : //
      28             : // (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form
      29             : //     without changes from the version obtained under this License, or (ii) Licensee makes a
      30             : //     reference solely to the software portion of its product, Licensee must refer to the
      31             : //     software as "EnergyPlus version X" software, where "X" is the version number Licensee
      32             : //     obtained under this License and may not use a different name for the software. Except as
      33             : //     specifically required in this Section (4), Licensee shall not use in a company name, a
      34             : //     product name, in advertising, publicity, or other promotional activities any name, trade
      35             : //     name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly
      36             : //     similar designation, without the U.S. Department of Energy's prior written consent.
      37             : //
      38             : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
      39             : // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
      40             : // AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
      41             : // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
      42             : // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
      43             : // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
      44             : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
      45             : // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
      46             : // POSSIBILITY OF SUCH DAMAGE.
      47             : 
      48             : // C++ Headers
      49             : 
      50             : // ObjexxFCL Headers
      51             : #include <ObjexxFCL/Array.functions.hh>
      52             : #include <ObjexxFCL/Optional.hh>
      53             : 
      54             : // EnergyPlus Headers
      55             : #include <EnergyPlus/Autosizing/Base.hh>
      56             : #include <EnergyPlus/BranchNodeConnections.hh>
      57             : #include <EnergyPlus/CurveManager.hh>
      58             : #include <EnergyPlus/DXCoils.hh>
      59             : #include <EnergyPlus/Data/EnergyPlusData.hh>
      60             : #include <EnergyPlus/DataAirSystems.hh>
      61             : #include <EnergyPlus/DataContaminantBalance.hh>
      62             : #include <EnergyPlus/DataEnvironment.hh>
      63             : #include <EnergyPlus/DataHVACGlobals.hh>
      64             : #include <EnergyPlus/DataHeatBalance.hh>
      65             : #include <EnergyPlus/DataSizing.hh>
      66             : #include <EnergyPlus/DataWater.hh>
      67             : #include <EnergyPlus/Fans.hh>
      68             : #include <EnergyPlus/FluidProperties.hh>
      69             : #include <EnergyPlus/General.hh>
      70             : #include <EnergyPlus/GeneralRoutines.hh>
      71             : #include <EnergyPlus/GlobalNames.hh>
      72             : #include <EnergyPlus/HVACFan.hh>
      73             : #include <EnergyPlus/InputProcessing/InputProcessor.hh>
      74             : #include <EnergyPlus/NodeInputManager.hh>
      75             : #include <EnergyPlus/OutAirNodeManager.hh>
      76             : #include <EnergyPlus/OutputProcessor.hh>
      77             : #include <EnergyPlus/OutputReportPredefined.hh>
      78             : #include <EnergyPlus/PlantUtilities.hh>
      79             : #include <EnergyPlus/Psychrometrics.hh>
      80             : #include <EnergyPlus/ReportCoilSelection.hh>
      81             : #include <EnergyPlus/ScheduleManager.hh>
      82             : #include <EnergyPlus/UnitarySystem.hh>
      83             : #include <EnergyPlus/VariableSpeedCoils.hh>
      84             : #include <EnergyPlus/WaterManager.hh>
      85             : 
      86             : namespace EnergyPlus {
      87             : 
      88             : namespace VariableSpeedCoils {
      89             : 
      90             :     // Using/Aliasing
      91             :     using namespace DataLoopNode;
      92             :     using namespace Psychrometrics;
      93             :     using namespace DataSizing;
      94             :     using namespace DataHVACGlobals;
      95             : 
      96             :     using DXCoils::AdjustCBF;
      97             :     using DXCoils::CalcCBF;
      98             : 
      99             :     Real64 constexpr RatedInletAirTemp = 26.6667;       // 26.6667C or 80F
     100             :     Real64 constexpr RatedInletWetBulbTemp = 19.4444;   // 19.44 or 67F, cooling mode
     101             :     Real64 constexpr RatedInletAirHumRat = 0.0111847;   // Humidity ratio corresponding to 80F dry bulb/67F wet bulb
     102             :     Real64 constexpr RatedInletWaterTemp = 29.4444;     // 85 F cooling mode
     103             :     Real64 constexpr RatedAmbAirTemp = 35.0;            // 95 F cooling mode
     104             :     Real64 constexpr RatedInletAirTempHeat = 21.1111;   // 21.11C or 70F, heating mode
     105             :     Real64 constexpr RatedInletWaterTempHeat = 21.1111; // 21.11C or 70F, heating mode
     106             :     Real64 constexpr RatedAmbAirTempHeat = 8.3333;      // 8.33 or 47F, heating mode
     107             :     Real64 constexpr RatedAmbAirWBHeat = 6.1111;        // 8.33 or 43F, heating mode, rated wet bulb temperature
     108             :                                                         // Water Systems
     109             :     int constexpr CondensateDiscarded = 1001;           // default mode where water is "lost"
     110             :     int constexpr CondensateToTank = 1002;              // collect coil condensate from air and store in water storage tank
     111             : 
     112             :     int constexpr WaterSupplyFromMains = 101;
     113             :     int constexpr WaterSupplyFromTank = 102;
     114             : 
     115             :     // Defrost strategy (heat pump only)
     116             :     int constexpr ReverseCycle = 1; // uses reverse cycle defrost strategy
     117             :     int constexpr Resistive = 2;    // uses electric resistance heater for defrost
     118             :                                     // Defrost control  (heat pump only)
     119             :     int constexpr Timed = 1;        // defrost cycle is timed
     120             :     int constexpr OnDemand = 2;     // defrost cycle occurs only when required
     121             : 
     122    43381475 :     void SimVariableSpeedCoils(EnergyPlusData &state,
     123             :                                std::string_view CompName,              // Coil Name
     124             :                                int &CompIndex,                         // Index for Component name
     125             :                                int const CyclingScheme,                // Continuous fan OR cycling compressor
     126             :                                Real64 &MaxONOFFCyclesperHour,          // Maximum cycling rate of heat pump [cycles/hr]
     127             :                                Real64 &HPTimeConstant,                 // Heat pump time constant [s]
     128             :                                Real64 &FanDelayTime,                   // Fan delay time, time delay for the HP's fan to
     129             :                                CompressorOperation const CompressorOp, // compressor on/off. 0 = off; 1= on
     130             :                                Real64 const PartLoadFrac,
     131             :                                int const SpeedNum,                    // compressor speed number
     132             :                                Real64 const SpeedRatio,               // compressor speed ratio
     133             :                                Real64 const SensLoad,                 // Sensible demand load [W]
     134             :                                Real64 const LatentLoad,               // Latent demand load [W]
     135             :                                Optional<Real64 const> OnOffAirFlowRat // ratio of comp on to comp off air flow rate
     136             :     )
     137             :     {
     138             : 
     139             :         //       AUTHOR         Bo Shen, ORNL
     140             :         //       DATE WRITTEN   March 2012
     141             :         //       MODIFIED       Bo Shen, 12/2014, add variable-speed HPWH
     142             :         //       RE-ENGINEERED  na
     143             : 
     144             :         // PURPOSE OF THIS SUBROUTINE:
     145             :         // This subroutine manages variable-speed Water to Air Heat Pump component simulation.
     146             : 
     147             :         // Using/Aliasing
     148             :         using FluidProperties::FindGlycol;
     149             :         using General::SolveRoot;
     150             : 
     151             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     152             :         int DXCoilNum;            // The WatertoAirHP that you are currently loading input into
     153             :         Real64 OnOffAirFlowRatio; // ratio of comp on to comp off air flow rate
     154             :         Real64 RuntimeFrac;       // run time fraction
     155             :         int SpeedCal;             // variable for error proof speed input
     156             : 
     157             :         // Obtains and Allocates WatertoAirHP related parameters from input file
     158    43381475 :         if (state.dataVariableSpeedCoils->GetCoilsInputFlag) { // First time subroutine has been entered
     159           0 :             GetVarSpeedCoilInput(state);
     160           0 :             state.dataVariableSpeedCoils->GetCoilsInputFlag = false;
     161             :         }
     162             : 
     163    43381475 :         if (CompIndex == 0) {
     164           4 :             DXCoilNum = UtilityRoutines::FindItemInList(CompName, state.dataVariableSpeedCoils->VarSpeedCoil);
     165           4 :             if (DXCoilNum == 0) {
     166           0 :                 ShowFatalError(state, "WaterToAirHPVSWEquationFit not found=" + std::string{CompName});
     167             :             }
     168           4 :             CompIndex = DXCoilNum;
     169             :         } else {
     170    43381471 :             DXCoilNum = CompIndex;
     171    43381471 :             if (DXCoilNum > state.dataVariableSpeedCoils->NumVarSpeedCoils || DXCoilNum < 1) {
     172           0 :                 ShowFatalError(state,
     173           0 :                                format("SimVariableSpeedCoils: Invalid CompIndex passed={}, Number of Water to Air HPs={}, WaterToAir HP name={}",
     174             :                                       DXCoilNum,
     175           0 :                                       state.dataVariableSpeedCoils->NumVarSpeedCoils,
     176           0 :                                       CompName));
     177             :             }
     178    43381471 :             if (!CompName.empty() && CompName != state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name) {
     179           0 :                 ShowFatalError(
     180             :                     state,
     181           0 :                     format("SimVariableSpeedCoils: Invalid CompIndex passed={}, WaterToAir HP name={}, stored WaterToAir HP Name for that index={}",
     182             :                            DXCoilNum,
     183             :                            CompName,
     184           0 :                            state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name));
     185             :             }
     186             :         }
     187             : 
     188    43381475 :         if (present(OnOffAirFlowRat)) {
     189    43118494 :             OnOffAirFlowRatio = OnOffAirFlowRat;
     190             :         } else {
     191      262981 :             OnOffAirFlowRatio = 1.0;
     192             :         }
     193             : 
     194             :         // ERROR PROOF
     195    43381475 :         if (SpeedNum < 1) {
     196      404944 :             SpeedCal = 1;
     197             :         } else {
     198    42976531 :             SpeedCal = SpeedNum;
     199             :         }
     200             : 
     201    82259304 :         if ((state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == DataHVACGlobals::Coil_CoolingWaterToAirHPVSEquationFit) ||
     202    38877829 :             (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_CoolingAirToAirVariableSpeed)) {
     203             :             // Cooling mode
     204    36443687 :             InitVarSpeedCoil(state,
     205             :                              DXCoilNum,
     206             :                              MaxONOFFCyclesperHour,
     207             :                              HPTimeConstant,
     208             :                              FanDelayTime,
     209             :                              SensLoad,
     210             :                              LatentLoad,
     211             :                              CyclingScheme,
     212             :                              OnOffAirFlowRatio,
     213             :                              SpeedRatio,
     214             :                              SpeedCal);
     215    36443687 :             CalcVarSpeedCoilCooling(state,
     216             :                                     DXCoilNum,
     217             :                                     CyclingScheme,
     218             :                                     RuntimeFrac,
     219             :                                     SensLoad,
     220             :                                     LatentLoad,
     221             :                                     CompressorOp,
     222             :                                     PartLoadFrac,
     223             :                                     OnOffAirFlowRatio,
     224             :                                     SpeedRatio,
     225             :                                     SpeedCal);
     226    36443687 :             UpdateVarSpeedCoil(state, DXCoilNum);
     227     9371930 :         } else if ((state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == DataHVACGlobals::Coil_HeatingWaterToAirHPVSEquationFit) ||
     228     2434142 :                    (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_HeatingAirToAirVariableSpeed)) {
     229             :             // Heating mode
     230     5319729 :             InitVarSpeedCoil(state,
     231             :                              DXCoilNum,
     232             :                              MaxONOFFCyclesperHour,
     233             :                              HPTimeConstant,
     234             :                              FanDelayTime,
     235             :                              SensLoad,
     236             :                              LatentLoad,
     237             :                              CyclingScheme,
     238             :                              OnOffAirFlowRatio,
     239             :                              SpeedRatio,
     240             :                              SpeedCal);
     241     5319729 :             CalcVarSpeedCoilHeating(
     242             :                 state, DXCoilNum, CyclingScheme, RuntimeFrac, SensLoad, CompressorOp, PartLoadFrac, OnOffAirFlowRatio, SpeedRatio, SpeedCal);
     243     5319729 :             UpdateVarSpeedCoil(state, DXCoilNum);
     244     1618059 :         } else if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == CoilDX_HeatPumpWaterHeaterVariableSpeed) {
     245             :             // Heating mode
     246     1618059 :             InitVarSpeedCoil(state,
     247             :                              DXCoilNum,
     248             :                              MaxONOFFCyclesperHour,
     249             :                              HPTimeConstant,
     250             :                              FanDelayTime,
     251             :                              SensLoad,
     252             :                              LatentLoad,
     253             :                              CyclingScheme,
     254             :                              OnOffAirFlowRatio,
     255             :                              SpeedRatio,
     256             :                              SpeedCal);
     257     1618059 :             CalcVarSpeedHPWH(state, DXCoilNum, RuntimeFrac, PartLoadFrac, SpeedRatio, SpeedNum, CyclingScheme);
     258     1618059 :             UpdateVarSpeedCoil(state, DXCoilNum);
     259             :         } else {
     260           0 :             ShowFatalError(state, "SimVariableSpeedCoils: WatertoAir heatpump not in either HEATING or COOLING mode");
     261             :         }
     262             : 
     263             :         // two additional output variables
     264    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SpeedNumReport = SpeedCal;
     265    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SpeedRatioReport = SpeedRatio;
     266    43381475 :     }
     267             : 
     268          19 :     void GetVarSpeedCoilInput(EnergyPlusData &state)
     269             :     {
     270             : 
     271             :         // SUBROUTINE INFORMATION:
     272             :         //       AUTHOR         Bo Shen
     273             :         //       DATE WRITTEN   March, 2012
     274             :         //       MODIFIED       Bo Shen, 12/2014, add variable-speed HPWH
     275             :         //       RE-ENGINEERED  na
     276             : 
     277             :         // PURPOSE OF THIS SUBROUTINE:
     278             :         // Obtains input data for HPs and stores it in HP data structures
     279             : 
     280             :         // METHODOLOGY EMPLOYED:
     281             :         // Uses "Get" routines to read in data.
     282             : 
     283             :         // Using/Aliasing
     284             :         using namespace NodeInputManager;
     285             :         using BranchNodeConnections::TestCompSet;
     286             :         using GlobalNames::VerifyUniqueCoilName;
     287             :         using namespace OutputReportPredefined;
     288             :         using Curve::CurveValue;
     289             :         using Curve::GetCurveIndex;
     290             :         using Curve::SetCurveOutputMinMaxValues;
     291             : 
     292             :         using OutAirNodeManager::CheckOutAirNodeNumber;
     293             :         using ScheduleManager::GetScheduleIndex;
     294             :         using WaterManager::SetupTankDemandComponent;
     295             :         using WaterManager::SetupTankSupplyComponent;
     296             : 
     297             :         // SUBROUTINE PARAMETER DEFINITIONS:
     298             :         static constexpr std::string_view RoutineName("GetVarSpeedCoilInput: "); // include trailing blank space
     299             : 
     300             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     301             :         int DXCoilNum;         // The Water to Air HP that you are currently loading input into
     302             :         int NumCool;           // Counter for cooling coil, water source
     303             :         int NumCoolAS;         // Counter for cooling coil, air source
     304             :         int NumHeat;           // Counter for heating coil, water source
     305             :         int NumHeatAS;         // Counter for heating coil, air source
     306             :         int NumHPWHAirToWater; // counter for air source HPWH
     307             :         int CoilCounter;       // Counter
     308             :         int I;                 // Loop index increment
     309             :         int NumAlphas;         // Number of variables in String format
     310             :         int NumNums;           // Number of variables in Numeric format
     311             :         int NumParams;         // Total number of input fields
     312          19 :         int MaxNums(0);        // Maximum number of numeric input fields
     313          19 :         int MaxAlphas(0);      // Maximum number of alpha input fields
     314             :         int IOStat;
     315             :         int AlfaFieldIncre;              // increment number of Alfa field
     316          19 :         bool ErrorsFound(false);         // If errors detected in input
     317             :         Real64 CurveVal;                 // Used to verify modifier curves equal 1 at rated conditions
     318             :         Real64 WHInletAirTemp;           // Used to pass proper inlet air temp to HPWH DX coil performance curves
     319             :         Real64 WHInletWaterTemp;         // Used to pass proper inlet water temp to HPWH DX coil performance curves
     320          38 :         std::string CurrentModuleObject; // for ease in getting objects
     321          38 :         Array1D_string AlphArray;        // Alpha input items for object
     322          38 :         Array1D_string cAlphaFields;     // Alpha field names
     323          38 :         Array1D_string cNumericFields;   // Numeric field names
     324          38 :         Array1D<Real64> NumArray;        // Numeric input items for object
     325          38 :         Array1D_bool lAlphaBlanks;       // Logical array, alpha field input BLANK = .TRUE.
     326          38 :         Array1D_bool lNumericBlanks;     // Logical array, numeric field input BLANK = .TRUE.
     327             : 
     328          19 :         NumCool = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "COIL:COOLING:WATERTOAIRHEATPUMP:VARIABLESPEEDEQUATIONFIT");
     329          19 :         NumHeat = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "COIL:HEATING:WATERTOAIRHEATPUMP:VARIABLESPEEDEQUATIONFIT");
     330          19 :         NumCoolAS = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "COIL:COOLING:DX:VARIABLESPEED");
     331          19 :         NumHeatAS = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "COIL:HEATING:DX:VARIABLESPEED");
     332          19 :         NumHPWHAirToWater =
     333          38 :             state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "COIL:WATERHEATING:AIRTOWATERHEATPUMP:VARIABLESPEED");
     334          19 :         state.dataVariableSpeedCoils->NumVarSpeedCoils = NumCool + NumHeat + NumCoolAS + NumHeatAS + NumHPWHAirToWater;
     335          19 :         DXCoilNum = 0;
     336             : 
     337          19 :         if (state.dataVariableSpeedCoils->NumVarSpeedCoils <= 0) {
     338           0 :             ShowSevereError(state, "No Equipment found in GetVarSpeedCoilInput");
     339           0 :             ErrorsFound = true;
     340             :         }
     341             : 
     342             :         // Allocate Arrays
     343          19 :         if (state.dataVariableSpeedCoils->NumVarSpeedCoils > 0) {
     344          19 :             state.dataVariableSpeedCoils->VarSpeedCoil.allocate(state.dataVariableSpeedCoils->NumVarSpeedCoils);
     345          19 :             state.dataHeatBal->HeatReclaimVS_DXCoil.allocate(state.dataVariableSpeedCoils->NumVarSpeedCoils);
     346             :         }
     347             : 
     348          38 :         state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     349          19 :             state, "COIL:COOLING:WATERTOAIRHEATPUMP:VARIABLESPEEDEQUATIONFIT", NumParams, NumAlphas, NumNums);
     350          19 :         MaxNums = max(MaxNums, NumNums);
     351          19 :         MaxAlphas = max(MaxAlphas, NumAlphas);
     352          38 :         state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     353          19 :             state, "COIL:HEATING:WATERTOAIRHEATPUMP:VARIABLESPEEDEQUATIONFIT", NumParams, NumAlphas, NumNums);
     354          19 :         MaxNums = max(MaxNums, NumNums);
     355          19 :         MaxAlphas = max(MaxAlphas, NumAlphas);
     356             : 
     357          19 :         state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, "COIL:COOLING:DX:VARIABLESPEED", NumParams, NumAlphas, NumNums);
     358          19 :         MaxNums = max(MaxNums, NumNums);
     359          19 :         MaxAlphas = max(MaxAlphas, NumAlphas);
     360          19 :         state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, "COIL:HEATING:DX:VARIABLESPEED", NumParams, NumAlphas, NumNums);
     361          19 :         MaxNums = max(MaxNums, NumNums);
     362          19 :         MaxAlphas = max(MaxAlphas, NumAlphas);
     363             : 
     364             :         // variable speed air-source HPWH
     365          38 :         state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     366          19 :             state, "COIL:WATERHEATING:AIRTOWATERHEATPUMP:VARIABLESPEED", NumParams, NumAlphas, NumNums);
     367          19 :         MaxNums = max(MaxNums, NumNums);
     368          19 :         MaxAlphas = max(MaxAlphas, NumAlphas);
     369             : 
     370          19 :         AlphArray.allocate(MaxAlphas);
     371          19 :         cAlphaFields.allocate(MaxAlphas);
     372          19 :         lAlphaBlanks.dimension(MaxAlphas, true);
     373          19 :         cNumericFields.allocate(MaxNums);
     374          19 :         lNumericBlanks.dimension(MaxNums, true);
     375          19 :         NumArray.dimension(MaxNums, 0.0);
     376             : 
     377             :         // Get the data for cooling coil, WATER SOURCE
     378          19 :         CurrentModuleObject = "Coil:Cooling:WaterToAirHeatPump:VariableSpeedEquationFit"; // for reporting
     379             : 
     380          36 :         for (CoilCounter = 1; CoilCounter <= NumCool; ++CoilCounter) {
     381             : 
     382          17 :             ++DXCoilNum;
     383          17 :             AlfaFieldIncre = 1;
     384             : 
     385          17 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
     386             :                                                                      CurrentModuleObject,
     387             :                                                                      CoilCounter,
     388             :                                                                      AlphArray,
     389             :                                                                      NumAlphas,
     390             :                                                                      NumArray,
     391             :                                                                      NumNums,
     392             :                                                                      IOStat,
     393             :                                                                      lNumericBlanks,
     394             :                                                                      lAlphaBlanks,
     395             :                                                                      cAlphaFields,
     396             :                                                                      cNumericFields);
     397             : 
     398             :             // ErrorsFound will be set to True if problem was found, left untouched otherwise
     399          17 :             VerifyUniqueCoilName(state, CurrentModuleObject, AlphArray(1), ErrorsFound, CurrentModuleObject + " Name");
     400             : 
     401          17 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).bIsDesuperheater = false;
     402          17 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name = AlphArray(1);
     403          17 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CoolHeatType = "COOLING";
     404          17 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType = DataHVACGlobals::Coil_CoolingWaterToAirHPVSEquationFit;
     405          34 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VarSpeedCoilType =
     406          34 :                 DataHVACGlobals::cAllCoilTypes(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType);
     407          17 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds = int(NumArray(1));
     408          17 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel = int(NumArray(2));
     409          17 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedCapCoolTotal = NumArray(3);
     410          17 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedAirVolFlowRate = NumArray(4);
     411          17 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedWaterVolFlowRate = NumArray(5);
     412          17 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Twet_Rated = NumArray(6);
     413          17 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Gamma_Rated = NumArray(7);
     414          17 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HOTGASREHEATFLG = int(NumArray(8));
     415          17 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserType = DataHeatBalance::RefrigCondenserType::Water;
     416             : 
     417          17 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterInletNodeNum =
     418          34 :                 GetOnlySingleNode(state,
     419          17 :                                   AlphArray(2),
     420             :                                   ErrorsFound,
     421             :                                   DataLoopNode::ConnectionObjectType::CoilCoolingWaterToAirHeatPumpVariableSpeedEquationFit,
     422          17 :                                   AlphArray(1),
     423             :                                   DataLoopNode::NodeFluidType::Water,
     424             :                                   DataLoopNode::ConnectionType::Inlet,
     425             :                                   NodeInputManager::CompFluidStream::Secondary,
     426          17 :                                   ObjectIsNotParent);
     427          17 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterOutletNodeNum =
     428          34 :                 GetOnlySingleNode(state,
     429          17 :                                   AlphArray(3),
     430             :                                   ErrorsFound,
     431             :                                   DataLoopNode::ConnectionObjectType::CoilCoolingWaterToAirHeatPumpVariableSpeedEquationFit,
     432          17 :                                   AlphArray(1),
     433             :                                   DataLoopNode::NodeFluidType::Water,
     434             :                                   DataLoopNode::ConnectionType::Outlet,
     435             :                                   NodeInputManager::CompFluidStream::Secondary,
     436          17 :                                   ObjectIsNotParent);
     437          17 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirInletNodeNum =
     438          34 :                 GetOnlySingleNode(state,
     439          17 :                                   AlphArray(4),
     440             :                                   ErrorsFound,
     441             :                                   DataLoopNode::ConnectionObjectType::CoilCoolingWaterToAirHeatPumpVariableSpeedEquationFit,
     442          17 :                                   AlphArray(1),
     443             :                                   DataLoopNode::NodeFluidType::Air,
     444             :                                   DataLoopNode::ConnectionType::Inlet,
     445             :                                   NodeInputManager::CompFluidStream::Primary,
     446          17 :                                   ObjectIsNotParent);
     447          17 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirOutletNodeNum =
     448          34 :                 GetOnlySingleNode(state,
     449          17 :                                   AlphArray(5),
     450             :                                   ErrorsFound,
     451             :                                   DataLoopNode::ConnectionObjectType::CoilCoolingWaterToAirHeatPumpVariableSpeedEquationFit,
     452          17 :                                   AlphArray(1),
     453             :                                   DataLoopNode::NodeFluidType::Air,
     454             :                                   DataLoopNode::ConnectionType::Outlet,
     455             :                                   NodeInputManager::CompFluidStream::Primary,
     456          17 :                                   ObjectIsNotParent);
     457             : 
     458          17 :             TestCompSet(state, CurrentModuleObject, AlphArray(1), AlphArray(2), AlphArray(3), "Water Nodes");
     459          17 :             TestCompSet(state, CurrentModuleObject, AlphArray(1), AlphArray(4), AlphArray(5), "Air Nodes");
     460             : 
     461             :             //   If (VarSpeedCoil(DXCoilNum)%NumOfSpeeds .LT. 2) Then
     462          17 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds < 1) {
     463           0 :                 ShowSevereError(state,
     464           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name +
     465             :                                     "\", invalid");
     466           0 :                 ShowContinueError(state, format("...{} must be >= 1. entered number is {:.0T}", cNumericFields(1), NumArray(1)));
     467           0 :                 ErrorsFound = true;
     468             :             }
     469             : 
     470          34 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel >
     471          17 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds) {
     472           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel =
     473           0 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds;
     474             :             }
     475             : 
     476          34 :             if ((state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel >
     477          34 :                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds) ||
     478          17 :                 (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel <= 0)) {
     479           0 :                 ShowSevereError(state,
     480           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name +
     481             :                                     "\", invalid");
     482           0 :                 ShowContinueError(state, format("...{} must be valid speed level entered number is {:.0T}", cNumericFields(2), NumArray(2)));
     483           0 :                 ErrorsFound = true;
     484             :             }
     485             : 
     486             :             // part load curve
     487          17 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PLFFPLR = GetCurveIndex(state, AlphArray(6)); // convert curve name to number
     488          17 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PLFFPLR == 0) {
     489           0 :                 if (lAlphaBlanks(6)) {
     490           0 :                     ShowSevereError(state,
     491           0 :                                     std::string{RoutineName} + CurrentModuleObject + "=\"" +
     492           0 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", missing");
     493           0 :                     ShowContinueError(state, "...required " + cAlphaFields(6) + " is blank.");
     494             :                 } else {
     495           0 :                     ShowSevereError(state,
     496           0 :                                     std::string{RoutineName} + CurrentModuleObject + "=\"" +
     497           0 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", invalid");
     498           0 :                     ShowContinueError(state, "...not found " + cAlphaFields(6) + "=\"" + AlphArray(6) + "\".");
     499             :                 }
     500           0 :                 ErrorsFound = true;
     501             :             } else {
     502          17 :                 CurveVal = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PLFFPLR, 1.0);
     503          17 :                 if (CurveVal > 1.10 || CurveVal < 0.90) {
     504           0 :                     ShowWarningError(state,
     505           0 :                                      std::string{RoutineName} + CurrentModuleObject + "=\"" +
     506           0 :                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", curve values");
     507           0 :                     ShowContinueError(state, "..." + cAlphaFields(6) + " output is not equal to 1.0 (+ or - 10%) at rated conditions.");
     508           0 :                     ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
     509             :                 }
     510             :             }
     511             : 
     512         187 :             for (I = 1; I <= state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds; ++I) {
     513         170 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I) = NumArray(9 + (I - 1) * 6);
     514         170 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedSHR(I) = NumArray(10 + (I - 1) * 6);
     515         170 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedCOP(I) = NumArray(11 + (I - 1) * 6);
     516         170 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowRate(I) = NumArray(12 + (I - 1) * 6);
     517         170 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterVolFlowRate(I) = NumArray(13 + (I - 1) * 6);
     518         170 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeatFrac(I) = NumArray(14 + (I - 1) * 6);
     519             : 
     520         170 :                 AlfaFieldIncre = 7 + (I - 1) * 7;
     521         170 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(I) =
     522         170 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
     523         170 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(I) == 0) {
     524           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
     525           0 :                         ShowSevereError(state,
     526           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
     527           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", missing");
     528           0 :                         ShowContinueError(state, "...required " + cAlphaFields(AlfaFieldIncre) + " is blank.");
     529             :                     } else {
     530           0 :                         ShowSevereError(state,
     531           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
     532           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", invalid");
     533           0 :                         ShowContinueError(state, "...not found " + cAlphaFields(AlfaFieldIncre) + "=\"" + AlphArray(AlfaFieldIncre) + "\".");
     534             :                     }
     535           0 :                     ErrorsFound = true;
     536             :                 } else {
     537             :                     // Verify Curve Object, only legal type is BiQuadratic
     538         510 :                     ErrorsFound |= Curve::CheckCurveDims(state,
     539         170 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(I), // Curve index
     540             :                                                          {2},                                                                  // Valid dimensions
     541             :                                                          RoutineName,                                                          // Routine name
     542             :                                                          CurrentModuleObject,                                                  // Object Type
     543         170 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,           // Object Name
     544         170 :                                                          cAlphaFields(AlfaFieldIncre));                                        // Field Name
     545             : 
     546         170 :                     if (!ErrorsFound) {
     547         340 :                         CurveVal = CurveValue(
     548         170 :                             state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(I), RatedInletWetBulbTemp, RatedInletWaterTemp);
     549         170 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
     550           0 :                             ShowWarningError(state,
     551           0 :                                              std::string{RoutineName} + CurrentModuleObject + "=\"" +
     552           0 :                                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", curve values");
     553           0 :                             ShowContinueError(state,
     554           0 :                                               "..." + cAlphaFields(AlfaFieldIncre) + " output is not equal to 1.0 (+ or - 10%) at rated conditions.");
     555           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
     556             :                         }
     557             :                     }
     558             :                 }
     559             : 
     560         170 :                 AlfaFieldIncre = 8 + (I - 1) * 7;
     561         170 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(I) =
     562         170 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
     563         170 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(I) == 0) {
     564           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
     565           0 :                         ShowSevereError(state,
     566           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
     567           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", missing");
     568           0 :                         ShowContinueError(state, "...required " + cAlphaFields(AlfaFieldIncre) + " is blank.");
     569             :                     } else {
     570           0 :                         ShowSevereError(state,
     571           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
     572           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", invalid");
     573           0 :                         ShowContinueError(state, "...not found " + cAlphaFields(AlfaFieldIncre) + "=\"" + AlphArray(AlfaFieldIncre) + "\".");
     574             :                     }
     575           0 :                     ErrorsFound = true;
     576             :                 } else {
     577             :                     // Verify Curve Object, only legal type is Quadratic
     578         510 :                     ErrorsFound |= Curve::CheckCurveDims(state,
     579         170 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(I), // Curve index
     580             :                                                          {1},                                                                     // Valid dimensions
     581             :                                                          RoutineName,                                                             // Routine name
     582             :                                                          CurrentModuleObject,                                                     // Object Type
     583         170 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,              // Object Name
     584         170 :                                                          cAlphaFields(AlfaFieldIncre));                                           // Field Name
     585             : 
     586         170 :                     if (!ErrorsFound) {
     587         170 :                         CurveVal = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(I), 1.0);
     588         170 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
     589           0 :                             ShowWarningError(state,
     590           0 :                                              std::string{RoutineName} + CurrentModuleObject + "=\"" +
     591           0 :                                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", curve values");
     592           0 :                             ShowContinueError(state,
     593           0 :                                               "..." + cAlphaFields(AlfaFieldIncre) + " output is not equal to 1.0 (+ or - 10%) at rated conditions.");
     594           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
     595             :                         }
     596             :                     }
     597             :                 }
     598             : 
     599         170 :                 AlfaFieldIncre = 9 + (I - 1) * 7;
     600         170 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(I) =
     601         170 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
     602         170 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(I) == 0) {
     603           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
     604           0 :                         ShowSevereError(state,
     605           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
     606           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", missing");
     607           0 :                         ShowContinueError(state, "...required " + cAlphaFields(AlfaFieldIncre) + " is blank.");
     608             :                     } else {
     609           0 :                         ShowSevereError(state,
     610           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
     611           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", invalid");
     612           0 :                         ShowContinueError(state, "...not found " + cAlphaFields(AlfaFieldIncre) + "=\"" + AlphArray(AlfaFieldIncre) + "\".");
     613             :                     }
     614           0 :                     ErrorsFound = true;
     615             :                 } else {
     616             :                     // Verify Curve Object, only legal type is Quadratic
     617         510 :                     ErrorsFound |= Curve::CheckCurveDims(state,
     618         170 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(I), // Curve index
     619             :                                                          {1},                                                        // Valid dimensions
     620             :                                                          RoutineName,                                                // Routine name
     621             :                                                          CurrentModuleObject,                                        // Object Type
     622         170 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name, // Object Name
     623         170 :                                                          cAlphaFields(AlfaFieldIncre));                              // Field Name
     624             : 
     625         170 :                     if (!ErrorsFound) {
     626         170 :                         CurveVal = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(I), 1.0);
     627         170 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
     628           0 :                             ShowWarningError(state,
     629           0 :                                              std::string{RoutineName} + CurrentModuleObject + "=\"" +
     630           0 :                                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", curve values");
     631           0 :                             ShowContinueError(state,
     632           0 :                                               "..." + cAlphaFields(AlfaFieldIncre) + " output is not equal to 1.0 (+ or - 10%) at rated conditions.");
     633           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
     634             :                         }
     635             :                     }
     636             :                 }
     637             : 
     638         170 :                 AlfaFieldIncre = 10 + (I - 1) * 7;
     639         170 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(I) =
     640         170 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
     641         170 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(I) == 0) {
     642           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
     643           0 :                         ShowSevereError(state,
     644           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
     645           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", missing");
     646           0 :                         ShowContinueError(state, "...required " + cAlphaFields(AlfaFieldIncre) + " is blank.");
     647             :                     } else {
     648           0 :                         ShowSevereError(state,
     649           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
     650           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", invalid");
     651           0 :                         ShowContinueError(state, "...not found " + cAlphaFields(AlfaFieldIncre) + "=\"" + AlphArray(AlfaFieldIncre) + "\".");
     652             :                     }
     653           0 :                     ErrorsFound = true;
     654             :                 } else {
     655             :                     // Verify Curve Object, only legal type is BiQuadratic
     656         510 :                     ErrorsFound |= Curve::CheckCurveDims(state,
     657         170 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(I), // Curve index
     658             :                                                          {2},                                                                 // Valid dimensions
     659             :                                                          RoutineName,                                                         // Routine name
     660             :                                                          CurrentModuleObject,                                                 // Object Type
     661         170 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,          // Object Name
     662         170 :                                                          cAlphaFields(AlfaFieldIncre));                                       // Field Name
     663             : 
     664         170 :                     if (!ErrorsFound) {
     665         340 :                         CurveVal = CurveValue(
     666         170 :                             state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(I), RatedInletWetBulbTemp, RatedInletWaterTemp);
     667         170 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
     668           0 :                             ShowWarningError(state,
     669           0 :                                              std::string{RoutineName} + CurrentModuleObject + "=\"" +
     670           0 :                                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", curve values");
     671           0 :                             ShowContinueError(state,
     672           0 :                                               "..." + cAlphaFields(AlfaFieldIncre) + " output is not equal to 1.0 (+ or - 10%) at rated conditions.");
     673           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
     674             :                         }
     675             :                     }
     676             :                 }
     677             : 
     678         170 :                 AlfaFieldIncre = 11 + (I - 1) * 7;
     679         170 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(I) =
     680         170 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
     681         170 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(I) == 0) {
     682           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
     683           0 :                         ShowSevereError(state,
     684           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
     685           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", missing");
     686           0 :                         ShowContinueError(state, "...required " + cAlphaFields(AlfaFieldIncre) + " is blank.");
     687             :                     } else {
     688           0 :                         ShowSevereError(state,
     689           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
     690           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", invalid");
     691           0 :                         ShowContinueError(state, "...not found " + cAlphaFields(AlfaFieldIncre) + "=\"" + AlphArray(AlfaFieldIncre) + "\".");
     692             :                     }
     693           0 :                     ErrorsFound = true;
     694             :                 } else {
     695             :                     // Verify Curve Object, only legal type is Quadratic
     696         510 :                     ErrorsFound |= Curve::CheckCurveDims(state,
     697         170 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(I), // Curve index
     698             :                                                          {1},                                                                    // Valid dimensions
     699             :                                                          RoutineName,                                                            // Routine name
     700             :                                                          CurrentModuleObject,                                                    // Object Type
     701         170 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,             // Object Name
     702         170 :                                                          cAlphaFields(AlfaFieldIncre));                                          // Field Name
     703             : 
     704         170 :                     if (!ErrorsFound) {
     705         170 :                         CurveVal = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(I), 1.0);
     706         170 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
     707           0 :                             ShowWarningError(state,
     708           0 :                                              std::string{RoutineName} + CurrentModuleObject + "=\"" +
     709           0 :                                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", curve values");
     710           0 :                             ShowContinueError(state,
     711           0 :                                               "..." + cAlphaFields(AlfaFieldIncre) + " output is not equal to 1.0 (+ or - 10%) at rated conditions.");
     712           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
     713             :                         }
     714             :                     }
     715             :                 }
     716             : 
     717         170 :                 AlfaFieldIncre = 12 + (I - 1) * 7;
     718         170 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRWaterFFlow(I) =
     719         170 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
     720         170 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRWaterFFlow(I) == 0) {
     721           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
     722           0 :                         ShowSevereError(state,
     723           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
     724           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", missing");
     725           0 :                         ShowContinueError(state, "...required " + cAlphaFields(AlfaFieldIncre) + " is blank.");
     726             :                     } else {
     727           0 :                         ShowSevereError(state,
     728           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
     729           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", invalid");
     730           0 :                         ShowContinueError(state, "...not found " + cAlphaFields(AlfaFieldIncre) + "=\"" + AlphArray(AlfaFieldIncre) + "\".");
     731             :                     }
     732           0 :                     ErrorsFound = true;
     733             :                 } else {
     734             :                     // Verify Curve Object, only legal type is Quadratic
     735         510 :                     ErrorsFound |= Curve::CheckCurveDims(state,
     736         170 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRWaterFFlow(I), // Curve index
     737             :                                                          {1},                                                                      // Valid dimensions
     738             :                                                          RoutineName,                                                              // Routine name
     739             :                                                          CurrentModuleObject,                                                      // Object Type
     740         170 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,               // Object Name
     741         170 :                                                          cAlphaFields(AlfaFieldIncre));                                            // Field Name
     742             : 
     743         170 :                     if (!ErrorsFound) {
     744         170 :                         CurveVal = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRWaterFFlow(I), 1.0);
     745         170 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
     746           0 :                             ShowWarningError(state,
     747           0 :                                              std::string{RoutineName} + CurrentModuleObject + "=\"" +
     748           0 :                                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", curve values");
     749           0 :                             ShowContinueError(state,
     750           0 :                                               "..." + cAlphaFields(AlfaFieldIncre) + " output is not equal to 1.0 (+ or - 10%) at rated conditions.");
     751           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
     752             :                         }
     753             :                     }
     754             :                 }
     755             : 
     756         170 :                 AlfaFieldIncre = 13 + (I - 1) * 7;
     757             :                 // Read waste heat modifier curve name
     758         170 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeat(I) =
     759         170 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
     760         170 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeat(I) == 0) {
     761           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
     762           0 :                         ShowSevereError(state,
     763           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
     764           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", missing");
     765           0 :                         ShowContinueError(state, "...required " + cAlphaFields(AlfaFieldIncre) + " is blank.");
     766             :                     } else {
     767           0 :                         ShowSevereError(state,
     768           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
     769           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", invalid");
     770           0 :                         ShowContinueError(state, "...not found " + cAlphaFields(AlfaFieldIncre) + "=\"" + AlphArray(AlfaFieldIncre) + "\".");
     771             :                     }
     772           0 :                     ErrorsFound = true;
     773             :                 } else {
     774             :                     // Verify Curve Object, only legal types are BiQuadratic
     775         510 :                     ErrorsFound |= Curve::CheckCurveDims(state,
     776         170 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeat(I), // Curve index
     777             :                                                          {2},                                                                  // Valid dimensions
     778             :                                                          RoutineName,                                                          // Routine name
     779             :                                                          CurrentModuleObject,                                                  // Object Type
     780         170 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,           // Object Name
     781         170 :                                                          cAlphaFields(AlfaFieldIncre));                                        // Field Name
     782             : 
     783         170 :                     if (!ErrorsFound) {
     784         340 :                         CurveVal = CurveValue(
     785         170 :                             state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeat(I), RatedInletWaterTemp, RatedInletAirTemp);
     786         170 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
     787           0 :                             ShowWarningError(state,
     788           0 :                                              std::string{RoutineName} + CurrentModuleObject + "=\"" +
     789           0 :                                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", curve values");
     790           0 :                             ShowContinueError(state,
     791           0 :                                               "..." + cAlphaFields(AlfaFieldIncre) + " output is not equal to 1.0 (+ or - 10%) at rated conditions.");
     792           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
     793             :                         }
     794             :                     }
     795             :                 }
     796             :             }
     797             : 
     798         187 :             for (I = 1; I <= state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds; ++I) {
     799         170 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedPercentTotCap(I) =
     800         340 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I) /
     801         340 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(
     802         170 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds);
     803         170 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowPerRatedTotCap(I) =
     804         340 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowRate(I) /
     805         170 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I);
     806         170 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterVolFlowPerRatedTotCap(I) =
     807         340 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterVolFlowRate(I) /
     808         170 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I);
     809             :             }
     810             : 
     811             :             // CurrentModuleObject = "Coil:Cooling:WaterToAirHeatPump:VariableSpeedEquationFit"
     812          68 :             SetupOutputVariable(state,
     813             :                                 "Cooling Coil Electricity Energy",
     814             :                                 OutputProcessor::Unit::J,
     815          17 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Energy,
     816             :                                 OutputProcessor::SOVTimeStepType::System,
     817             :                                 OutputProcessor::SOVStoreType::Summed,
     818          17 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
     819             :                                 _,
     820             :                                 "Electricity",
     821             :                                 "Cooling",
     822             :                                 _,
     823          17 :                                 "System");
     824          68 :             SetupOutputVariable(state,
     825             :                                 "Cooling Coil Total Cooling Energy",
     826             :                                 OutputProcessor::Unit::J,
     827          17 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLoadTotal,
     828             :                                 OutputProcessor::SOVTimeStepType::System,
     829             :                                 OutputProcessor::SOVStoreType::Summed,
     830          17 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
     831             :                                 _,
     832             :                                 "ENERGYTRANSFER",
     833             :                                 "COOLINGCOILS",
     834             :                                 _,
     835          17 :                                 "System");
     836          68 :             SetupOutputVariable(state,
     837             :                                 "Cooling Coil Sensible Cooling Energy",
     838             :                                 OutputProcessor::Unit::J,
     839          17 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergySensible,
     840             :                                 OutputProcessor::SOVTimeStepType::System,
     841             :                                 OutputProcessor::SOVStoreType::Summed,
     842          34 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
     843          68 :             SetupOutputVariable(state,
     844             :                                 "Cooling Coil Latent Cooling Energy",
     845             :                                 OutputProcessor::Unit::J,
     846          17 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLatent,
     847             :                                 OutputProcessor::SOVTimeStepType::System,
     848             :                                 OutputProcessor::SOVStoreType::Summed,
     849          34 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
     850          68 :             SetupOutputVariable(state,
     851             :                                 "Cooling Coil Source Side Heat Transfer Energy",
     852             :                                 OutputProcessor::Unit::J,
     853          17 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergySource,
     854             :                                 OutputProcessor::SOVTimeStepType::System,
     855             :                                 OutputProcessor::SOVStoreType::Summed,
     856          17 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
     857             :                                 _,
     858             :                                 "PLANTLOOPCOOLINGDEMAND",
     859             :                                 "COOLINGCOILS",
     860             :                                 _,
     861          17 :                                 "System");
     862             : 
     863             :             // for table output, being consistent with outher water-to-air coils
     864             :             //        IF (VarSpeedCoil(DXCoilNum)%RatedCapCoolTotal /= AutoSize) THEN
     865             :             //            VarSpeedCoil(DXCoilNum)%RatedCapCoolSens = VarSpeedCoil(DXCoilNum)%RatedCapCoolTotal &
     866             :             //                *VarSpeedCoil(DXCoilNum)%MSRatedSHR(VarSpeedCoil(DXCoilNum)%NormSpedLevel)
     867             :             //        ELSE
     868             :             //            VarSpeedCoil(DXCoilNum)%RatedCapCoolSens = AUTOSIZE
     869             :             //        END IF
     870             : 
     871          17 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedCapCoolSens =
     872             :                 AutoSize; // always auto-sized, to be determined in the sizing calculation
     873             : 
     874             :             // BAN Sept 30 2103, CR9322, commented out, now it is redundant, it is reported from sizing routine
     875             :             // create predefined report entries
     876             :             // PreDefTableEntry(state,  pdchCoolCoilType, VarSpeedCoil( DXCoilNum ).Name, CurrentModuleObject );
     877             :             // PreDefTableEntry(state,  pdchCoolCoilTotCap, VarSpeedCoil( DXCoilNum ).Name, VarSpeedCoil( DXCoilNum ).RatedCapCoolTotal );
     878             :             // PreDefTableEntry(state,  pdchCoolCoilSensCap, VarSpeedCoil( DXCoilNum ).Name, VarSpeedCoil( DXCoilNum ).RatedCapCoolSens );
     879             :             // PreDefTableEntry(state,  pdchCoolCoilLatCap, VarSpeedCoil( DXCoilNum ).Name, VarSpeedCoil( DXCoilNum ).RatedCapCoolTotal -
     880             :             // VarSpeedCoil( DXCoilNum ).RatedCapCoolSens );  PreDefTableEntry(state,  pdchCoolCoilSHR, VarSpeedCoil( DXCoilNum ).Name, VarSpeedCoil(
     881             :             // DXCoilNum
     882             :             // ).RatedCapCoolSens / VarSpeedCoil( DXCoilNum ).RatedCapCoolTotal );  PreDefTableEntry(state,  pdchCoolCoilNomEff, VarSpeedCoil(
     883             :             // DXCoilNum
     884             :             // ).Name, VarSpeedCoil( DXCoilNum ).MSRatedCOP( VarSpeedCoil( DXCoilNum ).NormSpedLevel ) );
     885             :         }
     886             : 
     887             :         //-------------------------AIR SOURCE, COOLING---BEGIN
     888             :         // Get the data for cooling coil, AIR SOURCE
     889          19 :         CurrentModuleObject = "Coil:Cooling:DX:VariableSpeed"; // for reporting
     890             : 
     891          39 :         for (CoilCounter = 1; CoilCounter <= NumCoolAS; ++CoilCounter) {
     892             : 
     893          20 :             ++DXCoilNum;
     894          20 :             AlfaFieldIncre = 1;
     895             : 
     896          20 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
     897             :                                                                      CurrentModuleObject,
     898             :                                                                      CoilCounter,
     899             :                                                                      AlphArray,
     900             :                                                                      NumAlphas,
     901             :                                                                      NumArray,
     902             :                                                                      NumNums,
     903             :                                                                      IOStat,
     904             :                                                                      lNumericBlanks,
     905             :                                                                      lAlphaBlanks,
     906             :                                                                      cAlphaFields,
     907             :                                                                      cNumericFields);
     908             :             // ErrorsFound will be set to True if problem was found, left untouched otherwise
     909          20 :             VerifyUniqueCoilName(state, CurrentModuleObject, AlphArray(1), ErrorsFound, CurrentModuleObject + " Name");
     910             : 
     911          20 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).bIsDesuperheater = false;
     912          20 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name = AlphArray(1);
     913             :             // Initialize DataHeatBalance heat reclaim variable name for use by heat reclaim coils
     914          20 :             state.dataHeatBal->HeatReclaimVS_DXCoil(DXCoilNum).Name = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name;
     915          20 :             state.dataHeatBal->HeatReclaimVS_DXCoil(DXCoilNum).SourceType = CurrentModuleObject;
     916          20 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CoolHeatType = "COOLING";
     917          20 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType = Coil_CoolingAirToAirVariableSpeed;
     918          40 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VarSpeedCoilType =
     919          40 :                 DataHVACGlobals::cAllCoilTypes(Coil_CoolingAirToAirVariableSpeed);
     920          20 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds = int(NumArray(1));
     921          20 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel = int(NumArray(2));
     922          20 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedCapCoolTotal = NumArray(3);
     923          20 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedAirVolFlowRate = NumArray(4);
     924          20 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Twet_Rated = NumArray(5);
     925          20 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Gamma_Rated = NumArray(6);
     926             : 
     927          20 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirInletNodeNum =
     928          40 :                 GetOnlySingleNode(state,
     929          20 :                                   AlphArray(2),
     930             :                                   ErrorsFound,
     931             :                                   DataLoopNode::ConnectionObjectType::CoilCoolingDXVariableSpeed,
     932          20 :                                   AlphArray(1),
     933             :                                   DataLoopNode::NodeFluidType::Air,
     934             :                                   DataLoopNode::ConnectionType::Inlet,
     935             :                                   NodeInputManager::CompFluidStream::Primary,
     936          20 :                                   ObjectIsNotParent);
     937          20 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirOutletNodeNum =
     938          40 :                 GetOnlySingleNode(state,
     939          20 :                                   AlphArray(3),
     940             :                                   ErrorsFound,
     941             :                                   DataLoopNode::ConnectionObjectType::CoilCoolingDXVariableSpeed,
     942          20 :                                   AlphArray(1),
     943             :                                   DataLoopNode::NodeFluidType::Air,
     944             :                                   DataLoopNode::ConnectionType::Outlet,
     945             :                                   NodeInputManager::CompFluidStream::Primary,
     946          20 :                                   ObjectIsNotParent);
     947             : 
     948          20 :             TestCompSet(state, CurrentModuleObject, AlphArray(1), AlphArray(2), AlphArray(3), "Air Nodes");
     949             : 
     950          20 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds < 1) {
     951           0 :                 ShowSevereError(state,
     952           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name +
     953             :                                     "\", invalid");
     954           0 :                 ShowContinueError(state, format("...{} must be >= 1. entered number is {:.0T}", cNumericFields(1), NumArray(1)));
     955           0 :                 ErrorsFound = true;
     956             :             }
     957             : 
     958          40 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel >
     959          20 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds) {
     960           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel =
     961           0 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds;
     962             :             }
     963             : 
     964          40 :             if ((state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel >
     965          40 :                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds) ||
     966          20 :                 (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel <= 0)) {
     967           0 :                 ShowSevereError(state,
     968           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name +
     969             :                                     "\", invalid");
     970           0 :                 ShowContinueError(state, format("...{} must be valid speed level entered number is {:.0T}", cNumericFields(2), NumArray(2)));
     971           0 :                 ErrorsFound = true;
     972             :             }
     973             : 
     974             :             // part load curve
     975          20 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PLFFPLR = GetCurveIndex(state, AlphArray(4)); // convert curve name to number
     976          20 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PLFFPLR == 0) {
     977           0 :                 if (lAlphaBlanks(4)) {
     978           0 :                     ShowSevereError(state,
     979           0 :                                     std::string{RoutineName} + CurrentModuleObject + "=\"" +
     980           0 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", missing");
     981           0 :                     ShowContinueError(state, "...required " + cAlphaFields(6) + " is blank.");
     982             :                 } else {
     983           0 :                     ShowSevereError(state,
     984           0 :                                     std::string{RoutineName} + CurrentModuleObject + "=\"" +
     985           0 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", invalid");
     986           0 :                     ShowContinueError(state, "...not found " + cAlphaFields(4) + "=\"" + AlphArray(4) + "\".");
     987             :                 }
     988           0 :                 ErrorsFound = true;
     989             :             } else {
     990          20 :                 CurveVal = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PLFFPLR, 1.0);
     991          20 :                 if (CurveVal > 1.10 || CurveVal < 0.90) {
     992           0 :                     ShowWarningError(state,
     993           0 :                                      std::string{RoutineName} + CurrentModuleObject + "=\"" +
     994           0 :                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", curve values");
     995           0 :                     ShowContinueError(state, "..." + cAlphaFields(4) + " output is not equal to 1.0 (+ or - 10%) at rated conditions.");
     996           0 :                     ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
     997             :                 }
     998             :             }
     999             : 
    1000             :             // outdoor condenser node
    1001          20 :             if (lAlphaBlanks(5)) {
    1002          19 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum = 0;
    1003             :             } else {
    1004           1 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum =
    1005           3 :                     GetOnlySingleNode(state,
    1006           1 :                                       AlphArray(5),
    1007             :                                       ErrorsFound,
    1008             :                                       DataLoopNode::ConnectionObjectType::CoilCoolingDXVariableSpeed,
    1009           1 :                                       state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    1010             :                                       DataLoopNode::NodeFluidType::Air,
    1011             :                                       DataLoopNode::ConnectionType::OutsideAirReference,
    1012             :                                       NodeInputManager::CompFluidStream::Primary,
    1013           1 :                                       ObjectIsNotParent);
    1014             : 
    1015           1 :                 if (!CheckOutAirNodeNumber(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum)) {
    1016           0 :                     ShowWarningError(state,
    1017           0 :                                      std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1018           0 :                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", may be invalid");
    1019           0 :                     ShowContinueError(state,
    1020           0 :                                       cAlphaFields(10) + "=\"" + AlphArray(5) +
    1021             :                                           "\", node does not appear in an OutdoorAir:NodeList or as an OutdoorAir:Node.");
    1022           0 :                     ShowContinueError(
    1023             :                         state, "This node needs to be included in an air system or the coil model will not be valid, and the simulation continues");
    1024             :                 }
    1025             :             }
    1026             : 
    1027          20 :             if ((UtilityRoutines::SameString(AlphArray(6), "AirCooled")) || lAlphaBlanks(6)) {
    1028          20 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserType = DataHeatBalance::RefrigCondenserType::Air;
    1029           0 :             } else if (UtilityRoutines::SameString(AlphArray(6), "EvaporativelyCooled")) {
    1030           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserType = DataHeatBalance::RefrigCondenserType::Evap;
    1031           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).ReportEvapCondVars = true;
    1032             :             } else {
    1033           0 :                 ShowSevereError(state,
    1034           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name +
    1035             :                                     "\", invalid");
    1036           0 :                 ShowContinueError(state, "..." + cAlphaFields(6) + "=\"" + AlphArray(6) + "\":");
    1037           0 :                 ShowContinueError(state, "...must be AirCooled or EvaporativelyCooled.");
    1038           0 :                 ErrorsFound = true;
    1039             :             }
    1040             : 
    1041          20 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondPumpElecNomPower = NumArray(7);
    1042             : 
    1043          20 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondPumpElecNomPower < 0.0) {
    1044           0 :                 ShowSevereError(state,
    1045           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name +
    1046             :                                     "\", invalid");
    1047           0 :                 ShowContinueError(state, "..." + cNumericFields(7) + " cannot be < 0.0.");
    1048           0 :                 ShowContinueError(state, format("...entered value=[{:.2T}].", NumArray(7)));
    1049           0 :                 ErrorsFound = true;
    1050             :             }
    1051             : 
    1052             :             // Set crankcase heater capacity
    1053          20 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterCapacity = NumArray(8);
    1054          20 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterCapacity < 0.0) {
    1055           0 :                 ShowSevereError(state,
    1056           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name +
    1057             :                                     "\", invalid");
    1058           0 :                 ShowContinueError(state, "..." + cNumericFields(8) + " cannot be < 0.0.");
    1059           0 :                 ShowContinueError(state, format("...entered value=[{:.2T}].", NumArray(8)));
    1060           0 :                 ErrorsFound = true;
    1061             :             }
    1062             : 
    1063             :             // Set crankcase heater cutout temperature
    1064          20 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MaxOATCrankcaseHeater = NumArray(9);
    1065             : 
    1066             :             // Set crankcase heater cutout temperature
    1067          20 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MinOATCompressor = NumArray(10);
    1068             : 
    1069             :             // Get Water System tank connections
    1070             :             //  A7, \field Name of Water Storage Tank for Supply
    1071          20 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapWaterSupplyName = AlphArray(7);
    1072          20 :             if (lAlphaBlanks(7)) {
    1073          20 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapWaterSupplyMode = WaterSupplyFromMains;
    1074             :             } else {
    1075           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapWaterSupplyMode = WaterSupplyFromTank;
    1076           0 :                 SetupTankDemandComponent(state,
    1077           0 :                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    1078             :                                          CurrentModuleObject,
    1079           0 :                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapWaterSupplyName,
    1080             :                                          ErrorsFound,
    1081           0 :                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapWaterSupTankID,
    1082           0 :                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapWaterTankDemandARRID);
    1083             :             }
    1084             : 
    1085             :             // A8; \field Name of Water Storage Tank for Condensate Collection
    1086          20 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondensateCollectName = AlphArray(8);
    1087          20 :             if (lAlphaBlanks(8)) {
    1088          20 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondensateCollectMode = CondensateDiscarded;
    1089             :             } else {
    1090           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondensateCollectMode = CondensateToTank;
    1091           0 :                 SetupTankSupplyComponent(state,
    1092           0 :                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    1093             :                                          CurrentModuleObject,
    1094           0 :                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondensateCollectName,
    1095             :                                          ErrorsFound,
    1096           0 :                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondensateTankID,
    1097           0 :                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondensateTankSupplyARRID);
    1098             :             }
    1099             : 
    1100             :             //   Basin heater power as a function of temperature must be greater than or equal to 0
    1101          20 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterPowerFTempDiff = NumArray(11);
    1102          20 :             if (NumArray(11) < 0.0) {
    1103           0 :                 ShowSevereError(state,
    1104           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name +
    1105             :                                     "\", invalid");
    1106           0 :                 ShowContinueError(state, "..." + cNumericFields(11) + " must be >= 0.0.");
    1107           0 :                 ShowContinueError(state, format("...entered value=[{:.2T}].", NumArray(11)));
    1108           0 :                 ErrorsFound = true;
    1109             :             }
    1110             : 
    1111          20 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterSetPointTemp = NumArray(12);
    1112          20 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterPowerFTempDiff > 0.0) {
    1113           0 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterSetPointTemp < 2.0) {
    1114           0 :                     ShowWarningError(state,
    1115           0 :                                      std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1116           0 :                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", freeze possible");
    1117           0 :                     ShowContinueError(state, "..." + cNumericFields(12) + " is < 2 {C}. Freezing could occur.");
    1118           0 :                     ShowContinueError(state, format("...entered value=[{:.2T}].", NumArray(12)));
    1119             :                 }
    1120             :             }
    1121             : 
    1122          20 :             if (!lAlphaBlanks(9)) {
    1123           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterSchedulePtr = GetScheduleIndex(state, AlphArray(9));
    1124           0 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterSchedulePtr == 0) {
    1125           0 :                     ShowWarningError(state,
    1126           0 :                                      std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1127           0 :                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", invalid");
    1128           0 :                     ShowContinueError(state, "...not found " + cAlphaFields(14) + "=\"" + AlphArray(9) + "\".");
    1129           0 :                     ShowContinueError(state, "Basin heater will be available to operate throughout the simulation.");
    1130             :                 }
    1131             :             }
    1132             : 
    1133         166 :             for (I = 1; I <= state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds; ++I) {
    1134         146 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I) = NumArray(13 + (I - 1) * 6);
    1135         146 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedSHR(I) = NumArray(14 + (I - 1) * 6);
    1136         146 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedCOP(I) = NumArray(15 + (I - 1) * 6);
    1137         146 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowRate(I) = NumArray(16 + (I - 1) * 6);
    1138         146 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondAirFlow(I) = NumArray(17 + (I - 1) * 6);
    1139             : 
    1140         146 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondEffect(I) = NumArray(18 + (I - 1) * 6);
    1141         292 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondEffect(I) < 0.0 ||
    1142         146 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondEffect(I) > 1.0) {
    1143           0 :                     ShowSevereError(state,
    1144           0 :                                     std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1145           0 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", invalid");
    1146           0 :                     ShowContinueError(state, "..." + cNumericFields(18 + (I - 1) * 6) + " cannot be < 0.0 or > 1.0.");
    1147           0 :                     ShowContinueError(state, format("...entered value=[{:.2T}].", NumArray(18 + (I - 1) * 6)));
    1148           0 :                     ErrorsFound = true;
    1149             :                 }
    1150             : 
    1151         146 :                 AlfaFieldIncre = 10 + (I - 1) * 4;
    1152         146 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(I) =
    1153         146 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
    1154         146 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(I) == 0) {
    1155           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
    1156           0 :                         ShowSevereError(state,
    1157           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1158           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", missing");
    1159           0 :                         ShowContinueError(state, "...required " + cAlphaFields(AlfaFieldIncre) + " is blank.");
    1160             :                     } else {
    1161           0 :                         ShowSevereError(state,
    1162           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1163           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", invalid");
    1164           0 :                         ShowContinueError(state, "...not found " + cAlphaFields(AlfaFieldIncre) + "=\"" + AlphArray(AlfaFieldIncre) + "\".");
    1165             :                     }
    1166           0 :                     ErrorsFound = true;
    1167             :                 } else {
    1168             :                     // Verify Curve Object, only legal type is BiQuadratic
    1169         438 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    1170         146 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(I), // Curve index
    1171             :                                                          {2},                                                                  // Valid dimensions
    1172             :                                                          RoutineName,                                                          // Routine name
    1173             :                                                          CurrentModuleObject,                                                  // Object Type
    1174         146 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,           // Object Name
    1175         146 :                                                          cAlphaFields(AlfaFieldIncre));                                        // Field Name
    1176             : 
    1177         146 :                     if (!ErrorsFound) {
    1178         292 :                         CurveVal = CurveValue(
    1179         146 :                             state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(I), RatedInletWetBulbTemp, RatedAmbAirTemp);
    1180         146 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
    1181           0 :                             ShowWarningError(state,
    1182           0 :                                              std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1183           0 :                                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", curve values");
    1184           0 :                             ShowContinueError(state,
    1185           0 :                                               "..." + cAlphaFields(AlfaFieldIncre) + " output is not equal to 1.0 (+ or - 10%) at rated conditions.");
    1186           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    1187             :                         }
    1188             :                     }
    1189             :                 }
    1190             : 
    1191         146 :                 AlfaFieldIncre = 11 + (I - 1) * 4;
    1192         146 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(I) =
    1193         146 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
    1194         146 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(I) == 0) {
    1195           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
    1196           0 :                         ShowSevereError(state,
    1197           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1198           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", missing");
    1199           0 :                         ShowContinueError(state, "...required " + cAlphaFields(AlfaFieldIncre) + " is blank.");
    1200             :                     } else {
    1201           0 :                         ShowSevereError(state,
    1202           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1203           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", invalid");
    1204           0 :                         ShowContinueError(state, "...not found " + cAlphaFields(AlfaFieldIncre) + "=\"" + AlphArray(AlfaFieldIncre) + "\".");
    1205             :                     }
    1206           0 :                     ErrorsFound = true;
    1207             :                 } else {
    1208             :                     // Verify Curve Object, only legal type is Quadratic
    1209         438 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    1210         146 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(I), // Curve index
    1211             :                                                          {1},                                                                     // Valid dimensions
    1212             :                                                          RoutineName,                                                             // Routine name
    1213             :                                                          CurrentModuleObject,                                                     // Object Type
    1214         146 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,              // Object Name
    1215         146 :                                                          cAlphaFields(AlfaFieldIncre));                                           // Field Name
    1216             : 
    1217         146 :                     if (!ErrorsFound) {
    1218         146 :                         CurveVal = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(I), 1.0);
    1219         146 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
    1220           0 :                             ShowWarningError(state,
    1221           0 :                                              std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1222           0 :                                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", curve values");
    1223           0 :                             ShowContinueError(state,
    1224           0 :                                               "..." + cAlphaFields(AlfaFieldIncre) + " output is not equal to 1.0 (+ or - 10%) at rated conditions.");
    1225           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    1226             :                         }
    1227             :                     }
    1228             :                 }
    1229             : 
    1230         146 :                 AlfaFieldIncre = 12 + (I - 1) * 4;
    1231         146 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(I) =
    1232         146 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
    1233         146 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(I) == 0) {
    1234           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
    1235           0 :                         ShowSevereError(state,
    1236           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1237           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", missing");
    1238           0 :                         ShowContinueError(state, "...required " + cAlphaFields(AlfaFieldIncre) + " is blank.");
    1239             :                     } else {
    1240           0 :                         ShowSevereError(state,
    1241           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1242           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", invalid");
    1243           0 :                         ShowContinueError(state, "...not found " + cAlphaFields(AlfaFieldIncre) + "=\"" + AlphArray(AlfaFieldIncre) + "\".");
    1244             :                     }
    1245           0 :                     ErrorsFound = true;
    1246             :                 } else {
    1247             :                     // Verify Curve Object, only legal type is BiQuadratic
    1248         438 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    1249         146 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(I), // Curve index
    1250             :                                                          {2},                                                                 // Valid dimensions
    1251             :                                                          RoutineName,                                                         // Routine name
    1252             :                                                          CurrentModuleObject,                                                 // Object Type
    1253         146 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,          // Object Name
    1254         146 :                                                          cAlphaFields(AlfaFieldIncre));                                       // Field Name
    1255             : 
    1256         146 :                     if (!ErrorsFound) {
    1257         292 :                         CurveVal = CurveValue(
    1258         146 :                             state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(I), RatedInletWetBulbTemp, RatedAmbAirTemp);
    1259         146 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
    1260           0 :                             ShowWarningError(state,
    1261           0 :                                              std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1262           0 :                                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", curve values");
    1263           0 :                             ShowContinueError(state,
    1264           0 :                                               "..." + cAlphaFields(AlfaFieldIncre) + " output is not equal to 1.0 (+ or - 10%) at rated conditions.");
    1265           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    1266             :                         }
    1267             :                     }
    1268             :                 }
    1269             : 
    1270         146 :                 AlfaFieldIncre = 13 + (I - 1) * 4;
    1271         146 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(I) =
    1272         146 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
    1273         146 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(I) == 0) {
    1274           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
    1275           0 :                         ShowSevereError(state,
    1276           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1277           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", missing");
    1278           0 :                         ShowContinueError(state, "...required " + cAlphaFields(AlfaFieldIncre) + " is blank.");
    1279             :                     } else {
    1280           0 :                         ShowSevereError(state,
    1281           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1282           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", invalid");
    1283           0 :                         ShowContinueError(state, "...not found " + cAlphaFields(AlfaFieldIncre) + "=\"" + AlphArray(AlfaFieldIncre) + "\".");
    1284             :                     }
    1285           0 :                     ErrorsFound = true;
    1286             :                 } else {
    1287             :                     // Verify Curve Object, only legal type is Quadratic
    1288         438 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    1289         146 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(I), // Curve index
    1290             :                                                          {1},                                                                    // Valid dimensions
    1291             :                                                          RoutineName,                                                            // Routine name
    1292             :                                                          CurrentModuleObject,                                                    // Object Type
    1293         146 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,             // Object Name
    1294         146 :                                                          cAlphaFields(AlfaFieldIncre));                                          // Field Name
    1295             : 
    1296         146 :                     if (!ErrorsFound) {
    1297         146 :                         CurveVal = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(I), 1.0);
    1298         146 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
    1299           0 :                             ShowWarningError(state,
    1300           0 :                                              std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1301           0 :                                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", curve values");
    1302           0 :                             ShowContinueError(state,
    1303           0 :                                               "..." + cAlphaFields(AlfaFieldIncre) + " output is not equal to 1.0 (+ or - 10%) at rated conditions.");
    1304           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    1305             :                         }
    1306             :                     }
    1307             :                 }
    1308             :             }
    1309             : 
    1310         166 :             for (I = 1; I <= state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds; ++I) {
    1311         146 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedPercentTotCap(I) =
    1312         292 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I) /
    1313         292 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(
    1314         146 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds);
    1315         146 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowPerRatedTotCap(I) =
    1316         292 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowRate(I) /
    1317         146 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I);
    1318         146 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedEvapCondVolFlowPerRatedTotCap(I) =
    1319         292 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondAirFlow(I) /
    1320         146 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I);
    1321             :             }
    1322             : 
    1323             :             // CurrentModuleObject = "Coil:Cooling:DX:VariableSpeed"
    1324          80 :             SetupOutputVariable(state,
    1325             :                                 "Cooling Coil Electricity Energy",
    1326             :                                 OutputProcessor::Unit::J,
    1327          20 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Energy,
    1328             :                                 OutputProcessor::SOVTimeStepType::System,
    1329             :                                 OutputProcessor::SOVStoreType::Summed,
    1330          20 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    1331             :                                 _,
    1332             :                                 "Electricity",
    1333             :                                 "Cooling",
    1334             :                                 _,
    1335          20 :                                 "System");
    1336          80 :             SetupOutputVariable(state,
    1337             :                                 "Cooling Coil Total Cooling Energy",
    1338             :                                 OutputProcessor::Unit::J,
    1339          20 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLoadTotal,
    1340             :                                 OutputProcessor::SOVTimeStepType::System,
    1341             :                                 OutputProcessor::SOVStoreType::Summed,
    1342          20 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    1343             :                                 _,
    1344             :                                 "ENERGYTRANSFER",
    1345             :                                 "COOLINGCOILS",
    1346             :                                 _,
    1347          20 :                                 "System");
    1348          80 :             SetupOutputVariable(state,
    1349             :                                 "Cooling Coil Sensible Cooling Energy",
    1350             :                                 OutputProcessor::Unit::J,
    1351          20 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergySensible,
    1352             :                                 OutputProcessor::SOVTimeStepType::System,
    1353             :                                 OutputProcessor::SOVStoreType::Summed,
    1354          40 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    1355          80 :             SetupOutputVariable(state,
    1356             :                                 "Cooling Coil Latent Cooling Energy",
    1357             :                                 OutputProcessor::Unit::J,
    1358          20 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLatent,
    1359             :                                 OutputProcessor::SOVTimeStepType::System,
    1360             :                                 OutputProcessor::SOVStoreType::Summed,
    1361          40 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    1362          80 :             SetupOutputVariable(state,
    1363             :                                 "Cooling Coil Source Side Heat Transfer Energy",
    1364             :                                 OutputProcessor::Unit::J,
    1365          20 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergySource,
    1366             :                                 OutputProcessor::SOVTimeStepType::System,
    1367             :                                 OutputProcessor::SOVStoreType::Summed,
    1368          40 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    1369             : 
    1370          20 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedCapCoolSens =
    1371             :                 AutoSize; // always auto-sized, to be determined in the sizing calculation
    1372             : 
    1373             :             // BAN Sept 30 2103, CR9322, commented out, now it is redundant, it is reported from sizing routine
    1374             :             // create predefined report entries
    1375             :             // PreDefTableEntry(state,  pdchCoolCoilType, VarSpeedCoil( DXCoilNum ).Name, CurrentModuleObject );
    1376             :             // PreDefTableEntry(state,  pdchCoolCoilTotCap, VarSpeedCoil( DXCoilNum ).Name, VarSpeedCoil( DXCoilNum ).RatedCapCoolTotal );
    1377             :             // PreDefTableEntry(state,  pdchCoolCoilSensCap, VarSpeedCoil( DXCoilNum ).Name, VarSpeedCoil( DXCoilNum ).RatedCapCoolSens );
    1378             :             // PreDefTableEntry(state,  pdchCoolCoilLatCap, VarSpeedCoil( DXCoilNum ).Name, VarSpeedCoil( DXCoilNum ).RatedCapCoolTotal -
    1379             :             // VarSpeedCoil( DXCoilNum ).RatedCapCoolSens );  PreDefTableEntry(state,  pdchCoolCoilSHR, VarSpeedCoil( DXCoilNum ).Name, VarSpeedCoil(
    1380             :             // DXCoilNum
    1381             :             // ).RatedCapCoolSens / VarSpeedCoil( DXCoilNum ).RatedCapCoolTotal );  PreDefTableEntry(state,  pdchCoolCoilNomEff, VarSpeedCoil(
    1382             :             // DXCoilNum
    1383             :             // ).Name, VarSpeedCoil( DXCoilNum ).MSRatedCOP( VarSpeedCoil( DXCoilNum ).NormSpedLevel ) );
    1384             :         }
    1385             : 
    1386             :         //-------------------------AIR SOURCE COOLING---END
    1387             : 
    1388             :         // Get the data for heating coil, WATER SOURCE
    1389          19 :         CurrentModuleObject = "Coil:Heating:WaterToAirHeatPump:VariableSpeedEquationFit";
    1390             : 
    1391          36 :         for (CoilCounter = 1; CoilCounter <= NumHeat; ++CoilCounter) {
    1392             : 
    1393          17 :             ++DXCoilNum;
    1394             : 
    1395          17 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
    1396             :                                                                      CurrentModuleObject,
    1397             :                                                                      CoilCounter,
    1398             :                                                                      AlphArray,
    1399             :                                                                      NumAlphas,
    1400             :                                                                      NumArray,
    1401             :                                                                      NumNums,
    1402             :                                                                      IOStat,
    1403             :                                                                      lNumericBlanks,
    1404             :                                                                      lAlphaBlanks,
    1405             :                                                                      cAlphaFields,
    1406             :                                                                      cNumericFields);
    1407             :             // ErrorsFound will be set to True if problem was found, left untouched otherwise
    1408          17 :             VerifyUniqueCoilName(state, CurrentModuleObject, AlphArray(1), ErrorsFound, CurrentModuleObject + " Name");
    1409             : 
    1410          17 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).bIsDesuperheater = false;
    1411          17 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name = AlphArray(1);
    1412          17 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CoolHeatType = "HEATING";
    1413          17 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType = Coil_HeatingWaterToAirHPVSEquationFit; // fix coil type
    1414             : 
    1415          34 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VarSpeedCoilType =
    1416          34 :                 DataHVACGlobals::cAllCoilTypes(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType);
    1417          17 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds = int(NumArray(1));
    1418          17 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel = int(NumArray(2));
    1419          17 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedCapHeat = NumArray(3);
    1420          17 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedAirVolFlowRate = NumArray(4);
    1421          17 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedWaterVolFlowRate = NumArray(5);
    1422          17 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserType = DataHeatBalance::RefrigCondenserType::Water;
    1423             : 
    1424          17 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterInletNodeNum =
    1425          34 :                 GetOnlySingleNode(state,
    1426          17 :                                   AlphArray(2),
    1427             :                                   ErrorsFound,
    1428             :                                   DataLoopNode::ConnectionObjectType::CoilHeatingWaterToAirHeatPumpVariableSpeedEquationFit,
    1429          17 :                                   AlphArray(1),
    1430             :                                   DataLoopNode::NodeFluidType::Water,
    1431             :                                   DataLoopNode::ConnectionType::Inlet,
    1432             :                                   NodeInputManager::CompFluidStream::Secondary,
    1433          17 :                                   ObjectIsNotParent);
    1434          17 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterOutletNodeNum =
    1435          34 :                 GetOnlySingleNode(state,
    1436          17 :                                   AlphArray(3),
    1437             :                                   ErrorsFound,
    1438             :                                   DataLoopNode::ConnectionObjectType::CoilHeatingWaterToAirHeatPumpVariableSpeedEquationFit,
    1439          17 :                                   AlphArray(1),
    1440             :                                   DataLoopNode::NodeFluidType::Water,
    1441             :                                   DataLoopNode::ConnectionType::Outlet,
    1442             :                                   NodeInputManager::CompFluidStream::Secondary,
    1443          17 :                                   ObjectIsNotParent);
    1444          17 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirInletNodeNum =
    1445          34 :                 GetOnlySingleNode(state,
    1446          17 :                                   AlphArray(4),
    1447             :                                   ErrorsFound,
    1448             :                                   DataLoopNode::ConnectionObjectType::CoilHeatingWaterToAirHeatPumpVariableSpeedEquationFit,
    1449          17 :                                   AlphArray(1),
    1450             :                                   DataLoopNode::NodeFluidType::Air,
    1451             :                                   DataLoopNode::ConnectionType::Inlet,
    1452             :                                   NodeInputManager::CompFluidStream::Primary,
    1453          17 :                                   ObjectIsNotParent);
    1454          17 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirOutletNodeNum =
    1455          34 :                 GetOnlySingleNode(state,
    1456          17 :                                   AlphArray(5),
    1457             :                                   ErrorsFound,
    1458             :                                   DataLoopNode::ConnectionObjectType::CoilHeatingWaterToAirHeatPumpVariableSpeedEquationFit,
    1459          17 :                                   AlphArray(1),
    1460             :                                   DataLoopNode::NodeFluidType::Air,
    1461             :                                   DataLoopNode::ConnectionType::Outlet,
    1462             :                                   NodeInputManager::CompFluidStream::Primary,
    1463          17 :                                   ObjectIsNotParent);
    1464             : 
    1465          17 :             TestCompSet(state, CurrentModuleObject, AlphArray(1), AlphArray(2), AlphArray(3), "Water Nodes");
    1466          17 :             TestCompSet(state, CurrentModuleObject, AlphArray(1), AlphArray(4), AlphArray(5), "Air Nodes");
    1467             : 
    1468             :             //       If (VarSpeedCoil(DXCoilNum)%NumOfSpeeds .LT. 2) Then
    1469          17 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds < 1) {
    1470           0 :                 ShowSevereError(state,
    1471           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name +
    1472             :                                     "\", invalid");
    1473           0 :                 ShowContinueError(state, format("...{} must be >= 1. entered number is {:.0T}", cNumericFields(1), NumArray(1)));
    1474           0 :                 ErrorsFound = true;
    1475             :             }
    1476             : 
    1477          34 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel >
    1478          17 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds) {
    1479           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel =
    1480           0 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds;
    1481             :             }
    1482             : 
    1483          34 :             if ((state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel >
    1484          34 :                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds) ||
    1485          17 :                 (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel <= 0)) {
    1486           0 :                 ShowSevereError(state,
    1487           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name +
    1488             :                                     "\", invalid");
    1489           0 :                 ShowContinueError(state, format("...{} must be valid speed level entered number is {:.0T}", cNumericFields(2), NumArray(2)));
    1490           0 :                 ErrorsFound = true;
    1491             :             }
    1492             : 
    1493             :             // part load curve
    1494          17 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PLFFPLR = GetCurveIndex(state, AlphArray(6)); // convert curve name to number
    1495          17 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PLFFPLR == 0) {
    1496           0 :                 if (lAlphaBlanks(6)) {
    1497           0 :                     ShowSevereError(state,
    1498           0 :                                     std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1499           0 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", missing");
    1500           0 :                     ShowContinueError(state, "...required " + cAlphaFields(6) + " is blank.");
    1501             :                 } else {
    1502           0 :                     ShowSevereError(state,
    1503           0 :                                     std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1504           0 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", invalid");
    1505           0 :                     ShowContinueError(state, "...not found " + cAlphaFields(6) + "=\"" + AlphArray(6) + "\".");
    1506             :                 }
    1507           0 :                 ErrorsFound = true;
    1508             :             } else {
    1509          17 :                 CurveVal = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PLFFPLR, 1.0);
    1510          17 :                 if (CurveVal > 1.10 || CurveVal < 0.90) {
    1511           0 :                     ShowWarningError(state,
    1512           0 :                                      std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1513           0 :                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", curve values");
    1514           0 :                     ShowContinueError(state, "..." + cAlphaFields(6) + " output is not equal to 1.0 (+ or - 10%) at rated conditions.");
    1515           0 :                     ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    1516             :                 }
    1517             :             }
    1518             : 
    1519         187 :             for (I = 1; I <= state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds; ++I) {
    1520         170 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I) = NumArray(6 + (I - 1) * 5);
    1521         170 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedCOP(I) = NumArray(7 + (I - 1) * 5);
    1522         170 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowRate(I) = NumArray(8 + (I - 1) * 5);
    1523         170 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterVolFlowRate(I) = NumArray(9 + (I - 1) * 5);
    1524         170 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeatFrac(I) = NumArray(10 + (I - 1) * 5);
    1525             : 
    1526         170 :                 AlfaFieldIncre = 7 + (I - 1) * 7;
    1527         170 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(I) =
    1528         170 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
    1529         170 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(I) == 0) {
    1530           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
    1531           0 :                         ShowSevereError(state,
    1532           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1533           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", missing");
    1534           0 :                         ShowContinueError(state, "...required " + cAlphaFields(AlfaFieldIncre) + " is blank.");
    1535             :                     } else {
    1536           0 :                         ShowSevereError(state,
    1537           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1538           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", invalid");
    1539           0 :                         ShowContinueError(state, "...not found " + cAlphaFields(AlfaFieldIncre) + "=\"" + AlphArray(AlfaFieldIncre) + "\".");
    1540             :                     }
    1541           0 :                     ErrorsFound = true;
    1542             :                 } else {
    1543             :                     // Verify Curve Object, only legal type is BiQuadratic
    1544         510 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    1545         170 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(I), // Curve index
    1546             :                                                          {2},                                                                  // Valid dimensions
    1547             :                                                          RoutineName,                                                          // Routine name
    1548             :                                                          CurrentModuleObject,                                                  // Object Type
    1549         170 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,           // Object Name
    1550         170 :                                                          cAlphaFields(AlfaFieldIncre));                                        // Field Name
    1551             : 
    1552         170 :                     if (!ErrorsFound) {
    1553         340 :                         CurveVal = CurveValue(state,
    1554         170 :                                               state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(I),
    1555             :                                               RatedInletAirTempHeat,
    1556             :                                               RatedInletWaterTempHeat);
    1557         170 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
    1558           0 :                             ShowWarningError(state,
    1559           0 :                                              std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1560           0 :                                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", curve values");
    1561           0 :                             ShowContinueError(state,
    1562           0 :                                               "..." + cAlphaFields(AlfaFieldIncre) + " output is not equal to 1.0 (+ or - 10%) at rated conditions.");
    1563           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    1564             :                         }
    1565             :                     }
    1566             :                 }
    1567             : 
    1568         170 :                 AlfaFieldIncre = 8 + (I - 1) * 7;
    1569         170 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(I) =
    1570         170 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
    1571         170 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(I) == 0) {
    1572           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
    1573           0 :                         ShowSevereError(state,
    1574           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1575           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", missing");
    1576           0 :                         ShowContinueError(state, "...required " + cAlphaFields(AlfaFieldIncre) + " is blank.");
    1577             :                     } else {
    1578           0 :                         ShowSevereError(state,
    1579           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1580           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", invalid");
    1581           0 :                         ShowContinueError(state, "...not found " + cAlphaFields(AlfaFieldIncre) + "=\"" + AlphArray(AlfaFieldIncre) + "\".");
    1582             :                     }
    1583           0 :                     ErrorsFound = true;
    1584             :                 } else {
    1585             :                     // Verify Curve Object, only legal type is Quadratic
    1586         510 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    1587         170 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(I), // Curve index
    1588             :                                                          {1},                                                                     // Valid dimensions
    1589             :                                                          RoutineName,                                                             // Routine name
    1590             :                                                          CurrentModuleObject,                                                     // Object Type
    1591         170 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,              // Object Name
    1592         170 :                                                          cAlphaFields(AlfaFieldIncre));                                           // Field Name
    1593             : 
    1594         170 :                     if (!ErrorsFound) {
    1595         170 :                         CurveVal = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(I), 1.0);
    1596         170 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
    1597           0 :                             ShowWarningError(state,
    1598           0 :                                              std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1599           0 :                                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", curve values");
    1600           0 :                             ShowContinueError(state,
    1601           0 :                                               "..." + cAlphaFields(AlfaFieldIncre) + " output is not equal to 1.0 (+ or - 10%) at rated conditions.");
    1602           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    1603             :                         }
    1604             :                     }
    1605             :                 }
    1606             : 
    1607         170 :                 AlfaFieldIncre = 9 + (I - 1) * 7;
    1608         170 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(I) =
    1609         170 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
    1610         170 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(I) == 0) {
    1611           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
    1612           0 :                         ShowSevereError(state,
    1613           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1614           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", missing");
    1615           0 :                         ShowContinueError(state, "...required " + cAlphaFields(AlfaFieldIncre) + " is blank.");
    1616             :                     } else {
    1617           0 :                         ShowSevereError(state,
    1618           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1619           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", invalid");
    1620           0 :                         ShowContinueError(state, "...not found " + cAlphaFields(AlfaFieldIncre) + "=\"" + AlphArray(14 + (I - 1) * 6) + "\".");
    1621             :                     }
    1622           0 :                     ErrorsFound = true;
    1623             :                 } else {
    1624             :                     // Verify Curve Object, only legal type is Quadratic
    1625         510 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    1626         170 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(I), // Curve index
    1627             :                                                          {1},                                                        // Valid dimensions
    1628             :                                                          RoutineName,                                                // Routine name
    1629             :                                                          CurrentModuleObject,                                        // Object Type
    1630         170 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name, // Object Name
    1631         170 :                                                          cAlphaFields(AlfaFieldIncre));                              // Field Name
    1632             : 
    1633         170 :                     if (!ErrorsFound) {
    1634         170 :                         CurveVal = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(I), 1.0);
    1635         170 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
    1636           0 :                             ShowWarningError(state,
    1637           0 :                                              std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1638           0 :                                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", curve values");
    1639           0 :                             ShowContinueError(state,
    1640           0 :                                               "..." + cAlphaFields(AlfaFieldIncre) + " output is not equal to 1.0 (+ or - 10%) at rated conditions.");
    1641           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    1642             :                         }
    1643             :                     }
    1644             :                 }
    1645             : 
    1646         170 :                 AlfaFieldIncre = 10 + (I - 1) * 7;
    1647         170 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(I) =
    1648         170 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
    1649         170 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(I) == 0) {
    1650           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
    1651           0 :                         ShowSevereError(state,
    1652           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1653           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", missing");
    1654           0 :                         ShowContinueError(state, "...required " + cAlphaFields(AlfaFieldIncre) + " is blank.");
    1655             :                     } else {
    1656           0 :                         ShowSevereError(state,
    1657           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1658           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", invalid");
    1659           0 :                         ShowContinueError(state, "...not found " + cAlphaFields(AlfaFieldIncre) + "=\"" + AlphArray(AlfaFieldIncre) + "\".");
    1660             :                     }
    1661           0 :                     ErrorsFound = true;
    1662             :                 } else {
    1663             :                     // Verify Curve Object, only legal type is BiQuadratic
    1664         510 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    1665         170 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(I), // Curve index
    1666             :                                                          {2},                                                                 // Valid dimensions
    1667             :                                                          RoutineName,                                                         // Routine name
    1668             :                                                          CurrentModuleObject,                                                 // Object Type
    1669         170 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,          // Object Name
    1670         170 :                                                          cAlphaFields(AlfaFieldIncre));                                       // Field Name
    1671             : 
    1672         170 :                     if (!ErrorsFound) {
    1673         340 :                         CurveVal = CurveValue(state,
    1674         170 :                                               state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(I),
    1675             :                                               RatedInletAirTempHeat,
    1676             :                                               RatedInletWaterTempHeat);
    1677         170 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
    1678           0 :                             ShowWarningError(state,
    1679           0 :                                              std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1680           0 :                                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", curve values");
    1681           0 :                             ShowContinueError(state,
    1682           0 :                                               "..." + cAlphaFields(AlfaFieldIncre) + " output is not equal to 1.0 (+ or - 10%) at rated conditions.");
    1683           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    1684             :                         }
    1685             :                     }
    1686             :                 }
    1687             : 
    1688         170 :                 AlfaFieldIncre = 11 + (I - 1) * 7;
    1689         170 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(I) =
    1690         170 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
    1691         170 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(I) == 0) {
    1692           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
    1693           0 :                         ShowSevereError(state,
    1694           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1695           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", missing");
    1696           0 :                         ShowContinueError(state, "...required " + cAlphaFields(AlfaFieldIncre) + " is blank.");
    1697             :                     } else {
    1698           0 :                         ShowSevereError(state,
    1699           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1700           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", invalid");
    1701           0 :                         ShowContinueError(state, "...not found " + cAlphaFields(AlfaFieldIncre) + "=\"" + AlphArray(16 + (I - 1) * 6) + "\".");
    1702             :                     }
    1703           0 :                     ErrorsFound = true;
    1704             :                 } else {
    1705             :                     // Verify Curve Object, only legal type is Quadratic
    1706         510 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    1707         170 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(I), // Curve index
    1708             :                                                          {1},                                                                    // Valid dimensions
    1709             :                                                          RoutineName,                                                            // Routine name
    1710             :                                                          CurrentModuleObject,                                                    // Object Type
    1711         170 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,             // Object Name
    1712         170 :                                                          cAlphaFields(AlfaFieldIncre));                                          // Field Name
    1713             : 
    1714         170 :                     if (!ErrorsFound) {
    1715         170 :                         CurveVal = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(I), 1.0);
    1716         170 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
    1717           0 :                             ShowWarningError(state,
    1718           0 :                                              std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1719           0 :                                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", curve values");
    1720           0 :                             ShowContinueError(state,
    1721           0 :                                               "..." + cAlphaFields(AlfaFieldIncre) + " output is not equal to 1.0 (+ or - 10%) at rated conditions.");
    1722           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    1723             :                         }
    1724             :                     }
    1725             :                 }
    1726             : 
    1727         170 :                 AlfaFieldIncre = 12 + (I - 1) * 7;
    1728         170 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRWaterFFlow(I) =
    1729         170 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
    1730         170 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRWaterFFlow(I) == 0) {
    1731           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
    1732           0 :                         ShowSevereError(state,
    1733           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1734           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", missing");
    1735           0 :                         ShowContinueError(state, "...required " + cAlphaFields(AlfaFieldIncre) + " is blank.");
    1736             :                     } else {
    1737           0 :                         ShowSevereError(state,
    1738           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1739           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", invalid");
    1740           0 :                         ShowContinueError(state, "...not found " + cAlphaFields(AlfaFieldIncre) + "=\"" + AlphArray(AlfaFieldIncre) + "\".");
    1741             :                     }
    1742           0 :                     ErrorsFound = true;
    1743             :                 } else {
    1744             :                     // Verify Curve Object, only legal type is Quadratic
    1745         510 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    1746         170 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRWaterFFlow(I), // Curve index
    1747             :                                                          {1},                                                                      // Valid dimensions
    1748             :                                                          RoutineName,                                                              // Routine name
    1749             :                                                          CurrentModuleObject,                                                      // Object Type
    1750         170 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,               // Object Name
    1751         170 :                                                          cAlphaFields(AlfaFieldIncre));                                            // Field Name
    1752             : 
    1753         170 :                     if (!ErrorsFound) {
    1754         170 :                         CurveVal = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRWaterFFlow(I), 1.0);
    1755         170 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
    1756           0 :                             ShowWarningError(state,
    1757           0 :                                              std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1758           0 :                                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", curve values");
    1759           0 :                             ShowContinueError(state,
    1760           0 :                                               "..." + cAlphaFields(AlfaFieldIncre) + " output is not equal to 1.0 (+ or - 10%) at rated conditions.");
    1761           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    1762             :                         }
    1763             :                     }
    1764             :                 }
    1765             : 
    1766         170 :                 AlfaFieldIncre = 13 + (I - 1) * 7;
    1767             :                 // Read waste heat modifier curve name
    1768         170 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeat(I) =
    1769         170 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
    1770         170 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeat(I) == 0) {
    1771           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
    1772           0 :                         ShowSevereError(state,
    1773           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1774           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", missing");
    1775           0 :                         ShowContinueError(state, "...required " + cAlphaFields(AlfaFieldIncre) + " is blank.");
    1776             :                     } else {
    1777           0 :                         ShowSevereError(state,
    1778           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1779           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", invalid");
    1780           0 :                         ShowContinueError(state, "...not found " + cAlphaFields(AlfaFieldIncre) + "=\"" + AlphArray(AlfaFieldIncre) + "\".");
    1781             :                     }
    1782           0 :                     ErrorsFound = true;
    1783             :                 } else {
    1784             :                     // Verify Curve Object, only legal types are BiQuadratic
    1785         510 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    1786         170 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeat(I), // Curve index
    1787             :                                                          {2},                                                                  // Valid dimensions
    1788             :                                                          RoutineName,                                                          // Routine name
    1789             :                                                          CurrentModuleObject,                                                  // Object Type
    1790         170 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,           // Object Name
    1791         170 :                                                          cAlphaFields(AlfaFieldIncre));                                        // Field Name
    1792             : 
    1793         170 :                     if (!ErrorsFound) {
    1794         340 :                         CurveVal = CurveValue(state,
    1795         170 :                                               state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeat(I),
    1796             :                                               RatedInletAirTempHeat,
    1797             :                                               RatedInletWaterTempHeat);
    1798         170 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
    1799           0 :                             ShowWarningError(state,
    1800           0 :                                              std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1801           0 :                                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", curve values");
    1802           0 :                             ShowContinueError(state,
    1803           0 :                                               "..." + cAlphaFields(AlfaFieldIncre) + " output is not equal to 1.0 (+ or - 10%) at rated conditions.");
    1804           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    1805             :                         }
    1806             :                     }
    1807             :                 }
    1808             :             }
    1809             : 
    1810         187 :             for (I = 1; I <= state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds; ++I) {
    1811         170 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedPercentTotCap(I) =
    1812         340 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I) /
    1813         340 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(
    1814         170 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds);
    1815         170 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowPerRatedTotCap(I) =
    1816         340 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowRate(I) /
    1817         170 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I);
    1818         170 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterVolFlowPerRatedTotCap(I) =
    1819         340 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterVolFlowRate(I) /
    1820         170 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I);
    1821             :             }
    1822             : 
    1823             :             // CurrentModuleObject = "Coil:Heating:WaterToAirHeatPump:VariableSpeedEquationFit"
    1824          68 :             SetupOutputVariable(state,
    1825             :                                 "Heating Coil Electricity Energy",
    1826             :                                 OutputProcessor::Unit::J,
    1827          17 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Energy,
    1828             :                                 OutputProcessor::SOVTimeStepType::System,
    1829             :                                 OutputProcessor::SOVStoreType::Summed,
    1830          17 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    1831             :                                 _,
    1832             :                                 "Electricity",
    1833             :                                 "Heating",
    1834             :                                 _,
    1835          17 :                                 "System");
    1836          68 :             SetupOutputVariable(state,
    1837             :                                 "Heating Coil Heating Energy",
    1838             :                                 OutputProcessor::Unit::J,
    1839          17 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLoadTotal,
    1840             :                                 OutputProcessor::SOVTimeStepType::System,
    1841             :                                 OutputProcessor::SOVStoreType::Summed,
    1842          17 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    1843             :                                 _,
    1844             :                                 "ENERGYTRANSFER",
    1845             :                                 "HEATINGCOILS",
    1846             :                                 _,
    1847          17 :                                 "System");
    1848          68 :             SetupOutputVariable(state,
    1849             :                                 "Heating Coil Source Side Heat Transfer Energy",
    1850             :                                 OutputProcessor::Unit::J,
    1851          17 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergySource,
    1852             :                                 OutputProcessor::SOVTimeStepType::System,
    1853             :                                 OutputProcessor::SOVStoreType::Summed,
    1854          17 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    1855             :                                 _,
    1856             :                                 "PLANTLOOPHEATINGDEMAND",
    1857             :                                 "HEATINGCOILS",
    1858             :                                 _,
    1859          17 :                                 "System");
    1860             : 
    1861             :             // create predefined report entries
    1862          51 :             PreDefTableEntry(
    1863          34 :                 state, state.dataOutRptPredefined->pdchHeatCoilType, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name, CurrentModuleObject);
    1864          68 :             PreDefTableEntry(state,
    1865          17 :                              state.dataOutRptPredefined->pdchHeatCoilNomCap,
    1866          17 :                              state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    1867          17 :                              state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedCapHeat);
    1868          68 :             PreDefTableEntry(state,
    1869          17 :                              state.dataOutRptPredefined->pdchHeatCoilNomEff,
    1870          17 :                              state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    1871          17 :                              state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedCOP(
    1872          17 :                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel));
    1873             :         }
    1874             : 
    1875             :         //-------------------------AIR SOURCE, HEATING---BEGIN
    1876             :         // Get the data for heating coil, AIR SOURCE
    1877          19 :         CurrentModuleObject = "COIL:HEATING:DX:VARIABLESPEED";
    1878             : 
    1879          27 :         for (CoilCounter = 1; CoilCounter <= NumHeatAS; ++CoilCounter) {
    1880             : 
    1881           8 :             ++DXCoilNum;
    1882             : 
    1883           8 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
    1884             :                                                                      CurrentModuleObject,
    1885             :                                                                      CoilCounter,
    1886             :                                                                      AlphArray,
    1887             :                                                                      NumAlphas,
    1888             :                                                                      NumArray,
    1889             :                                                                      NumNums,
    1890             :                                                                      IOStat,
    1891             :                                                                      lNumericBlanks,
    1892             :                                                                      lAlphaBlanks,
    1893             :                                                                      cAlphaFields,
    1894             :                                                                      cNumericFields);
    1895             :             // ErrorsFound will be set to True if problem was found, left untouched otherwise
    1896           8 :             VerifyUniqueCoilName(state, CurrentModuleObject, AlphArray(1), ErrorsFound, CurrentModuleObject + " Name");
    1897             : 
    1898           8 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).bIsDesuperheater = false;
    1899           8 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name = AlphArray(1);
    1900           8 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CoolHeatType = "HEATING";
    1901           8 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType = Coil_HeatingAirToAirVariableSpeed;
    1902          16 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VarSpeedCoilType =
    1903          16 :                 DataHVACGlobals::cAllCoilTypes(Coil_HeatingAirToAirVariableSpeed);
    1904           8 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds = int(NumArray(1));
    1905           8 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel = int(NumArray(2));
    1906           8 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedCapHeat = NumArray(3);
    1907           8 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedAirVolFlowRate = NumArray(4);
    1908             : 
    1909           8 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirInletNodeNum =
    1910          16 :                 GetOnlySingleNode(state,
    1911           8 :                                   AlphArray(2),
    1912             :                                   ErrorsFound,
    1913             :                                   DataLoopNode::ConnectionObjectType::CoilHeatingDXVariableSpeed,
    1914           8 :                                   AlphArray(1),
    1915             :                                   DataLoopNode::NodeFluidType::Air,
    1916             :                                   DataLoopNode::ConnectionType::Inlet,
    1917             :                                   NodeInputManager::CompFluidStream::Primary,
    1918           8 :                                   ObjectIsNotParent);
    1919           8 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirOutletNodeNum =
    1920          16 :                 GetOnlySingleNode(state,
    1921           8 :                                   AlphArray(3),
    1922             :                                   ErrorsFound,
    1923             :                                   DataLoopNode::ConnectionObjectType::CoilHeatingDXVariableSpeed,
    1924           8 :                                   AlphArray(1),
    1925             :                                   DataLoopNode::NodeFluidType::Air,
    1926             :                                   DataLoopNode::ConnectionType::Outlet,
    1927             :                                   NodeInputManager::CompFluidStream::Primary,
    1928           8 :                                   ObjectIsNotParent);
    1929             : 
    1930           8 :             TestCompSet(state, CurrentModuleObject, AlphArray(1), AlphArray(2), AlphArray(3), "Air Nodes");
    1931             : 
    1932           8 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds < 1) {
    1933           0 :                 ShowSevereError(state,
    1934           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name +
    1935             :                                     "\", invalid");
    1936           0 :                 ShowContinueError(state, format("...{} must be >= 1. entered number is {:.0T}", cNumericFields(1), NumArray(1)));
    1937           0 :                 ErrorsFound = true;
    1938             :             }
    1939             : 
    1940          16 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel >
    1941           8 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds) {
    1942           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel =
    1943           0 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds;
    1944             :             }
    1945             : 
    1946          16 :             if ((state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel >
    1947          16 :                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds) ||
    1948           8 :                 (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel <= 0)) {
    1949           0 :                 ShowSevereError(state,
    1950           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name +
    1951             :                                     "\", invalid");
    1952           0 :                 ShowContinueError(state, format("...{} must be valid speed level entered number is {:.0T}", cNumericFields(2), NumArray(2)));
    1953           0 :                 ErrorsFound = true;
    1954             :             }
    1955             : 
    1956             :             // part load curve
    1957           8 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PLFFPLR = GetCurveIndex(state, AlphArray(4)); // convert curve name to number
    1958           8 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PLFFPLR == 0) {
    1959           0 :                 if (lAlphaBlanks(4)) {
    1960           0 :                     ShowSevereError(state,
    1961           0 :                                     std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1962           0 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", missing");
    1963           0 :                     ShowContinueError(state, "...required " + cAlphaFields(4) + " is blank.");
    1964             :                 } else {
    1965           0 :                     ShowSevereError(state,
    1966           0 :                                     std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1967           0 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", invalid");
    1968           0 :                     ShowContinueError(state, "...not found " + cAlphaFields(4) + "=\"" + AlphArray(4) + "\".");
    1969             :                 }
    1970           0 :                 ErrorsFound = true;
    1971             :             } else {
    1972           8 :                 CurveVal = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PLFFPLR, 1.0);
    1973           8 :                 if (CurveVal > 1.10 || CurveVal < 0.90) {
    1974           0 :                     ShowWarningError(state,
    1975           0 :                                      std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1976           0 :                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", curve values");
    1977           0 :                     ShowContinueError(state, "..." + cAlphaFields(4) + " output is not equal to 1.0 (+ or - 10%) at rated conditions.");
    1978           0 :                     ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    1979             :                 }
    1980             :             }
    1981             : 
    1982           8 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostEIRFT = GetCurveIndex(state, AlphArray(5)); // convert curve name to number
    1983             : 
    1984           8 :             if (UtilityRoutines::SameString(AlphArray(6), "ReverseCycle")) {
    1985           0 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostEIRFT == 0) {
    1986           0 :                     if (lAlphaBlanks(5)) {
    1987           0 :                         ShowSevereError(state,
    1988           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1989           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", missing");
    1990           0 :                         ShowContinueError(state, "...required " + cAlphaFields(5) + " is blank.");
    1991           0 :                         ShowContinueError(state, "...field is required because " + cAlphaFields(6) + " is \"ReverseCycle\".");
    1992             :                     } else {
    1993           0 :                         ShowSevereError(state,
    1994           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    1995           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", invalid");
    1996           0 :                         ShowContinueError(state, "...not found " + cAlphaFields(5) + "=\"" + AlphArray(5) + "\".");
    1997             :                     }
    1998           0 :                     ErrorsFound = true;
    1999             :                 } else {
    2000             :                     // Verify Curve Object, only legal type is BiQuadratic
    2001           0 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    2002           0 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostEIRFT, // Curve index
    2003             :                                                          {2},                                                                // Valid dimensions
    2004             :                                                          RoutineName,                                                        // Routine name
    2005             :                                                          CurrentModuleObject,                                                // Object Type
    2006           0 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,         // Object Name
    2007           0 :                                                          cAlphaFields(AlfaFieldIncre));                                      // Field Name
    2008             :                 }
    2009             :             }
    2010             : 
    2011           8 :             if (UtilityRoutines::SameString(AlphArray(6), "ReverseCycle"))
    2012           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostStrategy = ReverseCycle;
    2013           8 :             if (UtilityRoutines::SameString(AlphArray(6), "Resistive"))
    2014           8 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostStrategy = Resistive;
    2015           8 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostStrategy == 0) {
    2016           0 :                 ShowSevereError(state,
    2017           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name +
    2018             :                                     "\", invalid");
    2019           0 :                 ShowContinueError(state, "...illegal " + cAlphaFields(6) + "=\"" + AlphArray(6) + "\".");
    2020           0 :                 ShowContinueError(state, "...valid values for this field are ReverseCycle or Resistive.");
    2021           0 :                 ErrorsFound = true;
    2022             :             }
    2023             : 
    2024           8 :             if (UtilityRoutines::SameString(AlphArray(7), "Timed")) state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostControl = Timed;
    2025           8 :             if (UtilityRoutines::SameString(AlphArray(7), "OnDemand"))
    2026           2 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostControl = OnDemand;
    2027           8 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostControl == 0) {
    2028           0 :                 ShowSevereError(state,
    2029           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name +
    2030             :                                     "\", invalid");
    2031           0 :                 ShowContinueError(state, "...illegal " + cAlphaFields(7) + "=\"" + AlphArray(7) + "\".");
    2032           0 :                 ShowContinueError(state, "...valid values for this field are Timed or OnDemand.");
    2033           0 :                 ErrorsFound = true;
    2034             :             }
    2035             : 
    2036             :             // Set minimum OAT for heat pump compressor operation
    2037           8 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MinOATCompressor = NumArray(5);
    2038             : 
    2039             :             // reserved for HSPF calculation
    2040           8 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OATempCompressorOn = NumArray(6);
    2041             : 
    2042             :             // Set maximum outdoor temp for defrost to occur
    2043           8 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MaxOATDefrost = NumArray(7);
    2044             : 
    2045             :             // Set crankcase heater capacity
    2046           8 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterCapacity = NumArray(8);
    2047           8 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterCapacity < 0.0) {
    2048           0 :                 ShowSevereError(state,
    2049           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name +
    2050             :                                     "\", invalid");
    2051           0 :                 ShowContinueError(state, "..." + cNumericFields(9) + " cannot be < 0.0.");
    2052           0 :                 ShowContinueError(state, format("...entered value=[{:.2T}].", NumArray(9)));
    2053           0 :                 ErrorsFound = true;
    2054             :             }
    2055             : 
    2056             :             // Set crankcase heater cutout temperature
    2057           8 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MaxOATCrankcaseHeater = NumArray(9);
    2058             : 
    2059             :             // Set defrost time period
    2060           8 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostTime = NumArray(10);
    2061           8 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostTime == 0.0 &&
    2062           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostControl == 1) {
    2063           0 :                 ShowWarningError(state,
    2064           0 :                                  std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name +
    2065             :                                      "\", ");
    2066           0 :                 ShowContinueError(state, "..." + cNumericFields(5) + " = 0.0 for defrost control = TIMED.");
    2067             :             }
    2068             : 
    2069             :             // Set defrost capacity (for resistive defrost)
    2070           8 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostCapacity = NumArray(11);
    2071           8 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostCapacity == 0.0 &&
    2072           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostStrategy == 2) {
    2073           0 :                 ShowWarningError(state,
    2074           0 :                                  std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name +
    2075             :                                      "\", ");
    2076           0 :                 ShowContinueError(state, "..." + cNumericFields(6) + " = 0.0 for defrost strategy = RESISTIVE.");
    2077             :             }
    2078             : 
    2079          78 :             for (I = 1; I <= state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds; ++I) {
    2080          70 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I) = NumArray(12 + (I - 1) * 3);
    2081          70 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedCOP(I) = NumArray(13 + (I - 1) * 3);
    2082          70 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowRate(I) = NumArray(14 + (I - 1) * 3);
    2083             : 
    2084          70 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I) < 1.e-10) {
    2085           0 :                     ShowSevereError(state,
    2086           0 :                                     std::string{RoutineName} + CurrentModuleObject + "=\"" +
    2087           0 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", invalid value");
    2088           0 :                     ShowContinueError(state,
    2089           0 :                                       format("...too small {}=[{:.2R}].",
    2090           0 :                                              cNumericFields(12 + (I - 1) * 3),
    2091           0 :                                              state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I)));
    2092           0 :                     ErrorsFound = true;
    2093             :                 }
    2094             : 
    2095          70 :                 AlfaFieldIncre = 8 + (I - 1) * 4;
    2096          70 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(I) =
    2097          70 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
    2098          70 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(I) == 0) {
    2099           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
    2100           0 :                         ShowSevereError(state,
    2101           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    2102           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", missing");
    2103           0 :                         ShowContinueError(state, "...required " + cAlphaFields(AlfaFieldIncre) + " is blank.");
    2104             :                     } else {
    2105           0 :                         ShowSevereError(state,
    2106           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    2107           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", invalid");
    2108           0 :                         ShowContinueError(state, "...not found " + cAlphaFields(AlfaFieldIncre) + "=\"" + AlphArray(AlfaFieldIncre) + "\".");
    2109             :                     }
    2110           0 :                     ErrorsFound = true;
    2111             :                 } else {
    2112             :                     // Verify Curve Object, only legal type is BiQuadratic
    2113         210 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    2114          70 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(I), // Curve index
    2115             :                                                          {2},                                                                  // Valid dimensions
    2116             :                                                          RoutineName,                                                          // Routine name
    2117             :                                                          CurrentModuleObject,                                                  // Object Type
    2118          70 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,           // Object Name
    2119          70 :                                                          cAlphaFields(AlfaFieldIncre));                                        // Field Name
    2120             : 
    2121          70 :                     if (!ErrorsFound) {
    2122         140 :                         CurveVal = CurveValue(
    2123          70 :                             state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(I), RatedInletAirTempHeat, RatedAmbAirTempHeat);
    2124          70 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
    2125           0 :                             ShowWarningError(state,
    2126           0 :                                              std::string{RoutineName} + CurrentModuleObject + "=\"" +
    2127           0 :                                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", curve values");
    2128           0 :                             ShowContinueError(state,
    2129           0 :                                               "..." + cAlphaFields(AlfaFieldIncre) + " output is not equal to 1.0 (+ or - 10%) at rated conditions.");
    2130           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    2131             :                         }
    2132             :                     }
    2133             :                 }
    2134             : 
    2135          70 :                 AlfaFieldIncre = 9 + (I - 1) * 4;
    2136          70 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(I) =
    2137          70 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
    2138          70 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(I) == 0) {
    2139           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
    2140           0 :                         ShowSevereError(state,
    2141           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    2142           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", missing");
    2143           0 :                         ShowContinueError(state, "...required " + cAlphaFields(AlfaFieldIncre) + " is blank.");
    2144             :                     } else {
    2145           0 :                         ShowSevereError(state,
    2146           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    2147           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", invalid");
    2148           0 :                         ShowContinueError(state, "...not found " + cAlphaFields(AlfaFieldIncre) + "=\"" + AlphArray(AlfaFieldIncre) + "\".");
    2149             :                     }
    2150           0 :                     ErrorsFound = true;
    2151             :                 } else {
    2152             :                     // Verify Curve Object, only legal type is Quadratic
    2153         210 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    2154          70 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(I), // Curve index
    2155             :                                                          {1},                                                                     // Valid dimensions
    2156             :                                                          RoutineName,                                                             // Routine name
    2157             :                                                          CurrentModuleObject,                                                     // Object Type
    2158          70 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,              // Object Name
    2159          70 :                                                          cAlphaFields(AlfaFieldIncre));                                           // Field Name
    2160             : 
    2161          70 :                     if (!ErrorsFound) {
    2162          70 :                         CurveVal = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(I), 1.0);
    2163          70 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
    2164           0 :                             ShowWarningError(state,
    2165           0 :                                              std::string{RoutineName} + CurrentModuleObject + "=\"" +
    2166           0 :                                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", curve values");
    2167           0 :                             ShowContinueError(state,
    2168           0 :                                               "..." + cAlphaFields(AlfaFieldIncre) + " output is not equal to 1.0 (+ or - 10%) at rated conditions.");
    2169           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    2170             :                         }
    2171             :                     }
    2172             :                 }
    2173             : 
    2174          70 :                 AlfaFieldIncre = 10 + (I - 1) * 4;
    2175          70 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(I) =
    2176          70 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
    2177          70 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(I) == 0) {
    2178           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
    2179           0 :                         ShowSevereError(state,
    2180           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    2181           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", missing");
    2182           0 :                         ShowContinueError(state, "...required " + cAlphaFields(AlfaFieldIncre) + " is blank.");
    2183             :                     } else {
    2184           0 :                         ShowSevereError(state,
    2185           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    2186           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", invalid");
    2187           0 :                         ShowContinueError(state, "...not found " + cAlphaFields(AlfaFieldIncre) + "=\"" + AlphArray(AlfaFieldIncre) + "\".");
    2188             :                     }
    2189           0 :                     ErrorsFound = true;
    2190             :                 } else {
    2191             :                     // Verify Curve Object, only legal type is BiQuadratic
    2192         210 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    2193          70 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(I), // Curve index
    2194             :                                                          {2},                                                                 // Valid dimensions
    2195             :                                                          RoutineName,                                                         // Routine name
    2196             :                                                          CurrentModuleObject,                                                 // Object Type
    2197          70 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,          // Object Name
    2198          70 :                                                          cAlphaFields(AlfaFieldIncre));                                       // Field Name
    2199             : 
    2200          70 :                     if (!ErrorsFound) {
    2201         140 :                         CurveVal = CurveValue(
    2202          70 :                             state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(I), RatedInletAirTempHeat, RatedAmbAirTempHeat);
    2203          70 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
    2204           0 :                             ShowWarningError(state,
    2205           0 :                                              std::string{RoutineName} + CurrentModuleObject + "=\"" +
    2206           0 :                                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", curve values");
    2207           0 :                             ShowContinueError(state,
    2208           0 :                                               "..." + cAlphaFields(AlfaFieldIncre) + " output is not equal to 1.0 (+ or - 10%) at rated conditions.");
    2209           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    2210             :                         }
    2211             :                     }
    2212             :                 }
    2213             : 
    2214          70 :                 AlfaFieldIncre = 11 + (I - 1) * 4;
    2215          70 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(I) =
    2216          70 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
    2217          70 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(I) == 0) {
    2218           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
    2219           0 :                         ShowSevereError(state,
    2220           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    2221           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", missing");
    2222           0 :                         ShowContinueError(state, "...required " + cAlphaFields(AlfaFieldIncre) + " is blank.");
    2223             :                     } else {
    2224           0 :                         ShowSevereError(state,
    2225           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    2226           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", invalid");
    2227           0 :                         ShowContinueError(state, "...not found " + cAlphaFields(AlfaFieldIncre) + "=\"" + AlphArray(AlfaFieldIncre) + "\".");
    2228             :                     }
    2229           0 :                     ErrorsFound = true;
    2230             :                 } else {
    2231             :                     // Verify Curve Object, only legal type is Quadratic
    2232         210 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    2233          70 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(I), // Curve index
    2234             :                                                          {1},                                                                    // Valid dimensions
    2235             :                                                          RoutineName,                                                            // Routine name
    2236             :                                                          CurrentModuleObject,                                                    // Object Type
    2237          70 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,             // Object Name
    2238          70 :                                                          cAlphaFields(AlfaFieldIncre));                                          // Field Name
    2239             : 
    2240          70 :                     if (!ErrorsFound) {
    2241          70 :                         CurveVal = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(I), 1.0);
    2242          70 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
    2243           0 :                             ShowWarningError(state,
    2244           0 :                                              std::string{RoutineName} + CurrentModuleObject + "=\"" +
    2245           0 :                                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", curve values");
    2246           0 :                             ShowContinueError(state,
    2247           0 :                                               "..." + cAlphaFields(AlfaFieldIncre) + " output is not equal to 1.0 (+ or - 10%) at rated conditions.");
    2248           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    2249             :                         }
    2250             :                     }
    2251             :                 }
    2252             :             }
    2253             : 
    2254           8 :             if (ErrorsFound) continue;
    2255             : 
    2256          78 :             for (I = 1; I <= state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds; ++I) {
    2257          70 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedPercentTotCap(I) =
    2258         140 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I) /
    2259         140 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(
    2260          70 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds);
    2261          70 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowPerRatedTotCap(I) =
    2262         140 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowRate(I) /
    2263          70 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I);
    2264             :             }
    2265             : 
    2266             :             // CurrentModuleObject = "Coil:Heating:DX:Variablespeed "
    2267          32 :             SetupOutputVariable(state,
    2268             :                                 "Heating Coil Electricity Energy",
    2269             :                                 OutputProcessor::Unit::J,
    2270           8 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Energy,
    2271             :                                 OutputProcessor::SOVTimeStepType::System,
    2272             :                                 OutputProcessor::SOVStoreType::Summed,
    2273           8 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    2274             :                                 _,
    2275             :                                 "Electricity",
    2276             :                                 "Heating",
    2277             :                                 _,
    2278           8 :                                 "System");
    2279          32 :             SetupOutputVariable(state,
    2280             :                                 "Heating Coil Heating Energy",
    2281             :                                 OutputProcessor::Unit::J,
    2282           8 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLoadTotal,
    2283             :                                 OutputProcessor::SOVTimeStepType::System,
    2284             :                                 OutputProcessor::SOVStoreType::Summed,
    2285           8 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    2286             :                                 _,
    2287             :                                 "ENERGYTRANSFER",
    2288             :                                 "HEATINGCOILS",
    2289             :                                 _,
    2290           8 :                                 "System");
    2291          32 :             SetupOutputVariable(state,
    2292             :                                 "Heating Coil Source Side Heat Transfer Energy",
    2293             :                                 OutputProcessor::Unit::J,
    2294           8 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergySource,
    2295             :                                 OutputProcessor::SOVTimeStepType::System,
    2296             :                                 OutputProcessor::SOVStoreType::Summed,
    2297          16 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    2298             : 
    2299             :             // create predefined report entries
    2300          24 :             PreDefTableEntry(
    2301          16 :                 state, state.dataOutRptPredefined->pdchHeatCoilType, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name, CurrentModuleObject);
    2302          32 :             PreDefTableEntry(state,
    2303           8 :                              state.dataOutRptPredefined->pdchHeatCoilNomCap,
    2304           8 :                              state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    2305           8 :                              state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedCapHeat);
    2306          32 :             PreDefTableEntry(state,
    2307           8 :                              state.dataOutRptPredefined->pdchHeatCoilNomEff,
    2308           8 :                              state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    2309           8 :                              state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedCOP(
    2310           8 :                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel));
    2311             :         }
    2312             : 
    2313             :         //-------------------------AIR SOURCE HEATING---END
    2314             : 
    2315             :         //------------------------VARIABLE-SPEED AIR SOURCE HPWH---BEGIN
    2316          19 :         CurrentModuleObject = "COIL:WATERHEATING:AIRTOWATERHEATPUMP:VARIABLESPEED"; // for reporting
    2317             : 
    2318          29 :         for (CoilCounter = 1; CoilCounter <= NumHPWHAirToWater; ++CoilCounter) {
    2319             : 
    2320          10 :             ++DXCoilNum;
    2321          10 :             AlfaFieldIncre = 1;
    2322             : 
    2323          10 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
    2324             :                                                                      CurrentModuleObject,
    2325             :                                                                      CoilCounter,
    2326             :                                                                      AlphArray,
    2327             :                                                                      NumAlphas,
    2328             :                                                                      NumArray,
    2329             :                                                                      NumNums,
    2330             :                                                                      IOStat,
    2331             :                                                                      lNumericBlanks,
    2332             :                                                                      lAlphaBlanks,
    2333             :                                                                      cAlphaFields,
    2334             :                                                                      cNumericFields);
    2335             :             // ErrorsFound will be set to True if problem was found, left untouched otherwise
    2336          10 :             VerifyUniqueCoilName(state, CurrentModuleObject, AlphArray(1), ErrorsFound, CurrentModuleObject + " Name");
    2337             : 
    2338          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).bIsDesuperheater = false;
    2339          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserType = DataHeatBalance::RefrigCondenserType::WaterHeater;
    2340          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CoolHeatType = "WATERHEATING";
    2341          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType = CoilDX_HeatPumpWaterHeaterVariableSpeed;
    2342          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VarSpeedCoilType = cAllCoilTypes(CoilDX_HeatPumpWaterHeaterVariableSpeed);
    2343             : 
    2344          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name = AlphArray(1);
    2345          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds = int(NumArray(1));
    2346          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel = int(NumArray(2));
    2347             : 
    2348          10 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds < 1) {
    2349           0 :                 ShowSevereError(state,
    2350           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name +
    2351             :                                     "\", invalid");
    2352           0 :                 ShowContinueError(state, format("...{} must be >= 1. entered number is {:.0T}", cNumericFields(1), NumArray(1)));
    2353           0 :                 ErrorsFound = true;
    2354             :             }
    2355             : 
    2356          20 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel >
    2357          10 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds) {
    2358           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel =
    2359           0 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds;
    2360             :             }
    2361             : 
    2362          20 :             if ((state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel >
    2363          20 :                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds) ||
    2364          10 :                 (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel <= 0)) {
    2365           0 :                 ShowSevereError(state,
    2366           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name +
    2367             :                                     "\", invalid");
    2368           0 :                 ShowContinueError(state, format("...{} must be valid speed level entered number is {:.0T}", cNumericFields(2), NumArray(2)));
    2369           0 :                 ErrorsFound = true;
    2370             :             }
    2371             : 
    2372          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedCapWH = NumArray(3);
    2373          10 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedCapWH <= 0.0) {
    2374           0 :                 ShowSevereError(state,
    2375           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name +
    2376             :                                     "\", invalid");
    2377           0 :                 ShowContinueError(state, format("...{} must be > 0.0, entered value=[{:.2T}].", cNumericFields(3), NumArray(3)));
    2378           0 :                 ErrorsFound = true;
    2379             :             }
    2380             : 
    2381          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WHRatedInletDBTemp = NumArray(4);
    2382          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WHRatedInletWBTemp = NumArray(5);
    2383          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WHRatedInletWaterTemp = NumArray(6);
    2384             : 
    2385          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedAirVolFlowRate = NumArray(7);
    2386          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedWaterVolFlowRate = NumArray(8);
    2387             : 
    2388          10 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedAirVolFlowRate != DataGlobalConstants::AutoCalculate) {
    2389           6 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedAirVolFlowRate <= 0.0) {
    2390           0 :                     ShowSevereError(state,
    2391           0 :                                     std::string{RoutineName} + CurrentModuleObject + "=\"" +
    2392           0 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", invalid");
    2393           0 :                     ShowContinueError(state, format("...{} must be > 0.0.  entered value=[{:.3T}].", cNumericFields(7), NumArray(7)));
    2394           0 :                     ErrorsFound = true;
    2395             :                 }
    2396             :             }
    2397             : 
    2398          10 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedWaterVolFlowRate != DataGlobalConstants::AutoCalculate) {
    2399           6 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedWaterVolFlowRate <= 0.0) {
    2400           0 :                     ShowSevereError(state,
    2401           0 :                                     std::string{RoutineName} + CurrentModuleObject + "=\"" +
    2402           0 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", invalid");
    2403           0 :                     ShowContinueError(state, format("...{} must be > 0.0  entered value=[{:.3T}].", cNumericFields(8), NumArray(8)));
    2404           0 :                     ErrorsFound = true;
    2405             :                 }
    2406             :             }
    2407             : 
    2408          10 :             if (UtilityRoutines::SameString(AlphArray(2), "Yes") || UtilityRoutines::SameString(AlphArray(2), "No")) {
    2409             :                 //  initialized to TRUE on allocate
    2410          10 :                 if (UtilityRoutines::SameString(AlphArray(2), "No"))
    2411           9 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).FanPowerIncludedInCOP = false;
    2412             :                 else
    2413           1 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).FanPowerIncludedInCOP = true;
    2414             :             } else {
    2415           0 :                 ShowSevereError(state,
    2416           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name +
    2417             :                                     "\", invalid");
    2418           0 :                 ShowContinueError(state, ",,,invalid choice for " + cAlphaFields(2) + ".  Entered choice = " + AlphArray(2));
    2419           0 :                 ShowContinueError(state, "Valid choices are Yes or No.");
    2420           0 :                 ErrorsFound = true;
    2421             :             }
    2422             : 
    2423          10 :             if (UtilityRoutines::SameString(AlphArray(3), "Yes") || UtilityRoutines::SameString(AlphArray(3), "No")) {
    2424             :                 //  initialized to FALSE on allocate
    2425          10 :                 if (UtilityRoutines::SameString(AlphArray(3), "Yes"))
    2426           0 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondPumpPowerInCOP = true;
    2427             :                 else
    2428          10 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondPumpPowerInCOP = false;
    2429             :             } else {
    2430           0 :                 ShowSevereError(state,
    2431           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name +
    2432             :                                     "\", invalid");
    2433           0 :                 ShowContinueError(state, ",,,invalid choice for " + cAlphaFields(3) + ".  Entered choice = " + AlphArray(3));
    2434           0 :                 ShowContinueError(state, "Valid choices are Yes or No.");
    2435           0 :                 ErrorsFound = true;
    2436             :             }
    2437             : 
    2438          10 :             if (UtilityRoutines::SameString(AlphArray(4), "Yes") || UtilityRoutines::SameString(AlphArray(4), "No")) {
    2439             :                 //  initialized to FALSE on allocate
    2440          10 :                 if (UtilityRoutines::SameString(AlphArray(4), "Yes"))
    2441           0 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondPumpHeatInCapacity = true;
    2442             :                 else
    2443          10 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondPumpHeatInCapacity = false;
    2444             :             } else {
    2445           0 :                 ShowSevereError(state,
    2446           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name +
    2447             :                                     "\", invalid");
    2448           0 :                 ShowContinueError(state, ",,,invalid choice for " + cAlphaFields(4) + ".  Entered choice = " + AlphArray(4));
    2449           0 :                 ShowContinueError(state, "Valid choices are Yes or No.");
    2450           0 :                 ErrorsFound = true;
    2451             :             }
    2452             : 
    2453          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpFracToWater = NumArray(9);
    2454          20 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpFracToWater <= 0.0 ||
    2455          10 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpFracToWater > 1.0) {
    2456           0 :                 ShowSevereError(state,
    2457           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name +
    2458             :                                     "\", invalid");
    2459           0 :                 ShowContinueError(state, format("...{} must be >= 0 and <= 1.  entered value=[{:.3T}].", cNumericFields(10), NumArray(9)));
    2460           0 :                 ErrorsFound = true;
    2461             :             }
    2462             : 
    2463          10 :             if (!state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondPumpHeatInCapacity) {
    2464          10 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpFracToWater = 0.0;
    2465             :             }
    2466             : 
    2467             :             // Air nodes
    2468          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirInletNodeNum =
    2469          20 :                 GetOnlySingleNode(state,
    2470          10 :                                   AlphArray(5),
    2471             :                                   ErrorsFound,
    2472             :                                   DataLoopNode::ConnectionObjectType::CoilWaterHeatingAirToWaterHeatPumpVariableSpeed,
    2473          10 :                                   AlphArray(1),
    2474             :                                   DataLoopNode::NodeFluidType::Air,
    2475             :                                   DataLoopNode::ConnectionType::Inlet,
    2476             :                                   NodeInputManager::CompFluidStream::Primary,
    2477          10 :                                   ObjectIsNotParent);
    2478             : 
    2479          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirOutletNodeNum =
    2480          20 :                 GetOnlySingleNode(state,
    2481          10 :                                   AlphArray(6),
    2482             :                                   ErrorsFound,
    2483             :                                   DataLoopNode::ConnectionObjectType::CoilWaterHeatingAirToWaterHeatPumpVariableSpeed,
    2484          10 :                                   AlphArray(1),
    2485             :                                   DataLoopNode::NodeFluidType::Air,
    2486             :                                   DataLoopNode::ConnectionType::Outlet,
    2487             :                                   NodeInputManager::CompFluidStream::Primary,
    2488          10 :                                   ObjectIsNotParent);
    2489             : 
    2490          10 :             TestCompSet(state, CurrentModuleObject, AlphArray(1), AlphArray(5), AlphArray(6), "Air Nodes");
    2491             : 
    2492             :             // Check if the air inlet node is OA node, to justify whether the coil is placed in zone or not
    2493          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).IsDXCoilInZone =
    2494          10 :                 !CheckOutAirNodeNumber(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirInletNodeNum);
    2495             : 
    2496             :             // Water nodes
    2497          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterInletNodeNum =
    2498          20 :                 GetOnlySingleNode(state,
    2499          10 :                                   AlphArray(7),
    2500             :                                   ErrorsFound,
    2501             :                                   DataLoopNode::ConnectionObjectType::CoilWaterHeatingAirToWaterHeatPumpVariableSpeed,
    2502          10 :                                   AlphArray(1),
    2503             :                                   DataLoopNode::NodeFluidType::Water,
    2504             :                                   DataLoopNode::ConnectionType::Inlet,
    2505             :                                   NodeInputManager::CompFluidStream::Secondary,
    2506          10 :                                   ObjectIsNotParent);
    2507             : 
    2508          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterOutletNodeNum =
    2509          20 :                 GetOnlySingleNode(state,
    2510          10 :                                   AlphArray(8),
    2511             :                                   ErrorsFound,
    2512             :                                   DataLoopNode::ConnectionObjectType::CoilWaterHeatingAirToWaterHeatPumpVariableSpeed,
    2513          10 :                                   AlphArray(1),
    2514             :                                   DataLoopNode::NodeFluidType::Water,
    2515             :                                   DataLoopNode::ConnectionType::Outlet,
    2516             :                                   NodeInputManager::CompFluidStream::Secondary,
    2517          10 :                                   ObjectIsNotParent);
    2518             : 
    2519          10 :             TestCompSet(state, CurrentModuleObject, AlphArray(1), AlphArray(7), AlphArray(8), "Water Nodes");
    2520             : 
    2521          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterCapacity = NumArray(10);
    2522          10 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterCapacity < 0.0) {
    2523           0 :                 ShowSevereError(state,
    2524           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name +
    2525             :                                     "\", invalid");
    2526           0 :                 ShowContinueError(state, format("...{} must be >= 0.0  entered value=[{:.1T}].", cNumericFields(10), NumArray(10)));
    2527           0 :                 ErrorsFound = true;
    2528             :             }
    2529             : 
    2530          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MaxOATCrankcaseHeater = NumArray(11);
    2531          10 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MaxOATCrankcaseHeater < 0.0) {
    2532           0 :                 ShowSevereError(state,
    2533           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name +
    2534             :                                     "\", invalid");
    2535           0 :                 ShowContinueError(state, format("...{} must be >= 0 {{C}}.  entered value=[{:.1T}].", cNumericFields(11), NumArray(11)));
    2536           0 :                 ErrorsFound = true;
    2537             :             }
    2538             : 
    2539          10 :             if (UtilityRoutines::SameString(AlphArray(9), "DryBulbTemperature")) {
    2540           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirTemperatureType = DryBulbIndicator;
    2541          10 :             } else if (UtilityRoutines::SameString(AlphArray(9), "WetBulbTemperature")) {
    2542          10 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirTemperatureType = WetBulbIndicator;
    2543             :             } else {
    2544             :                 //   wrong temperature type selection
    2545           0 :                 ShowSevereError(state,
    2546           0 :                                 std::string{RoutineName} + CurrentModuleObject + "=\"" + state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name +
    2547             :                                     "\", invalid");
    2548           0 :                 ShowContinueError(state, "..." + cAlphaFields(9) + " must be DryBulbTemperature or WetBulbTemperature.");
    2549           0 :                 ShowContinueError(state, "...entered value=\"" + AlphArray(9) + "\".");
    2550           0 :                 ErrorsFound = true;
    2551             :             }
    2552             : 
    2553             :             // set rated inlet air temperature for curve object verification
    2554          10 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirTemperatureType == WetBulbIndicator) {
    2555          10 :                 WHInletAirTemp = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WHRatedInletWBTemp;
    2556             :             } else {
    2557           0 :                 WHInletAirTemp = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WHRatedInletDBTemp;
    2558             :             }
    2559             :             // set rated water temperature for curve object verification
    2560          10 :             WHInletWaterTemp = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WHRatedInletWaterTemp;
    2561             : 
    2562             :             // part load curve
    2563          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PLFFPLR = GetCurveIndex(state, AlphArray(10)); // convert curve name to number
    2564          10 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PLFFPLR == 0) {
    2565           0 :                 if (lAlphaBlanks(10)) {
    2566           0 :                     ShowSevereError(state,
    2567           0 :                                     std::string{RoutineName} + CurrentModuleObject + "=\"" +
    2568           0 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", missing");
    2569           0 :                     ShowContinueError(state, "...required " + cAlphaFields(10) + " is blank.");
    2570             :                 } else {
    2571           0 :                     ShowSevereError(state,
    2572           0 :                                     std::string{RoutineName} + CurrentModuleObject + "=\"" +
    2573           0 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", invalid");
    2574           0 :                     ShowContinueError(state, "...not found " + cAlphaFields(10) + "=\"" + AlphArray(10) + "\".");
    2575             :                 }
    2576           0 :                 ErrorsFound = true;
    2577             :             } else {
    2578          10 :                 CurveVal = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PLFFPLR, 1.0);
    2579          10 :                 if (CurveVal > 1.10 || CurveVal < 0.90) {
    2580           0 :                     ShowWarningError(state,
    2581           0 :                                      std::string{RoutineName} + CurrentModuleObject + "=\"" +
    2582           0 :                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", curve values");
    2583           0 :                     ShowContinueError(state,
    2584           0 :                                       "..." + cAlphaFields(10) +
    2585             :                                           " output is not equal to 1.0 "
    2586             :                                           "(+ or - 10%) at rated conditions.");
    2587           0 :                     ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    2588             :                 }
    2589             :             }
    2590             : 
    2591         110 :             for (I = 1; I <= state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds; ++I) {
    2592         100 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I) = NumArray(12 + (I - 1) * 6);
    2593         100 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedCOP(I) = NumArray(13 + (I - 1) * 6);
    2594         100 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedSHR(I) = NumArray(14 + (I - 1) * 6);
    2595         100 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowRate(I) = NumArray(15 + (I - 1) * 6);
    2596         100 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterVolFlowRate(I) = NumArray(16 + (I - 1) * 6);
    2597         100 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWHPumpPower(I) = NumArray(17 + (I - 1) * 6);
    2598             : 
    2599         100 :                 AlfaFieldIncre = 11 + (I - 1) * 6;
    2600         100 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(I) =
    2601         100 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
    2602         100 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(I) == 0) {
    2603           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
    2604           0 :                         ShowSevereError(state,
    2605           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    2606           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", missing");
    2607           0 :                         ShowContinueError(state, "...required " + cAlphaFields(AlfaFieldIncre) + " is blank.");
    2608             :                     } else {
    2609           0 :                         ShowSevereError(state,
    2610           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    2611           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", invalid");
    2612           0 :                         ShowContinueError(state, "...not found " + cAlphaFields(AlfaFieldIncre) + "=\"" + AlphArray(AlfaFieldIncre) + "\".");
    2613             :                     }
    2614           0 :                     ErrorsFound = true;
    2615             :                 } else {
    2616             :                     // Verify Curve Object, only legal type is BiQuadratic
    2617         300 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    2618         100 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(I), // Curve index
    2619             :                                                          {2},                                                                  // Valid dimensions
    2620             :                                                          RoutineName,                                                          // Routine name
    2621             :                                                          CurrentModuleObject,                                                  // Object Type
    2622         100 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,           // Object Name
    2623         100 :                                                          cAlphaFields(AlfaFieldIncre));                                        // Field Name
    2624             : 
    2625         100 :                     if (!ErrorsFound) {
    2626         100 :                         CurveVal =
    2627         200 :                             CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(I), WHInletAirTemp, WHInletWaterTemp);
    2628         100 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
    2629           0 :                             ShowWarningError(state,
    2630           0 :                                              std::string{RoutineName} + CurrentModuleObject + "=\"" +
    2631           0 :                                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", curve values");
    2632           0 :                             ShowContinueError(state,
    2633           0 :                                               "..." + cAlphaFields(AlfaFieldIncre) +
    2634             :                                                   " output is not equal to 1.0 "
    2635             :                                                   "(+ or - 10%) at rated conditions.");
    2636           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    2637             :                         }
    2638             :                     }
    2639             :                 }
    2640             : 
    2641         100 :                 AlfaFieldIncre = 12 + (I - 1) * 6;
    2642         100 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(I) =
    2643         100 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
    2644         100 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(I) == 0) {
    2645           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
    2646           0 :                         ShowSevereError(state,
    2647           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    2648           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", missing");
    2649           0 :                         ShowContinueError(state, "...required " + cAlphaFields(AlfaFieldIncre) + " is blank.");
    2650             :                     } else {
    2651           0 :                         ShowSevereError(state,
    2652           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    2653           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", invalid");
    2654           0 :                         ShowContinueError(state, "...not found " + cAlphaFields(AlfaFieldIncre) + "=\"" + AlphArray(AlfaFieldIncre) + "\".");
    2655             :                     }
    2656           0 :                     ErrorsFound = true;
    2657             :                 } else {
    2658             :                     // Verify Curve Object, only legal type is Quadratic
    2659         300 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    2660         100 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(I), // Curve index
    2661             :                                                          {1},                                                                     // Valid dimensions
    2662             :                                                          RoutineName,                                                             // Routine name
    2663             :                                                          CurrentModuleObject,                                                     // Object Type
    2664         100 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,              // Object Name
    2665         100 :                                                          cAlphaFields(AlfaFieldIncre));                                           // Field Name
    2666             : 
    2667         100 :                     if (!ErrorsFound) {
    2668         100 :                         CurveVal = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(I), 1.0);
    2669         100 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
    2670           0 :                             ShowWarningError(state,
    2671           0 :                                              std::string{RoutineName} + CurrentModuleObject + "=\"" +
    2672           0 :                                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", curve values");
    2673           0 :                             ShowContinueError(state,
    2674           0 :                                               "..." + cAlphaFields(AlfaFieldIncre) +
    2675             :                                                   " output is not equal to 1.0 "
    2676             :                                                   "(+ or - 10%) at rated conditions.");
    2677           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    2678             :                         }
    2679             :                     }
    2680             :                 }
    2681             : 
    2682         100 :                 AlfaFieldIncre = 13 + (I - 1) * 6;
    2683         100 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(I) =
    2684         100 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
    2685         100 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(I) == 0) {
    2686           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
    2687           0 :                         ShowSevereError(state,
    2688           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    2689           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", missing");
    2690           0 :                         ShowContinueError(state, "...required " + cAlphaFields(AlfaFieldIncre) + " is blank.");
    2691             :                     } else {
    2692           0 :                         ShowSevereError(state,
    2693           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    2694           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", invalid");
    2695           0 :                         ShowContinueError(state, "...not found " + cAlphaFields(AlfaFieldIncre) + "=\"" + AlphArray(AlfaFieldIncre) + "\".");
    2696             :                     }
    2697           0 :                     ErrorsFound = true;
    2698             :                 } else {
    2699             :                     // Verify Curve Object, only legal type is Quadratic
    2700         300 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    2701         100 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(I), // Curve index
    2702             :                                                          {1},                                                        // Valid dimensions
    2703             :                                                          RoutineName,                                                // Routine name
    2704             :                                                          CurrentModuleObject,                                        // Object Type
    2705         100 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name, // Object Name
    2706         100 :                                                          cAlphaFields(AlfaFieldIncre));                              // Field Name
    2707             : 
    2708         100 :                     if (!ErrorsFound) {
    2709         100 :                         CurveVal = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(I), 1.0);
    2710         100 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
    2711           0 :                             ShowWarningError(state,
    2712           0 :                                              std::string{RoutineName} + CurrentModuleObject + "=\"" +
    2713           0 :                                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", curve values");
    2714           0 :                             ShowContinueError(state,
    2715           0 :                                               "..." + cAlphaFields(AlfaFieldIncre) +
    2716             :                                                   " output is not equal to 1.0 "
    2717             :                                                   "(+ or - 10%) at rated conditions.");
    2718           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    2719             :                         }
    2720             :                     }
    2721             :                 }
    2722             : 
    2723         100 :                 AlfaFieldIncre = 14 + (I - 1) * 6;
    2724         100 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(I) =
    2725         100 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
    2726         100 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(I) == 0) {
    2727           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
    2728           0 :                         ShowSevereError(state,
    2729           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    2730           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", missing");
    2731           0 :                         ShowContinueError(state, "...required " + cAlphaFields(AlfaFieldIncre) + " is blank.");
    2732             :                     } else {
    2733           0 :                         ShowSevereError(state,
    2734           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    2735           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", invalid");
    2736           0 :                         ShowContinueError(state, "...not found " + cAlphaFields(AlfaFieldIncre) + "=\"" + AlphArray(AlfaFieldIncre) + "\".");
    2737             :                     }
    2738           0 :                     ErrorsFound = true;
    2739             :                 } else {
    2740             :                     // Verify Curve Object, only legal type is BiQuadratic
    2741         300 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    2742         100 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(I), // Curve index
    2743             :                                                          {2},                                                                 // Valid dimensions
    2744             :                                                          RoutineName,                                                         // Routine name
    2745             :                                                          CurrentModuleObject,                                                 // Object Type
    2746         100 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,          // Object Name
    2747         100 :                                                          cAlphaFields(AlfaFieldIncre));                                       // Field Name
    2748             : 
    2749         100 :                     if (!ErrorsFound) {
    2750         100 :                         CurveVal =
    2751         200 :                             CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(I), WHInletAirTemp, WHInletWaterTemp);
    2752         100 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
    2753           0 :                             ShowWarningError(state,
    2754           0 :                                              std::string{RoutineName} + CurrentModuleObject + "=\"" +
    2755           0 :                                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", curve values");
    2756           0 :                             ShowContinueError(state,
    2757           0 :                                               "..." + cAlphaFields(AlfaFieldIncre) +
    2758             :                                                   " output is not equal to 1.0 "
    2759             :                                                   "(+ or - 10%) at rated conditions.");
    2760           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    2761             :                         }
    2762             :                     }
    2763             :                 }
    2764             : 
    2765         100 :                 AlfaFieldIncre = 15 + (I - 1) * 6;
    2766         100 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(I) =
    2767         100 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
    2768         100 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(I) == 0) {
    2769           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
    2770           0 :                         ShowSevereError(state,
    2771           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    2772           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", missing");
    2773           0 :                         ShowContinueError(state, "...required " + cAlphaFields(AlfaFieldIncre) + " is blank.");
    2774             :                     } else {
    2775           0 :                         ShowSevereError(state,
    2776           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    2777           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", invalid");
    2778           0 :                         ShowContinueError(state, "...not found " + cAlphaFields(AlfaFieldIncre) + "=\"" + AlphArray(AlfaFieldIncre) + "\".");
    2779             :                     }
    2780           0 :                     ErrorsFound = true;
    2781             :                 } else {
    2782             :                     // Verify Curve Object, only legal type is Quadratic
    2783         300 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    2784         100 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(I), // Curve index
    2785             :                                                          {1},                                                                    // Valid dimensions
    2786             :                                                          RoutineName,                                                            // Routine name
    2787             :                                                          CurrentModuleObject,                                                    // Object Type
    2788         100 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,             // Object Name
    2789         100 :                                                          cAlphaFields(AlfaFieldIncre));                                          // Field Name
    2790             : 
    2791         100 :                     if (!ErrorsFound) {
    2792         100 :                         CurveVal = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(I), 1.0);
    2793         100 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
    2794           0 :                             ShowWarningError(state,
    2795           0 :                                              std::string{RoutineName} + CurrentModuleObject + "=\"" +
    2796           0 :                                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", curve values");
    2797           0 :                             ShowContinueError(state,
    2798           0 :                                               "..." + cAlphaFields(AlfaFieldIncre) +
    2799             :                                                   " output is not equal to 1.0 "
    2800             :                                                   "(+ or - 10%) at rated conditions.");
    2801           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    2802             :                         }
    2803             :                     }
    2804             :                 }
    2805             : 
    2806         100 :                 AlfaFieldIncre = 16 + (I - 1) * 6;
    2807         100 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRWaterFFlow(I) =
    2808         100 :                     GetCurveIndex(state, AlphArray(AlfaFieldIncre)); // convert curve name to number
    2809         100 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRWaterFFlow(I) == 0) {
    2810           0 :                     if (lAlphaBlanks(AlfaFieldIncre)) {
    2811           0 :                         ShowSevereError(state,
    2812           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    2813           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", missing");
    2814           0 :                         ShowContinueError(state, "...required " + cAlphaFields(AlfaFieldIncre) + " is blank.");
    2815             :                     } else {
    2816           0 :                         ShowSevereError(state,
    2817           0 :                                         std::string{RoutineName} + CurrentModuleObject + "=\"" +
    2818           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", invalid");
    2819           0 :                         ShowContinueError(state, "...not found " + cAlphaFields(AlfaFieldIncre) + "=\"" + AlphArray(AlfaFieldIncre) + "\".");
    2820             :                     }
    2821           0 :                     ErrorsFound = true;
    2822             :                 } else {
    2823             :                     // Verify Curve Object, only legal type is Quadratic
    2824         300 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    2825         100 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRWaterFFlow(I), // Curve index
    2826             :                                                          {1},                                                                      // Valid dimensions
    2827             :                                                          RoutineName,                                                              // Routine name
    2828             :                                                          CurrentModuleObject,                                                      // Object Type
    2829         100 :                                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,               // Object Name
    2830         100 :                                                          cAlphaFields(AlfaFieldIncre));                                            // Field Name
    2831             : 
    2832         100 :                     if (!ErrorsFound) {
    2833         100 :                         CurveVal = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRWaterFFlow(I), 1.0);
    2834         100 :                         if (CurveVal > 1.10 || CurveVal < 0.90) {
    2835           0 :                             ShowWarningError(state,
    2836           0 :                                              std::string{RoutineName} + CurrentModuleObject + "=\"" +
    2837           0 :                                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name + "\", curve values");
    2838           0 :                             ShowContinueError(state,
    2839           0 :                                               "..." + cAlphaFields(AlfaFieldIncre) +
    2840             :                                                   " output is not equal to 1.0 "
    2841             :                                                   "(+ or - 10%) at rated conditions.");
    2842           0 :                             ShowContinueError(state, format("...Curve output at rated conditions = {:.3T}", CurveVal));
    2843             :                         }
    2844             :                     }
    2845             :                 }
    2846             :             }
    2847             : 
    2848             :             // get scale values
    2849         110 :             for (I = 1; I <= state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds; ++I) {
    2850         100 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedPercentTotCap(I) =
    2851         200 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I) /
    2852         200 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(
    2853         100 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds);
    2854         100 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowPerRatedTotCap(I) =
    2855         200 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowRate(I) /
    2856         100 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I);
    2857         100 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterVolFlowPerRatedTotCap(I) =
    2858         200 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterVolFlowRate(I) /
    2859         100 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I);
    2860         100 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWHPumpPowerPerRatedTotCap(I) =
    2861         200 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWHPumpPower(I) /
    2862         100 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(I);
    2863             :             }
    2864             : 
    2865             :             // CurrentModuleObject = "Coil:Waterheating:Airtowaterheatpump:Variablespeed"
    2866          40 :             SetupOutputVariable(state,
    2867             :                                 "Cooling Coil Electricity Energy",
    2868             :                                 OutputProcessor::Unit::J,
    2869          10 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Energy,
    2870             :                                 OutputProcessor::SOVTimeStepType::System,
    2871             :                                 OutputProcessor::SOVStoreType::Summed,
    2872          10 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    2873             :                                 _,
    2874             :                                 "Electricity",
    2875             :                                 "Heating",
    2876             :                                 _,
    2877          10 :                                 "System");
    2878          40 :             SetupOutputVariable(state,
    2879             :                                 "Cooling Coil Sensible Cooling Energy",
    2880             :                                 OutputProcessor::Unit::J,
    2881          10 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergySensible,
    2882             :                                 OutputProcessor::SOVTimeStepType::System,
    2883             :                                 OutputProcessor::SOVStoreType::Summed,
    2884          20 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    2885          40 :             SetupOutputVariable(state,
    2886             :                                 "Cooling Coil Latent Cooling Energy",
    2887             :                                 OutputProcessor::Unit::J,
    2888          10 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLatent,
    2889             :                                 OutputProcessor::SOVTimeStepType::System,
    2890             :                                 OutputProcessor::SOVStoreType::Summed,
    2891          20 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    2892          40 :             SetupOutputVariable(state,
    2893             :                                 "Cooling Coil Water Side Heat Transfer Energy",
    2894             :                                 OutputProcessor::Unit::J,
    2895          10 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergySource,
    2896             :                                 OutputProcessor::SOVTimeStepType::System,
    2897             :                                 OutputProcessor::SOVStoreType::Summed,
    2898          10 :                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    2899             :                                 _,
    2900             :                                 "PLANTLOOPHEATINGDEMAND",
    2901             :                                 "HEATINGCOILS",
    2902             :                                 _,
    2903          10 :                                 "System");
    2904             : 
    2905          10 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).IsDXCoilInZone) {
    2906          40 :                 SetupOutputVariable(state,
    2907             :                                     "Cooling Coil Cooling Energy",
    2908             :                                     OutputProcessor::Unit::J,
    2909          10 :                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLoadTotal,
    2910             :                                     OutputProcessor::SOVTimeStepType::System,
    2911             :                                     OutputProcessor::SOVStoreType::Summed,
    2912          10 :                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    2913             :                                     _,
    2914             :                                     "ENERGYTRANSFER",
    2915             :                                     "COOLINGCOILS",
    2916             :                                     _,
    2917          10 :                                     "System");
    2918             :             } else {
    2919           0 :                 SetupOutputVariable(state,
    2920             :                                     "Cooling Coil Cooling Energy",
    2921             :                                     OutputProcessor::Unit::J,
    2922           0 :                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLoadTotal,
    2923             :                                     OutputProcessor::SOVTimeStepType::System,
    2924             :                                     OutputProcessor::SOVStoreType::Summed,
    2925           0 :                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    2926             :             }
    2927             : 
    2928          10 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedCapCoolSens =
    2929             :                 AutoSize; // always auto-sized, to be determined in the sizing calculation
    2930             :         }
    2931             :         //---------------------------VARIABLE-SPEED AIR SOURCE HPWH END --------------
    2932             : 
    2933          19 :         AlphArray.deallocate();
    2934          19 :         cAlphaFields.deallocate();
    2935          19 :         lAlphaBlanks.deallocate();
    2936          19 :         cNumericFields.deallocate();
    2937          19 :         lNumericBlanks.deallocate();
    2938          19 :         NumArray.deallocate();
    2939             : 
    2940          19 :         if (ErrorsFound) {
    2941           0 :             ShowFatalError(state, std::string{RoutineName} + "Errors found getting input. Program terminates.");
    2942             :         }
    2943             : 
    2944          91 :         for (DXCoilNum = 1; DXCoilNum <= state.dataVariableSpeedCoils->NumVarSpeedCoils; ++DXCoilNum) {
    2945         124 :             if ((state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_CoolingAirToAirVariableSpeed) ||
    2946          52 :                 (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_HeatingAirToAirVariableSpeed)) {
    2947             :                 // Setup Report variables for the Heat Pump
    2948             : 
    2949             :                 // cooling and heating coils separately
    2950          28 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_CoolingAirToAirVariableSpeed) {
    2951             :                     // air source cooling coils
    2952          80 :                     SetupOutputVariable(state,
    2953             :                                         "Cooling Coil Air Mass Flow Rate",
    2954             :                                         OutputProcessor::Unit::kg_s,
    2955          20 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate,
    2956             :                                         OutputProcessor::SOVTimeStepType::System,
    2957             :                                         OutputProcessor::SOVStoreType::Average,
    2958          40 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    2959          80 :                     SetupOutputVariable(state,
    2960             :                                         "Cooling Coil Air Inlet Temperature",
    2961             :                                         OutputProcessor::Unit::C,
    2962          20 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirDBTemp,
    2963             :                                         OutputProcessor::SOVTimeStepType::System,
    2964             :                                         OutputProcessor::SOVStoreType::Average,
    2965          40 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    2966          80 :                     SetupOutputVariable(state,
    2967             :                                         "Cooling Coil Air Inlet Humidity Ratio",
    2968             :                                         OutputProcessor::Unit::kgWater_kgDryAir,
    2969          20 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirHumRat,
    2970             :                                         OutputProcessor::SOVTimeStepType::System,
    2971             :                                         OutputProcessor::SOVStoreType::Average,
    2972          40 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    2973          80 :                     SetupOutputVariable(state,
    2974             :                                         "Cooling Coil Latent Cooling Rate",
    2975             :                                         OutputProcessor::Unit::W,
    2976          20 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLatent,
    2977             :                                         OutputProcessor::SOVTimeStepType::System,
    2978             :                                         OutputProcessor::SOVStoreType::Average,
    2979          40 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    2980          80 :                     SetupOutputVariable(state,
    2981             :                                         "Cooling Coil Air Outlet Temperature",
    2982             :                                         OutputProcessor::Unit::C,
    2983          20 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirDBTemp,
    2984             :                                         OutputProcessor::SOVTimeStepType::System,
    2985             :                                         OutputProcessor::SOVStoreType::Average,
    2986          40 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    2987          80 :                     SetupOutputVariable(state,
    2988             :                                         "Cooling Coil Air Outlet Humidity Ratio",
    2989             :                                         OutputProcessor::Unit::kgWater_kgDryAir,
    2990          20 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirHumRat,
    2991             :                                         OutputProcessor::SOVTimeStepType::System,
    2992             :                                         OutputProcessor::SOVStoreType::Average,
    2993          40 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    2994          80 :                     SetupOutputVariable(state,
    2995             :                                         "Cooling Coil Sensible Cooling Rate",
    2996             :                                         OutputProcessor::Unit::W,
    2997          20 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSensible,
    2998             :                                         OutputProcessor::SOVTimeStepType::System,
    2999             :                                         OutputProcessor::SOVStoreType::Average,
    3000          40 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3001          80 :                     SetupOutputVariable(state,
    3002             :                                         "Cooling Coil Total Cooling Rate",
    3003             :                                         OutputProcessor::Unit::W,
    3004          20 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLoadTotal,
    3005             :                                         OutputProcessor::SOVTimeStepType::System,
    3006             :                                         OutputProcessor::SOVStoreType::Average,
    3007          40 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3008          80 :                     SetupOutputVariable(state,
    3009             :                                         "Cooling Coil Part Load Ratio",
    3010             :                                         OutputProcessor::Unit::None,
    3011          20 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PartLoadRatio,
    3012             :                                         OutputProcessor::SOVTimeStepType::System,
    3013             :                                         OutputProcessor::SOVStoreType::Average,
    3014          40 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3015          80 :                     SetupOutputVariable(state,
    3016             :                                         "Cooling Coil Electricity Rate",
    3017             :                                         OutputProcessor::Unit::W,
    3018          20 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Power,
    3019             :                                         OutputProcessor::SOVTimeStepType::System,
    3020             :                                         OutputProcessor::SOVStoreType::Average,
    3021          40 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3022          80 :                     SetupOutputVariable(state,
    3023             :                                         "Cooling Coil Runtime Fraction",
    3024             :                                         OutputProcessor::Unit::None,
    3025          20 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac,
    3026             :                                         OutputProcessor::SOVTimeStepType::System,
    3027             :                                         OutputProcessor::SOVStoreType::Average,
    3028          40 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3029          80 :                     SetupOutputVariable(state,
    3030             :                                         "Cooling Coil Source Side Heat Transfer Rate",
    3031             :                                         OutputProcessor::Unit::W,
    3032          20 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSource,
    3033             :                                         OutputProcessor::SOVTimeStepType::System,
    3034             :                                         OutputProcessor::SOVStoreType::Average,
    3035          40 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3036          80 :                     SetupOutputVariable(state,
    3037             :                                         "Cooling Coil Upper Speed Level",
    3038             :                                         OutputProcessor::Unit::None,
    3039          20 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SpeedNumReport,
    3040             :                                         OutputProcessor::SOVTimeStepType::System,
    3041             :                                         OutputProcessor::SOVStoreType::Average,
    3042          40 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3043          80 :                     SetupOutputVariable(state,
    3044             :                                         "Cooling Coil Neighboring Speed Levels Ratio",
    3045             :                                         OutputProcessor::Unit::None,
    3046          20 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SpeedRatioReport,
    3047             :                                         OutputProcessor::SOVTimeStepType::System,
    3048             :                                         OutputProcessor::SOVStoreType::Average,
    3049          40 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3050             : 
    3051          20 :                     if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondensateCollectMode == CondensateToTank) {
    3052           0 :                         SetupOutputVariable(state,
    3053             :                                             "Cooling Coil Condensate Volume Flow Rate",
    3054             :                                             OutputProcessor::Unit::m3_s,
    3055           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondensateVdot,
    3056             :                                             OutputProcessor::SOVTimeStepType::System,
    3057             :                                             OutputProcessor::SOVStoreType::Average,
    3058           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3059           0 :                         SetupOutputVariable(state,
    3060             :                                             "Cooling Coil Condensate Volume",
    3061             :                                             OutputProcessor::Unit::m3,
    3062           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondensateVol,
    3063             :                                             OutputProcessor::SOVTimeStepType::System,
    3064             :                                             OutputProcessor::SOVStoreType::Summed,
    3065           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    3066             :                                             _,
    3067             :                                             "OnSiteWater",
    3068             :                                             "Condensate",
    3069             :                                             _,
    3070           0 :                                             "System");
    3071             :                     }
    3072             : 
    3073          20 :                     if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).ReportEvapCondVars) {
    3074           0 :                         SetupOutputVariable(state,
    3075             :                                             "Cooling Coil Condenser Inlet Temperature",
    3076             :                                             OutputProcessor::Unit::C,
    3077           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondInletTemp,
    3078             :                                             OutputProcessor::SOVTimeStepType::System,
    3079             :                                             OutputProcessor::SOVStoreType::Average,
    3080           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3081           0 :                         SetupOutputVariable(state,
    3082             :                                             "Cooling Coil Evaporative Condenser Water Volume",
    3083             :                                             OutputProcessor::Unit::m3,
    3084           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapWaterConsump,
    3085             :                                             OutputProcessor::SOVTimeStepType::System,
    3086             :                                             OutputProcessor::SOVStoreType::Summed,
    3087           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    3088             :                                             _,
    3089             :                                             "Water",
    3090             :                                             "Cooling",
    3091             :                                             _,
    3092           0 :                                             "System");
    3093           0 :                         SetupOutputVariable(state,
    3094             :                                             "Cooling Coil Evaporative Condenser Mains Water Volume",
    3095             :                                             OutputProcessor::Unit::m3,
    3096           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapWaterConsump,
    3097             :                                             OutputProcessor::SOVTimeStepType::System,
    3098             :                                             OutputProcessor::SOVStoreType::Summed,
    3099           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    3100             :                                             _,
    3101             :                                             "MainsWater",
    3102             :                                             "Cooling",
    3103             :                                             _,
    3104           0 :                                             "System");
    3105           0 :                         SetupOutputVariable(state,
    3106             :                                             "Cooling Coil Evaporative Condenser Pump Electricity Rate",
    3107             :                                             OutputProcessor::Unit::W,
    3108           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondPumpElecPower,
    3109             :                                             OutputProcessor::SOVTimeStepType::System,
    3110             :                                             OutputProcessor::SOVStoreType::Average,
    3111           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3112           0 :                         SetupOutputVariable(state,
    3113             :                                             "Cooling Coil Evaporative Condenser Pump Electricity Energy",
    3114             :                                             OutputProcessor::Unit::J,
    3115           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondPumpElecConsumption,
    3116             :                                             OutputProcessor::SOVTimeStepType::System,
    3117             :                                             OutputProcessor::SOVStoreType::Summed,
    3118           0 :                                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    3119             :                                             _,
    3120             :                                             "Electricity",
    3121             :                                             "COOLING",
    3122             :                                             _,
    3123           0 :                                             "System");
    3124           0 :                         if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterPowerFTempDiff > 0.0) {
    3125           0 :                             SetupOutputVariable(state,
    3126             :                                                 "Cooling Coil Basin Heater Electricity Rate",
    3127             :                                                 OutputProcessor::Unit::W,
    3128           0 :                                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterPower,
    3129             :                                                 OutputProcessor::SOVTimeStepType::System,
    3130             :                                                 OutputProcessor::SOVStoreType::Average,
    3131           0 :                                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3132           0 :                             SetupOutputVariable(state,
    3133             :                                                 "Cooling Coil Basin Heater Electricity Energy",
    3134             :                                                 OutputProcessor::Unit::J,
    3135           0 :                                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterConsumption,
    3136             :                                                 OutputProcessor::SOVTimeStepType::System,
    3137             :                                                 OutputProcessor::SOVStoreType::Summed,
    3138           0 :                                                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    3139             :                                                 _,
    3140             :                                                 "Electricity",
    3141             :                                                 "COOLING",
    3142             :                                                 _,
    3143           0 :                                                 "System");
    3144             :                         }
    3145             :                     }
    3146             : 
    3147          80 :                     SetupOutputVariable(state,
    3148             :                                         "Cooling Coil Crankcase Heater Electricity Rate",
    3149             :                                         OutputProcessor::Unit::W,
    3150          20 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterPower,
    3151             :                                         OutputProcessor::SOVTimeStepType::System,
    3152             :                                         OutputProcessor::SOVStoreType::Average,
    3153          40 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3154          80 :                     SetupOutputVariable(state,
    3155             :                                         "Cooling Coil Crankcase Heater Electricity Energy",
    3156             :                                         OutputProcessor::Unit::J,
    3157          20 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterConsumption,
    3158             :                                         OutputProcessor::SOVTimeStepType::System,
    3159             :                                         OutputProcessor::SOVStoreType::Summed,
    3160          20 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    3161             :                                         _,
    3162             :                                         "Electricity",
    3163             :                                         "COOLING",
    3164             :                                         _,
    3165          20 :                                         "System");
    3166             :                 } else {
    3167             :                     // air source heating coils
    3168          32 :                     SetupOutputVariable(state,
    3169             :                                         "Heating Coil Air Mass Flow Rate",
    3170             :                                         OutputProcessor::Unit::kg_s,
    3171           8 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate,
    3172             :                                         OutputProcessor::SOVTimeStepType::System,
    3173             :                                         OutputProcessor::SOVStoreType::Average,
    3174          16 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3175          32 :                     SetupOutputVariable(state,
    3176             :                                         "Heating Coil Air Inlet Temperature",
    3177             :                                         OutputProcessor::Unit::C,
    3178           8 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirDBTemp,
    3179             :                                         OutputProcessor::SOVTimeStepType::System,
    3180             :                                         OutputProcessor::SOVStoreType::Average,
    3181          16 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3182          32 :                     SetupOutputVariable(state,
    3183             :                                         "Heating Coil Air Inlet Humidity Ratio",
    3184             :                                         OutputProcessor::Unit::kgWater_kgDryAir,
    3185           8 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirHumRat,
    3186             :                                         OutputProcessor::SOVTimeStepType::System,
    3187             :                                         OutputProcessor::SOVStoreType::Average,
    3188          16 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3189          32 :                     SetupOutputVariable(state,
    3190             :                                         "Heating Coil Air Outlet Temperature",
    3191             :                                         OutputProcessor::Unit::C,
    3192           8 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirDBTemp,
    3193             :                                         OutputProcessor::SOVTimeStepType::System,
    3194             :                                         OutputProcessor::SOVStoreType::Average,
    3195          16 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3196          32 :                     SetupOutputVariable(state,
    3197             :                                         "Heating Coil Air Outlet Humidity Ratio",
    3198             :                                         OutputProcessor::Unit::kgWater_kgDryAir,
    3199           8 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirHumRat,
    3200             :                                         OutputProcessor::SOVTimeStepType::System,
    3201             :                                         OutputProcessor::SOVStoreType::Average,
    3202          16 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3203          32 :                     SetupOutputVariable(state,
    3204             :                                         "Heating Coil Sensible Heating Rate",
    3205             :                                         OutputProcessor::Unit::W,
    3206           8 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSensible,
    3207             :                                         OutputProcessor::SOVTimeStepType::System,
    3208             :                                         OutputProcessor::SOVStoreType::Average,
    3209          16 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3210          32 :                     SetupOutputVariable(state,
    3211             :                                         "Heating Coil Heating Rate",
    3212             :                                         OutputProcessor::Unit::W,
    3213           8 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLoadTotal,
    3214             :                                         OutputProcessor::SOVTimeStepType::System,
    3215             :                                         OutputProcessor::SOVStoreType::Average,
    3216          16 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3217          32 :                     SetupOutputVariable(state,
    3218             :                                         "Heating Coil Part Load Ratio",
    3219             :                                         OutputProcessor::Unit::None,
    3220           8 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PartLoadRatio,
    3221             :                                         OutputProcessor::SOVTimeStepType::System,
    3222             :                                         OutputProcessor::SOVStoreType::Average,
    3223          16 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3224          32 :                     SetupOutputVariable(state,
    3225             :                                         "Heating Coil Electricity Rate",
    3226             :                                         OutputProcessor::Unit::W,
    3227           8 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Power,
    3228             :                                         OutputProcessor::SOVTimeStepType::System,
    3229             :                                         OutputProcessor::SOVStoreType::Average,
    3230          16 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3231          32 :                     SetupOutputVariable(state,
    3232             :                                         "Heating Coil Runtime Fraction",
    3233             :                                         OutputProcessor::Unit::None,
    3234           8 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac,
    3235             :                                         OutputProcessor::SOVTimeStepType::System,
    3236             :                                         OutputProcessor::SOVStoreType::Average,
    3237          16 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3238             : 
    3239          32 :                     SetupOutputVariable(state,
    3240             :                                         "Heating Coil Source Side Heat Transfer Rate",
    3241             :                                         OutputProcessor::Unit::W,
    3242           8 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSource,
    3243             :                                         OutputProcessor::SOVTimeStepType::System,
    3244             :                                         OutputProcessor::SOVStoreType::Average,
    3245          16 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3246          32 :                     SetupOutputVariable(state,
    3247             :                                         "Heating Coil Upper Speed Level",
    3248             :                                         OutputProcessor::Unit::None,
    3249           8 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SpeedNumReport,
    3250             :                                         OutputProcessor::SOVTimeStepType::System,
    3251             :                                         OutputProcessor::SOVStoreType::Average,
    3252          16 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3253          32 :                     SetupOutputVariable(state,
    3254             :                                         "Heating Coil Neighboring Speed Levels Ratio",
    3255             :                                         OutputProcessor::Unit::None,
    3256           8 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SpeedRatioReport,
    3257             :                                         OutputProcessor::SOVTimeStepType::System,
    3258             :                                         OutputProcessor::SOVStoreType::Average,
    3259          16 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3260             : 
    3261          32 :                     SetupOutputVariable(state,
    3262             :                                         "Heating Coil Defrost Electricity Rate",
    3263             :                                         OutputProcessor::Unit::W,
    3264           8 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostPower,
    3265             :                                         OutputProcessor::SOVTimeStepType::System,
    3266             :                                         OutputProcessor::SOVStoreType::Average,
    3267          16 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3268          32 :                     SetupOutputVariable(state,
    3269             :                                         "Heating Coil Defrost Electricity Energy",
    3270             :                                         OutputProcessor::Unit::J,
    3271           8 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostConsumption,
    3272             :                                         OutputProcessor::SOVTimeStepType::System,
    3273             :                                         OutputProcessor::SOVStoreType::Summed,
    3274           8 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    3275             :                                         _,
    3276             :                                         "Electricity",
    3277             :                                         "HEATING",
    3278             :                                         _,
    3279           8 :                                         "System");
    3280          32 :                     SetupOutputVariable(state,
    3281             :                                         "Heating Coil Crankcase Heater Electricity Rate",
    3282             :                                         OutputProcessor::Unit::W,
    3283           8 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterPower,
    3284             :                                         OutputProcessor::SOVTimeStepType::System,
    3285             :                                         OutputProcessor::SOVStoreType::Average,
    3286          16 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3287          32 :                     SetupOutputVariable(state,
    3288             :                                         "Heating Coil Crankcase Heater Electricity Energy",
    3289             :                                         OutputProcessor::Unit::J,
    3290           8 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterConsumption,
    3291             :                                         OutputProcessor::SOVTimeStepType::System,
    3292             :                                         OutputProcessor::SOVStoreType::Summed,
    3293           8 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    3294             :                                         _,
    3295             :                                         "Electricity",
    3296             :                                         "HEATING",
    3297             :                                         _,
    3298           8 :                                         "System");
    3299             :                 }
    3300             :             } else {
    3301             : 
    3302          44 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_CoolingWaterToAirHPVSEquationFit) { // fix coil type
    3303             :                     // cooling WAHP coil
    3304             :                     // Setup Report variables for water source Heat Pump
    3305          68 :                     SetupOutputVariable(state,
    3306             :                                         "Cooling Coil Electricity Rate",
    3307             :                                         OutputProcessor::Unit::W,
    3308          17 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Power,
    3309             :                                         OutputProcessor::SOVTimeStepType::System,
    3310             :                                         OutputProcessor::SOVStoreType::Average,
    3311          34 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3312          68 :                     SetupOutputVariable(state,
    3313             :                                         "Cooling Coil Total Cooling Rate",
    3314             :                                         OutputProcessor::Unit::W,
    3315          17 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLoadTotal,
    3316             :                                         OutputProcessor::SOVTimeStepType::System,
    3317             :                                         OutputProcessor::SOVStoreType::Average,
    3318          34 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3319          68 :                     SetupOutputVariable(state,
    3320             :                                         "Cooling Coil Sensible Cooling Rate",
    3321             :                                         OutputProcessor::Unit::W,
    3322          17 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSensible,
    3323             :                                         OutputProcessor::SOVTimeStepType::System,
    3324             :                                         OutputProcessor::SOVStoreType::Average,
    3325          34 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3326          68 :                     SetupOutputVariable(state,
    3327             :                                         "Cooling Coil Latent Cooling Rate",
    3328             :                                         OutputProcessor::Unit::W,
    3329          17 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLatent,
    3330             :                                         OutputProcessor::SOVTimeStepType::System,
    3331             :                                         OutputProcessor::SOVStoreType::Average,
    3332          34 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3333          68 :                     SetupOutputVariable(state,
    3334             :                                         "Cooling Coil Source Side Heat Transfer Rate",
    3335             :                                         OutputProcessor::Unit::W,
    3336          17 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSource,
    3337             :                                         OutputProcessor::SOVTimeStepType::System,
    3338             :                                         OutputProcessor::SOVStoreType::Average,
    3339          34 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3340          68 :                     SetupOutputVariable(state,
    3341             :                                         "Cooling Coil Part Load Ratio",
    3342             :                                         OutputProcessor::Unit::None,
    3343          17 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PartLoadRatio,
    3344             :                                         OutputProcessor::SOVTimeStepType::System,
    3345             :                                         OutputProcessor::SOVStoreType::Average,
    3346          34 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3347          68 :                     SetupOutputVariable(state,
    3348             :                                         "Cooling Coil Runtime Fraction",
    3349             :                                         OutputProcessor::Unit::None,
    3350          17 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac,
    3351             :                                         OutputProcessor::SOVTimeStepType::System,
    3352             :                                         OutputProcessor::SOVStoreType::Average,
    3353          34 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3354             : 
    3355          68 :                     SetupOutputVariable(state,
    3356             :                                         "Cooling Coil Air Mass Flow Rate",
    3357             :                                         OutputProcessor::Unit::kg_s,
    3358          17 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate,
    3359             :                                         OutputProcessor::SOVTimeStepType::System,
    3360             :                                         OutputProcessor::SOVStoreType::Average,
    3361          34 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3362          68 :                     SetupOutputVariable(state,
    3363             :                                         "Cooling Coil Air Inlet Temperature",
    3364             :                                         OutputProcessor::Unit::C,
    3365          17 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirDBTemp,
    3366             :                                         OutputProcessor::SOVTimeStepType::System,
    3367             :                                         OutputProcessor::SOVStoreType::Average,
    3368          34 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3369          68 :                     SetupOutputVariable(state,
    3370             :                                         "Cooling Coil Air Inlet Humidity Ratio",
    3371             :                                         OutputProcessor::Unit::kgWater_kgDryAir,
    3372          17 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirHumRat,
    3373             :                                         OutputProcessor::SOVTimeStepType::System,
    3374             :                                         OutputProcessor::SOVStoreType::Average,
    3375          34 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3376          68 :                     SetupOutputVariable(state,
    3377             :                                         "Cooling Coil Air Outlet Temperature",
    3378             :                                         OutputProcessor::Unit::C,
    3379          17 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirDBTemp,
    3380             :                                         OutputProcessor::SOVTimeStepType::System,
    3381             :                                         OutputProcessor::SOVStoreType::Average,
    3382          34 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3383          68 :                     SetupOutputVariable(state,
    3384             :                                         "Cooling Coil Air Outlet Humidity Ratio",
    3385             :                                         OutputProcessor::Unit::kgWater_kgDryAir,
    3386          17 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirHumRat,
    3387             :                                         OutputProcessor::SOVTimeStepType::System,
    3388             :                                         OutputProcessor::SOVStoreType::Average,
    3389          34 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3390          68 :                     SetupOutputVariable(state,
    3391             :                                         "Cooling Coil Source Side Mass Flow Rate",
    3392             :                                         OutputProcessor::Unit::kg_s,
    3393          17 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterMassFlowRate,
    3394             :                                         OutputProcessor::SOVTimeStepType::System,
    3395             :                                         OutputProcessor::SOVStoreType::Average,
    3396          34 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3397          68 :                     SetupOutputVariable(state,
    3398             :                                         "Cooling Coil Source Side Inlet Temperature",
    3399             :                                         OutputProcessor::Unit::C,
    3400          17 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterTemp,
    3401             :                                         OutputProcessor::SOVTimeStepType::System,
    3402             :                                         OutputProcessor::SOVStoreType::Average,
    3403          34 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3404          68 :                     SetupOutputVariable(state,
    3405             :                                         "Cooling Coil Source Side Outlet Temperature",
    3406             :                                         OutputProcessor::Unit::C,
    3407          17 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletWaterTemp,
    3408             :                                         OutputProcessor::SOVTimeStepType::System,
    3409             :                                         OutputProcessor::SOVStoreType::Average,
    3410          34 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3411             : 
    3412          68 :                     SetupOutputVariable(state,
    3413             :                                         "Cooling Coil Upper Speed Level",
    3414             :                                         OutputProcessor::Unit::None,
    3415          17 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SpeedNumReport,
    3416             :                                         OutputProcessor::SOVTimeStepType::System,
    3417             :                                         OutputProcessor::SOVStoreType::Average,
    3418          34 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3419          68 :                     SetupOutputVariable(state,
    3420             :                                         "Cooling Coil Neighboring Speed Levels Ratio",
    3421             :                                         OutputProcessor::Unit::None,
    3422          17 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SpeedRatioReport,
    3423             :                                         OutputProcessor::SOVTimeStepType::System,
    3424             :                                         OutputProcessor::SOVStoreType::Average,
    3425          34 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3426          68 :                     SetupOutputVariable(state,
    3427             :                                         "Cooling Coil Recoverable Heat Transfer Rate",
    3428             :                                         OutputProcessor::Unit::W,
    3429          17 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QWasteHeat,
    3430             :                                         OutputProcessor::SOVTimeStepType::System,
    3431             :                                         OutputProcessor::SOVStoreType::Average,
    3432          34 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3433          27 :                 } else if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType ==
    3434             :                            Coil_HeatingWaterToAirHPVSEquationFit) { // fix coil type
    3435             :                     // heating WAHP coil
    3436             :                     // Setup Report variables for water source Heat Pump
    3437          68 :                     SetupOutputVariable(state,
    3438             :                                         "Heating Coil Electricity Rate",
    3439             :                                         OutputProcessor::Unit::W,
    3440          17 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Power,
    3441             :                                         OutputProcessor::SOVTimeStepType::System,
    3442             :                                         OutputProcessor::SOVStoreType::Average,
    3443          34 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3444          68 :                     SetupOutputVariable(state,
    3445             :                                         "Heating Coil Heating Rate",
    3446             :                                         OutputProcessor::Unit::W,
    3447          17 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLoadTotal,
    3448             :                                         OutputProcessor::SOVTimeStepType::System,
    3449             :                                         OutputProcessor::SOVStoreType::Average,
    3450          34 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3451          68 :                     SetupOutputVariable(state,
    3452             :                                         "Heating Coil Sensible Heating Rate",
    3453             :                                         OutputProcessor::Unit::W,
    3454          17 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSensible,
    3455             :                                         OutputProcessor::SOVTimeStepType::System,
    3456             :                                         OutputProcessor::SOVStoreType::Average,
    3457          34 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3458             : 
    3459          68 :                     SetupOutputVariable(state,
    3460             :                                         "Heating Coil Source Side Heat Transfer Rate",
    3461             :                                         OutputProcessor::Unit::W,
    3462          17 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSource,
    3463             :                                         OutputProcessor::SOVTimeStepType::System,
    3464             :                                         OutputProcessor::SOVStoreType::Average,
    3465          34 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3466          68 :                     SetupOutputVariable(state,
    3467             :                                         "Heating Coil Part Load Ratio",
    3468             :                                         OutputProcessor::Unit::None,
    3469          17 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PartLoadRatio,
    3470             :                                         OutputProcessor::SOVTimeStepType::System,
    3471             :                                         OutputProcessor::SOVStoreType::Average,
    3472          34 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3473          68 :                     SetupOutputVariable(state,
    3474             :                                         "Heating Coil Runtime Fraction",
    3475             :                                         OutputProcessor::Unit::None,
    3476          17 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac,
    3477             :                                         OutputProcessor::SOVTimeStepType::System,
    3478             :                                         OutputProcessor::SOVStoreType::Average,
    3479          34 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3480             : 
    3481          68 :                     SetupOutputVariable(state,
    3482             :                                         "Heating Coil Air Mass Flow Rate",
    3483             :                                         OutputProcessor::Unit::kg_s,
    3484          17 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate,
    3485             :                                         OutputProcessor::SOVTimeStepType::System,
    3486             :                                         OutputProcessor::SOVStoreType::Average,
    3487          34 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3488          68 :                     SetupOutputVariable(state,
    3489             :                                         "Heating Coil Air Inlet Temperature",
    3490             :                                         OutputProcessor::Unit::C,
    3491          17 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirDBTemp,
    3492             :                                         OutputProcessor::SOVTimeStepType::System,
    3493             :                                         OutputProcessor::SOVStoreType::Average,
    3494          34 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3495          68 :                     SetupOutputVariable(state,
    3496             :                                         "Heating Coil Air Inlet Humidity Ratio",
    3497             :                                         OutputProcessor::Unit::kgWater_kgDryAir,
    3498          17 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirHumRat,
    3499             :                                         OutputProcessor::SOVTimeStepType::System,
    3500             :                                         OutputProcessor::SOVStoreType::Average,
    3501          34 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3502          68 :                     SetupOutputVariable(state,
    3503             :                                         "Heating Coil Air Outlet Temperature",
    3504             :                                         OutputProcessor::Unit::C,
    3505          17 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirDBTemp,
    3506             :                                         OutputProcessor::SOVTimeStepType::System,
    3507             :                                         OutputProcessor::SOVStoreType::Average,
    3508          34 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3509          68 :                     SetupOutputVariable(state,
    3510             :                                         "Heating Coil Air Outlet Humidity Ratio",
    3511             :                                         OutputProcessor::Unit::kgWater_kgDryAir,
    3512          17 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirHumRat,
    3513             :                                         OutputProcessor::SOVTimeStepType::System,
    3514             :                                         OutputProcessor::SOVStoreType::Average,
    3515          34 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3516          68 :                     SetupOutputVariable(state,
    3517             :                                         "Heating Coil Source Side Mass Flow Rate",
    3518             :                                         OutputProcessor::Unit::kg_s,
    3519          17 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterMassFlowRate,
    3520             :                                         OutputProcessor::SOVTimeStepType::System,
    3521             :                                         OutputProcessor::SOVStoreType::Average,
    3522          34 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3523          68 :                     SetupOutputVariable(state,
    3524             :                                         "Heating Coil Source Side Inlet Temperature",
    3525             :                                         OutputProcessor::Unit::C,
    3526          17 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterTemp,
    3527             :                                         OutputProcessor::SOVTimeStepType::System,
    3528             :                                         OutputProcessor::SOVStoreType::Average,
    3529          34 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3530          68 :                     SetupOutputVariable(state,
    3531             :                                         "Heating Coil Source Side Outlet Temperature",
    3532             :                                         OutputProcessor::Unit::C,
    3533          17 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletWaterTemp,
    3534             :                                         OutputProcessor::SOVTimeStepType::System,
    3535             :                                         OutputProcessor::SOVStoreType::Average,
    3536          34 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3537             : 
    3538          68 :                     SetupOutputVariable(state,
    3539             :                                         "Heating Coil Upper Speed Level",
    3540             :                                         OutputProcessor::Unit::None,
    3541          17 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SpeedNumReport,
    3542             :                                         OutputProcessor::SOVTimeStepType::System,
    3543             :                                         OutputProcessor::SOVStoreType::Average,
    3544          34 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3545          68 :                     SetupOutputVariable(state,
    3546             :                                         "Heating Coil Neighboring Speed Levels Ratio",
    3547             :                                         OutputProcessor::Unit::None,
    3548          17 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SpeedRatioReport,
    3549             :                                         OutputProcessor::SOVTimeStepType::System,
    3550             :                                         OutputProcessor::SOVStoreType::Average,
    3551          34 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3552          68 :                     SetupOutputVariable(state,
    3553             :                                         "Heating Coil Recoverable Heat Transfer Rate",
    3554             :                                         OutputProcessor::Unit::W,
    3555          17 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QWasteHeat,
    3556             :                                         OutputProcessor::SOVTimeStepType::System,
    3557             :                                         OutputProcessor::SOVStoreType::Average,
    3558          34 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3559          10 :                 } else if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == CoilDX_HeatPumpWaterHeaterVariableSpeed) {
    3560             :                     // air source water heating coil
    3561          40 :                     SetupOutputVariable(state,
    3562             :                                         "Cooling Coil Water Heating Electricity Rate",
    3563             :                                         OutputProcessor::Unit::W,
    3564          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Power,
    3565             :                                         OutputProcessor::SOVTimeStepType::System,
    3566             :                                         OutputProcessor::SOVStoreType::Average,
    3567          20 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3568          40 :                     SetupOutputVariable(state,
    3569             :                                         "Cooling Coil Total Cooling Rate",
    3570             :                                         OutputProcessor::Unit::W,
    3571          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLoadTotal,
    3572             :                                         OutputProcessor::SOVTimeStepType::System,
    3573             :                                         OutputProcessor::SOVStoreType::Average,
    3574          20 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3575          40 :                     SetupOutputVariable(state,
    3576             :                                         "Cooling Coil Sensible Cooling Rate",
    3577             :                                         OutputProcessor::Unit::W,
    3578          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSensible,
    3579             :                                         OutputProcessor::SOVTimeStepType::System,
    3580             :                                         OutputProcessor::SOVStoreType::Average,
    3581          20 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3582          40 :                     SetupOutputVariable(state,
    3583             :                                         "Cooling Coil Latent Cooling Rate",
    3584             :                                         OutputProcessor::Unit::W,
    3585          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLatent,
    3586             :                                         OutputProcessor::SOVTimeStepType::System,
    3587             :                                         OutputProcessor::SOVStoreType::Average,
    3588          20 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3589          40 :                     SetupOutputVariable(state,
    3590             :                                         "Cooling Coil Total Water Heating Rate",
    3591             :                                         OutputProcessor::Unit::W,
    3592          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).TotalHeatingEnergyRate,
    3593             :                                         OutputProcessor::SOVTimeStepType::System,
    3594             :                                         OutputProcessor::SOVStoreType::Average,
    3595          20 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3596          40 :                     SetupOutputVariable(state,
    3597             :                                         "Cooling Coil Part Load Ratio",
    3598             :                                         OutputProcessor::Unit::None,
    3599          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PartLoadRatio,
    3600             :                                         OutputProcessor::SOVTimeStepType::System,
    3601             :                                         OutputProcessor::SOVStoreType::Average,
    3602          20 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3603          40 :                     SetupOutputVariable(state,
    3604             :                                         "Cooling Coil Runtime Fraction",
    3605             :                                         OutputProcessor::Unit::None,
    3606          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac,
    3607             :                                         OutputProcessor::SOVTimeStepType::System,
    3608             :                                         OutputProcessor::SOVStoreType::Average,
    3609          20 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3610             : 
    3611          40 :                     SetupOutputVariable(state,
    3612             :                                         "Cooling Coil Air Mass Flow Rate",
    3613             :                                         OutputProcessor::Unit::kg_s,
    3614          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate,
    3615             :                                         OutputProcessor::SOVTimeStepType::System,
    3616             :                                         OutputProcessor::SOVStoreType::Average,
    3617          20 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3618          40 :                     SetupOutputVariable(state,
    3619             :                                         "Cooling Coil Air Inlet Temperature",
    3620             :                                         OutputProcessor::Unit::C,
    3621          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirDBTemp,
    3622             :                                         OutputProcessor::SOVTimeStepType::System,
    3623             :                                         OutputProcessor::SOVStoreType::Average,
    3624          20 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3625          40 :                     SetupOutputVariable(state,
    3626             :                                         "Cooling Coil Air Inlet Humidity Ratio",
    3627             :                                         OutputProcessor::Unit::kgWater_kgDryAir,
    3628          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirHumRat,
    3629             :                                         OutputProcessor::SOVTimeStepType::System,
    3630             :                                         OutputProcessor::SOVStoreType::Average,
    3631          20 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3632          40 :                     SetupOutputVariable(state,
    3633             :                                         "Cooling Coil Air Outlet Temperature",
    3634             :                                         OutputProcessor::Unit::C,
    3635          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirDBTemp,
    3636             :                                         OutputProcessor::SOVTimeStepType::System,
    3637             :                                         OutputProcessor::SOVStoreType::Average,
    3638          20 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3639          40 :                     SetupOutputVariable(state,
    3640             :                                         "Cooling Coil Air Outlet Humidity Ratio",
    3641             :                                         OutputProcessor::Unit::kgWater_kgDryAir,
    3642          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirHumRat,
    3643             :                                         OutputProcessor::SOVTimeStepType::System,
    3644             :                                         OutputProcessor::SOVStoreType::Average,
    3645          20 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3646          40 :                     SetupOutputVariable(state,
    3647             :                                         "Cooling Coil Water Mass Flow Rate",
    3648             :                                         OutputProcessor::Unit::kg_s,
    3649          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterMassFlowRate,
    3650             :                                         OutputProcessor::SOVTimeStepType::System,
    3651             :                                         OutputProcessor::SOVStoreType::Average,
    3652          20 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3653          40 :                     SetupOutputVariable(state,
    3654             :                                         "Cooling Coil Water Inlet Temperature",
    3655             :                                         OutputProcessor::Unit::C,
    3656          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterTemp,
    3657             :                                         OutputProcessor::SOVTimeStepType::System,
    3658             :                                         OutputProcessor::SOVStoreType::Average,
    3659          20 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3660          40 :                     SetupOutputVariable(state,
    3661             :                                         "Cooling Coil Water Outlet Temperature",
    3662             :                                         OutputProcessor::Unit::C,
    3663          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletWaterTemp,
    3664             :                                         OutputProcessor::SOVTimeStepType::System,
    3665             :                                         OutputProcessor::SOVStoreType::Average,
    3666          20 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3667             : 
    3668          40 :                     SetupOutputVariable(state,
    3669             :                                         "Cooling Coil Crankcase Heater Electricity Rate",
    3670             :                                         OutputProcessor::Unit::W,
    3671          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterPower,
    3672             :                                         OutputProcessor::SOVTimeStepType::System,
    3673             :                                         OutputProcessor::SOVStoreType::Average,
    3674          20 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3675          40 :                     SetupOutputVariable(state,
    3676             :                                         "Cooling Coil Crankcase Heater Electricity Energy",
    3677             :                                         OutputProcessor::Unit::J,
    3678          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterConsumption,
    3679             :                                         OutputProcessor::SOVTimeStepType::System,
    3680             :                                         OutputProcessor::SOVStoreType::Summed,
    3681          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    3682             :                                         _,
    3683             :                                         "Electricity",
    3684             :                                         "HEATING",
    3685             :                                         _,
    3686          10 :                                         "System");
    3687             : 
    3688          40 :                     SetupOutputVariable(state,
    3689             :                                         "Cooling Coil Upper Speed Level",
    3690             :                                         OutputProcessor::Unit::None,
    3691          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SpeedNumReport,
    3692             :                                         OutputProcessor::SOVTimeStepType::System,
    3693             :                                         OutputProcessor::SOVStoreType::Average,
    3694          20 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3695          40 :                     SetupOutputVariable(state,
    3696             :                                         "Cooling Coil Neighboring Speed Levels Ratio",
    3697             :                                         OutputProcessor::Unit::None,
    3698          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SpeedRatioReport,
    3699             :                                         OutputProcessor::SOVTimeStepType::System,
    3700             :                                         OutputProcessor::SOVStoreType::Average,
    3701          20 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3702             : 
    3703          40 :                     SetupOutputVariable(state,
    3704             :                                         "Cooling Coil Water Heating Pump Electricity Rate",
    3705             :                                         OutputProcessor::Unit::W,
    3706          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower,
    3707             :                                         OutputProcessor::SOVTimeStepType::System,
    3708             :                                         OutputProcessor::SOVStoreType::Average,
    3709          20 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name);
    3710          40 :                     SetupOutputVariable(state,
    3711             :                                         "Cooling Coil Water Heating Pump Electricity Energy",
    3712             :                                         OutputProcessor::Unit::J,
    3713          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondPumpElecConsumption,
    3714             :                                         OutputProcessor::SOVTimeStepType::System,
    3715             :                                         OutputProcessor::SOVStoreType::Summed,
    3716          10 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    3717             :                                         _,
    3718             :                                         "Electricity",
    3719             :                                         "HEATING",
    3720             :                                         _,
    3721          10 :                                         "System");
    3722             :                 }
    3723             :             }
    3724             :         }
    3725             : 
    3726          19 :         if (ErrorsFound) {
    3727           0 :             ShowFatalError(state,
    3728           0 :                            std::string{RoutineName} + "Errors found in getting " + CurrentModuleObject +
    3729             :                                " input.  Preceding condition(s) causes termination.");
    3730             :         }
    3731          19 :     }
    3732             : 
    3733             :     // Beginning Initialization Section of the Module
    3734             :     //******************************************************************************
    3735             : 
    3736    43381475 :     void InitVarSpeedCoil(EnergyPlusData &state,
    3737             :                           int const DXCoilNum,                             // Current DXCoilNum under simulation
    3738             :                           Real64 const MaxONOFFCyclesperHour,              // Maximum cycling rate of heat pump [cycles/hr]
    3739             :                           Real64 const HPTimeConstant,                     // Heat pump time constant [s]
    3740             :                           Real64 const FanDelayTime,                       // Fan delay time, time delay for the HP's fan to
    3741             :                           Real64 const SensLoad,                           // Control zone sensible load[W]
    3742             :                           Real64 const LatentLoad,                         // Control zone latent load[W]
    3743             :                           int const CyclingScheme,                         // fan operating mode
    3744             :                           [[maybe_unused]] Real64 const OnOffAirFlowRatio, // ratio of compressor on flow to average flow over time step
    3745             :                           Real64 const SpeedRatio,                         // compressor speed ratio
    3746             :                           int const SpeedNum                               // compressor speed number
    3747             :     )
    3748             :     {
    3749             : 
    3750             :         // SUBROUTINE INFORMATION:
    3751             :         //       AUTHOR         Bo Shen, based on  MODULE WaterToAirHeatPumpSimple:InitSimpleWatertoAirHP
    3752             :         //       DATE WRITTEN   March, 2012
    3753             :         //       MODIFIED       Bo Shen, 12/2014, add variable-speed HPWH
    3754             :         //       RE-ENGINEERED  na
    3755             : 
    3756             :         // PURPOSE OF THIS SUBROUTINE:
    3757             :         // This subroutine is for initializations of the variable speed Water to Air HP Components.
    3758             : 
    3759             :         // METHODOLOGY EMPLOYED:
    3760             :         // Uses the status flags to trigger initializations.
    3761             : 
    3762             :         // Using/Aliasing
    3763             :         using FluidProperties::GetDensityGlycol;
    3764             :         using FluidProperties::GetSpecificHeatGlycol;
    3765             : 
    3766             :         using PlantUtilities::InitComponentNodes;
    3767             :         using PlantUtilities::ScanPlantLoopsForObject;
    3768             :         using PlantUtilities::SetComponentFlowRate;
    3769             :         using Psychrometrics::PsyRhoAirFnPbTdbW;
    3770             : 
    3771             :         // Locals
    3772             :         // SUBROUTINE ARGUMENT DEFINITIONS:
    3773             : 
    3774             :         // shut off after compressor cycle off  [s]
    3775             : 
    3776             :         // SUBROUTINE PARAMETER DEFINITIONS:
    3777             :         static constexpr std::string_view RoutineNameSimpleWatertoAirHP("InitSimpleWatertoAirHP");
    3778             : 
    3779             :         // INTERFACE BLOCK SPECIFICATIONS
    3780             :         // na
    3781             : 
    3782             :         // DERIVED TYPE DEFINITIONS
    3783             :         // na
    3784             : 
    3785             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    3786             :         int AirInletNode;                  // Node Number of the air inlet
    3787             :         int WaterInletNode;                // Node Number of the Water inlet
    3788             :         Real64 rho;                        // local fluid density
    3789             :         Real64 Cp;                         // local fluid specific heat
    3790             :         int SpeedCal;                      // calculated speed level
    3791    43381475 :         bool ErrorsFound(false);           // TRUE when errors found, air loop initialization error
    3792             :         Real64 RatedVolFlowPerRatedTotCap; // Rated Air Volume Flow Rate divided by Rated Total Capacity [m3/s-W)
    3793             :         int Mode;                          // Performance mode for MultiMode DX coil; Always 1 for other coil types
    3794             :         Real64 RatedHeatPumpIndoorAirTemp; // Indoor dry-bulb temperature to heat pump evaporator at rated conditions [C]
    3795             :         Real64 RatedHeatPumpIndoorHumRat;  // Inlet humidity ratio to heat pump evaporator at rated conditions [kg/kg]
    3796             :         Real64 WaterFlowScale;             // water flow scaling factor match rated flow rate
    3797             : 
    3798             :         // SUBROUTINE PARAMETER DEFINITIONS:
    3799             :         static constexpr std::string_view RoutineName("InitVarSpeedCoil");
    3800             : 
    3801    43381475 :         if (state.dataVariableSpeedCoils->MyOneTimeFlag) {
    3802             :             // initialize the environment and sizing flags
    3803          19 :             state.dataVariableSpeedCoils->MySizeFlag.allocate(state.dataVariableSpeedCoils->NumVarSpeedCoils);
    3804          19 :             state.dataVariableSpeedCoils->MyEnvrnFlag.allocate(state.dataVariableSpeedCoils->NumVarSpeedCoils);
    3805          19 :             state.dataVariableSpeedCoils->MyPlantScanFlag.allocate(state.dataVariableSpeedCoils->NumVarSpeedCoils);
    3806          19 :             state.dataVariableSpeedCoils->MySizeFlag = true;
    3807          19 :             state.dataVariableSpeedCoils->MyEnvrnFlag = true;
    3808          19 :             state.dataVariableSpeedCoils->MyPlantScanFlag = true;
    3809          19 :             state.dataVariableSpeedCoils->MyOneTimeFlag = false;
    3810             :         }
    3811             : 
    3812    43381475 :         state.dataHVACGlobal->DXCT = 1; // hard-code to non-DOAS sizing routine for cfm/ton until .ISHundredPercentDOASDXCoil member from DXcoils.cc
    3813             :                                         // is added to VarSpeedCoil object
    3814             : 
    3815             :         // variable-speed heat pump water heating, begin
    3816    44999534 :         if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == CoilDX_HeatPumpWaterHeaterVariableSpeed &&
    3817     1618059 :             state.dataVariableSpeedCoils->MySizeFlag(DXCoilNum)) {
    3818             : 
    3819          10 :             ErrorsFound = false;
    3820          10 :             SizeVarSpeedCoil(state, DXCoilNum, ErrorsFound);
    3821          10 :             if (ErrorsFound) {
    3822           0 :                 ShowFatalError(state, format("{}: Failed to size variable speed coil.", RoutineName));
    3823             :             }
    3824             : 
    3825             :             //   get rated coil bypass factor excluding fan heat
    3826             : 
    3827          10 :             state.dataVariableSpeedCoils->MySizeFlag(DXCoilNum) = false;
    3828             :         }
    3829             :         // variable-speed heat pump water heating, end
    3830             : 
    3831             :         // water source
    3832    82259304 :         if ((state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == DataHVACGlobals::Coil_CoolingWaterToAirHPVSEquationFit) ||
    3833    38877829 :             (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType ==
    3834             :              DataHVACGlobals::Coil_HeatingWaterToAirHPVSEquationFit)) { // fix coil type
    3835     9007292 :             if (state.dataVariableSpeedCoils->MyPlantScanFlag(DXCoilNum) && allocated(state.dataPlnt->PlantLoop)) {
    3836             :                 // switch from coil type numbers in DataHVACGlobals, to coil type numbers in plant.
    3837          34 :                 DataPlant::PlantEquipmentType CoilVSWAHPType(DataPlant::PlantEquipmentType::Invalid);
    3838          34 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == DataHVACGlobals::Coil_CoolingWaterToAirHPVSEquationFit) {
    3839          17 :                     CoilVSWAHPType = DataPlant::PlantEquipmentType::CoilVSWAHPCoolingEquationFit;
    3840          17 :                 } else if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType ==
    3841             :                            DataHVACGlobals::Coil_HeatingWaterToAirHPVSEquationFit) {
    3842          17 :                     CoilVSWAHPType = DataPlant::PlantEquipmentType::CoilVSWAHPHeatingEquationFit;
    3843             :                 }
    3844          34 :                 ErrorsFound = false;
    3845         102 :                 ScanPlantLoopsForObject(state,
    3846          34 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    3847             :                                         CoilVSWAHPType,
    3848          34 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).plantLoc,
    3849             :                                         ErrorsFound,
    3850             :                                         _,
    3851             :                                         _,
    3852             :                                         _,
    3853             :                                         _,
    3854             :                                         _);
    3855          34 :                 if (ErrorsFound) {
    3856           0 :                     ShowFatalError(state, "InitVarSpeedCoil: Program terminated for previous conditions.");
    3857             :                 }
    3858          34 :                 state.dataVariableSpeedCoils->MyPlantScanFlag(DXCoilNum) = false;
    3859             :             }
    3860             :         } else {
    3861    34374183 :             state.dataVariableSpeedCoils->MyPlantScanFlag(DXCoilNum) = false;
    3862             :         }
    3863             : 
    3864    43381537 :         if (!state.dataGlobal->SysSizingCalc && state.dataVariableSpeedCoils->MySizeFlag(DXCoilNum) &&
    3865          62 :             !state.dataVariableSpeedCoils->MyPlantScanFlag(DXCoilNum)) {
    3866             :             // for each furnace, do the sizing once.
    3867          62 :             ErrorsFound = false;
    3868          62 :             SizeVarSpeedCoil(state, DXCoilNum, ErrorsFound);
    3869          62 :             if (ErrorsFound) {
    3870           0 :                 ShowFatalError(state, format("{}: Failed to size variable speed coil.", RoutineName));
    3871             :             }
    3872             : 
    3873          62 :             state.dataVariableSpeedCoils->MySizeFlag(DXCoilNum) = false;
    3874             : 
    3875             :             // Multispeed Cooling
    3876         107 :             if ((state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == DataHVACGlobals::Coil_CoolingWaterToAirHPVSEquationFit) ||
    3877          45 :                 (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_CoolingAirToAirVariableSpeed)) {
    3878         353 :                 for (Mode = 1; Mode <= state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds; ++Mode) {
    3879             :                     // Check for zero capacity or zero max flow rate
    3880         316 :                     if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(Mode) <= 0.0) {
    3881           0 :                         ShowSevereError(state,
    3882           0 :                                         format("Sizing: {} {} has zero rated total capacity at speed {}",
    3883           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VarSpeedCoilType,
    3884           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    3885           0 :                                                Mode));
    3886           0 :                         ErrorsFound = true;
    3887             :                     }
    3888         316 :                     if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowRate(Mode) <= 0.0) {
    3889           0 :                         ShowSevereError(state,
    3890           0 :                                         format("Sizing: {} {} has zero rated air flow rate at speed {}",
    3891           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VarSpeedCoilType,
    3892           0 :                                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    3893           0 :                                                Mode));
    3894           0 :                         ErrorsFound = true;
    3895             :                     }
    3896         316 :                     if (ErrorsFound) {
    3897           0 :                         ShowFatalError(state, "Preceding condition causes termination.");
    3898             :                     }
    3899             :                     // Check for valid range of (Rated Air Volume Flow Rate / Rated Total Capacity)
    3900         632 :                     RatedVolFlowPerRatedTotCap = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowRate(Mode) /
    3901         316 :                                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(Mode);
    3902             :                     // note: variable-speed HP can exceed the flow rate restrictions at low speed levels
    3903             :                     //        IF (((MinRatedAirVolFlowPerRatedTotCap - RatedVolFlowPerRatedTotCap) > SmallDifferenceTest).OR. &
    3904             :                     //           ((RatedVolFlowPerRatedTotCap - MaxRatedAirVolFlowPerRatedTotCap) > SmallDifferenceTest)) THEN
    3905             :                     //          CALL ShowSevereError(state,'Sizing: '//TRIM(VarSpeedCoil(DXCoilNum)%VarSpeedCoilType) &
    3906             :                     //           // ' "'//TRIM(VarSpeedCoil(DXCoilNum)%Name)//  &
    3907             :                     //                '": Rated air volume flow rate per watt of rated total '// &
    3908             :                     //                'cooling capacity is out of range at speed '//TRIM(TrimSigDigits(Mode)))
    3909             :                     //          CALL ShowContinueError &
    3910             :                     //           ('Min Rated Vol Flow Per Watt=['//TRIM(TrimSigDigits(MinRatedAirVolFlowPerRatedTotCap,3))//'], '// &
    3911             :                     //           'Rated Vol Flow Per Watt=['//TRIM(TrimSigDigits(RatedVolFlowPerRatedTotCap,3))//'],  &
    3912             :                     //           Max Rated Vol Flow Per Watt=['// &
    3913             :                     //           TRIM(TrimSigDigits(MaxRatedAirVolFlowPerRatedTotCap,3))//']. See Input-Output Reference Manual for valid range.')
    3914             :                     //        END IF
    3915             :                     //        VarSpeedCoil(DXCoilNum)%MSRatedAirMassFlowRate(Mode) = VarSpeedCoil(DXCoilNum)%MSRatedAirVolFlowRate(Mode)* &
    3916             :                     //          PsyRhoAirFnPbTdbW(state, OutBaroPress,RatedInletAirTemp,RatedInletAirHumRat,RoutineName)
    3917             :                     //        ! get high speed rated coil bypass factor
    3918             :                     //        VarSpeedCoil(DXCoilNum)%MSRatedCBF(Mode) = CalcCBF(VarSpeedCoil(DXCoilNum)%VarSpeedCoilType, &
    3919             :                     //               VarSpeedCoil(DXCoilNum)%Name,&
    3920             :                     //                                           RatedInletAirTemp,RatedInletAirHumRat,VarSpeedCoil(DXCoilNum)%MSRatedTotCap(Mode),&
    3921             :                     //                                           VarSpeedCoil(DXCoilNum)%MSRatedAirMassFlowRate(Mode), &
    3922             :                     //                           VarSpeedCoil(DXCoilNum)%MSRatedSHR(Mode))
    3923             :                 }
    3924             :                 // call coil model with everthing set at rating point
    3925          37 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirDBTemp = RatedInletAirTemp;
    3926          37 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirHumRat =
    3927          74 :                     Psychrometrics::PsyWFnTdbTwbPb(state, RatedInletAirTemp, RatedInletWetBulbTemp, DataEnvironment::StdPressureSeaLevel);
    3928          37 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirEnthalpy =
    3929          37 :                     Psychrometrics::PsyHFnTdbW(RatedInletAirTemp, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirHumRat);
    3930          37 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirPressure = DataEnvironment::StdPressureSeaLevel;
    3931             : 
    3932          37 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate =
    3933          74 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedAirVolFlowRate *
    3934          74 :                     Psychrometrics::PsyRhoAirFnPbTdbW(state,
    3935             :                                                       DataEnvironment::StdPressureSeaLevel,
    3936             :                                                       RatedInletAirTemp,
    3937          37 :                                                       state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirHumRat);
    3938             :                 // store environment data fill back in after rating point calc is over
    3939          37 :                 Real64 holdOutDryBulbTemp = state.dataEnvrn->OutDryBulbTemp;
    3940          37 :                 Real64 holdOutHumRat = state.dataEnvrn->OutHumRat;
    3941          37 :                 Real64 holdOutWetBulb = state.dataEnvrn->OutWetBulbTemp;
    3942          37 :                 Real64 holdOutBaroPress = state.dataEnvrn->OutBaroPress;
    3943          37 :                 Real64 ratedOutdoorAirWetBulb = 23.9; // from I/O ref. more precise value?
    3944             : 
    3945          37 :                 state.dataEnvrn->OutDryBulbTemp = RatedAmbAirTemp;
    3946          37 :                 state.dataEnvrn->OutWetBulbTemp = ratedOutdoorAirWetBulb;
    3947          37 :                 state.dataEnvrn->OutBaroPress = DataEnvironment::StdPressureSeaLevel; // assume rating is for sea level.
    3948          37 :                 state.dataEnvrn->OutHumRat =
    3949          37 :                     Psychrometrics::PsyWFnTdbTwbPb(state, RatedAmbAirTemp, ratedOutdoorAirWetBulb, DataEnvironment::StdPressureSeaLevel, RoutineName);
    3950          37 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum > 0) {
    3951           1 :                     state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum).Temp = RatedAmbAirTemp;
    3952           1 :                     state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum).HumRat =
    3953           1 :                         state.dataEnvrn->OutHumRat;
    3954           1 :                     state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum).Press =
    3955             :                         DataEnvironment::StdPressureSeaLevel;
    3956           1 :                     state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum).OutAirWetBulb =
    3957             :                         ratedOutdoorAirWetBulb;
    3958             :                 }
    3959          37 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType ==
    3960             :                     DataHVACGlobals::Coil_CoolingWaterToAirHPVSEquationFit) { // need to set water info for WSHP
    3961          17 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterMassFlowRate =
    3962          34 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterMassFlowRate(
    3963          17 :                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds);
    3964          17 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterTemp = RatedInletWaterTemp; // 85 F cooling mode
    3965          51 :                     Real64 CpSource = GetSpecificHeatGlycol(
    3966             :                         state,
    3967          17 :                         state.dataPlnt->PlantLoop(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).plantLoc.loopNum).FluidName,
    3968          17 :                         state.dataVariableSpeedCoils->SourceSideInletTemp,
    3969          17 :                         state.dataPlnt->PlantLoop(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).plantLoc.loopNum).FluidIndex,
    3970          17 :                         RoutineName);
    3971          17 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterEnthalpy =
    3972          17 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterTemp * CpSource;
    3973             :                 }
    3974             : 
    3975             :                 // calculate coil model at rating point
    3976          37 :                 Real64 runtimeFrac(1.0);
    3977          37 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignAirMassFlowRate =
    3978          74 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirMassFlowRate(
    3979          37 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds);
    3980          37 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignAirVolFlowRate =
    3981          74 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowRate(
    3982          37 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds);
    3983          37 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignWaterMassFlowRate =
    3984          74 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterMassFlowRate(
    3985          37 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds);
    3986          37 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignWaterVolFlowRate =
    3987          74 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterVolFlowRate(
    3988          37 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds);
    3989             : 
    3990          37 :                 CalcVarSpeedCoilCooling(state,
    3991             :                                         DXCoilNum,
    3992             :                                         2.0,
    3993             :                                         runtimeFrac,
    3994             :                                         SensLoad,
    3995             :                                         LatentLoad,
    3996             :                                         CompressorOperation::On,
    3997             :                                         1.0,
    3998             :                                         1.0,
    3999             :                                         1.0,
    4000          37 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds);
    4001             :                 // coil outlets
    4002          37 :                 Real64 RatedOutletWetBulb(0.0);
    4003          74 :                 RatedOutletWetBulb = Psychrometrics::PsyTwbFnTdbWPb(state,
    4004          37 :                                                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirDBTemp,
    4005          37 :                                                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirHumRat,
    4006             :                                                                     DataEnvironment::StdPressureSeaLevel,
    4007             :                                                                     RoutineName);
    4008         407 :                 state.dataRptCoilSelection->coilSelectionReportObj->setRatedCoilConditions(
    4009             :                     state,
    4010          37 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    4011          37 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VarSpeedCoilType,
    4012          37 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLoadTotal, // this is the report variable
    4013          37 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSensible,  // this is the report variable
    4014          37 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate,
    4015          37 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirDBTemp,
    4016          37 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirHumRat,
    4017             :                     RatedInletWetBulbTemp,
    4018          37 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirDBTemp,
    4019          37 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirHumRat,
    4020             :                     RatedOutletWetBulb,
    4021             :                     RatedAmbAirTemp,
    4022             :                     ratedOutdoorAirWetBulb,
    4023          37 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedCBF(
    4024          37 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds),
    4025             :                     -999.0); // coil effectiveness not define for DX
    4026             : 
    4027             :                 // now replace the outdoor air conditions set above for one time rating point calc
    4028          37 :                 state.dataEnvrn->OutDryBulbTemp = holdOutDryBulbTemp;
    4029          37 :                 state.dataEnvrn->OutHumRat = holdOutHumRat;
    4030          37 :                 state.dataEnvrn->OutWetBulbTemp = holdOutWetBulb;
    4031          37 :                 state.dataEnvrn->OutBaroPress = holdOutBaroPress;
    4032             :             }
    4033             : 
    4034             :             // Multispeed Heating
    4035         107 :             if ((state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == DataHVACGlobals::Coil_HeatingWaterToAirHPVSEquationFit) ||
    4036          45 :                 (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_HeatingAirToAirVariableSpeed)) {
    4037          25 :                 RatedHeatPumpIndoorAirTemp = 21.11;  // 21.11C or 70F
    4038          25 :                 RatedHeatPumpIndoorHumRat = 0.00881; // Humidity ratio corresponding to 70F dry bulb/60F wet bulb
    4039         265 :                 for (Mode = 1; Mode <= state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds; ++Mode) {
    4040             : 
    4041         240 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirMassFlowRate(Mode) =
    4042         480 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowRate(Mode) *
    4043         240 :                         PsyRhoAirFnPbTdbW(state, state.dataEnvrn->OutBaroPress, RatedHeatPumpIndoorAirTemp, RatedHeatPumpIndoorHumRat, RoutineName);
    4044             :                     // Check for valid range of (Rated Air Volume Flow Rate / Rated Total Capacity)
    4045         480 :                     RatedVolFlowPerRatedTotCap = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowRate(Mode) /
    4046         240 :                                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(Mode);
    4047             :                     // note: variable-speed HP can exceed the flow rate restrictions at low speed levels
    4048             :                     //        IF (((MinRatedAirVolFlowPerRatedTotCap - RatedVolFlowPerRatedTotCap) > SmallDifferenceTest).OR. &
    4049             :                     //            ((RatedVolFlowperRatedTotCap - MaxRatedAirVolFlowPerRatedTotCap) > SmallDifferenceTest)) THEN
    4050             :                     //          CALL ShowSevereError(state,'Coil:Heating:DX:MultiSpeed '//TRIM(VarSpeedCoil(DXCoilNum)%Name)//  &
    4051             :                     //                              ': Rated air volume flow rate per watt of rated total '// &
    4052             :                     //                'heating capacity is out of range at speed '//TRIM(TrimSigDigits(Mode)))
    4053             :                     //          CALL ShowContinueError(state, 'Min Rated Vol Flow Per Watt=['//TRIM(TrimSigDigits &
    4054             :                     //           (MinRatedAirVolFlowPerRatedTotCap,3))//'], '// &
    4055             :                     //           'Rated Vol Flow Per Watt=['//TRIM(TrimSigDigits(RatedVolFlowPerRatedTotCap,3))//'],  &
    4056             :                     //               Max Rated Vol Flow Per Watt=['// &
    4057             :                     //           TRIM(TrimSigDigits(MaxRatedAirVolFlowPerRatedTotCap,3))//']. See Input-Output Reference  &
    4058             :                     //                Manual for valid range.')
    4059             :                     //        END IF
    4060             :                 }
    4061             :                 // call coil model with everthing set at rating point
    4062          25 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirDBTemp = RatedInletAirTempHeat;
    4063          25 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirHumRat =
    4064          50 :                     Psychrometrics::PsyWFnTdbTwbPb(state, RatedInletAirTempHeat, RatedInletWetBulbTemp, DataEnvironment::StdPressureSeaLevel);
    4065          25 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirEnthalpy =
    4066          25 :                     Psychrometrics::PsyHFnTdbW(RatedInletAirTempHeat, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirHumRat);
    4067          25 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirPressure = DataEnvironment::StdPressureSeaLevel;
    4068             : 
    4069          25 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate =
    4070          50 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedAirVolFlowRate *
    4071          50 :                     Psychrometrics::PsyRhoAirFnPbTdbW(state,
    4072             :                                                       DataEnvironment::StdPressureSeaLevel,
    4073             :                                                       RatedInletAirTempHeat,
    4074          25 :                                                       state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirHumRat);
    4075             :                 // store environment data fill back in after rating point calc is over
    4076          25 :                 Real64 holdOutDryBulbTemp = state.dataEnvrn->OutDryBulbTemp;
    4077          25 :                 Real64 holdOutHumRat = state.dataEnvrn->OutHumRat;
    4078          25 :                 Real64 holdOutWetBulb = state.dataEnvrn->OutWetBulbTemp;
    4079          25 :                 Real64 holdOutBaroPress = state.dataEnvrn->OutBaroPress;
    4080             : 
    4081          25 :                 state.dataEnvrn->OutDryBulbTemp = RatedAmbAirTempHeat;
    4082          25 :                 state.dataEnvrn->OutWetBulbTemp = RatedAmbAirWBHeat;
    4083          25 :                 state.dataEnvrn->OutBaroPress = DataEnvironment::StdPressureSeaLevel; // assume rating is for sea level.
    4084          25 :                 state.dataEnvrn->OutHumRat =
    4085          25 :                     Psychrometrics::PsyWFnTdbTwbPb(state, RatedAmbAirTempHeat, RatedAmbAirWBHeat, DataEnvironment::StdPressureSeaLevel, RoutineName);
    4086          25 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum > 0) {
    4087           0 :                     state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum).Temp = RatedAmbAirTempHeat;
    4088           0 :                     state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum).HumRat =
    4089           0 :                         state.dataEnvrn->OutHumRat;
    4090           0 :                     state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum).Press =
    4091             :                         DataEnvironment::StdPressureSeaLevel;
    4092           0 :                     state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum).OutAirWetBulb =
    4093             :                         RatedAmbAirWBHeat;
    4094             :                 }
    4095             : 
    4096          25 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType ==
    4097             :                     DataHVACGlobals::Coil_HeatingWaterToAirHPVSEquationFit) { // need to set water info for WSHP
    4098          17 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterMassFlowRate =
    4099          34 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterMassFlowRate(
    4100          17 :                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds);
    4101          17 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterTemp = RatedInletWaterTempHeat; // 21.11C or 70F, heating mode
    4102          51 :                     Real64 CpSource = GetSpecificHeatGlycol(
    4103             :                         state,
    4104          17 :                         state.dataPlnt->PlantLoop(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).plantLoc.loopNum).FluidName,
    4105          17 :                         state.dataVariableSpeedCoils->SourceSideInletTemp,
    4106          17 :                         state.dataPlnt->PlantLoop(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).plantLoc.loopNum).FluidIndex,
    4107          17 :                         RoutineName);
    4108          17 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterEnthalpy =
    4109          17 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterTemp * CpSource;
    4110             :                 }
    4111             : 
    4112             :                 // calculate coil model at rating point
    4113          25 :                 Real64 runtimeFrac(1.0);
    4114          25 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignAirMassFlowRate =
    4115          50 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirMassFlowRate(
    4116          25 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds);
    4117          25 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignAirVolFlowRate =
    4118          50 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowRate(
    4119          25 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds);
    4120          25 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignWaterMassFlowRate =
    4121          50 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterMassFlowRate(
    4122          25 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds);
    4123          25 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignWaterVolFlowRate =
    4124          50 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterVolFlowRate(
    4125          25 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds);
    4126          25 :                 CalcVarSpeedCoilHeating(state,
    4127             :                                         DXCoilNum,
    4128             :                                         2.0,
    4129             :                                         runtimeFrac,
    4130             :                                         SensLoad,
    4131             :                                         CompressorOperation::On,
    4132             :                                         1.0,
    4133             :                                         1.0,
    4134             :                                         1.0,
    4135          25 :                                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds);
    4136             :                 // coil outlets
    4137          25 :                 Real64 RatedOutletWetBulb(0.0);
    4138          50 :                 RatedOutletWetBulb = Psychrometrics::PsyTwbFnTdbWPb(state,
    4139          25 :                                                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirDBTemp,
    4140          25 :                                                                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirHumRat,
    4141             :                                                                     DataEnvironment::StdPressureSeaLevel,
    4142             :                                                                     RoutineName);
    4143         275 :                 state.dataRptCoilSelection->coilSelectionReportObj->setRatedCoilConditions(
    4144             :                     state,
    4145          25 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    4146          25 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VarSpeedCoilType,
    4147          25 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLoadTotal, // this is the report variable
    4148          25 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSensible,  // this is the report variable
    4149          25 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate,
    4150          25 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirDBTemp,
    4151          25 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirHumRat,
    4152             :                     RatedInletWetBulbTemp,
    4153          25 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirDBTemp,
    4154          25 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirHumRat,
    4155             :                     RatedOutletWetBulb,
    4156             :                     RatedAmbAirTempHeat,
    4157             :                     RatedAmbAirWBHeat,
    4158          25 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedCBF(
    4159          25 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds),
    4160             :                     -999.0); // coil effectiveness not define for DX
    4161             : 
    4162             :                 // now replace the outdoor air conditions set above for one time rating point calc
    4163          25 :                 state.dataEnvrn->OutDryBulbTemp = holdOutDryBulbTemp;
    4164          25 :                 state.dataEnvrn->OutHumRat = holdOutHumRat;
    4165          25 :                 state.dataEnvrn->OutWetBulbTemp = holdOutWetBulb;
    4166          25 :                 state.dataEnvrn->OutBaroPress = holdOutBaroPress;
    4167             :             }
    4168             : 
    4169             :             // store fan info for coil
    4170          62 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SupplyFan_TypeNum == DataHVACGlobals::FanType_SystemModelObject) {
    4171           7 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SupplyFanIndex > -1) {
    4172          35 :                     state.dataRptCoilSelection->coilSelectionReportObj->setCoilSupplyFanInfo(
    4173             :                         state,
    4174           7 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    4175           7 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VarSpeedCoilType,
    4176           7 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SupplyFanName,
    4177             :                         DataAirSystems::ObjectVectorOOFanSystemModel,
    4178           7 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SupplyFanIndex);
    4179             :                 }
    4180             : 
    4181             :             } else {
    4182          55 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SupplyFanIndex > 0) {
    4183          15 :                     state.dataRptCoilSelection->coilSelectionReportObj->setCoilSupplyFanInfo(
    4184             :                         state,
    4185           3 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    4186           3 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VarSpeedCoilType,
    4187           3 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SupplyFanName,
    4188             :                         DataAirSystems::StructArrayLegacyFanModels,
    4189           3 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SupplyFanIndex);
    4190             :                 }
    4191             :             }
    4192             :         }
    4193             : 
    4194    43381475 :         if (SpeedNum > state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds) {
    4195           0 :             SpeedCal = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds;
    4196    43381475 :         } else if (SpeedNum < 1) {
    4197           0 :             SpeedCal = 1;
    4198             :         } else {
    4199    43381475 :             SpeedCal = SpeedNum;
    4200             :         }
    4201             : 
    4202    43381475 :         if ((SpeedNum <= 1) || (SpeedNum > state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds)) {
    4203    21122198 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignAirMassFlowRate =
    4204    21122198 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirMassFlowRate(SpeedCal);
    4205    21122198 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignAirVolFlowRate =
    4206    21122198 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowRate(SpeedCal);
    4207    21122198 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignWaterMassFlowRate =
    4208    21122198 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterMassFlowRate(SpeedCal);
    4209    21122198 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignWaterVolFlowRate =
    4210    21122198 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterVolFlowRate(SpeedCal);
    4211             :         } else {
    4212    22259277 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignAirMassFlowRate =
    4213    44518554 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirMassFlowRate(SpeedCal) * SpeedRatio +
    4214    22259277 :                 (1.0 - SpeedRatio) * state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirMassFlowRate(SpeedCal - 1);
    4215    22259277 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignAirVolFlowRate =
    4216    44518554 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowRate(SpeedCal) * SpeedRatio +
    4217    22259277 :                 (1.0 - SpeedRatio) * state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirVolFlowRate(SpeedCal - 1);
    4218    22259277 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignWaterMassFlowRate =
    4219    44518554 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterMassFlowRate(SpeedCal) * SpeedRatio +
    4220    22259277 :                 (1.0 - SpeedRatio) * state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterMassFlowRate(SpeedCal - 1);
    4221    22259277 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignWaterVolFlowRate =
    4222    44518554 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterVolFlowRate(SpeedCal) * SpeedRatio +
    4223    22259277 :                 (1.0 - SpeedRatio) * state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterVolFlowRate(SpeedCal - 1);
    4224             :         }
    4225             : 
    4226             :         // Do the Begin Environment initializations
    4227    43381898 :         if (state.dataGlobal->BeginEnvrnFlag && state.dataVariableSpeedCoils->MyEnvrnFlag(DXCoilNum) &&
    4228         423 :             !state.dataVariableSpeedCoils->MyPlantScanFlag(DXCoilNum)) {
    4229             :             // Do the initializations to start simulation
    4230             : 
    4231         423 :             AirInletNode = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirInletNodeNum;
    4232             : 
    4233             :             // Initialize all report variables to a known state at beginning of simulation
    4234         423 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirVolFlowRate = 0.0;
    4235         423 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirDBTemp = 0.0;
    4236         423 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirHumRat = 0.0;
    4237         423 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirDBTemp = 0.0;
    4238         423 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirHumRat = 0.0;
    4239         423 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterVolFlowRate = 0.0;
    4240         423 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterMassFlowRate = 0.0;
    4241         423 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterTemp = 0.0;
    4242         423 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterEnthalpy = 0.0;
    4243         423 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletWaterEnthalpy = 0.0;
    4244         423 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletWaterTemp = 0.0;
    4245         423 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Power = 0.0;
    4246         423 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLoadTotal = 0.0;
    4247         423 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSensible = 0.0;
    4248         423 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLatent = 0.0;
    4249         423 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSource = 0.0;
    4250         423 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Energy = 0.0;
    4251         423 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLoadTotal = 0.0;
    4252         423 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergySensible = 0.0;
    4253         423 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLatent = 0.0;
    4254         423 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergySource = 0.0;
    4255         423 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).COP = 0.0;
    4256         423 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac = 0.0;
    4257         423 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PartLoadRatio = 0.0;
    4258             : 
    4259         423 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MaxONOFFCyclesperHour = MaxONOFFCyclesperHour;
    4260         423 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPTimeConstant = HPTimeConstant;
    4261         423 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).FanDelayTime = FanDelayTime;
    4262             : 
    4263         746 :             if ((state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_HeatingWaterToAirHPVSEquationFit) ||
    4264         323 :                 (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_CoolingWaterToAirHPVSEquationFit)) {
    4265         200 :                 WaterInletNode = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterInletNodeNum;
    4266             : 
    4267         400 :                 rho = GetDensityGlycol(state,
    4268         200 :                                        state.dataPlnt->PlantLoop(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).plantLoc.loopNum).FluidName,
    4269             :                                        DataGlobalConstants::CWInitConvTemp,
    4270         200 :                                        state.dataPlnt->PlantLoop(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).plantLoc.loopNum).FluidIndex,
    4271             :                                        RoutineNameSimpleWatertoAirHP);
    4272         400 :                 Cp = GetSpecificHeatGlycol(
    4273             :                     state,
    4274         200 :                     state.dataPlnt->PlantLoop(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).plantLoc.loopNum).FluidName,
    4275             :                     DataGlobalConstants::CWInitConvTemp,
    4276         200 :                     state.dataPlnt->PlantLoop(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).plantLoc.loopNum).FluidIndex,
    4277             :                     RoutineNameSimpleWatertoAirHP);
    4278             : 
    4279             :                 //    VarSpeedCoil(DXCoilNum)%DesignWaterMassFlowRate= &
    4280             :                 //                             rho * VarSpeedCoil(DXCoilNum)%RatedWaterVolFlowRate
    4281             : 
    4282         600 :                 InitComponentNodes(state,
    4283             :                                    0.0,
    4284         200 :                                    state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignWaterMassFlowRate,
    4285         200 :                                    state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterInletNodeNum,
    4286         200 :                                    state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterOutletNodeNum);
    4287             : 
    4288         200 :                 state.dataLoopNodes->Node(WaterInletNode).Temp = 5.0;
    4289         200 :                 state.dataLoopNodes->Node(WaterInletNode).Enthalpy = Cp * state.dataLoopNodes->Node(WaterInletNode).Temp;
    4290         200 :                 state.dataLoopNodes->Node(WaterInletNode).Quality = 0.0;
    4291         200 :                 state.dataLoopNodes->Node(WaterInletNode).Press = 0.0;
    4292         200 :                 state.dataLoopNodes->Node(WaterInletNode).HumRat = 0.0;
    4293             : 
    4294         200 :                 state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterOutletNodeNum).Temp = 5.0;
    4295         200 :                 state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterOutletNodeNum).Enthalpy =
    4296         200 :                     Cp * state.dataLoopNodes->Node(WaterInletNode).Temp;
    4297         200 :                 state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterOutletNodeNum).Quality = 0.0;
    4298         200 :                 state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterOutletNodeNum).Press = 0.0;
    4299         200 :                 state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterOutletNodeNum).HumRat = 0.0;
    4300             :             }
    4301             : 
    4302         423 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SimFlag = true;
    4303         423 :             state.dataHeatBal->HeatReclaimVS_DXCoil(DXCoilNum).AvailCapacity = 0.0;
    4304             : 
    4305         423 :             state.dataVariableSpeedCoils->MyEnvrnFlag(DXCoilNum) = false;
    4306             : 
    4307             :         } // End If for the Begin Environment initializations
    4308             : 
    4309    43381475 :         if (!state.dataGlobal->BeginEnvrnFlag) {
    4310    43338638 :             state.dataVariableSpeedCoils->MyEnvrnFlag(DXCoilNum) = true;
    4311             :         }
    4312             : 
    4313             :         // Do the following initializations (every time step): This should be the info from
    4314             :         // the previous components outlets or the node data in this section.
    4315             :         // First set the conditions for the air into the heat pump model
    4316             : 
    4317             :         // Set water and air inlet nodes
    4318             : 
    4319    43381475 :         AirInletNode = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirInletNodeNum;
    4320    43381475 :         WaterInletNode = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterInletNodeNum;
    4321             : 
    4322    43381475 :         if ((SensLoad != 0.0 || LatentLoad != 0.0) && (state.dataLoopNodes->Node(AirInletNode).MassFlowRate > 0.0)) {
    4323             : 
    4324    89453043 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterMassFlowRate(
    4325    59635362 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel) > 0.0) {
    4326     6850718 :                 WaterFlowScale = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedWaterMassFlowRate /
    4327     6850718 :                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedWaterMassFlowRate(
    4328     3425359 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NormSpedLevel);
    4329     3425359 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterMassFlowRate =
    4330     3425359 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignWaterMassFlowRate * WaterFlowScale;
    4331             :             } else {
    4332    26392322 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterMassFlowRate = 0.0;
    4333             :             }
    4334             : 
    4335    29817681 :             if (CyclingScheme == ContFanCycCoil) {
    4336             :                 // continuous fan, cycling compressor
    4337    29305857 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate = state.dataLoopNodes->Node(AirInletNode).MassFlowRate;
    4338             :                 //    VarSpeedCoil(DXCoilNum)%AirMassFlowRate   = VarSpeedCoil(DXCoilNum)%DesignAirVolFlowRate*  &
    4339             :                 //             PsyRhoAirFnPbTdbW(state, OutBaroPress,Node(AirInletNode)%Temp,Node(AirInletNode)%HumRat)
    4340             :                 // If air flow is less than 25% rated flow. Then set air flow to the 25% of rated conditions
    4341    87917571 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate <
    4342    58611714 :                     0.25 * state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignAirVolFlowRate *
    4343   117223428 :                         PsyRhoAirFnPbTdbW(state,
    4344    29305857 :                                           state.dataEnvrn->OutBaroPress,
    4345    29305857 :                                           state.dataLoopNodes->Node(AirInletNode).Temp,
    4346    29305857 :                                           state.dataLoopNodes->Node(AirInletNode).HumRat)) {
    4347      104277 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate =
    4348      208554 :                         0.25 * state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignAirVolFlowRate *
    4349      417108 :                         PsyRhoAirFnPbTdbW(state,
    4350      104277 :                                           state.dataEnvrn->OutBaroPress,
    4351      104277 :                                           state.dataLoopNodes->Node(AirInletNode).Temp,
    4352      104277 :                                           state.dataLoopNodes->Node(AirInletNode).HumRat);
    4353             :                 }
    4354             :             } else { // CYCLIC FAN, NOT CORRECTION, WILL BE PROCESSED IN THE FOLLOWING SUBROUTINES
    4355      511824 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate = state.dataLoopNodes->Node(AirInletNode).MassFlowRate;
    4356             :             }
    4357             : 
    4358             :         } else { // heat pump is off
    4359    13563794 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterMassFlowRate = 0.0;
    4360    13563794 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate = 0.0;
    4361             :         }
    4362             : 
    4363    82259304 :         if ((state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_HeatingWaterToAirHPVSEquationFit) ||
    4364    38877829 :             (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_CoolingWaterToAirHPVSEquationFit)) {
    4365    36029168 :             SetComponentFlowRate(state,
    4366     9007292 :                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterMassFlowRate,
    4367     9007292 :                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterInletNodeNum,
    4368     9007292 :                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterOutletNodeNum,
    4369     9007292 :                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).plantLoc);
    4370             : 
    4371     9007292 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterTemp = state.dataLoopNodes->Node(WaterInletNode).Temp;
    4372     9007292 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterEnthalpy = state.dataLoopNodes->Node(WaterInletNode).Enthalpy;
    4373             :         } else {
    4374    34374183 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterTemp = 0.0;
    4375    34374183 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterEnthalpy = 0.0;
    4376             :         }
    4377             : 
    4378    43381475 :         if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == CoilDX_HeatPumpWaterHeaterVariableSpeed) {
    4379     1618059 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterTemp = state.dataLoopNodes->Node(WaterInletNode).Temp;
    4380     1618059 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterEnthalpy = state.dataLoopNodes->Node(WaterInletNode).Enthalpy;
    4381             :         };
    4382             : 
    4383    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirDBTemp = state.dataLoopNodes->Node(AirInletNode).Temp;
    4384    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirHumRat = state.dataLoopNodes->Node(AirInletNode).HumRat;
    4385    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirEnthalpy = state.dataLoopNodes->Node(AirInletNode).Enthalpy;
    4386             : 
    4387    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MaxONOFFCyclesperHour = MaxONOFFCyclesperHour;
    4388    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPTimeConstant = HPTimeConstant;
    4389    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).FanDelayTime = FanDelayTime;
    4390             : 
    4391    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirPressure = state.dataEnvrn->OutBaroPress; // temporary
    4392             :         // Outlet variables
    4393    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Power = 0.0;
    4394    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLoadTotal = 0.0;
    4395    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSensible = 0.0;
    4396    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLatent = 0.0;
    4397    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSource = 0.0;
    4398    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QWasteHeat = 0.0;
    4399    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Energy = 0.0;
    4400    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLoadTotal = 0.0;
    4401    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergySensible = 0.0;
    4402    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLatent = 0.0;
    4403    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergySource = 0.0;
    4404    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).COP = 0.0;
    4405             : 
    4406    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirDBTemp = 0.0;
    4407    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletWaterTemp = 0.0;
    4408    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirHumRat = 0.0;
    4409    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirEnthalpy = 0.0;
    4410    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletWaterEnthalpy = 0.0;
    4411             : 
    4412             :         // bug fix, must set zeros to the variables below, otherwise can't pass switch DD test
    4413    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterConsumption = 0.0;
    4414    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapWaterConsump = 0.0;
    4415    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterConsumption = 0.0;
    4416    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondPumpElecConsumption = 0.0;
    4417    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterPower = 0.0;
    4418    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostConsumption = 0.0;
    4419    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondensateVdot = 0.0;
    4420    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondensateVol = 0.0;
    4421    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QWasteHeat = 0.0;
    4422             : 
    4423             :         // clear zeros to HPWH variables
    4424    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).ElecWaterHeatingPower =
    4425             :             0.0; // Total electric power consumed by compressor and condenser pump [W]
    4426    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).ElecWaterHeatingConsumption =
    4427             :             0.0; // Total electric consumption by compressor and condenser pump [J]
    4428    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).TotalHeatingEnergy = 0.0;       // total water heating energy
    4429    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).TotalHeatingEnergyRate = 0.0;   // total WH energy rate
    4430    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower = 0.0; // power power
    4431             : 
    4432    43381475 :         state.dataVariableSpeedCoils->VSHPWHHeatingCapacity = 0.0; // Used by Heat Pump:Water Heater object as total water heating capacity [W]
    4433    43381475 :         state.dataVariableSpeedCoils->VSHPWHHeatingCOP = 0.0;      // Used by Heat Pump:Water Heater object as water heating COP [W/W]
    4434    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletWaterTemp = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterTemp;
    4435    43381475 :         state.dataHeatBal->HeatReclaimVS_DXCoil(DXCoilNum).AvailCapacity = 0.0;
    4436    43381475 :     }
    4437             : 
    4438          80 :     void SizeVarSpeedCoil(EnergyPlusData &state, int const DXCoilNum, bool &ErrorsFound)
    4439             :     {
    4440             : 
    4441             :         // SUBROUTINE INFORMATION:
    4442             :         //       AUTHOR         Bo Shen, based on WaterToAirHeatPumpSimple:SizeHVACWaterToAir
    4443             :         //       DATE WRITTEN   March, 2012
    4444             :         //       MODIFIED       August 2013 Daeho Kang, add component sizing table entries
    4445             :         //       MODIFIED       Bo Shen, 12/2014, add variable-speed HPWH
    4446             : 
    4447             :         // PURPOSE OF THIS SUBROUTINE:
    4448             :         // This subroutine is for sizing WSHP Components for which nominal capacities
    4449             :         // and flow rates have not been specified in the input
    4450             : 
    4451             :         // METHODOLOGY EMPLOYED:
    4452             :         // Obtains heating capacities and flow rates from the zone or system sizing arrays.
    4453             :         // NOTE: For WSHP's we are sizing the heating capacity to be
    4454             :         // equal to the cooling capacity.  Thus the cooling and
    4455             :         // and heating capacities of a DX heat pump system will be identical. In real life the ARI
    4456             :         // heating and cooling capacities are close but not identical.
    4457             : 
    4458             :         // SUBROUTINE PARAMETER DEFINITIONS:
    4459             :         static constexpr std::string_view RoutineName("SizeVarSpeedCoil");
    4460             :         static constexpr std::string_view RoutineNameAlt("SizeHVACWaterToAir");
    4461             : 
    4462          80 :         auto &ZoneEqSizing(state.dataSize->ZoneEqSizing);
    4463          80 :         auto &varSpeedCoil = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum);
    4464             : 
    4465             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    4466          80 :         Real64 rhoair = state.dataEnvrn->StdRhoAir;
    4467          80 :         Real64 MixTemp = -999.0;
    4468          80 :         Real64 MixHumRat = -999.0;
    4469          80 :         Real64 MixEnth = -999.0;
    4470          80 :         Real64 MixWetBulb = -999.0;
    4471          80 :         Real64 SupTemp = -999.0;
    4472          80 :         Real64 SupHumRat = -999.0;
    4473          80 :         Real64 SupEnth = -999.0;
    4474          80 :         Real64 OutTemp = -999.0;
    4475          80 :         Real64 OutAirFrac = -999.0;
    4476          80 :         Real64 VolFlowRate = -999.0;
    4477          80 :         Real64 CoolCapAtPeak = -999.0;
    4478          80 :         Real64 TotCapTempModFac = -999.0;
    4479             :         int TimeStepNumAtMax;
    4480             :         int DDNum;
    4481             :         bool RatedCapCoolTotalAutoSized;
    4482             :         bool RatedCapCoolSensAutoSized;
    4483             :         Real64 SystemCapacity;
    4484             :         Real64 rho;
    4485             :         Real64 cp;
    4486             :         int Mode;                     // speed level
    4487             :         Real64 rhoW;                  // water density
    4488             :         Real64 SHR;                   // sensible heat transfer ratio
    4489             :         Real64 RatedAirMassFlowRate;  // rated air mass flow rate
    4490             :         Real64 CBFRated;              // bypass factor at the rated condition, considering difference in flow rates
    4491             :         Real64 RatedInletEnth;        // rated inlet air enthalpy
    4492             :         Real64 QLoadTotal1;           // placeholder for calculating SHR
    4493             :         Real64 QLoadTotal2;           // placeholder for calculating SHR
    4494             :         Real64 QLoadTotal;            // placeholder for calculating SHR
    4495             :         Real64 AirMassFlowRatio;      // air mass flow ratio
    4496             :         Real64 WaterMassFlowRatio;    // water mass flow rate
    4497             :         Real64 RatedSourceTempCool;   // rated source temperature, space cooling mode
    4498         160 :         std::string CurrentObjSubfix; // Object subfix type for printing
    4499             :         bool HardSizeNoDesRun;        // Indicator to hardsize withouth sizing runs
    4500             :         bool SizingDesRunThisAirSys;  // true if a particular air system had a Sizing:System object and system sizing done
    4501             :         bool SizingDesRunThisZone;    // true if a particular zone had a Sizing:Zone object and zone sizing was done
    4502             :         Real64 HPInletAirHumRat;      // Rated inlet air humidity ratio for heat pump water heater [kgWater/kgDryAir]
    4503             :         Real64 HPWHCoolCapacity;      // estimate cooling capacity in HPWH
    4504             : 
    4505          80 :         int UpperSpeed = varSpeedCoil.NumOfSpeeds;
    4506          80 :         int NormSpeed = varSpeedCoil.NormSpedLevel;
    4507          80 :         int PltSizNum = 0;
    4508          80 :         bool RatedAirFlowAutoSized = false;
    4509          80 :         bool RatedWaterFlowAutoSized = false;
    4510          80 :         bool RatedCapHeatAutoSized = false;
    4511          80 :         bool IsAutoSize = false;
    4512             : 
    4513          80 :         if (state.dataSize->SysSizingRunDone || state.dataSize->ZoneSizingRunDone) {
    4514          50 :             HardSizeNoDesRun = false;
    4515             :         } else {
    4516          30 :             HardSizeNoDesRun = true;
    4517             :         }
    4518          80 :         if (state.dataSize->CurSysNum > 0) {
    4519          60 :             CheckThisAirSystemForSizing(state, state.dataSize->CurSysNum, SizingDesRunThisAirSys);
    4520             :         } else {
    4521          20 :             SizingDesRunThisAirSys = false;
    4522             :         }
    4523          80 :         if (state.dataSize->CurZoneEqNum > 0) {
    4524          16 :             CheckThisZoneForSizing(state, state.dataSize->CurZoneEqNum, SizingDesRunThisZone);
    4525             :         } else {
    4526          64 :             SizingDesRunThisZone = false;
    4527             :         }
    4528          80 :         bool HardSizeNoDesRunAirFlow = false;
    4529          80 :         Real64 RatedAirVolFlowRateDes = 0.0;
    4530          80 :         Real64 RatedAirVolFlowRateUser = 0.0;
    4531          80 :         Real64 RatedCapCoolTotalDes = 0.0;
    4532          80 :         Real64 RatedCapCoolTotalUser = 0.0;
    4533          80 :         Real64 RatedCapHeatDes = 0.0;
    4534          80 :         Real64 RatedCapHeatUser = 0.0;
    4535          80 :         Real64 RatedWaterVolFlowRateDes = 0.0;
    4536          80 :         Real64 RatedWaterVolFlowRateUser = 0.0;
    4537          80 :         Real64 RatedCapCoolSensDes = 0.0;
    4538          80 :         Real64 EvapCondPumpElecNomPowerDes = 0.0;
    4539          80 :         Real64 EvapCondPumpElecNomPowerUser = 0.0;
    4540          80 :         Real64 DefrostCapacityDes = 0.0;
    4541          80 :         Real64 DefrostCapacityUser = 0.0;
    4542             : 
    4543         143 :         if (varSpeedCoil.VSCoilType == DataHVACGlobals::Coil_CoolingWaterToAirHPVSEquationFit ||
    4544          63 :             varSpeedCoil.VSCoilType == DataHVACGlobals::Coil_HeatingWaterToAirHPVSEquationFit) {
    4545          34 :             CurrentObjSubfix = ":WATERTOAIRHEATPUMP:VARIABLESPEEDEQUATIONFIT";
    4546          46 :         } else if (varSpeedCoil.VSCoilType == CoilDX_HeatPumpWaterHeaterVariableSpeed) {
    4547          14 :             CurrentObjSubfix = ":WATERHEATING:AIRTOWATERHEATPUMP:VARIABLESPEED";
    4548             :         } else {
    4549          32 :             CurrentObjSubfix = ":DX:VARIABLESPEED";
    4550             :         }
    4551             : 
    4552          80 :         if (varSpeedCoil.VSCoilType == DataHVACGlobals::CoilDX_HeatPumpWaterHeaterVariableSpeed) {
    4553          14 :             if (varSpeedCoil.RatedAirVolFlowRate == DataGlobalConstants::AutoCalculate) {
    4554           4 :                 varSpeedCoil.RatedAirVolFlowRate =
    4555           4 :                     varSpeedCoil.RatedCapWH * varSpeedCoil.MSRatedAirVolFlowRate(NormSpeed) / varSpeedCoil.MSRatedTotCap(NormSpeed); // 0.00005035;
    4556           4 :                 varSpeedCoil.AirVolFlowAutoSized = true;
    4557             :             }
    4558          28 :             state.dataRptCoilSelection->coilSelectionReportObj->setCoilAirFlow(
    4559          14 :                 state, varSpeedCoil.Name, varSpeedCoil.VarSpeedCoilType, varSpeedCoil.RatedAirVolFlowRate, varSpeedCoil.AirVolFlowAutoSized);
    4560             : 
    4561          14 :             if (varSpeedCoil.RatedWaterVolFlowRate == DataGlobalConstants::AutoCalculate) {
    4562           8 :                 varSpeedCoil.RatedHPWHCondWaterFlow = varSpeedCoil.RatedCapWH * varSpeedCoil.MSRatedWaterVolFlowRate(NormSpeed) /
    4563           4 :                                                       varSpeedCoil.MSRatedTotCap(NormSpeed); // 0.00000004487;
    4564           4 :                 varSpeedCoil.RatedWaterVolFlowRate = varSpeedCoil.RatedHPWHCondWaterFlow;
    4565           4 :                 varSpeedCoil.WaterVolFlowAutoSized = true;
    4566             :             }
    4567          28 :             state.dataRptCoilSelection->coilSelectionReportObj->setCoilWaterFlowPltSizNum(state,
    4568             :                                                                                           varSpeedCoil.Name,
    4569             :                                                                                           varSpeedCoil.VarSpeedCoilType,
    4570             :                                                                                           varSpeedCoil.RatedWaterVolFlowRate,
    4571          14 :                                                                                           varSpeedCoil.WaterVolFlowAutoSized,
    4572             :                                                                                           -999,
    4573             :                                                                                           varSpeedCoil.plantLoc.loopNum);
    4574             :         }
    4575             : 
    4576          80 :         if (varSpeedCoil.RatedAirVolFlowRate == AutoSize) {
    4577          22 :             RatedAirFlowAutoSized = true;
    4578             :         }
    4579             : 
    4580          80 :         if (state.dataSize->CurSysNum > 0) {
    4581          60 :             if (!RatedAirFlowAutoSized && !SizingDesRunThisAirSys) { // Simulation continue
    4582          49 :                 HardSizeNoDesRunAirFlow = true;
    4583          98 :                 if (varSpeedCoil.RatedAirVolFlowRate > 0.0) {
    4584         196 :                     BaseSizer::reportSizerOutput(state,
    4585          98 :                                                  format("COIL:{}{}", varSpeedCoil.CoolHeatType, CurrentObjSubfix),
    4586             :                                                  varSpeedCoil.Name,
    4587             :                                                  "User-Specified Rated Air Flow Rate [m3/s]",
    4588          49 :                                                  varSpeedCoil.RatedAirVolFlowRate);
    4589             :                 }
    4590             :             } else {
    4591          11 :                 CheckSysSizing(state, format("COIL:{}{}", varSpeedCoil.CoolHeatType, CurrentObjSubfix), varSpeedCoil.Name);
    4592          11 :                 if (state.dataSize->FinalSysSizing(state.dataSize->CurSysNum).DesMainVolFlow >= DataHVACGlobals::SmallAirVolFlow) {
    4593          11 :                     RatedAirVolFlowRateDes = state.dataSize->FinalSysSizing(state.dataSize->CurSysNum).DesMainVolFlow;
    4594             :                 } else {
    4595           0 :                     RatedAirVolFlowRateDes = 0.0;
    4596             :                 }
    4597             :             }
    4598             :         }
    4599             : 
    4600          80 :         if (state.dataSize->CurZoneEqNum > 0) {
    4601          16 :             if (!RatedAirFlowAutoSized && !SizingDesRunThisZone) { // Simulation continue
    4602           0 :                 HardSizeNoDesRunAirFlow = true;
    4603           0 :                 if (varSpeedCoil.RatedAirVolFlowRate > 0.0) {
    4604           0 :                     BaseSizer::reportSizerOutput(state,
    4605           0 :                                                  format("COIL:{}{}", varSpeedCoil.CoolHeatType, CurrentObjSubfix),
    4606             :                                                  varSpeedCoil.Name,
    4607             :                                                  "User-Specified Rated Air Flow Rate [m3/s]",
    4608           0 :                                                  varSpeedCoil.RatedAirVolFlowRate);
    4609             :                 }
    4610             :             } else {
    4611          16 :                 CheckZoneSizing(state, format("COIL:{}{}", varSpeedCoil.CoolHeatType, CurrentObjSubfix), varSpeedCoil.Name);
    4612          16 :                 RatedAirVolFlowRateDes = max(state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).DesCoolVolFlow,
    4613          16 :                                              state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).DesHeatVolFlow);
    4614          16 :                 if (RatedAirVolFlowRateDes < DataHVACGlobals::SmallAirVolFlow) {
    4615           0 :                     RatedAirVolFlowRateDes = 0.0;
    4616             :                 }
    4617             :             }
    4618             :         }
    4619             : 
    4620          80 :         if (RatedAirFlowAutoSized) varSpeedCoil.RatedAirVolFlowRate = RatedAirVolFlowRateDes;
    4621             : 
    4622          80 :         RatedCapCoolTotalAutoSized = false;
    4623          80 :         RatedCapCoolSensAutoSized = false;
    4624             : 
    4625             :         // size rated total cooling capacity
    4626          80 :         IsAutoSize = false;
    4627         129 :         if (varSpeedCoil.RatedCapCoolTotal == AutoSize && (varSpeedCoil.VSCoilType == DataHVACGlobals::Coil_CoolingWaterToAirHPVSEquationFit ||
    4628          49 :                                                            varSpeedCoil.VSCoilType == DataHVACGlobals::Coil_CoolingAirToAirVariableSpeed)) {
    4629          16 :             RatedCapCoolTotalAutoSized = true;
    4630             :         }
    4631          80 :         if (SizingDesRunThisZone || SizingDesRunThisAirSys) HardSizeNoDesRun = false;
    4632          80 :         if (state.dataSize->CurSysNum > 0) {
    4633          60 :             if (!RatedCapCoolTotalAutoSized && !SizingDesRunThisAirSys) { // Simulation continue
    4634          49 :                 HardSizeNoDesRun = true;
    4635          98 :                 if (varSpeedCoil.RatedCapCoolTotal > 0.0) {
    4636         108 :                     BaseSizer::reportSizerOutput(state,
    4637          54 :                                                  format("COIL:{}{}", varSpeedCoil.CoolHeatType, CurrentObjSubfix),
    4638             :                                                  varSpeedCoil.Name,
    4639             :                                                  "User-Specified Rated Total Cooling Capacity [W]",
    4640          27 :                                                  varSpeedCoil.RatedCapCoolTotal);
    4641             :                 }
    4642             :             } else {
    4643          11 :                 CheckSysSizing(state, format("COIL:{}{}", varSpeedCoil.CoolHeatType, CurrentObjSubfix), varSpeedCoil.Name);
    4644          11 :                 auto &finalSysSizing = state.dataSize->FinalSysSizing(state.dataSize->CurSysNum);
    4645          11 :                 VolFlowRate = varSpeedCoil.RatedAirVolFlowRate;
    4646          11 :                 if (VolFlowRate >= DataHVACGlobals::SmallAirVolFlow) {
    4647          11 :                     if (state.dataSize->CurOASysNum > 0) { // coil is in the OA stream
    4648           0 :                         MixTemp = finalSysSizing.OutTempAtCoolPeak;
    4649           0 :                         MixHumRat = finalSysSizing.OutHumRatAtCoolPeak;
    4650           0 :                         SupTemp = finalSysSizing.PrecoolTemp;
    4651           0 :                         SupHumRat = finalSysSizing.PrecoolHumRat;
    4652             :                     } else { // coil is on the main air loop
    4653          11 :                         SupTemp = finalSysSizing.CoolSupTemp;
    4654          11 :                         SupHumRat = finalSysSizing.CoolSupHumRat;
    4655          11 :                         if (state.dataAirSystemsData->PrimaryAirSystems(state.dataSize->CurSysNum).NumOACoolCoils ==
    4656             :                             0) { // there is no precooling of the OA stream
    4657          11 :                             MixTemp = finalSysSizing.MixTempAtCoolPeak;
    4658          11 :                             MixHumRat = finalSysSizing.MixHumRatAtCoolPeak;
    4659             :                         } else { // there is precooling of OA stream
    4660           0 :                             if (VolFlowRate > 0.0) {
    4661           0 :                                 OutAirFrac = finalSysSizing.DesOutAirVolFlow / VolFlowRate;
    4662             :                             } else {
    4663           0 :                                 OutAirFrac = 1.0;
    4664             :                             }
    4665           0 :                             OutAirFrac = min(1.0, max(0.0, OutAirFrac));
    4666           0 :                             MixTemp = OutAirFrac * finalSysSizing.PrecoolTemp + (1.0 - OutAirFrac) * finalSysSizing.RetTempAtCoolPeak;
    4667           0 :                             MixHumRat = OutAirFrac * finalSysSizing.PrecoolHumRat + (1.0 - OutAirFrac) * finalSysSizing.RetHumRatAtCoolPeak;
    4668             :                         }
    4669             :                     }
    4670          11 :                     OutTemp = finalSysSizing.OutTempAtCoolPeak;
    4671          11 :                     MixEnth = Psychrometrics::PsyHFnTdbW(MixTemp, MixHumRat);
    4672          11 :                     SupEnth = Psychrometrics::PsyHFnTdbW(SupTemp, SupHumRat);
    4673             : 
    4674             :                     // design fan heat will be added to coil load
    4675             :                     Real64 FanCoolLoad =
    4676          11 :                         DataAirSystems::calcFanDesignHeatGain(state, state.dataSize->DataFanEnumType, state.dataSize->DataFanIndex, VolFlowRate);
    4677             :                     // inlet/outlet temp is adjusted after enthalpy is calculcated so fan heat is not double counted
    4678          11 :                     Real64 CpAir = Psychrometrics::PsyCpAirFnW(MixHumRat);
    4679          11 :                     if (state.dataAirSystemsData->PrimaryAirSystems(state.dataSize->CurSysNum).supFanLocation ==
    4680             :                         DataAirSystems::FanPlacement::BlowThru) {
    4681          11 :                         MixTemp += FanCoolLoad / (CpAir * rhoair * VolFlowRate);
    4682           0 :                     } else if (state.dataAirSystemsData->PrimaryAirSystems(state.dataSize->CurSysNum).supFanLocation ==
    4683             :                                DataAirSystems::FanPlacement::DrawThru) {
    4684           0 :                         SupTemp -= FanCoolLoad / (CpAir * rhoair * VolFlowRate);
    4685             :                     }
    4686          11 :                     MixWetBulb = Psychrometrics::PsyTwbFnTdbWPb(state, MixTemp, MixHumRat, state.dataEnvrn->StdBaroPress, RoutineName);
    4687          11 :                     if (varSpeedCoil.CondenserType == DataHeatBalance::RefrigCondenserType::Air) {
    4688          11 :                         RatedSourceTempCool = OutTemp;
    4689             :                     } else {
    4690           0 :                         RatedSourceTempCool = GetVSCoilRatedSourceTemp(state, DXCoilNum);
    4691             :                     }
    4692          11 :                     TotCapTempModFac =
    4693          22 :                         Curve::CurveValue(state, varSpeedCoil.MSCCapFTemp(varSpeedCoil.NormSpedLevel), MixWetBulb, RatedSourceTempCool);
    4694             : 
    4695             :                     //       The mixed air temp for zone equipment without an OA mixer is 0.
    4696             :                     //       This test avoids a negative capacity until a solution can be found.
    4697          11 :                     if (MixEnth > SupEnth) {
    4698          11 :                         CoolCapAtPeak = (rhoair * VolFlowRate * (MixEnth - SupEnth)) + FanCoolLoad;
    4699             :                     } else {
    4700           0 :                         CoolCapAtPeak = (rhoair * VolFlowRate * (48000.0 - SupEnth)) + FanCoolLoad;
    4701             :                     }
    4702          11 :                     CoolCapAtPeak = max(0.0, CoolCapAtPeak);
    4703          11 :                     if (TotCapTempModFac > 0.0) {
    4704          11 :                         RatedCapCoolTotalDes = CoolCapAtPeak / TotCapTempModFac;
    4705             :                     } else {
    4706           0 :                         RatedCapCoolTotalDes = CoolCapAtPeak;
    4707             :                     }
    4708             :                 } else {
    4709           0 :                     RatedCapCoolTotalDes = 0.0;
    4710             :                 }
    4711             :             }
    4712             : 
    4713          20 :         } else if (state.dataSize->CurZoneEqNum > 0) {
    4714          16 :             if (!RatedCapCoolTotalAutoSized && !SizingDesRunThisZone) { // Simulation continue
    4715           0 :                 HardSizeNoDesRun = true;
    4716           0 :                 if (varSpeedCoil.RatedCapCoolTotal > 0.0) {
    4717           0 :                     BaseSizer::reportSizerOutput(state,
    4718           0 :                                                  format("COIL:{}{}", varSpeedCoil.CoolHeatType, CurrentObjSubfix),
    4719             :                                                  varSpeedCoil.Name,
    4720             :                                                  "User-Specified Rated Total Cooling Capacity [W]",
    4721           0 :                                                  varSpeedCoil.RatedCapCoolTotal);
    4722             :                 }
    4723             :             } else {
    4724          16 :                 CheckZoneSizing(state, format("COIL:{}{}", varSpeedCoil.CoolHeatType, CurrentObjSubfix), varSpeedCoil.Name);
    4725          16 :                 auto &finalZoneSizing = state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum);
    4726          16 :                 VolFlowRate = varSpeedCoil.RatedAirVolFlowRate;
    4727          16 :                 if (VolFlowRate >= DataHVACGlobals::SmallAirVolFlow) {
    4728          16 :                     if (state.dataSize->ZoneEqDXCoil) {
    4729          12 :                         if (ZoneEqSizing(state.dataSize->CurZoneEqNum).OAVolFlow > 0.0) {
    4730          10 :                             MixTemp = finalZoneSizing.DesCoolCoilInTemp;
    4731          10 :                             MixHumRat = finalZoneSizing.DesCoolCoilInHumRat;
    4732             :                         } else {
    4733           2 :                             MixTemp = finalZoneSizing.ZoneTempAtCoolPeak;
    4734           2 :                             MixHumRat = finalZoneSizing.ZoneHumRatAtCoolPeak;
    4735             :                         }
    4736             :                     } else {
    4737           4 :                         MixTemp = finalZoneSizing.DesCoolCoilInTemp;
    4738           4 :                         MixHumRat = finalZoneSizing.DesCoolCoilInHumRat;
    4739             :                     }
    4740          16 :                     SupTemp = finalZoneSizing.CoolDesTemp;
    4741          16 :                     SupHumRat = finalZoneSizing.CoolDesHumRat;
    4742          16 :                     TimeStepNumAtMax = finalZoneSizing.TimeStepNumAtCoolMax;
    4743          16 :                     DDNum = finalZoneSizing.CoolDDNum;
    4744          16 :                     if (DDNum > 0 && TimeStepNumAtMax > 0) {
    4745          16 :                         OutTemp = state.dataSize->DesDayWeath(DDNum).Temp(TimeStepNumAtMax);
    4746             :                     } else {
    4747           0 :                         OutTemp = 0.0;
    4748             :                     }
    4749          16 :                     MixEnth = Psychrometrics::PsyHFnTdbW(MixTemp, MixHumRat);
    4750          16 :                     SupEnth = Psychrometrics::PsyHFnTdbW(SupTemp, SupHumRat);
    4751             : 
    4752             :                     // design fan heat will be added to coil load
    4753             :                     Real64 FanCoolLoad =
    4754          16 :                         DataAirSystems::calcFanDesignHeatGain(state, state.dataSize->DataFanEnumType, state.dataSize->DataFanIndex, VolFlowRate);
    4755             :                     // inlet/outlet temp is adjusted after enthalpy is calculcated so fan heat is not double counted
    4756          16 :                     Real64 CpAir = Psychrometrics::PsyCpAirFnW(MixHumRat);
    4757             : 
    4758          16 :                     if (state.dataSize->DataFanPlacement == DataSizing::ZoneFanPlacement::BlowThru) {
    4759          11 :                         MixTemp += FanCoolLoad / (CpAir * rhoair * VolFlowRate);
    4760             :                     } else {
    4761           5 :                         SupTemp -= FanCoolLoad / (CpAir * rhoair * VolFlowRate);
    4762             :                     }
    4763             : 
    4764          16 :                     MixWetBulb = Psychrometrics::PsyTwbFnTdbWPb(state, MixTemp, MixHumRat, state.dataEnvrn->StdBaroPress, RoutineName);
    4765          16 :                     if (varSpeedCoil.CondenserType == DataHeatBalance::RefrigCondenserType::Air) {
    4766          10 :                         RatedSourceTempCool = OutTemp;
    4767             :                     } else {
    4768           6 :                         RatedSourceTempCool = GetVSCoilRatedSourceTemp(state, DXCoilNum);
    4769             :                     }
    4770          16 :                     TotCapTempModFac =
    4771          32 :                         Curve::CurveValue(state, varSpeedCoil.MSCCapFTemp(varSpeedCoil.NormSpedLevel), MixWetBulb, RatedSourceTempCool);
    4772             : 
    4773             :                     //       The mixed air temp for zone equipment without an OA mixer is 0.
    4774             :                     //       This test avoids a negative capacity until a solution can be found.
    4775          16 :                     if (MixEnth > SupEnth) {
    4776          16 :                         CoolCapAtPeak = (rhoair * VolFlowRate * (MixEnth - SupEnth)) + FanCoolLoad;
    4777             :                     } else {
    4778           0 :                         CoolCapAtPeak = (rhoair * VolFlowRate * (48000.0 - SupEnth)) + FanCoolLoad;
    4779             :                     }
    4780          16 :                     CoolCapAtPeak = max(0.0, CoolCapAtPeak);
    4781          16 :                     if (TotCapTempModFac > 0.0) {
    4782          16 :                         RatedCapCoolTotalDes = CoolCapAtPeak / TotCapTempModFac;
    4783             :                     } else {
    4784           0 :                         RatedCapCoolTotalDes = CoolCapAtPeak;
    4785             :                     }
    4786             :                 } else {
    4787           0 :                     RatedCapCoolTotalDes = 0.0;
    4788             :                 }
    4789             :             }
    4790             :         }
    4791          80 :         if (RatedCapCoolTotalDes < DataHVACGlobals::SmallLoad) {
    4792          53 :             RatedCapCoolTotalDes = 0.0;
    4793             :         }
    4794          80 :         if (!HardSizeNoDesRun) {
    4795          30 :             if (RatedCapCoolTotalAutoSized) {
    4796          16 :                 varSpeedCoil.RatedCapCoolTotal = RatedCapCoolTotalDes;
    4797          64 :                 BaseSizer::reportSizerOutput(state,
    4798          32 :                                              format("COIL:{}{}", varSpeedCoil.CoolHeatType, CurrentObjSubfix),
    4799             :                                              varSpeedCoil.Name,
    4800             :                                              "Design Size Rated Total Cooling Capacity [W]",
    4801          16 :                                              varSpeedCoil.RatedCapCoolTotal);
    4802          32 :                 OutputReportPredefined::PreDefTableEntry(
    4803          16 :                     state, state.dataOutRptPredefined->pdchCoolCoilTotCap, varSpeedCoil.Name, varSpeedCoil.RatedCapCoolTotal);
    4804          48 :                 OutputReportPredefined::PreDefTableEntry(state,
    4805          16 :                                                          state.dataOutRptPredefined->pdchCoolCoilLatCap,
    4806             :                                                          varSpeedCoil.Name,
    4807          16 :                                                          varSpeedCoil.RatedCapCoolTotal - varSpeedCoil.RatedCapCoolSens);
    4808          16 :                 if (varSpeedCoil.RatedCapCoolTotal != 0.0) {
    4809          48 :                     OutputReportPredefined::PreDefTableEntry(state,
    4810          16 :                                                              state.dataOutRptPredefined->pdchCoolCoilSHR,
    4811             :                                                              varSpeedCoil.Name,
    4812          16 :                                                              varSpeedCoil.RatedCapCoolSens / varSpeedCoil.RatedCapCoolTotal);
    4813          48 :                     OutputReportPredefined::PreDefTableEntry(
    4814          32 :                         state, state.dataOutRptPredefined->pdchCoolCoilNomEff, varSpeedCoil.Name, varSpeedCoil.MSRatedCOP(NormSpeed));
    4815             :                 } else {
    4816           0 :                     OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoolCoilSHR, varSpeedCoil.Name, 0.0);
    4817           0 :                     OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoolCoilNomEff, varSpeedCoil.Name, 0.0);
    4818             :                 }
    4819          16 :                 OutputReportPredefined::addFootNoteSubTable(
    4820             :                     state,
    4821          16 :                     state.dataOutRptPredefined->pdstCoolCoil,
    4822          16 :                     "Nominal values are gross at rated conditions, i.e., the supply air fan heat and electric power NOT accounted for.");
    4823             :             } else {
    4824          14 :                 if (varSpeedCoil.RatedCapCoolTotal > 0.0 && RatedCapCoolTotalDes > 0.0) {
    4825           2 :                     RatedCapCoolTotalUser = varSpeedCoil.RatedCapCoolTotal;
    4826           8 :                     BaseSizer::reportSizerOutput(state,
    4827           4 :                                                  format("COIL:{}{}", varSpeedCoil.CoolHeatType, CurrentObjSubfix),
    4828             :                                                  varSpeedCoil.Name,
    4829             :                                                  "Design Size Rated Total Cooling Capacity [W]",
    4830             :                                                  RatedCapCoolTotalDes,
    4831             :                                                  "User-Specified Rated Total Cooling Capacity [W]",
    4832           2 :                                                  RatedCapCoolTotalUser);
    4833           2 :                     if (state.dataGlobal->DisplayExtraWarnings) {
    4834           0 :                         if ((std::abs(RatedCapCoolTotalDes - RatedCapCoolTotalUser) / RatedCapCoolTotalUser) >
    4835           0 :                             state.dataSize->AutoVsHardSizingThreshold) {
    4836           0 :                             ShowMessage(state,
    4837           0 :                                         format("SizeVarSpeedCoil: Potential issue with equipment sizing for {} {}",
    4838             :                                                varSpeedCoil.CoolHeatType,
    4839           0 :                                                CurrentObjSubfix));
    4840           0 :                             ShowContinueError(state, format("Coil Name = {}", varSpeedCoil.Name));
    4841           0 :                             ShowContinueError(state, format("User-Specified Rated Total Cooling Capacity of {:.2R} [W]", RatedCapCoolTotalUser));
    4842           0 :                             ShowContinueError(state,
    4843           0 :                                               format("differs from Design Size Rated Total Cooling Capacity of {:.2R} [W]", RatedCapCoolTotalDes));
    4844           0 :                             ShowContinueError(state, "This may, or may not, indicate mismatched component sizes.");
    4845           0 :                             ShowContinueError(state, "Verify that the value entered is intended and is consistent with other components.");
    4846             :                         }
    4847             :                     }
    4848             :                 }
    4849             :             }
    4850             : 
    4851          90 :             state.dataRptCoilSelection->coilSelectionReportObj->setCoilEntAirTemp(
    4852          60 :                 state, varSpeedCoil.Name, varSpeedCoil.VarSpeedCoilType, MixTemp, state.dataSize->CurSysNum, state.dataSize->CurZoneEqNum);
    4853          30 :             state.dataRptCoilSelection->coilSelectionReportObj->setCoilEntAirHumRat(
    4854             :                 state, varSpeedCoil.Name, varSpeedCoil.VarSpeedCoilType, MixHumRat);
    4855          30 :             state.dataRptCoilSelection->coilSelectionReportObj->setCoilLvgAirTemp(state, varSpeedCoil.Name, varSpeedCoil.VarSpeedCoilType, SupTemp);
    4856          30 :             state.dataRptCoilSelection->coilSelectionReportObj->setCoilLvgAirHumRat(
    4857             :                 state, varSpeedCoil.Name, varSpeedCoil.VarSpeedCoilType, SupHumRat);
    4858         120 :             state.dataRptCoilSelection->coilSelectionReportObj->setCoilCoolingCapacity(state,
    4859             :                                                                                        varSpeedCoil.Name,
    4860             :                                                                                        varSpeedCoil.VarSpeedCoilType,
    4861             :                                                                                        RatedCapCoolTotalDes,
    4862             :                                                                                        RatedCapCoolTotalAutoSized,
    4863          30 :                                                                                        state.dataSize->CurSysNum,
    4864          30 :                                                                                        state.dataSize->CurZoneEqNum,
    4865          30 :                                                                                        state.dataSize->CurOASysNum,
    4866             :                                                                                        0.0, // no fan load included in sizing
    4867             :                                                                                        TotCapTempModFac,
    4868             :                                                                                        -999.0,
    4869             :                                                                                        -999.0); // VS model doesn't limit, double check
    4870             :         }
    4871             : 
    4872             :         // Set the global DX cooling coil capacity variable for use by other objects
    4873         143 :         if (varSpeedCoil.VSCoilType == DataHVACGlobals::Coil_CoolingWaterToAirHPVSEquationFit ||
    4874          63 :             varSpeedCoil.VSCoilType == DataHVACGlobals::Coil_CoolingAirToAirVariableSpeed) {
    4875          39 :             state.dataSize->DXCoolCap = varSpeedCoil.RatedCapCoolTotal;
    4876             :         }
    4877             : 
    4878             :         // size rated heating capacity
    4879         137 :         if (varSpeedCoil.RatedCapHeat == AutoSize && (varSpeedCoil.VSCoilType == DataHVACGlobals::Coil_HeatingWaterToAirHPVSEquationFit ||
    4880          57 :                                                       varSpeedCoil.VSCoilType == DataHVACGlobals::Coil_HeatingAirToAirVariableSpeed)) {
    4881           6 :             RatedCapHeatAutoSized = true;
    4882             :         }
    4883             :         //   simply set heating capacity equal to the cooling capacity
    4884             :         // VarSpeedCoil(DXCoilNum)%RatedCapHeat = DXCoolCap
    4885         143 :         if (varSpeedCoil.VSCoilType == DataHVACGlobals::Coil_HeatingWaterToAirHPVSEquationFit ||
    4886          63 :             varSpeedCoil.VSCoilType == DataHVACGlobals::Coil_HeatingAirToAirVariableSpeed) {
    4887          27 :             if (varSpeedCoil.CompanionCoolingCoilNum > 0) {
    4888          22 :                 RatedCapHeatDes = state.dataVariableSpeedCoils->VarSpeedCoil(varSpeedCoil.CompanionCoolingCoilNum).RatedCapCoolTotal;
    4889          22 :                 varSpeedCoil.RatedCapCoolTotal = RatedCapHeatDes; // AVOID BEING ZERO
    4890             :             } else {
    4891           5 :                 RatedCapHeatDes = state.dataSize->DXCoolCap; // previous code, can be risky
    4892             :             }
    4893             :             // END IF
    4894          27 :             if (RatedCapHeatAutoSized) {
    4895           6 :                 if (RatedCapHeatDes == AutoSize) {
    4896           0 :                     ShowWarningError(
    4897           0 :                         state, format("COIL:{}:WATERTOAIRHEATPUMP:VARIABLESPEEDEQUATIONFIT \"{}\"", varSpeedCoil.CoolHeatType, varSpeedCoil.Name));
    4898           0 :                     ShowContinueError(state,
    4899           0 :                                       format("{}: Heating coil could not be autosized since cooling coil was not previously sized.", RoutineName));
    4900           0 :                     ShowContinueError(state, "... Cooling coil must be upstream of heating coil.");
    4901           0 :                     ShowContinueError(state, "... Manually sizing this heating coil will be required.");
    4902             :                 }
    4903             :             }
    4904          27 :             if (RatedCapHeatDes < DataHVACGlobals::SmallLoad) {
    4905           0 :                 RatedCapHeatDes = 0.0;
    4906             :             }
    4907         108 :             state.dataRptCoilSelection->coilSelectionReportObj->setCoilHeatingCapacity(state,
    4908             :                                                                                        varSpeedCoil.Name,
    4909             :                                                                                        varSpeedCoil.VarSpeedCoilType,
    4910             :                                                                                        RatedCapHeatDes,
    4911             :                                                                                        RatedCapHeatAutoSized,
    4912          27 :                                                                                        state.dataSize->CurSysNum,
    4913          27 :                                                                                        state.dataSize->CurZoneEqNum,
    4914          27 :                                                                                        state.dataSize->CurOASysNum,
    4915             :                                                                                        0.0,
    4916             :                                                                                        1.0,
    4917             :                                                                                        -999.0,
    4918             :                                                                                        -999.0);
    4919             :         }
    4920          80 :         if (RatedCapHeatAutoSized) {
    4921           6 :             varSpeedCoil.RatedCapHeat = RatedCapHeatDes;
    4922          24 :             BaseSizer::reportSizerOutput(state,
    4923          12 :                                          format("COIL:{}{}", varSpeedCoil.CoolHeatType, CurrentObjSubfix),
    4924             :                                          varSpeedCoil.Name,
    4925             :                                          "Design Size Nominal Heating Capacity [W]",
    4926           6 :                                          RatedCapHeatDes);
    4927          12 :             OutputReportPredefined::PreDefTableEntry(
    4928           6 :                 state, state.dataOutRptPredefined->pdchHeatCoilNomCap, varSpeedCoil.Name, varSpeedCoil.RatedCapHeat);
    4929           6 :             if (varSpeedCoil.RatedCapHeat != 0.0) {
    4930          18 :                 OutputReportPredefined::PreDefTableEntry(
    4931          12 :                     state, state.dataOutRptPredefined->pdchHeatCoilNomEff, varSpeedCoil.Name, varSpeedCoil.MSRatedCOP(NormSpeed));
    4932             :             } else {
    4933           0 :                 OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchHeatCoilNomEff, varSpeedCoil.Name, 0.0);
    4934             :             }
    4935           6 :             OutputReportPredefined::addFootNoteSubTable(
    4936             :                 state,
    4937           6 :                 state.dataOutRptPredefined->pdstHeatCoil,
    4938           6 :                 "Nominal values are gross at rated conditions, i.e., the supply air fan heat and electric power NOT accounted for.");
    4939             :         } else {
    4940          74 :             if (varSpeedCoil.RatedCapHeat > 0.0 && RatedCapHeatDes > 0.0) {
    4941          21 :                 RatedCapHeatUser = varSpeedCoil.RatedCapHeat;
    4942          84 :                 BaseSizer::reportSizerOutput(state,
    4943          42 :                                              format("COIL:{}{}", varSpeedCoil.CoolHeatType, CurrentObjSubfix),
    4944             :                                              varSpeedCoil.Name,
    4945             :                                              "Design Size Nominal Heating Capacity [W]",
    4946             :                                              RatedCapHeatDes,
    4947             :                                              "User-Specified Nominal Heating Capacity [W]",
    4948          21 :                                              RatedCapHeatUser);
    4949          21 :                 if (state.dataGlobal->DisplayExtraWarnings) {
    4950           4 :                     if ((std::abs(RatedCapHeatDes - RatedCapHeatUser) / RatedCapHeatUser) > state.dataSize->AutoVsHardSizingThreshold) {
    4951           0 :                         ShowMessage(
    4952             :                             state,
    4953           0 :                             format("SizeVarSpeedCoil: Potential issue with equipment sizing for {} {}", varSpeedCoil.CoolHeatType, CurrentObjSubfix));
    4954           0 :                         ShowContinueError(state, format("Coil Name = {}", varSpeedCoil.Name));
    4955           0 :                         ShowContinueError(state, format("User-Specified Rated Total Heating Capacity of {:.2R} [W]", RatedCapHeatUser));
    4956           0 :                         ShowContinueError(state, format("differs from Design Size Rated Total Heating Capacity of {:.2R} [W]", RatedCapHeatDes));
    4957           0 :                         ShowContinueError(state, "This may, or may not, indicate mismatched component sizes.");
    4958           0 :                         ShowContinueError(state, "Verify that the value entered is intended and is consistent with other components.");
    4959             :                     }
    4960             :                 }
    4961             :             }
    4962             :         }
    4963             : 
    4964             :         // FORCE BACK TO THE RATED AIR FLOW RATE WITH THE SAME RATIO DEFINED BY THE CATALOG DATA
    4965          80 :         if (!HardSizeNoDesRunAirFlow) {
    4966          31 :             if ((RatedCapCoolTotalAutoSized) && (RatedAirFlowAutoSized)) {
    4967          16 :                 RatedAirVolFlowRateDes = varSpeedCoil.RatedCapCoolTotal * varSpeedCoil.MSRatedAirVolFlowPerRatedTotCap(NormSpeed);
    4968          15 :             } else if ((RatedCapHeatAutoSized) && (RatedAirFlowAutoSized)) {
    4969           6 :                 RatedAirVolFlowRateDes = varSpeedCoil.RatedCapHeat * varSpeedCoil.MSRatedAirVolFlowPerRatedTotCap(NormSpeed);
    4970             :             }
    4971             : 
    4972             :             // write the air flow sizing output
    4973          31 :             if (RatedAirFlowAutoSized) {
    4974          22 :                 varSpeedCoil.RatedAirVolFlowRate = RatedAirVolFlowRateDes;
    4975          88 :                 BaseSizer::reportSizerOutput(state,
    4976          44 :                                              format("COIL:{}{}", varSpeedCoil.CoolHeatType, CurrentObjSubfix),
    4977             :                                              varSpeedCoil.Name,
    4978             :                                              "Design Size Rated Air Flow Rate [m3/s]",
    4979          22 :                                              RatedAirVolFlowRateDes);
    4980             :             } else {
    4981           9 :                 if (varSpeedCoil.RatedAirVolFlowRate > 0.0 && RatedAirVolFlowRateDes > 0.0) {
    4982           5 :                     RatedAirVolFlowRateUser = varSpeedCoil.RatedAirVolFlowRate;
    4983          20 :                     BaseSizer::reportSizerOutput(state,
    4984          10 :                                                  format("COIL:{}{}", varSpeedCoil.CoolHeatType, CurrentObjSubfix),
    4985             :                                                  varSpeedCoil.Name,
    4986             :                                                  "Design Size Rated Air Flow Rate [m3/s]",
    4987             :                                                  RatedAirVolFlowRateDes,
    4988             :                                                  "User-Specified Rated Air Flow Rate [m3/s]",
    4989           5 :                                                  RatedAirVolFlowRateUser);
    4990           5 :                     if (state.dataGlobal->DisplayExtraWarnings) {
    4991           0 :                         if ((std::abs(RatedAirVolFlowRateDes - RatedAirVolFlowRateUser) / RatedAirVolFlowRateUser) >
    4992           0 :                             state.dataSize->AutoVsHardSizingThreshold) {
    4993           0 :                             ShowMessage(state,
    4994           0 :                                         format("SizeVarSpeedCoil: Potential issue with equipment sizing for {} {}",
    4995             :                                                varSpeedCoil.CoolHeatType,
    4996           0 :                                                CurrentObjSubfix));
    4997           0 :                             ShowContinueError(state, format("Coil Name = {}", varSpeedCoil.Name));
    4998           0 :                             ShowContinueError(state, format("User-Specified Rated Air Flow Rate of {:.5R} [m3/s]", RatedAirVolFlowRateUser));
    4999           0 :                             ShowContinueError(state, format("differs from Design Size Rated Air Flow Rate of {:.5R} [m3/s]", RatedAirVolFlowRateDes));
    5000           0 :                             ShowContinueError(state, "This may, or may not, indicate mismatched component sizes.");
    5001           0 :                             ShowContinueError(state, "Verify that the value entered is intended and is consistent with other components.");
    5002             :                         }
    5003             :                     }
    5004             :                 }
    5005             :             }
    5006          31 :             state.dataRptCoilSelection->coilSelectionReportObj->setCoilAirFlow(
    5007             :                 state, varSpeedCoil.Name, varSpeedCoil.VarSpeedCoilType, RatedAirVolFlowRateDes, RatedAirFlowAutoSized);
    5008             :         }
    5009             : 
    5010             :         // Check that heat pump heating capacity is within 20% of cooling capacity. Check only for heating coil and report both.
    5011         143 :         if ((varSpeedCoil.VSCoilType == DataHVACGlobals::Coil_HeatingWaterToAirHPVSEquationFit ||
    5012          90 :              varSpeedCoil.VSCoilType == DataHVACGlobals::Coil_HeatingAirToAirVariableSpeed) &&
    5013          27 :             varSpeedCoil.CompanionCoolingCoilNum > 0) {
    5014             : 
    5015          22 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(varSpeedCoil.CompanionCoolingCoilNum).RatedCapCoolTotal > 0.0) {
    5016             : 
    5017          66 :                 if (std::abs(state.dataVariableSpeedCoils->VarSpeedCoil(varSpeedCoil.CompanionCoolingCoilNum).RatedCapCoolTotal -
    5018          44 :                              varSpeedCoil.RatedCapHeat) /
    5019          44 :                         state.dataVariableSpeedCoils->VarSpeedCoil(varSpeedCoil.CompanionCoolingCoilNum).RatedCapCoolTotal >
    5020             :                     0.2) {
    5021             : 
    5022           0 :                     ShowWarningError(
    5023           0 :                         state, format("COIL:{}:WATERTOAIRHEATPUMP:VARIABLESPEEDEQUATIONFIT \"{}\"", varSpeedCoil.CoolHeatType, varSpeedCoil.Name));
    5024           0 :                     ShowContinueError(state,
    5025           0 :                                       format("...used with COIL:{}:WATERTOAIRHEATPUMP:VARIABLESPEEDEQUATIONFIT \"{}\"",
    5026           0 :                                              state.dataVariableSpeedCoils->VarSpeedCoil(varSpeedCoil.CompanionCoolingCoilNum).CoolHeatType,
    5027           0 :                                              state.dataVariableSpeedCoils->VarSpeedCoil(varSpeedCoil.CompanionCoolingCoilNum).Name));
    5028           0 :                     ShowContinueError(state, "...heating capacity is disproportionate (> 20% different) to total cooling capacity");
    5029           0 :                     ShowContinueError(state, format("...heating capacity = {:.3T} W", varSpeedCoil.RatedCapHeat));
    5030           0 :                     ShowContinueError(state,
    5031           0 :                                       format("...cooling capacity = {:.3T} W",
    5032           0 :                                              state.dataVariableSpeedCoils->VarSpeedCoil(varSpeedCoil.CompanionCoolingCoilNum).RatedCapCoolTotal));
    5033             :                 }
    5034             :             }
    5035             :         }
    5036             : 
    5037             :         // ASSIGN CAPACITY
    5038          80 :         switch (varSpeedCoil.VSCoilType) {
    5039          39 :         case DataHVACGlobals::Coil_CoolingWaterToAirHPVSEquationFit:
    5040             :         case DataHVACGlobals::Coil_CoolingAirToAirVariableSpeed: {
    5041          39 :             varSpeedCoil.MSRatedTotCap(UpperSpeed) = varSpeedCoil.RatedCapCoolTotal / varSpeedCoil.MSRatedPercentTotCap(NormSpeed);
    5042          39 :         } break;
    5043          27 :         case DataHVACGlobals::Coil_HeatingWaterToAirHPVSEquationFit:
    5044             :         case DataHVACGlobals::Coil_HeatingAirToAirVariableSpeed: {
    5045          27 :             varSpeedCoil.MSRatedTotCap(UpperSpeed) = varSpeedCoil.RatedCapHeat / varSpeedCoil.MSRatedPercentTotCap(NormSpeed);
    5046          27 :         } break;
    5047          14 :         case DataHVACGlobals::CoilDX_HeatPumpWaterHeaterVariableSpeed: {
    5048          14 :             varSpeedCoil.MSRatedTotCap(UpperSpeed) = varSpeedCoil.RatedCapWH / varSpeedCoil.MSRatedPercentTotCap(NormSpeed);
    5049          14 :         } break;
    5050             :         }
    5051             : 
    5052          80 :         if (varSpeedCoil.VSCoilType == DataHVACGlobals::CoilDX_HeatPumpWaterHeaterVariableSpeed) {
    5053          14 :             HPInletAirHumRat = Psychrometrics::PsyWFnTdbTwbPb(
    5054          14 :                 state, varSpeedCoil.WHRatedInletDBTemp, varSpeedCoil.WHRatedInletWBTemp, state.dataEnvrn->StdBaroPress, RoutineName);
    5055             : 
    5056         154 :             for (Mode = varSpeedCoil.NumOfSpeeds; Mode >= 1; --Mode) {
    5057         140 :                 varSpeedCoil.MSRatedTotCap(Mode) = varSpeedCoil.MSRatedTotCap(UpperSpeed) * varSpeedCoil.MSRatedPercentTotCap(Mode);
    5058         140 :                 varSpeedCoil.MSRatedAirVolFlowRate(Mode) = varSpeedCoil.MSRatedTotCap(Mode) * varSpeedCoil.MSRatedAirVolFlowPerRatedTotCap(Mode);
    5059         140 :                 varSpeedCoil.MSRatedAirMassFlowRate(Mode) = varSpeedCoil.MSRatedAirVolFlowRate(Mode) * rhoair;
    5060             :                 // EVAPORATIVE PRECOOLING CONDENSER AIR FLOW RATE
    5061         140 :                 varSpeedCoil.EvapCondAirFlow(Mode) = 0.0;
    5062             :             }
    5063             :         } else {
    5064             :             // HPWH, the mass flow rate will be updated by a revised entering air density
    5065             : 
    5066          66 :             if (varSpeedCoil.MSHPDesignSpecIndex > -1 && state.dataUnitarySystems->designSpecMSHP.size() > 0) {
    5067           0 :                 if (varSpeedCoil.VSCoilType == DataHVACGlobals::Coil_CoolingWaterToAirHPVSEquationFit ||
    5068           0 :                     varSpeedCoil.VSCoilType == DataHVACGlobals::Coil_CoolingAirToAirVariableSpeed) {
    5069           0 :                     if (state.dataUnitarySystems->designSpecMSHP[varSpeedCoil.MSHPDesignSpecIndex].numOfSpeedCooling != varSpeedCoil.NumOfSpeeds) {
    5070           0 :                         ShowFatalError(state,
    5071           0 :                                        format("COIL:{} = {}{} number of speeds not equal to number of speed specified in "
    5072             :                                               "UnitarySystemPerformance:Multispeed object.",
    5073             :                                               varSpeedCoil.CoolHeatType,
    5074             :                                               CurrentObjSubfix,
    5075           0 :                                               varSpeedCoil.Name));
    5076             :                     } else {
    5077           0 :                         for (Mode = varSpeedCoil.NumOfSpeeds; Mode >= 1; --Mode) {
    5078           0 :                             varSpeedCoil.MSRatedAirVolFlowRate(Mode) =
    5079           0 :                                 varSpeedCoil.RatedAirVolFlowRate *
    5080           0 :                                 state.dataUnitarySystems->designSpecMSHP[varSpeedCoil.MSHPDesignSpecIndex].coolingVolFlowRatio[Mode - 1];
    5081           0 :                             varSpeedCoil.MSRatedTotCap(Mode) =
    5082           0 :                                 varSpeedCoil.MSRatedAirVolFlowRate(Mode) / varSpeedCoil.MSRatedAirVolFlowPerRatedTotCap(Mode);
    5083           0 :                             varSpeedCoil.MSRatedAirMassFlowRate(Mode) = varSpeedCoil.MSRatedAirVolFlowRate(Mode) * rhoair;
    5084             :                             // EVAPORATIVE PRECOOLING CONDENSER AIR FLOW RATE
    5085           0 :                             varSpeedCoil.EvapCondAirFlow(Mode) =
    5086           0 :                                 varSpeedCoil.MSRatedTotCap(Mode) * varSpeedCoil.MSRatedEvapCondVolFlowPerRatedTotCap(Mode);
    5087             :                         }
    5088             :                     }
    5089           0 :                 } else if (varSpeedCoil.VSCoilType == DataHVACGlobals::Coil_HeatingWaterToAirHPVSEquationFit ||
    5090           0 :                            varSpeedCoil.VSCoilType == DataHVACGlobals::Coil_HeatingAirToAirVariableSpeed) {
    5091           0 :                     if (state.dataUnitarySystems->designSpecMSHP[varSpeedCoil.MSHPDesignSpecIndex].numOfSpeedHeating != varSpeedCoil.NumOfSpeeds) {
    5092           0 :                         ShowFatalError(state,
    5093           0 :                                        format("COIL:{}{} = \"{}\" number of speeds not equal to number of speed specified in "
    5094             :                                               "UnitarySystemPerformance:Multispeed object.",
    5095             :                                               varSpeedCoil.CoolHeatType,
    5096             :                                               CurrentObjSubfix,
    5097           0 :                                               varSpeedCoil.Name));
    5098             :                     } else {
    5099           0 :                         for (Mode = varSpeedCoil.NumOfSpeeds; Mode >= 1; --Mode) {
    5100           0 :                             varSpeedCoil.MSRatedAirVolFlowRate(Mode) =
    5101           0 :                                 varSpeedCoil.RatedAirVolFlowRate *
    5102           0 :                                 state.dataUnitarySystems->designSpecMSHP[varSpeedCoil.MSHPDesignSpecIndex].heatingVolFlowRatio[Mode - 1];
    5103           0 :                             varSpeedCoil.MSRatedTotCap(Mode) =
    5104           0 :                                 varSpeedCoil.MSRatedAirVolFlowRate(Mode) / varSpeedCoil.MSRatedAirVolFlowPerRatedTotCap(Mode);
    5105           0 :                             varSpeedCoil.MSRatedAirMassFlowRate(Mode) = varSpeedCoil.MSRatedAirVolFlowRate(Mode) * rhoair;
    5106             :                             // EVAPORATIVE PRECOOLING CONDENSER AIR FLOW RATE
    5107           0 :                             varSpeedCoil.EvapCondAirFlow(Mode) =
    5108           0 :                                 varSpeedCoil.MSRatedTotCap(Mode) * varSpeedCoil.MSRatedEvapCondVolFlowPerRatedTotCap(Mode);
    5109             :                         }
    5110             :                     }
    5111             :                 }
    5112             :             } else {
    5113         662 :                 for (Mode = varSpeedCoil.NumOfSpeeds; Mode >= 1; --Mode) {
    5114         596 :                     varSpeedCoil.MSRatedTotCap(Mode) = varSpeedCoil.MSRatedTotCap(UpperSpeed) * varSpeedCoil.MSRatedPercentTotCap(Mode);
    5115         596 :                     varSpeedCoil.MSRatedAirVolFlowRate(Mode) = varSpeedCoil.MSRatedTotCap(Mode) * varSpeedCoil.MSRatedAirVolFlowPerRatedTotCap(Mode);
    5116         596 :                     varSpeedCoil.MSRatedAirMassFlowRate(Mode) = varSpeedCoil.MSRatedAirVolFlowRate(Mode) * rhoair;
    5117             :                     // EVAPORATIVE PRECOOLING CONDENSER AIR FLOW RATE
    5118         596 :                     varSpeedCoil.EvapCondAirFlow(Mode) = varSpeedCoil.MSRatedTotCap(Mode) * varSpeedCoil.MSRatedEvapCondVolFlowPerRatedTotCap(Mode);
    5119             :                 }
    5120             :             }
    5121             :         }
    5122             : 
    5123             :         // size rated power
    5124          80 :         switch (varSpeedCoil.VSCoilType) {
    5125          39 :         case DataHVACGlobals::Coil_CoolingWaterToAirHPVSEquationFit:
    5126             :         case DataHVACGlobals::Coil_CoolingAirToAirVariableSpeed: {
    5127          39 :             varSpeedCoil.RatedCOPCool = varSpeedCoil.MSRatedCOP(varSpeedCoil.NormSpedLevel);
    5128          39 :             varSpeedCoil.RatedPowerCool = varSpeedCoil.RatedCapCoolTotal / varSpeedCoil.RatedCOPCool;
    5129          39 :         } break;
    5130          27 :         case DataHVACGlobals::Coil_HeatingWaterToAirHPVSEquationFit:
    5131             :         case DataHVACGlobals::Coil_HeatingAirToAirVariableSpeed: {
    5132          27 :             varSpeedCoil.RatedCOPHeat = varSpeedCoil.MSRatedCOP(varSpeedCoil.NormSpedLevel);
    5133          27 :             varSpeedCoil.RatedPowerHeat = varSpeedCoil.RatedCapHeat / varSpeedCoil.RatedCOPHeat;
    5134          27 :             varSpeedCoil.RatedCapCoolTotal = varSpeedCoil.RatedCapHeat;
    5135          27 :         } break;
    5136          14 :         case DataHVACGlobals::CoilDX_HeatPumpWaterHeaterVariableSpeed: {
    5137          14 :             varSpeedCoil.RatedCOPHeat = varSpeedCoil.MSRatedCOP(varSpeedCoil.NormSpedLevel);
    5138          14 :             varSpeedCoil.RatedPowerHeat = varSpeedCoil.RatedCapWH / varSpeedCoil.RatedCOPHeat;
    5139          14 :             varSpeedCoil.RatedCapCoolTotal = varSpeedCoil.RatedCapWH * (1.0 - 1.0 / varSpeedCoil.RatedCOPHeat);
    5140          14 :         } break;
    5141             :         }
    5142             : 
    5143             :         // Size water volumetric flow rate
    5144         116 :         if ((varSpeedCoil.RatedWaterVolFlowRate == AutoSize) &&
    5145          70 :             (varSpeedCoil.VSCoilType == Coil_CoolingWaterToAirHPVSEquationFit || varSpeedCoil.VSCoilType == Coil_HeatingWaterToAirHPVSEquationFit)) {
    5146           4 :             RatedWaterFlowAutoSized = true;
    5147             :         }
    5148             : 
    5149             :         //   WSHP condenser can be on either a plant loop or condenser loop. Test each to find plant sizing number.
    5150             :         //   first check to see if coil is connected to a plant loop, no warning on this CALL
    5151          80 :         if (RatedWaterFlowAutoSized) {
    5152           4 :             if (varSpeedCoil.CondenserType == DataHeatBalance::RefrigCondenserType::Water)
    5153          12 :                 PltSizNum = PlantUtilities::MyPlantSizingIndex(state,
    5154           8 :                                                                format("COIL:{}{}", varSpeedCoil.CoolHeatType, CurrentObjSubfix),
    5155             :                                                                varSpeedCoil.Name,
    5156             :                                                                varSpeedCoil.WaterInletNodeNum,
    5157             :                                                                varSpeedCoil.WaterOutletNodeNum,
    5158             :                                                                ErrorsFound,
    5159             :                                                                false);
    5160             : 
    5161           4 :             if (PltSizNum > 0) {
    5162          12 :                 rho = FluidProperties::GetDensityGlycol(state,
    5163           4 :                                                         state.dataPlnt->PlantLoop(varSpeedCoil.plantLoc.loopNum).FluidName,
    5164           4 :                                                         state.dataSize->PlantSizData(PltSizNum).ExitTemp,
    5165           4 :                                                         state.dataPlnt->PlantLoop(varSpeedCoil.plantLoc.loopNum).FluidIndex,
    5166             :                                                         RoutineNameAlt);
    5167          12 :                 cp = FluidProperties::GetSpecificHeatGlycol(state,
    5168           4 :                                                             state.dataPlnt->PlantLoop(varSpeedCoil.plantLoc.loopNum).FluidName,
    5169           4 :                                                             state.dataSize->PlantSizData(PltSizNum).ExitTemp,
    5170           4 :                                                             state.dataPlnt->PlantLoop(varSpeedCoil.plantLoc.loopNum).FluidIndex,
    5171             :                                                             RoutineNameAlt);
    5172             : 
    5173           6 :                 if (varSpeedCoil.VSCoilType == DataHVACGlobals::Coil_HeatingWaterToAirHPVSEquationFit ||
    5174           2 :                     varSpeedCoil.VSCoilType == DataHVACGlobals::Coil_HeatingAirToAirVariableSpeed) {
    5175             : 
    5176           2 :                     RatedWaterVolFlowRateDes = varSpeedCoil.RatedCapHeat / (state.dataSize->PlantSizData(PltSizNum).DeltaT * cp * rho);
    5177             : 
    5178           4 :                     state.dataRptCoilSelection->coilSelectionReportObj->setCoilLvgWaterTemp(
    5179             :                         state,
    5180             :                         varSpeedCoil.Name,
    5181             :                         varSpeedCoil.VarSpeedCoilType,
    5182           2 :                         state.dataSize->PlantSizData(PltSizNum).ExitTemp +
    5183           2 :                             state.dataSize->PlantSizData(PltSizNum).DeltaT); // TRACE 3D Plus coil selection report
    5184             : 
    5185           2 :                 } else if (varSpeedCoil.VSCoilType == DataHVACGlobals::Coil_CoolingWaterToAirHPVSEquationFit ||
    5186           0 :                            varSpeedCoil.VSCoilType == DataHVACGlobals::Coil_CoolingAirToAirVariableSpeed) {
    5187             : 
    5188             :                     //       use companion heating coil capacity to calculate volumetric flow rate
    5189           2 :                     if (varSpeedCoil.CompanionCoolingCoilNum > 0) {
    5190           0 :                         SystemCapacity = state.dataVariableSpeedCoils->VarSpeedCoil(varSpeedCoil.CompanionCoolingCoilNum).RatedCapHeat;
    5191             :                     } else {
    5192           2 :                         SystemCapacity = varSpeedCoil.RatedCapCoolTotal;
    5193             :                     }
    5194             : 
    5195           2 :                     RatedWaterVolFlowRateDes = SystemCapacity / (state.dataSize->PlantSizData(PltSizNum).DeltaT * cp * rho);
    5196             : 
    5197           4 :                     state.dataRptCoilSelection->coilSelectionReportObj->setCoilLvgWaterTemp(
    5198             :                         state,
    5199             :                         varSpeedCoil.Name,
    5200             :                         varSpeedCoil.VarSpeedCoilType,
    5201           2 :                         state.dataSize->PlantSizData(PltSizNum).ExitTemp -
    5202           2 :                             state.dataSize->PlantSizData(PltSizNum).DeltaT); // TRACE 3D Plus coil selection report
    5203             :                 }
    5204             : 
    5205           8 :                 state.dataRptCoilSelection->coilSelectionReportObj->setCoilEntWaterTemp(
    5206             :                     state,
    5207             :                     varSpeedCoil.Name,
    5208             :                     varSpeedCoil.VarSpeedCoilType,
    5209           4 :                     state.dataSize->PlantSizData(PltSizNum).ExitTemp); // TRACE 3D Plus coil selection report
    5210             : 
    5211           8 :                 state.dataRptCoilSelection->coilSelectionReportObj->setCoilWaterDeltaT(
    5212             :                     state,
    5213             :                     varSpeedCoil.Name,
    5214             :                     varSpeedCoil.VarSpeedCoilType,
    5215           4 :                     state.dataSize->PlantSizData(PltSizNum).DeltaT); // TRACE 3D Plus coil selection report
    5216             :             } else {
    5217           0 :                 ShowSevereError(state, "Autosizing of water flow requires a loop Sizing:Plant object");
    5218           0 :                 ShowContinueError(state, "Autosizing also requires physical connection to a plant or condenser loop.");
    5219           0 :                 ShowContinueError(state, format("Occurs in COIL:{}{}  Object = {}", varSpeedCoil.CoolHeatType, CurrentObjSubfix, varSpeedCoil.Name));
    5220           0 :                 ErrorsFound = true;
    5221             :             }
    5222             :         }
    5223             : 
    5224             :         // WRITE THE WATER SIZING OUTPUT
    5225          80 :         if (RatedWaterFlowAutoSized) {
    5226             :             // FORCE BACK TO THE RATED WATER FLOW RATE WITH THE SAME RATIO DEFINED BY THE CATLOG DATA
    5227           4 :             if (RatedCapCoolTotalAutoSized) {
    5228           2 :                 RatedWaterVolFlowRateDes = varSpeedCoil.RatedCapCoolTotal * varSpeedCoil.MSRatedWaterVolFlowPerRatedTotCap(NormSpeed);
    5229           2 :             } else if (RatedCapHeatAutoSized) {
    5230           2 :                 RatedWaterVolFlowRateDes = varSpeedCoil.RatedCapHeat * varSpeedCoil.MSRatedWaterVolFlowPerRatedTotCap(NormSpeed);
    5231             :             }
    5232           4 :             state.dataRptCoilSelection->coilSelectionReportObj->setCoilWaterFlowNodeNums(state,
    5233             :                                                                                          varSpeedCoil.Name,
    5234             :                                                                                          varSpeedCoil.VarSpeedCoilType,
    5235             :                                                                                          RatedWaterVolFlowRateDes,
    5236             :                                                                                          RatedWaterFlowAutoSized,
    5237             :                                                                                          varSpeedCoil.WaterInletNodeNum,
    5238             :                                                                                          varSpeedCoil.WaterOutletNodeNum,
    5239             :                                                                                          varSpeedCoil.plantLoc.loopNum);
    5240           4 :             varSpeedCoil.RatedWaterVolFlowRate = RatedWaterVolFlowRateDes;
    5241          16 :             BaseSizer::reportSizerOutput(state,
    5242           8 :                                          format("COIL:{}{}", varSpeedCoil.CoolHeatType, CurrentObjSubfix),
    5243             :                                          varSpeedCoil.Name,
    5244             :                                          "Design Size Rated Water Flow Rate [m3/s]",
    5245           4 :                                          RatedWaterVolFlowRateDes);
    5246             :             // Ensure water flow rate at lower speed must be lower or
    5247             :             // equal to the flow rate at higher speed. Otherwise, a severe error is isssued.
    5248          40 :             for (Mode = 1; Mode <= varSpeedCoil.NumOfSpeeds - 1; ++Mode) {
    5249          36 :                 if (varSpeedCoil.MSRatedWaterVolFlowRate(Mode) > varSpeedCoil.MSRatedWaterVolFlowRate(Mode + 1) * 1.05) {
    5250           0 :                     ShowWarningError(
    5251             :                         state,
    5252           0 :                         format("SizeDXCoil: {} {}, Speed {} Rated Air Flow Rate must be less than or equal to Speed {} Rated Air Flow Rate.",
    5253             :                                varSpeedCoil.VarSpeedCoilType,
    5254             :                                varSpeedCoil.Name,
    5255             :                                Mode,
    5256           0 :                                Mode + 1));
    5257           0 :                     ShowContinueError(
    5258             :                         state,
    5259           0 :                         format("Instead, {:.2R} > {:.2R}", varSpeedCoil.MSRatedAirVolFlowRate(Mode), varSpeedCoil.MSRatedAirVolFlowRate(Mode + 1)));
    5260           0 :                     ShowFatalError(state, "Preceding conditions cause termination.");
    5261             :                 }
    5262             :             }
    5263             :         } else {
    5264          76 :             if (varSpeedCoil.RatedWaterVolFlowRate > 0.0 && RatedWaterVolFlowRateDes > 0.0) {
    5265           0 :                 RatedWaterVolFlowRateUser = varSpeedCoil.RatedWaterVolFlowRate;
    5266           0 :                 BaseSizer::reportSizerOutput(state,
    5267           0 :                                              format("COIL:{}{}", varSpeedCoil.CoolHeatType, CurrentObjSubfix),
    5268             :                                              varSpeedCoil.Name,
    5269             :                                              "Design Size Rated Water Flow Rate [m3/s]",
    5270             :                                              RatedWaterVolFlowRateDes,
    5271             :                                              "User-Specified Rated Water Flow Rate [m3/s]",
    5272           0 :                                              RatedWaterVolFlowRateUser);
    5273           0 :                 if (state.dataGlobal->DisplayExtraWarnings) {
    5274           0 :                     if ((std::abs(RatedWaterVolFlowRateDes - RatedWaterVolFlowRateUser) / RatedWaterVolFlowRateUser) >
    5275           0 :                         state.dataSize->AutoVsHardSizingThreshold) {
    5276           0 :                         ShowMessage(
    5277             :                             state,
    5278           0 :                             format("SizeVarSpeedCoil: Potential issue with equipment sizing for {} {}", varSpeedCoil.CoolHeatType, CurrentObjSubfix));
    5279           0 :                         ShowContinueError(state, format("Coil Name = {}", varSpeedCoil.Name));
    5280           0 :                         ShowContinueError(state, format("User-Specified Rated Water Flow Rate of {:.5R} [m3/s]", RatedWaterVolFlowRateUser));
    5281           0 :                         ShowContinueError(state, format("differs from Design Size Rated Water Flow Rate of {:.5R} [m3/s]", RatedWaterVolFlowRateDes));
    5282           0 :                         ShowContinueError(state, "This may, or may not, indicate mismatched component sizes.");
    5283           0 :                         ShowContinueError(state, "Verify that the value entered is intended and is consistent with other components.");
    5284             :                     }
    5285             :                 }
    5286             :             }
    5287             :         }
    5288             : 
    5289             :         // Save component design water volumetric flow rate.
    5290          80 :         if (varSpeedCoil.RatedWaterVolFlowRate > 0.0 && varSpeedCoil.VSCoilType == DataHVACGlobals::CoilDX_HeatPumpWaterHeaterVariableSpeed) {
    5291          14 :             PlantUtilities::RegisterPlantCompDesignFlow(state, varSpeedCoil.WaterInletNodeNum, varSpeedCoil.RatedWaterVolFlowRate);
    5292             :         }
    5293             :         // Use 1/2 flow since both cooling and heating coil will save flow yet only 1 will operate at a time
    5294          66 :         else if (varSpeedCoil.RatedWaterVolFlowRate > 0.0) {
    5295          34 :             PlantUtilities::RegisterPlantCompDesignFlow(state, varSpeedCoil.WaterInletNodeNum, 0.5 * varSpeedCoil.RatedWaterVolFlowRate);
    5296             :         }
    5297             : 
    5298          80 :         RatedSourceTempCool = GetVSCoilRatedSourceTemp(state, DXCoilNum);
    5299         114 :         if (varSpeedCoil.VSCoilType == Coil_CoolingWaterToAirHPVSEquationFit || varSpeedCoil.VSCoilType == Coil_HeatingWaterToAirHPVSEquationFit) {
    5300             : 
    5301          34 :             if (PltSizNum > 0) {
    5302           4 :                 rhoW = rho;
    5303             :             } else {
    5304          60 :                 rhoW = FluidProperties::GetDensityGlycol(state,
    5305          30 :                                                          state.dataPlnt->PlantLoop(varSpeedCoil.plantLoc.loopNum).FluidName,
    5306             :                                                          RatedSourceTempCool,
    5307          30 :                                                          state.dataPlnt->PlantLoop(varSpeedCoil.plantLoc.loopNum).FluidIndex,
    5308             :                                                          RoutineName);
    5309             :             }
    5310             : 
    5311          34 :             varSpeedCoil.RatedWaterMassFlowRate = varSpeedCoil.RatedWaterVolFlowRate * rhoW;
    5312         374 :             for (Mode = varSpeedCoil.NumOfSpeeds; Mode >= 1; --Mode) {
    5313         340 :                 varSpeedCoil.MSRatedWaterVolFlowRate(Mode) = varSpeedCoil.MSRatedTotCap(Mode) * varSpeedCoil.MSRatedWaterVolFlowPerRatedTotCap(Mode);
    5314         340 :                 varSpeedCoil.MSRatedWaterMassFlowRate(Mode) = varSpeedCoil.MSRatedWaterVolFlowRate(Mode) * rhoW;
    5315             :             }
    5316          46 :         } else if (varSpeedCoil.VSCoilType == DataHVACGlobals::CoilDX_HeatPumpWaterHeaterVariableSpeed) {
    5317          14 :             rhoW = RhoH2O(RatedSourceTempCool);
    5318          14 :             varSpeedCoil.RatedWaterMassFlowRate = varSpeedCoil.RatedWaterVolFlowRate * rhoW;
    5319         154 :             for (Mode = varSpeedCoil.NumOfSpeeds; Mode >= 1; --Mode) {
    5320         140 :                 varSpeedCoil.MSRatedWaterVolFlowRate(Mode) = varSpeedCoil.MSRatedTotCap(Mode) * varSpeedCoil.MSRatedWaterVolFlowPerRatedTotCap(Mode);
    5321         140 :                 varSpeedCoil.MSWHPumpPower(Mode) = varSpeedCoil.MSRatedTotCap(Mode) * varSpeedCoil.MSWHPumpPowerPerRatedTotCap(Mode);
    5322         140 :                 varSpeedCoil.MSRatedWaterMassFlowRate(Mode) = varSpeedCoil.MSRatedWaterVolFlowRate(Mode) * rhoW;
    5323             :             }
    5324             :         }
    5325             : 
    5326             :         // Ensure air flow rate at lower speed must be lower or
    5327             :         // equal to the flow rate at higher speed. Otherwise, a severe error is issued.
    5328         736 :         for (Mode = 1; Mode <= varSpeedCoil.NumOfSpeeds - 1; ++Mode) {
    5329         656 :             if (varSpeedCoil.MSRatedAirVolFlowRate(Mode) > varSpeedCoil.MSRatedAirVolFlowRate(Mode + 1)) {
    5330           0 :                 ShowWarningError(state,
    5331           0 :                                  format("SizeDXCoil: {} {}, Speed {} Rated Air Flow Rate must be less than or equal to Speed {} Rated Air Flow Rate.",
    5332             :                                         varSpeedCoil.VarSpeedCoilType,
    5333             :                                         varSpeedCoil.Name,
    5334             :                                         Mode,
    5335           0 :                                         Mode + 1));
    5336           0 :                 ShowContinueError(
    5337             :                     state,
    5338           0 :                     format("Instead, {:.2R} > {:.2R}", varSpeedCoil.MSRatedAirVolFlowRate(Mode), varSpeedCoil.MSRatedAirVolFlowRate(Mode + 1)));
    5339           0 :                 ShowFatalError(state, "Preceding conditions cause termination.");
    5340             :             }
    5341             :         }
    5342             : 
    5343             :         // Ensure capacity at lower speed must be lower or equal to the capacity at higher speed.
    5344         736 :         for (Mode = 1; Mode <= varSpeedCoil.NumOfSpeeds - 1; ++Mode) {
    5345         656 :             if (varSpeedCoil.MSRatedTotCap(Mode) > varSpeedCoil.MSRatedTotCap(Mode + 1)) {
    5346           0 :                 ShowWarningError(state,
    5347           0 :                                  format("SizeDXCoil: {} {}, Speed {} Rated Total Cooling Capacity must be less than or equal to Speed {} Rated Total "
    5348             :                                         "Cooling Capacity.",
    5349             :                                         varSpeedCoil.VarSpeedCoilType,
    5350             :                                         varSpeedCoil.Name,
    5351             :                                         Mode,
    5352           0 :                                         Mode + 1));
    5353           0 :                 ShowContinueError(state, format("Instead, {:.2R} > {:.2R}", varSpeedCoil.MSRatedTotCap(Mode), varSpeedCoil.MSRatedTotCap(Mode + 1)));
    5354           0 :                 ShowFatalError(state, "Preceding conditions cause termination.");
    5355             :             }
    5356             :         }
    5357             : 
    5358             :         // convert SHR to rated Bypass factor and effective air side surface area
    5359         182 :         if (varSpeedCoil.VSCoilType == DataHVACGlobals::Coil_CoolingWaterToAirHPVSEquationFit ||
    5360          63 :             varSpeedCoil.VSCoilType == DataHVACGlobals::Coil_CoolingAirToAirVariableSpeed) {
    5361         375 :             for (Mode = 1; Mode <= varSpeedCoil.NumOfSpeeds; ++Mode) {
    5362        1008 :                 varSpeedCoil.MSRatedCBF(Mode) = CalcCBF(state,
    5363             :                                                         varSpeedCoil.VarSpeedCoilType,
    5364             :                                                         varSpeedCoil.Name,
    5365             :                                                         RatedInletAirTemp,
    5366             :                                                         RatedInletAirHumRat,
    5367         336 :                                                         varSpeedCoil.MSRatedTotCap(Mode),
    5368         336 :                                                         varSpeedCoil.MSRatedAirVolFlowRate(Mode),
    5369         336 :                                                         varSpeedCoil.MSRatedSHR(Mode),
    5370             :                                                         true);
    5371         336 :                 if (varSpeedCoil.MSRatedCBF(Mode) > 0.0) {
    5372         336 :                     varSpeedCoil.MSEffectiveAo(Mode) = -std::log(varSpeedCoil.MSRatedCBF(Mode)) * varSpeedCoil.MSRatedAirMassFlowRate(Mode);
    5373             :                 } else {
    5374           0 :                     varSpeedCoil.MSEffectiveAo(Mode) = 0.0;
    5375             :                 }
    5376             :             }
    5377          41 :         } else if (varSpeedCoil.VSCoilType == DataHVACGlobals::CoilDX_HeatPumpWaterHeaterVariableSpeed) {
    5378          14 :             state.dataHVACGlobal->HPWHInletDBTemp = varSpeedCoil.WHRatedInletDBTemp;
    5379          14 :             state.dataHVACGlobal->HPWHInletWBTemp = varSpeedCoil.WHRatedInletWBTemp;
    5380             : 
    5381         154 :             for (Mode = 1; Mode <= varSpeedCoil.NumOfSpeeds; ++Mode) {
    5382         140 :                 varSpeedCoil.MSRatedAirMassFlowRate(Mode) = varSpeedCoil.MSRatedAirVolFlowRate(Mode) * rhoair;
    5383             :             }
    5384             : 
    5385         154 :             for (Mode = 1; Mode <= varSpeedCoil.NumOfSpeeds; ++Mode) {
    5386             :                 // get cooling capacity, without fan power, i.e. total coil cooling
    5387         140 :                 if (varSpeedCoil.CondPumpPowerInCOP)
    5388           0 :                     HPWHCoolCapacity = varSpeedCoil.MSRatedTotCap(Mode) * (1.0 - 1.0 / varSpeedCoil.MSRatedCOP(Mode)) +
    5389           0 :                                        varSpeedCoil.MSWHPumpPower(Mode) - varSpeedCoil.MSWHPumpPower(Mode) * varSpeedCoil.HPWHCondPumpFracToWater;
    5390             :                 else
    5391         280 :                     HPWHCoolCapacity = varSpeedCoil.MSRatedTotCap(Mode) * (1.0 - 1.0 / varSpeedCoil.MSRatedCOP(Mode)) -
    5392         140 :                                        varSpeedCoil.MSWHPumpPower(Mode) * varSpeedCoil.HPWHCondPumpFracToWater;
    5393             : 
    5394         420 :                 varSpeedCoil.MSRatedCBF(Mode) = CalcCBF(state,
    5395             :                                                         varSpeedCoil.VarSpeedCoilType,
    5396             :                                                         varSpeedCoil.Name,
    5397         140 :                                                         state.dataHVACGlobal->HPWHInletDBTemp,
    5398             :                                                         HPInletAirHumRat,
    5399             :                                                         HPWHCoolCapacity,
    5400         140 :                                                         varSpeedCoil.MSRatedAirVolFlowRate(Mode),
    5401         140 :                                                         varSpeedCoil.MSRatedSHR(Mode),
    5402             :                                                         true);
    5403         140 :                 if (varSpeedCoil.MSRatedCBF(Mode) > 0.0) {
    5404         140 :                     varSpeedCoil.MSEffectiveAo(Mode) = -std::log(varSpeedCoil.MSRatedCBF(Mode)) * varSpeedCoil.MSRatedAirMassFlowRate(Mode);
    5405             :                 } else {
    5406           0 :                     varSpeedCoil.MSEffectiveAo(Mode) = 0.0;
    5407             :                 }
    5408             :             }
    5409             : 
    5410             :             // update VarSpeedCoil(DXCoilNum).RatedCapCoolTotal
    5411          14 :             Mode = varSpeedCoil.NormSpedLevel;
    5412          14 :             if (varSpeedCoil.CondPumpPowerInCOP) {
    5413           0 :                 varSpeedCoil.RatedCapCoolTotal = varSpeedCoil.MSRatedTotCap(Mode) * (1.0 - 1.0 / varSpeedCoil.MSRatedCOP(Mode)) +
    5414           0 :                                                  varSpeedCoil.MSWHPumpPower(Mode) -
    5415           0 :                                                  varSpeedCoil.MSWHPumpPower(Mode) * varSpeedCoil.HPWHCondPumpFracToWater;
    5416             :             } else {
    5417          28 :                 varSpeedCoil.RatedCapCoolTotal = varSpeedCoil.MSRatedTotCap(Mode) * (1.0 - 1.0 / varSpeedCoil.MSRatedCOP(Mode)) -
    5418          14 :                                                  varSpeedCoil.MSWHPumpPower(Mode) * varSpeedCoil.HPWHCondPumpFracToWater;
    5419             :             }
    5420             :         }
    5421             : 
    5422             :         // size rated sensible cooling capacity
    5423          80 :         RatedCapCoolSensAutoSized = true; // always do that
    5424             : 
    5425         160 :         if (varSpeedCoil.RatedAirVolFlowRate >= DataHVACGlobals::SmallAirVolFlow &&
    5426         143 :             (varSpeedCoil.VSCoilType == DataHVACGlobals::Coil_CoolingWaterToAirHPVSEquationFit ||
    5427          63 :              varSpeedCoil.VSCoilType == DataHVACGlobals::Coil_CoolingAirToAirVariableSpeed)) {
    5428          39 :             RatedAirMassFlowRate =
    5429          39 :                 varSpeedCoil.RatedAirVolFlowRate *
    5430          39 :                 Psychrometrics::PsyRhoAirFnPbTdbW(state, state.dataEnvrn->StdBaroPress, RatedInletAirTemp, RatedInletAirHumRat, RoutineName);
    5431          39 :             RatedInletEnth = Psychrometrics::PsyHFnTdbW(RatedInletAirTemp, RatedInletAirHumRat);
    5432          39 :             CBFRated = AdjustCBF(varSpeedCoil.MSRatedCBF(NormSpeed), varSpeedCoil.MSRatedAirMassFlowRate(NormSpeed), RatedAirMassFlowRate);
    5433          39 :             if (CBFRated > 0.999) CBFRated = 0.999;
    5434          39 :             AirMassFlowRatio = RatedAirMassFlowRate / varSpeedCoil.MSRatedAirMassFlowRate(NormSpeed);
    5435             : 
    5436          39 :             if (varSpeedCoil.MSRatedWaterVolFlowRate(NormSpeed) > 1.0e-10) {
    5437          17 :                 WaterMassFlowRatio = varSpeedCoil.RatedWaterVolFlowRate / varSpeedCoil.MSRatedWaterVolFlowRate(NormSpeed);
    5438             :             } else {
    5439          22 :                 WaterMassFlowRatio = 1.0;
    5440             :             }
    5441             : 
    5442          39 :             Real64 TempInletWetBulb = RatedInletWetBulbTemp;
    5443         234 :             CalcTotCapSHR_VSWSHP(state,
    5444             :                                  RatedInletAirTemp,
    5445             :                                  RatedInletAirHumRat,
    5446             :                                  RatedInletEnth,
    5447             :                                  TempInletWetBulb,
    5448             :                                  AirMassFlowRatio,
    5449             :                                  WaterMassFlowRatio,
    5450             :                                  RatedAirMassFlowRate,
    5451             :                                  CBFRated,
    5452          39 :                                  varSpeedCoil.MSRatedTotCap(NormSpeed),
    5453          39 :                                  varSpeedCoil.MSCCapFTemp(NormSpeed),
    5454          39 :                                  varSpeedCoil.MSCCapAirFFlow(NormSpeed),
    5455          39 :                                  varSpeedCoil.MSCCapWaterFFlow(NormSpeed),
    5456             :                                  0.0,
    5457             :                                  0,
    5458             :                                  0,
    5459             :                                  0,
    5460             :                                  QLoadTotal1,
    5461             :                                  QLoadTotal2,
    5462             :                                  QLoadTotal,
    5463             :                                  SHR,
    5464             :                                  RatedSourceTempCool,
    5465          39 :                                  state.dataEnvrn->StdBaroPress,
    5466             :                                  0.0,
    5467             :                                  1,
    5468             :                                  varSpeedCoil.capModFacTotal);
    5469             : 
    5470          39 :             RatedCapCoolSensDes = varSpeedCoil.RatedCapCoolTotal * SHR;
    5471          82 :         } else if (varSpeedCoil.RatedAirVolFlowRate >= DataHVACGlobals::SmallAirVolFlow &&
    5472          41 :                    varSpeedCoil.VSCoilType == DataHVACGlobals::CoilDX_HeatPumpWaterHeaterVariableSpeed) {
    5473          14 :             SHR = varSpeedCoil.MSRatedSHR(NormSpeed);
    5474          14 :             RatedCapCoolSensDes = varSpeedCoil.RatedCapCoolTotal * SHR;
    5475             :         } else {
    5476          27 :             RatedCapCoolSensDes = 0.0;
    5477             :         }
    5478             : 
    5479          80 :         if (RatedCapCoolSensDes < DataHVACGlobals::SmallLoad) {
    5480          27 :             RatedCapCoolSensDes = 0.0;
    5481             :         }
    5482             : 
    5483         143 :         if (varSpeedCoil.VSCoilType == DataHVACGlobals::Coil_CoolingWaterToAirHPVSEquationFit ||
    5484          63 :             varSpeedCoil.VSCoilType == DataHVACGlobals::Coil_CoolingAirToAirVariableSpeed) { // always report for cooling mode
    5485          39 :             if (RatedCapCoolTotalAutoSized) {
    5486          16 :                 varSpeedCoil.RatedCapCoolSens = RatedCapCoolSensDes;
    5487          64 :                 BaseSizer::reportSizerOutput(state,
    5488          32 :                                              format("COIL:{}{}", varSpeedCoil.CoolHeatType, CurrentObjSubfix),
    5489             :                                              varSpeedCoil.Name,
    5490             :                                              "Design Size Rated Sensible Cooling Capacity [W]",
    5491          16 :                                              varSpeedCoil.RatedCapCoolSens);
    5492             : 
    5493             :             } else {
    5494             :                 // sensible capacity does not have an input field
    5495          23 :                 if (RatedCapCoolSensDes > 0.0) {
    5496          23 :                     varSpeedCoil.RatedCapCoolSens = RatedCapCoolSensDes;
    5497          92 :                     BaseSizer::reportSizerOutput(state,
    5498          46 :                                                  format("COIL:{}{}", varSpeedCoil.CoolHeatType, CurrentObjSubfix),
    5499             :                                                  varSpeedCoil.Name,
    5500             :                                                  "Design Size Rated Sensible Cooling Capacity [W]",
    5501          23 :                                                  RatedCapCoolSensDes); //, &
    5502             :                 }
    5503             :             }
    5504          78 :             OutputReportPredefined::PreDefTableEntry(
    5505          39 :                 state, state.dataOutRptPredefined->pdchCoolCoilTotCap, varSpeedCoil.Name, varSpeedCoil.RatedCapCoolTotal);
    5506          78 :             OutputReportPredefined::PreDefTableEntry(
    5507          39 :                 state, state.dataOutRptPredefined->pdchCoolCoilSensCap, varSpeedCoil.Name, varSpeedCoil.RatedCapCoolSens);
    5508         117 :             OutputReportPredefined::PreDefTableEntry(state,
    5509          39 :                                                      state.dataOutRptPredefined->pdchCoolCoilLatCap,
    5510             :                                                      varSpeedCoil.Name,
    5511          39 :                                                      varSpeedCoil.RatedCapCoolTotal - varSpeedCoil.RatedCapCoolSens);
    5512          39 :             if (varSpeedCoil.RatedCapCoolTotal != 0.0) {
    5513         117 :                 OutputReportPredefined::PreDefTableEntry(state,
    5514          39 :                                                          state.dataOutRptPredefined->pdchCoolCoilSHR,
    5515             :                                                          varSpeedCoil.Name,
    5516          39 :                                                          varSpeedCoil.RatedCapCoolSens / varSpeedCoil.RatedCapCoolTotal);
    5517             :             } else {
    5518           0 :                 OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoolCoilSHR, varSpeedCoil.Name, 0.0);
    5519             :             }
    5520         117 :             OutputReportPredefined::PreDefTableEntry(
    5521          78 :                 state, state.dataOutRptPredefined->pdchCoolCoilNomEff, varSpeedCoil.Name, varSpeedCoil.MSRatedCOP(varSpeedCoil.NormSpedLevel));
    5522          39 :             OutputReportPredefined::addFootNoteSubTable(
    5523             :                 state,
    5524          39 :                 state.dataOutRptPredefined->pdstCoolCoil,
    5525          39 :                 "Nominal values are gross at rated conditions, i.e., the supply air fan heat and electric power NOT accounted for.");
    5526             :         }
    5527             : 
    5528             :         // START SIZING EVAP PRECOOLING PUMP POWER
    5529          80 :         IsAutoSize = false;
    5530          80 :         if (varSpeedCoil.VSCoilType == Coil_CoolingAirToAirVariableSpeed) {
    5531          22 :             if (varSpeedCoil.EvapCondPumpElecNomPower == AutoSize) {
    5532           0 :                 IsAutoSize = true;
    5533             :             }
    5534             :             //     Auto size high speed evap condenser pump power to Total Capacity * 0.004266 w/w (15 w/ton)
    5535          22 :             EvapCondPumpElecNomPowerDes = varSpeedCoil.RatedCapCoolTotal * 0.004266;
    5536          22 :             if (IsAutoSize) {
    5537           0 :                 varSpeedCoil.EvapCondPumpElecNomPower = EvapCondPumpElecNomPowerDes;
    5538           0 :                 BaseSizer::reportSizerOutput(state,
    5539             :                                              "AS VS COOLING COIL",
    5540             :                                              varSpeedCoil.Name,
    5541             :                                              "Design Size Evaporative Condenser Pump Rated Power Consumption [W]",
    5542           0 :                                              EvapCondPumpElecNomPowerDes);
    5543             :             } else {
    5544          22 :                 if (varSpeedCoil.EvapCondPumpElecNomPower > 0.0 && EvapCondPumpElecNomPowerDes > 0.0) {
    5545           0 :                     EvapCondPumpElecNomPowerUser = varSpeedCoil.EvapCondPumpElecNomPower;
    5546           0 :                     BaseSizer::reportSizerOutput(state,
    5547             :                                                  "AS VS COOLING COIL",
    5548             :                                                  varSpeedCoil.Name,
    5549             :                                                  "Design Size Evaporative Condenser Pump Rated Power Consumption [W]",
    5550             :                                                  EvapCondPumpElecNomPowerDes,
    5551             :                                                  "User-Specified Evaporative Condenser Pump Rated Power Consumption [W]",
    5552           0 :                                                  EvapCondPumpElecNomPowerUser);
    5553           0 :                     if (state.dataGlobal->DisplayExtraWarnings) {
    5554           0 :                         if ((std::abs(EvapCondPumpElecNomPowerDes - EvapCondPumpElecNomPowerUser) / EvapCondPumpElecNomPowerUser) >
    5555           0 :                             state.dataSize->AutoVsHardSizingThreshold) {
    5556           0 :                             ShowMessage(state,
    5557           0 :                                         format("SizeVarSpeedCoil: Potential issue with equipment sizing for {} {}",
    5558             :                                                varSpeedCoil.CoolHeatType,
    5559           0 :                                                CurrentObjSubfix));
    5560           0 :                             ShowContinueError(state, format("Coil Name = {}", varSpeedCoil.Name));
    5561           0 :                             ShowContinueError(state,
    5562           0 :                                               format("User-Specified Evaporative Condenser Pump Rated Power Consumption of {:.2R} [W]",
    5563           0 :                                                      EvapCondPumpElecNomPowerUser));
    5564           0 :                             ShowContinueError(state,
    5565           0 :                                               format("differs from Design Size Evaporative Condenser Pump Rated Power Consumption of {:.2R} [W]",
    5566           0 :                                                      EvapCondPumpElecNomPowerDes));
    5567           0 :                             ShowContinueError(state, "This may, or may not, indicate mismatched component sizes.");
    5568           0 :                             ShowContinueError(state, "Verify that the value entered is intended and is consistent with other components.");
    5569             :                         }
    5570             :                     }
    5571             :                 }
    5572             :             }
    5573             :         }
    5574             :         // END SIZING EVAP PRE-COOLING PUMP POWER
    5575             : 
    5576             :         // SIZE DEFROST HEATER
    5577             : 
    5578             :         // Resistive Defrost Heater Capacity = capacity at the first stage
    5579          80 :         IsAutoSize = false;
    5580          80 :         if (varSpeedCoil.VSCoilType == Coil_HeatingAirToAirVariableSpeed) {
    5581          10 :             if (varSpeedCoil.DefrostCapacity == AutoSize) {
    5582           2 :                 IsAutoSize = true;
    5583             :             }
    5584          10 :             if (varSpeedCoil.DefrostStrategy == Resistive) {
    5585          10 :                 DefrostCapacityDes = varSpeedCoil.RatedCapHeat;
    5586             :             } else {
    5587           0 :                 DefrostCapacityDes = 0.0;
    5588             :             }
    5589          10 :             if (IsAutoSize) {
    5590           2 :                 varSpeedCoil.DefrostCapacity = DefrostCapacityDes;
    5591           6 :                 BaseSizer::reportSizerOutput(
    5592           4 :                     state, "AS VS HEATING COIL", varSpeedCoil.Name, "Design Size Resistive Defrost Heater Capacity [W]", DefrostCapacityDes);
    5593             :             } else {
    5594           8 :                 if (varSpeedCoil.DefrostCapacity > 0.0 && DefrostCapacityDes > 0.0 && !HardSizeNoDesRun) {
    5595           3 :                     DefrostCapacityUser = varSpeedCoil.DefrostCapacity;
    5596           9 :                     BaseSizer::reportSizerOutput(state,
    5597             :                                                  "AS VS HEATING COIL",
    5598             :                                                  varSpeedCoil.Name,
    5599             :                                                  "Design Size Resistive Defrost Heater Capacity [W]",
    5600             :                                                  DefrostCapacityDes,
    5601             :                                                  "User-Specified Resistive Defrost Heater Capacity [W]",
    5602           6 :                                                  DefrostCapacityUser);
    5603           3 :                     if (state.dataGlobal->DisplayExtraWarnings) {
    5604           0 :                         if ((std::abs(DefrostCapacityDes - DefrostCapacityUser) / DefrostCapacityUser) > state.dataSize->AutoVsHardSizingThreshold) {
    5605           0 :                             ShowMessage(state,
    5606           0 :                                         format("SizeVarSpeedCoil: Potential issue with equipment sizing for {} {}",
    5607             :                                                varSpeedCoil.CoolHeatType,
    5608           0 :                                                CurrentObjSubfix));
    5609           0 :                             ShowContinueError(state, format("Coil Name = {}", varSpeedCoil.Name));
    5610           0 :                             ShowContinueError(state, format("User-Specified Resistive Defrost Heater Capacity of {:.2R} [W]", DefrostCapacityUser));
    5611           0 :                             ShowContinueError(state,
    5612           0 :                                               format("differs from Design Size Resistive Defrost Heater Capacity of {:.2R} [W]", DefrostCapacityDes));
    5613           0 :                             ShowContinueError(state, "This may, or may not, indicate mismatched component sizes.");
    5614           0 :                             ShowContinueError(state, "Verify that the value entered is intended and is consistent with other components.");
    5615             :                         }
    5616             :                     }
    5617             :                 }
    5618             :             }
    5619             :         }
    5620             :         // END SIZING DEFROST HEATER
    5621             : 
    5622             :         // test autosized sensible and total cooling capacity for total > sensible
    5623          80 :         if (RatedCapCoolSensAutoSized && RatedCapCoolTotalAutoSized) {
    5624          32 :             if (varSpeedCoil.RatedCapCoolSens > varSpeedCoil.RatedCapCoolTotal) {
    5625           0 :                 ShowWarningError(state,
    5626           0 :                                  format("COIL:{}:WATERTOAIRHEATPUMP:VARIABLESPEEDEQUATIONFIT \"{}\"", varSpeedCoil.CoolHeatType, varSpeedCoil.Name));
    5627           0 :                 ShowContinueError(state, format("{}: Rated Sensible Cooling Capacity > Rated Total Cooling Capacity", RoutineName));
    5628           0 :                 ShowContinueError(state, "Each of these capacity inputs have been autosized.");
    5629           0 :                 ShowContinueError(state, format("Rated Sensible Cooling Capacity = {:.2T} W", varSpeedCoil.RatedCapCoolSens));
    5630           0 :                 ShowContinueError(state, format("Rated Total Cooling Capacity    = {:.2T} W", varSpeedCoil.RatedCapCoolTotal));
    5631           0 :                 ShowContinueError(state, "See eio file for further details.");
    5632           0 :                 ShowContinueError(state, "Check Total and Sensible Cooling Capacity Coefficients to ensure they are accurate.");
    5633           0 :                 ShowContinueError(state, "Check Zone and System Sizing objects to verify sizing inputs.");
    5634           0 :                 ShowContinueError(state, "Sizing statistics:");
    5635           0 :                 ShowContinueError(state, format("Entering Air Dry-Bulb Temperature = {:.3T} C", MixTemp));
    5636           0 :                 ShowContinueError(state, format("Entering Air Wet-Bulb Temperature = {:.3T} C", MixWetBulb));
    5637           0 :                 ShowContinueError(state, "Entering Condenser Water Temperature used = 24.4444 C");
    5638           0 :                 ShowContinueError(state, "Used design air and water flow rates (i.e., used 1 for ratioVL and ratioVS)");
    5639           0 :                 ShowContinueError(state, format("ratioTDB = {:.3T}", ((MixTemp + 283.15) / 273.15)));
    5640           0 :                 ShowContinueError(state, format("ratioTWB = {:.3T}", ((MixWetBulb + 283.15) / 273.15)));
    5641           0 :                 ShowContinueError(state, format("ratioTS  = {:.3T}", ((85.0 + 283.15) / 273.15)));
    5642           0 :                 ShowContinueError(state, "Rated Sensible Cooling Capacity = Rated Total Cooling Capacity * Sensible Heat Ratio");
    5643           0 :                 ShowContinueError(state, format("Total Cooling Capacity Modifier = {:.5T}", TotCapTempModFac));
    5644           0 :                 ShowContinueError(state, "...Rated Total Cooling Capacity = Total Design Load / Total Cooling Capacity Modifier");
    5645           0 :                 ShowContinueError(state, "Carefully review the Load Side Total, Sensible, and Latent heat transfer rates");
    5646           0 :                 ShowContinueError(state, "... to ensure they meet the expected manufacturers performance specifications.");
    5647             :             }
    5648          64 :         } else if (RatedCapCoolTotalAutoSized) {
    5649           0 :             if (varSpeedCoil.RatedCapCoolSens > varSpeedCoil.RatedCapCoolTotal) {
    5650           0 :                 ShowWarningError(state,
    5651           0 :                                  format("COIL:{}:WATERTOAIRHEATPUMP:VARIABLESPEEDEQUATIONFIT \"{}\"", varSpeedCoil.CoolHeatType, varSpeedCoil.Name));
    5652           0 :                 ShowContinueError(state, format("{}: Rated Sensible Cooling Capacity > Rated Total Cooling Capacity", RoutineName));
    5653           0 :                 ShowContinueError(state, "Only the rated total capacity input is autosized, consider autosizing both inputs.");
    5654           0 :                 ShowContinueError(state, format("Rated Sensible Cooling Capacity = {:.2T} W", varSpeedCoil.RatedCapCoolSens));
    5655           0 :                 ShowContinueError(state, format("Rated Total Cooling Capacity    = {:.2T} W", varSpeedCoil.RatedCapCoolTotal));
    5656           0 :                 ShowContinueError(state, "See eio file for further details.");
    5657           0 :                 ShowContinueError(state, "Check Total and Sensible Cooling Capacity Coefficients to ensure they are accurate.");
    5658           0 :                 ShowContinueError(state, "Check Zone and System Sizing objects to verify sizing inputs.");
    5659           0 :                 ShowContinueError(state, "Sizing statistics for Total Cooling Capacity:");
    5660           0 :                 ShowContinueError(state, format("Entering Air Wet-Bulb Temperature = {:.3T} C", MixWetBulb));
    5661           0 :                 ShowContinueError(state, "Entering Condenser Water Temperature used = 24.4444 C");
    5662           0 :                 ShowContinueError(state, "Used design air and water flow rates (i.e., used 1 for ratioVL and ratioVS)");
    5663           0 :                 ShowContinueError(state, format("ratioTWB = {:.3T}", ((MixWetBulb + 283.15) / 273.15)));
    5664           0 :                 ShowContinueError(state, format("ratioTS  = {:.3T}", ((85.0 + 283.15) / 273.15)));
    5665           0 :                 ShowContinueError(state, "Rated Sensible Cooling Capacity = Rated Total Cooling Capacity * Sensible Heat Ratio");
    5666           0 :                 ShowContinueError(state, "Carefully review the Load Side Total, Sensible, and Latent heat transfer rates");
    5667           0 :                 ShowContinueError(state, "... to ensure they meet the expected manufacturers performance specifications.");
    5668             :             }
    5669             :         }
    5670          80 :     }
    5671             : 
    5672    36443724 :     void CalcVarSpeedCoilCooling(EnergyPlusData &state,
    5673             :                                  int const DXCoilNum,                        // Heat Pump Number
    5674             :                                  int const CyclingScheme,                    // Fan/Compressor cycling scheme indicator
    5675             :                                  Real64 &RuntimeFrac,                        // Runtime Fraction of compressor or percent on time (on-time/cycle time)
    5676             :                                  [[maybe_unused]] Real64 const SensDemand,   // Cooling Sensible Demand [W] !unused1208
    5677             :                                  [[maybe_unused]] Real64 const LatentDemand, // Cooling Latent Demand [W]
    5678             :                                  CompressorOperation const CompressorOp,     // compressor operation flag
    5679             :                                  Real64 const PartLoadRatio,                 // compressor part load ratio
    5680             :                                  [[maybe_unused]] Real64 const OnOffAirFlowRatio, // ratio of compressor on flow to average flow over time step
    5681             :                                  Real64 const SpeedRatio, // SpeedRatio varies between 1.0 (higher speed) and 0.0 (lower speed)
    5682             :                                  int const SpeedNum       // Speed number, high bound
    5683             :     )
    5684             :     {
    5685             : 
    5686             :         //       AUTHOR         Bo Shen, based on WaterToAirHeatPumpSimple:CalcHPCoolingSimple
    5687             :         //       DATE WRITTEN   March 2012
    5688             :         //       MODIFIED       na
    5689             :         //       RE-ENGINEERED  na
    5690             : 
    5691             :         // PURPOSE OF THIS SUBROUTINE:
    5692             :         // This subroutine is for simulating the cooling mode of the Variable-Speed Water to Air HP Simple
    5693             : 
    5694             :         // METHODOLOGY EMPLOYED:
    5695             :         // Simulate the heat pump performance using the coefficients and rated conditions, interpolating between speed levels
    5696             :         // If the LatDegradModelSimFlag is enabled, the coil will be simulated twice:
    5697             :         // (1)first simulation at the rated conditions (2) second simulation at the
    5698             :         // actual operating conditions. Then call CalcEffectiveSHR and the effective SHR
    5699             :         // is adjusted.
    5700             :         // If the LatDegradModelSimFlag is disabled, the cooling coil is only simulated
    5701             :         // once at the actual operating conditions.
    5702             :         // Finally, adjust the heat pump outlet conditions based on the PartLoadRatio
    5703             :         // and RuntimeFrac.
    5704             : 
    5705             :         // Using/Aliasing
    5706             :         using Curve::CurveValue;
    5707    36443724 :         auto &TimeStepSys = state.dataHVACGlobal->TimeStepSys;
    5708             :         using FluidProperties::GetSpecificHeatGlycol;
    5709             :         using Psychrometrics::PsyCpAirFnW;
    5710             :         using Psychrometrics::PsyHFnTdbW;
    5711             :         using Psychrometrics::PsyRhoAirFnPbTdbW;
    5712             :         using Psychrometrics::PsyTdbFnHW;
    5713             :         using Psychrometrics::PsyTwbFnTdbWPb;
    5714             :         using Psychrometrics::PsyWFnTdbH;
    5715             :         using Psychrometrics::PsyWFnTdbTwbPb;
    5716             : 
    5717             :         // Locals
    5718             :         // SUBROUTINE ARGUMENT DEFINITIONS:
    5719             : 
    5720             :         // SUBROUTINE PARAMETER DEFINITIONS:
    5721             :         static constexpr std::string_view RoutineName("CalcVarSpeedCoilCooling");
    5722             :         static constexpr std::string_view RoutineNameSourceSideInletTemp("CalcVarSpeedCoilCooling:SourceSideInletTemp");
    5723             : 
    5724             :         // INTERFACE BLOCK SPECIFICATIONS
    5725             :         // na
    5726             : 
    5727             :         // DERIVED TYPE DEFINITIONS
    5728             :         // na
    5729             : 
    5730             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    5731             : 
    5732             :         Real64 Twet_Rated;  // Twet at rated conditions (coil air flow rate and air temperatures), sec
    5733             :         Real64 Gamma_Rated; // Gamma at rated conditions (coil air flow rate and air temperatures)
    5734             : 
    5735             :         Real64 SHRss;    // Sensible heat ratio at steady state
    5736             :         Real64 SHReff;   // Effective sensible heat ratio at part-load condition
    5737             :         Real64 CpSource; // Specific heat of water [J/kg_C]
    5738             :         Real64 CpAir;    // Specific heat of air [J/kg_C]
    5739             :         Real64 ReportingConstant;
    5740             : 
    5741             :         bool LatDegradModelSimFlag;      // Latent degradation model simulation flag
    5742             :         int NumIteration;                // Iteration Counter
    5743             :         Real64 LoadSideInletDBTemp_Unit; // calc conditions for unit
    5744             :         Real64 LoadSideInletWBTemp_Unit; // calc conditions for unit
    5745             :         Real64 LoadSideInletHumRat_Unit; // calc conditions for unit
    5746             :         Real64 LoadSideInletEnth_Unit;   // calc conditions for unit
    5747             :         Real64 CpAir_Unit;               // calc conditions for unit
    5748             :         Real64 AirMassFlowRatio;         // airflow ratio at low speed
    5749             :         Real64 WaterMassFlowRatio;       // airflow ratio at high speed
    5750             :         Real64 EIRAirFFModFac;           // air flow fraction modification
    5751             :         Real64 EIRWaterFFModFac;         // water flow fraction modification
    5752             :         Real64 EIRTempModFac;            // total capacity temperature correctio fraction
    5753             :         Real64 CBFSpeed;                 // total capacity temperature correctio fraction
    5754             :         Real64 SHR;                      // total capacity temperature correctio fraction
    5755             :         Real64 EIR;                      // total capacity temperature correctio fraction
    5756             :         int MaxSpeed;                    // maximum speed level
    5757             :         int SpeedCal;                    // calculated speed level
    5758             :         Real64 AoEff;                    // effective air side surface area
    5759             :         Real64 QLoadTotal1;              // total capacity at low speed
    5760             :         Real64 QLoadTotal2;              // total capacity at high speed
    5761             :         Real64 Winput1;                  // power consumption at low speed
    5762             :         Real64 Winput2;                  // power consumption at high speed
    5763             :         Real64 QWasteHeat;               // recoverable waste heat
    5764             :         Real64 QWasteHeat1;              // recoverable waste heat at low speed
    5765             :         Real64 QWasteHeat2;              // recoverable waste heat at high speed
    5766             :         Real64 PLF;                      // part-load function
    5767             :         Real64 MaxHumRat;                // max possible humidity
    5768             :         Real64 MaxOutletEnth;            // max possible outlet enthalpy
    5769             : 
    5770             :         // ADDED VARIABLES FOR air source coil
    5771             :         Real64 CondInletTemp; // Condenser inlet temperature (C). Outdoor dry-bulb temp for air-cooled condenser.
    5772             :         // Outdoor Wetbulb +(1 - effectiveness)*(outdoor drybulb - outdoor wetbulb) for evap condenser.
    5773             :         Real64 CondInletHumRat; // Condenser inlet humidity ratio (kg/kg). Zero for air-cooled condenser.
    5774             :         // For evap condenser, its the humidity ratio of the air leaving the evap cooling pads.
    5775             :         Real64 CondAirMassFlow;    // Condenser air mass flow rate [kg/s]
    5776             :         Real64 RhoSourceAir;       // Density of air [kg/m3]
    5777             :         Real64 RhoEvapCondWater;   // Density of water used for evaporative condenser [kg/m3]
    5778             :         Real64 EvapCondEffectSped; // condenser evaporative effectiveness at the speed level
    5779             :         Real64 RhoWater;           // condensed water density
    5780             :         Real64 SpecHumIn;          // inlet air specific humidity
    5781             :         Real64 SpecHumOut;         // outlet air specific humidity
    5782    36443724 :         Real64 rhoair(0);          // entering air density
    5783             : 
    5784    36443724 :         if (state.dataVariableSpeedCoils->firstTime) {
    5785             :             // Set indoor air conditions to the rated condition
    5786          17 :             state.dataVariableSpeedCoils->LoadSideInletDBTemp_Init = 26.7;
    5787          17 :             state.dataVariableSpeedCoils->LoadSideInletHumRat_Init = 0.0111;
    5788          17 :             state.dataVariableSpeedCoils->LoadSideInletEnth_Init =
    5789          17 :                 PsyHFnTdbW(state.dataVariableSpeedCoils->LoadSideInletDBTemp_Init, state.dataVariableSpeedCoils->LoadSideInletHumRat_Init);
    5790          17 :             state.dataVariableSpeedCoils->CpAir_Init = PsyCpAirFnW(state.dataVariableSpeedCoils->LoadSideInletHumRat_Init);
    5791          17 :             state.dataVariableSpeedCoils->firstTime = false;
    5792             :         }
    5793   109331172 :         state.dataVariableSpeedCoils->LoadSideInletWBTemp_Init = PsyTwbFnTdbWPb(state,
    5794    36443724 :                                                                                 state.dataVariableSpeedCoils->LoadSideInletDBTemp_Init,
    5795    36443724 :                                                                                 state.dataVariableSpeedCoils->LoadSideInletHumRat_Init,
    5796    36443724 :                                                                                 state.dataEnvrn->OutBaroPress,
    5797             :                                                                                 RoutineName);
    5798             : 
    5799    36443724 :         MaxSpeed = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds;
    5800             : 
    5801             :         // must be placed inside the loop, otherwise cause bug in release mode, need to be present at two places
    5802    36443724 :         if (SpeedNum > MaxSpeed) {
    5803           0 :             SpeedCal = MaxSpeed;
    5804             :         } else {
    5805    36443724 :             SpeedCal = SpeedNum;
    5806             :         }
    5807             : 
    5808             :         //  LOAD LOCAL VARIABLES FROM DATA STRUCTURE (for code readability)
    5809    36443724 :         if (!(CyclingScheme == ContFanCycCoil) && PartLoadRatio > 0.0) {
    5810      277383 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate =
    5811      277383 :                 state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirInletNodeNum).MassFlowRate / PartLoadRatio;
    5812             :         }
    5813             : 
    5814    36443724 :         Twet_Rated = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Twet_Rated;
    5815    36443724 :         Gamma_Rated = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Gamma_Rated;
    5816             : 
    5817    36443724 :         state.dataVariableSpeedCoils->LoadSideMassFlowRate = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate;
    5818             : 
    5819    36443724 :         if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_CoolingAirToAirVariableSpeed) {
    5820             :             // Get condenser outdoor node info from DX COOLING Coil
    5821    31940061 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum != 0) {
    5822       26940 :                 state.dataVariableSpeedCoils->OutdoorDryBulb_CalcVarSpeedCoilCooling =
    5823       26940 :                     state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum).Temp;
    5824       26940 :                 state.dataVariableSpeedCoils->OutdoorHumRat_CalcVarSpeedCoilCooling =
    5825       26940 :                     state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum).HumRat;
    5826       26940 :                 state.dataVariableSpeedCoils->OutdoorPressure_CalcVarSpeedCoilCooling =
    5827       26940 :                     state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum).Press;
    5828       26940 :                 state.dataVariableSpeedCoils->OutdoorWetBulb_CalcVarSpeedCoilCooling =
    5829       26940 :                     state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum).OutAirWetBulb;
    5830             :             } else {
    5831    31913121 :                 state.dataVariableSpeedCoils->OutdoorDryBulb_CalcVarSpeedCoilCooling = state.dataEnvrn->OutDryBulbTemp;
    5832    31913121 :                 state.dataVariableSpeedCoils->OutdoorHumRat_CalcVarSpeedCoilCooling = state.dataEnvrn->OutHumRat;
    5833    31913121 :                 state.dataVariableSpeedCoils->OutdoorPressure_CalcVarSpeedCoilCooling = state.dataEnvrn->OutBaroPress;
    5834    31913121 :                 state.dataVariableSpeedCoils->OutdoorWetBulb_CalcVarSpeedCoilCooling = state.dataEnvrn->OutWetBulbTemp;
    5835             :             }
    5836             : 
    5837    95820183 :             RhoSourceAir = PsyRhoAirFnPbTdbW(state,
    5838    31940061 :                                              state.dataVariableSpeedCoils->OutdoorPressure_CalcVarSpeedCoilCooling,
    5839    31940061 :                                              state.dataVariableSpeedCoils->OutdoorDryBulb_CalcVarSpeedCoilCooling,
    5840    31940061 :                                              state.dataVariableSpeedCoils->OutdoorHumRat_CalcVarSpeedCoilCooling);
    5841             : 
    5842    31940061 :             if ((SpeedNum == 1) || (SpeedNum > MaxSpeed) || (SpeedRatio == 1.0)) {
    5843    25346309 :                 CondAirMassFlow = RhoSourceAir * state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondAirFlow(SpeedCal);
    5844             :             } else {
    5845     6593752 :                 CondAirMassFlow =
    5846    13187504 :                     RhoSourceAir * (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondAirFlow(SpeedCal) * SpeedRatio +
    5847     6593752 :                                     (1.0 - SpeedRatio) * state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondAirFlow(SpeedCal - 1));
    5848             :             }
    5849             : 
    5850             :             // AIR COOL OR EVAP COOLED CONDENSER
    5851    31940061 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
    5852           0 :                 if ((SpeedNum == 1) || (SpeedNum > MaxSpeed) || (SpeedRatio == 1.0)) {
    5853           0 :                     EvapCondEffectSped = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondEffect(SpeedCal);
    5854             :                 } else {
    5855           0 :                     EvapCondEffectSped = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondEffect(SpeedCal) * SpeedRatio +
    5856           0 :                                          (1.0 - SpeedRatio) * state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondEffect(SpeedCal - 1);
    5857             :                 }
    5858             :                 // (Outdoor wet-bulb temp from DataEnvironment) + (1.0-EvapCondEffectiveness) * (drybulb - wetbulb)
    5859           0 :                 CondInletTemp = state.dataVariableSpeedCoils->OutdoorWetBulb_CalcVarSpeedCoilCooling +
    5860           0 :                                 (state.dataVariableSpeedCoils->OutdoorDryBulb_CalcVarSpeedCoilCooling -
    5861           0 :                                  state.dataVariableSpeedCoils->OutdoorWetBulb_CalcVarSpeedCoilCooling) *
    5862           0 :                                     (1.0 - EvapCondEffectSped);
    5863           0 :                 CondInletHumRat = PsyWFnTdbTwbPb(state,
    5864             :                                                  CondInletTemp,
    5865           0 :                                                  state.dataVariableSpeedCoils->OutdoorWetBulb_CalcVarSpeedCoilCooling,
    5866           0 :                                                  state.dataVariableSpeedCoils->OutdoorPressure_CalcVarSpeedCoilCooling);
    5867           0 :                 state.dataVariableSpeedCoils->CompAmbTemp_CalcVarSpeedCoilCooling = CondInletTemp;
    5868             :             } else {                                                                                  // AIR COOLED CONDENSER
    5869    31940061 :                 CondInletTemp = state.dataVariableSpeedCoils->OutdoorDryBulb_CalcVarSpeedCoilCooling; // Outdoor dry-bulb temp
    5870    31940061 :                 state.dataVariableSpeedCoils->CompAmbTemp_CalcVarSpeedCoilCooling =
    5871    31940061 :                     state.dataVariableSpeedCoils->OutdoorDryBulb_CalcVarSpeedCoilCooling;
    5872    31940061 :                 CondInletHumRat = state.dataEnvrn->OutHumRat;
    5873             :             }
    5874             : 
    5875    31940061 :             state.dataVariableSpeedCoils->SourceSideMassFlowRate = CondAirMassFlow;
    5876    31940061 :             state.dataVariableSpeedCoils->SourceSideInletTemp = CondInletTemp;
    5877    31940061 :             state.dataVariableSpeedCoils->SourceSideInletEnth = PsyHFnTdbW(CondInletTemp, CondInletHumRat);
    5878    31940061 :             CpSource = PsyCpAirFnW(CondInletHumRat);
    5879    31940061 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondInletTemp = CondInletTemp;
    5880             : 
    5881             :             // If used in a heat pump, the value of MaxOAT in the heating coil overrides that in the cooling coil (in GetInput)
    5882             :             // Initialize crankcase heater, operates below OAT defined in input deck for HP DX heating coil
    5883    63880122 :             if (state.dataVariableSpeedCoils->OutdoorDryBulb_CalcVarSpeedCoilCooling <
    5884    31940061 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MaxOATCrankcaseHeater) {
    5885      528608 :                 state.dataVariableSpeedCoils->CrankcaseHeatingPower_CalcVarSpeedCoilCooling =
    5886      528608 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterCapacity;
    5887             :             } else {
    5888    31411453 :                 state.dataVariableSpeedCoils->CrankcaseHeatingPower_CalcVarSpeedCoilCooling = 0.0;
    5889             :             }
    5890             :         } else {
    5891     4503663 :             state.dataVariableSpeedCoils->SourceSideMassFlowRate = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterMassFlowRate;
    5892     4503663 :             state.dataVariableSpeedCoils->SourceSideInletTemp = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterTemp;
    5893     4503663 :             state.dataVariableSpeedCoils->SourceSideInletEnth = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterEnthalpy;
    5894     4503663 :             CpSource =
    5895    13510989 :                 GetSpecificHeatGlycol(state,
    5896     4503663 :                                       state.dataPlnt->PlantLoop(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).plantLoc.loopNum).FluidName,
    5897     4503663 :                                       state.dataVariableSpeedCoils->SourceSideInletTemp,
    5898     4503663 :                                       state.dataPlnt->PlantLoop(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).plantLoc.loopNum).FluidIndex,
    5899             :                                       RoutineNameSourceSideInletTemp);
    5900             :         }
    5901             : 
    5902             :         // Check for flows, do not perform simulation if no flow in load side or source side.
    5903    36443724 :         if (state.dataVariableSpeedCoils->SourceSideMassFlowRate <= 0.0 || state.dataVariableSpeedCoils->LoadSideMassFlowRate <= 0.0) {
    5904             : 
    5905    21873779 :             if ((state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_CoolingAirToAirVariableSpeed) &&
    5906    13788877 :                 (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserType == DataHeatBalance::RefrigCondenserType::Air) &&
    5907     5703975 :                 (state.dataVariableSpeedCoils->LoadSideMassFlowRate > 0.0)) {
    5908             :                 // ALLOW SIMULATION IF AIR-COOLED CONDENSER COIL
    5909           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SimFlag = true;
    5910             :             } else {
    5911     8084902 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SimFlag = false;
    5912    16215869 :                 return;
    5913             :             }
    5914             :         } else {
    5915    28358822 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SimFlag = true;
    5916             :         }
    5917             : 
    5918    28358822 :         if (CompressorOp == CompressorOperation::Off) {
    5919       46065 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SimFlag = false;
    5920       46065 :             return;
    5921             :         }
    5922             : 
    5923    54504304 :         if ((state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_CoolingAirToAirVariableSpeed) &&
    5924    26191547 :             (CondInletTemp < state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MinOATCompressor)) {
    5925           0 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SimFlag = false;
    5926           0 :             return;
    5927             :         }
    5928             : 
    5929             :         // Loop the calculation at least once depending whether the latent degradation model
    5930             :         // is enabled. 1st iteration to calculate the QLatent(rated) at (TDB,TWB)indoorair=(26.7C,19.4C)
    5931             :         // and 2nd iteration to calculate the  QLatent(actual)
    5932    28312757 :         if ((PartLoadRatio < 1e-10) || (Twet_Rated <= 0.0) || (Gamma_Rated <= 0.0) || (SpeedNum > 1.0)) {
    5933    28295369 :             LatDegradModelSimFlag = false;
    5934             :             // Set NumIteration=1 so that latent model would quit after 1 simulation with the actual condition
    5935    28295369 :             NumIteration = 1;
    5936             :         } else {
    5937       17388 :             LatDegradModelSimFlag = true;
    5938             :             // Set NumIteration=0 so that latent model would simulate twice with rated and actual condition
    5939       17388 :             NumIteration = 0;
    5940             :         }
    5941             : 
    5942             :         // Set indoor air conditions to the actual condition
    5943    28312757 :         LoadSideInletDBTemp_Unit = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirDBTemp;
    5944    28312757 :         LoadSideInletHumRat_Unit = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirHumRat;
    5945    28312757 :         LoadSideInletWBTemp_Unit =
    5946    28312757 :             PsyTwbFnTdbWPb(state, LoadSideInletDBTemp_Unit, LoadSideInletHumRat_Unit, state.dataEnvrn->OutBaroPress, RoutineName);
    5947    28312757 :         LoadSideInletEnth_Unit = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirEnthalpy;
    5948    28312757 :         CpAir_Unit = PsyCpAirFnW(LoadSideInletHumRat_Unit);
    5949             : 
    5950    28312757 :         RuntimeFrac = 1.0;
    5951    28312757 :         state.dataHVACGlobal->OnOffFanPartLoadFraction = 1.0;
    5952    28312757 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac = 1.0;
    5953    28312757 :         if ((SpeedNum == 1) && (PartLoadRatio < 1.0)) {
    5954     4044411 :             PLF = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PLFFPLR, PartLoadRatio);
    5955     4044411 :             if (PLF < 0.7) {
    5956           0 :                 PLF = 0.7;
    5957             :             }
    5958     4044411 :             if (CyclingScheme == CycFanCycCoil)
    5959       46508 :                 state.dataHVACGlobal->OnOffFanPartLoadFraction =
    5960             :                     PLF; // save PLF for fan model, don't change fan power for constant fan mode if coil is off
    5961             :             // calculate the run time fraction
    5962     4044411 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac = PartLoadRatio / PLF;
    5963     4044411 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PartLoadRatio = PartLoadRatio;
    5964             : 
    5965     4044411 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac > 1.0) {
    5966           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac = 1.0; // Reset coil runtime fraction to 1.0
    5967     4044411 :             } else if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac < 0.0) {
    5968           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac = 0.0;
    5969             :             }
    5970             : 
    5971     4044411 :             RuntimeFrac = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac;
    5972             :         }
    5973             : 
    5974             :         while (true) {
    5975    28347533 :             ++NumIteration;
    5976    28330145 :             if (NumIteration == 1) {
    5977             :                 // Set indoor air conditions to the rated conditions
    5978       17388 :                 state.dataVariableSpeedCoils->LoadSideInletDBTemp = state.dataVariableSpeedCoils->LoadSideInletDBTemp_Init;
    5979       17388 :                 state.dataVariableSpeedCoils->LoadSideInletHumRat = state.dataVariableSpeedCoils->LoadSideInletHumRat_Init;
    5980       17388 :                 state.dataVariableSpeedCoils->LoadSideInletWBTemp = state.dataVariableSpeedCoils->LoadSideInletWBTemp_Init;
    5981       17388 :                 state.dataVariableSpeedCoils->LoadSideInletEnth = state.dataVariableSpeedCoils->LoadSideInletEnth_Init;
    5982       17388 :                 CpAir = state.dataVariableSpeedCoils->CpAir_Init;
    5983             :             } else {
    5984             :                 // Set indoor air conditions to the actual condition
    5985    28312757 :                 state.dataVariableSpeedCoils->LoadSideInletDBTemp = LoadSideInletDBTemp_Unit;
    5986    28312757 :                 state.dataVariableSpeedCoils->LoadSideInletHumRat = LoadSideInletHumRat_Unit;
    5987    28312757 :                 state.dataVariableSpeedCoils->LoadSideInletWBTemp = LoadSideInletWBTemp_Unit;
    5988    28312757 :                 state.dataVariableSpeedCoils->LoadSideInletEnth = LoadSideInletEnth_Unit;
    5989    28312757 :                 CpAir = CpAir_Unit;
    5990             :             }
    5991             : 
    5992             :             // must be placed inside the loop, otherwise cause bug in release mode
    5993    28330145 :             if (SpeedNum > MaxSpeed) {
    5994           0 :                 SpeedCal = MaxSpeed;
    5995             :             } else {
    5996    28330145 :                 SpeedCal = SpeedNum;
    5997             :             }
    5998             : 
    5999    28330145 :             if ((SpeedNum == 1) || (SpeedNum > MaxSpeed) || (SpeedRatio == 1.0)) {
    6000    21400749 :                 AirMassFlowRatio =
    6001    21400749 :                     state.dataVariableSpeedCoils->LoadSideMassFlowRate / state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignAirMassFlowRate;
    6002             : 
    6003    21400749 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_CoolingAirToAirVariableSpeed) {
    6004    19615183 :                     WaterMassFlowRatio = 1.0;
    6005             :                 } else {
    6006     3571132 :                     WaterMassFlowRatio = state.dataVariableSpeedCoils->SourceSideMassFlowRate /
    6007     1785566 :                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignWaterMassFlowRate;
    6008             :                 }
    6009             : 
    6010    42801498 :                 CBFSpeed = AdjustCBF(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedCBF(SpeedCal),
    6011    21400749 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirMassFlowRate(SpeedCal),
    6012    21400749 :                                      state.dataVariableSpeedCoils->LoadSideMassFlowRate);
    6013             : 
    6014    21400749 :                 if (CBFSpeed > 0.999) CBFSpeed = 0.999;
    6015             : 
    6016   278209737 :                 CalcTotCapSHR_VSWSHP(state,
    6017    21400749 :                                      state.dataVariableSpeedCoils->LoadSideInletDBTemp,
    6018    21400749 :                                      state.dataVariableSpeedCoils->LoadSideInletHumRat,
    6019    21400749 :                                      state.dataVariableSpeedCoils->LoadSideInletEnth,
    6020    21400749 :                                      state.dataVariableSpeedCoils->LoadSideInletWBTemp,
    6021             :                                      AirMassFlowRatio,
    6022             :                                      WaterMassFlowRatio,
    6023    21400749 :                                      state.dataVariableSpeedCoils->LoadSideMassFlowRate,
    6024             :                                      CBFSpeed,
    6025    21400749 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(SpeedCal),
    6026    21400749 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(SpeedCal),
    6027    21400749 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(SpeedCal),
    6028    21400749 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(SpeedCal),
    6029             :                                      0.0,
    6030             :                                      0,
    6031             :                                      0,
    6032             :                                      0,
    6033             :                                      QLoadTotal1,
    6034             :                                      QLoadTotal2,
    6035    21400749 :                                      state.dataVariableSpeedCoils->QLoadTotal,
    6036             :                                      SHR,
    6037    21400749 :                                      state.dataVariableSpeedCoils->SourceSideInletTemp,
    6038    21400749 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirPressure,
    6039             :                                      0.0,
    6040             :                                      1,
    6041    21400749 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).capModFacTotal);
    6042             : 
    6043    85602996 :                 EIRTempModFac = CurveValue(state,
    6044    21400749 :                                            state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(SpeedCal),
    6045    21400749 :                                            state.dataVariableSpeedCoils->LoadSideInletWBTemp,
    6046    21400749 :                                            state.dataVariableSpeedCoils->SourceSideInletTemp);
    6047    21400749 :                 EIRAirFFModFac = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(SpeedCal), AirMassFlowRatio);
    6048             : 
    6049    21400749 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_CoolingAirToAirVariableSpeed) {
    6050    19615183 :                     EIRWaterFFModFac = 1.0;
    6051             :                 } else {
    6052     1785566 :                     EIRWaterFFModFac =
    6053     3571132 :                         CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRWaterFFlow(SpeedCal), WaterMassFlowRatio);
    6054             :                 }
    6055             : 
    6056    21400749 :                 EIR = (1.0 / state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedCOP(SpeedCal)) * EIRTempModFac * EIRAirFFModFac *
    6057             :                       EIRWaterFFModFac;
    6058             : 
    6059    42801498 :                 CBFSpeed = AdjustCBF(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedCBF(SpeedCal),
    6060    21400749 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirMassFlowRate(SpeedCal),
    6061    21400749 :                                      state.dataVariableSpeedCoils->LoadSideMassFlowRate);
    6062             : 
    6063    21400749 :                 if (CBFSpeed > 0.999) CBFSpeed = 0.999;
    6064             : 
    6065   278209737 :                 CalcTotCapSHR_VSWSHP(state,
    6066    21400749 :                                      state.dataVariableSpeedCoils->LoadSideInletDBTemp,
    6067    21400749 :                                      state.dataVariableSpeedCoils->LoadSideInletHumRat,
    6068    21400749 :                                      state.dataVariableSpeedCoils->LoadSideInletEnth,
    6069    21400749 :                                      state.dataVariableSpeedCoils->LoadSideInletWBTemp,
    6070             :                                      AirMassFlowRatio,
    6071             :                                      WaterMassFlowRatio,
    6072    21400749 :                                      state.dataVariableSpeedCoils->LoadSideMassFlowRate,
    6073             :                                      CBFSpeed,
    6074    21400749 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(SpeedCal),
    6075    21400749 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(SpeedCal),
    6076    21400749 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(SpeedCal),
    6077    21400749 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(SpeedCal),
    6078             :                                      0.0,
    6079             :                                      0,
    6080             :                                      0,
    6081             :                                      0,
    6082             :                                      QLoadTotal1,
    6083             :                                      QLoadTotal2,
    6084    21400749 :                                      state.dataVariableSpeedCoils->QLoadTotal,
    6085             :                                      SHR,
    6086    21400749 :                                      state.dataVariableSpeedCoils->SourceSideInletTemp,
    6087    21400749 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirPressure,
    6088             :                                      0.0,
    6089             :                                      1,
    6090    21400749 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).capModFacTotal);
    6091             : 
    6092    21400749 :                 state.dataVariableSpeedCoils->Winput = state.dataVariableSpeedCoils->QLoadTotal * EIR;
    6093             : 
    6094    42801498 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_CoolingAirToAirVariableSpeed) {
    6095    19615183 :                     QWasteHeat = 0.0;
    6096             :                 } else {
    6097     1785566 :                     QWasteHeat =
    6098     1785566 :                         state.dataVariableSpeedCoils->Winput * state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeatFrac(SpeedCal);
    6099     7142264 :                     QWasteHeat *= CurveValue(state,
    6100     1785566 :                                              state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeat(SpeedCal),
    6101     1785566 :                                              state.dataVariableSpeedCoils->LoadSideInletWBTemp,
    6102     1785566 :                                              state.dataVariableSpeedCoils->SourceSideInletTemp);
    6103             :                 }
    6104             :             } else {
    6105     6929396 :                 AirMassFlowRatio =
    6106     6929396 :                     state.dataVariableSpeedCoils->LoadSideMassFlowRate / state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignAirMassFlowRate;
    6107             : 
    6108     6929396 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_CoolingAirToAirVariableSpeed) {
    6109     6593752 :                     WaterMassFlowRatio = 1.0;
    6110             :                 } else {
    6111      671288 :                     WaterMassFlowRatio = state.dataVariableSpeedCoils->SourceSideMassFlowRate /
    6112      335644 :                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignWaterMassFlowRate;
    6113             :                 }
    6114             : 
    6115    13858792 :                 AoEff = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEffectiveAo(SpeedCal) * SpeedRatio +
    6116     6929396 :                         (1.0 - SpeedRatio) * state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEffectiveAo(SpeedCal - 1);
    6117             : 
    6118     6929396 :                 CBFSpeed = std::exp(-AoEff / state.dataVariableSpeedCoils->LoadSideMassFlowRate);
    6119             : 
    6120     6929396 :                 if (CBFSpeed > 0.999) CBFSpeed = 0.999;
    6121             : 
    6122   117799732 :                 CalcTotCapSHR_VSWSHP(state,
    6123     6929396 :                                      state.dataVariableSpeedCoils->LoadSideInletDBTemp,
    6124     6929396 :                                      state.dataVariableSpeedCoils->LoadSideInletHumRat,
    6125     6929396 :                                      state.dataVariableSpeedCoils->LoadSideInletEnth,
    6126     6929396 :                                      state.dataVariableSpeedCoils->LoadSideInletWBTemp,
    6127             :                                      AirMassFlowRatio,
    6128             :                                      WaterMassFlowRatio,
    6129     6929396 :                                      state.dataVariableSpeedCoils->LoadSideMassFlowRate,
    6130             :                                      CBFSpeed,
    6131     6929396 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(SpeedCal - 1),
    6132     6929396 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(SpeedCal - 1),
    6133     6929396 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(SpeedCal - 1),
    6134     6929396 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(SpeedCal - 1),
    6135     6929396 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(SpeedCal),
    6136     6929396 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(SpeedCal),
    6137     6929396 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(SpeedCal),
    6138     6929396 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(SpeedCal),
    6139             :                                      QLoadTotal1,
    6140             :                                      QLoadTotal2,
    6141     6929396 :                                      state.dataVariableSpeedCoils->QLoadTotal,
    6142             :                                      SHR,
    6143     6929396 :                                      state.dataVariableSpeedCoils->SourceSideInletTemp,
    6144     6929396 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirPressure,
    6145             :                                      SpeedRatio,
    6146             :                                      2,
    6147     6929396 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).capModFacTotal);
    6148             : 
    6149     6929396 :                 SpeedCal = SpeedNum - 1;
    6150    27717584 :                 EIRTempModFac = CurveValue(state,
    6151     6929396 :                                            state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(SpeedCal),
    6152     6929396 :                                            state.dataVariableSpeedCoils->LoadSideInletWBTemp,
    6153     6929396 :                                            state.dataVariableSpeedCoils->SourceSideInletTemp);
    6154     6929396 :                 EIRAirFFModFac = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(SpeedCal), AirMassFlowRatio);
    6155             : 
    6156     6929396 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_CoolingAirToAirVariableSpeed) {
    6157     6593752 :                     EIRWaterFFModFac = 1.0;
    6158             :                 } else {
    6159      335644 :                     EIRWaterFFModFac =
    6160      671288 :                         CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRWaterFFlow(SpeedCal), WaterMassFlowRatio);
    6161             :                 }
    6162             : 
    6163     6929396 :                 EIR = (1.0 / state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedCOP(SpeedCal)) * EIRTempModFac * EIRAirFFModFac *
    6164             :                       EIRWaterFFModFac;
    6165     6929396 :                 Winput1 = QLoadTotal1 * EIR;
    6166             : 
    6167     6929396 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_CoolingAirToAirVariableSpeed) {
    6168     6593752 :                     QWasteHeat1 = 0.0;
    6169             :                 } else {
    6170      335644 :                     QWasteHeat1 = Winput1 * state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeatFrac(SpeedCal);
    6171     1342576 :                     QWasteHeat1 *= CurveValue(state,
    6172      335644 :                                               state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeat(SpeedCal),
    6173      335644 :                                               state.dataVariableSpeedCoils->LoadSideInletWBTemp,
    6174      335644 :                                               state.dataVariableSpeedCoils->SourceSideInletTemp);
    6175             :                 }
    6176             : 
    6177     6929396 :                 SpeedCal = SpeedNum;
    6178    27717584 :                 EIRTempModFac = CurveValue(state,
    6179     6929396 :                                            state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(SpeedCal),
    6180     6929396 :                                            state.dataVariableSpeedCoils->LoadSideInletWBTemp,
    6181     6929396 :                                            state.dataVariableSpeedCoils->SourceSideInletTemp);
    6182     6929396 :                 EIRAirFFModFac = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(SpeedCal), AirMassFlowRatio);
    6183             : 
    6184     6929396 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_CoolingAirToAirVariableSpeed) {
    6185     6593752 :                     EIRWaterFFModFac = 1.0;
    6186             :                 } else {
    6187      335644 :                     EIRWaterFFModFac =
    6188      671288 :                         CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRWaterFFlow(SpeedCal), WaterMassFlowRatio);
    6189             :                 }
    6190             : 
    6191     6929396 :                 EIR = (1.0 / state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedCOP(SpeedCal)) * EIRTempModFac * EIRAirFFModFac *
    6192             :                       EIRWaterFFModFac;
    6193     6929396 :                 Winput2 = QLoadTotal2 * EIR;
    6194             : 
    6195     6929396 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_CoolingAirToAirVariableSpeed) {
    6196     6593752 :                     QWasteHeat2 = 0.0;
    6197             :                 } else {
    6198      335644 :                     QWasteHeat2 = Winput2 * state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeatFrac(SpeedCal);
    6199     1342576 :                     QWasteHeat2 *= CurveValue(state,
    6200      335644 :                                               state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeat(SpeedCal),
    6201      335644 :                                               state.dataVariableSpeedCoils->LoadSideInletWBTemp,
    6202      335644 :                                               state.dataVariableSpeedCoils->SourceSideInletTemp);
    6203             :                 }
    6204             : 
    6205     6929396 :                 state.dataVariableSpeedCoils->Winput = Winput2 * SpeedRatio + (1.0 - SpeedRatio) * Winput1;
    6206     6929396 :                 QWasteHeat = QWasteHeat2 * SpeedRatio + (1.0 - SpeedRatio) * QWasteHeat1;
    6207             :             }
    6208             : 
    6209    28330145 :             state.dataVariableSpeedCoils->QSensible = state.dataVariableSpeedCoils->QLoadTotal * SHR;
    6210             : 
    6211    28330145 :             state.dataVariableSpeedCoils->QSource = state.dataVariableSpeedCoils->QLoadTotal + state.dataVariableSpeedCoils->Winput - QWasteHeat;
    6212             : 
    6213    28330145 :             if (state.dataVariableSpeedCoils->QSource < 0) {
    6214           0 :                 state.dataVariableSpeedCoils->QSource = 0.0;
    6215           0 :                 QWasteHeat = state.dataVariableSpeedCoils->QLoadTotal + state.dataVariableSpeedCoils->Winput;
    6216             :             }
    6217             : 
    6218             :             // Check if the Sensible Load is greater than the Total Cooling Load
    6219    28330145 :             if (state.dataVariableSpeedCoils->QSensible > state.dataVariableSpeedCoils->QLoadTotal) {
    6220           0 :                 state.dataVariableSpeedCoils->QSensible = state.dataVariableSpeedCoils->QLoadTotal;
    6221             :             }
    6222             : 
    6223    28330145 :             if (LatDegradModelSimFlag) {
    6224             :                 // Calculate for SHReff using the Latent Degradation Model
    6225       34776 :                 if (NumIteration == 1) {
    6226       17388 :                     state.dataVariableSpeedCoils->QLatRated = state.dataVariableSpeedCoils->QLoadTotal - state.dataVariableSpeedCoils->QSensible;
    6227       17388 :                 } else if (NumIteration == 2) {
    6228       17388 :                     state.dataVariableSpeedCoils->QLatActual = state.dataVariableSpeedCoils->QLoadTotal - state.dataVariableSpeedCoils->QSensible;
    6229       17388 :                     SHRss = state.dataVariableSpeedCoils->QSensible / state.dataVariableSpeedCoils->QLoadTotal;
    6230       69552 :                     SHReff = CalcEffectiveSHR(state,
    6231             :                                               DXCoilNum,
    6232             :                                               SHRss,
    6233             :                                               CyclingScheme,
    6234             :                                               RuntimeFrac,
    6235       17388 :                                               state.dataVariableSpeedCoils->QLatRated,
    6236       17388 :                                               state.dataVariableSpeedCoils->QLatActual,
    6237       17388 :                                               state.dataVariableSpeedCoils->LoadSideInletDBTemp,
    6238       17388 :                                               state.dataVariableSpeedCoils->LoadSideInletWBTemp);
    6239             :                     //       Update sensible capacity based on effective SHR
    6240       17388 :                     state.dataVariableSpeedCoils->QSensible = state.dataVariableSpeedCoils->QLoadTotal * SHReff;
    6241       17388 :                     goto LOOP_exit;
    6242             :                 }
    6243             :             } else {
    6244             :                 // Assume SHReff=SHRss
    6245    28295369 :                 SHReff = state.dataVariableSpeedCoils->QSensible / state.dataVariableSpeedCoils->QLoadTotal;
    6246    28295369 :                 goto LOOP_exit;
    6247             :             }
    6248             :         }
    6249    28312757 :     LOOP_exit:;
    6250             : 
    6251             :         // considering hot gas reheat here
    6252    28312757 :         if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HOTGASREHEATFLG > 0) {
    6253     1649857 :             state.dataVariableSpeedCoils->QLoadTotal -= QWasteHeat;
    6254     1649857 :             state.dataVariableSpeedCoils->QSensible -= QWasteHeat;
    6255     1649857 :             SHReff = state.dataVariableSpeedCoils->QSensible / state.dataVariableSpeedCoils->QLoadTotal;
    6256             :         }
    6257             : 
    6258    28312757 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterPower = 0.0;
    6259    28312757 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterPower = 0.0;
    6260             : 
    6261    28312757 :         if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_CoolingAirToAirVariableSpeed) {
    6262    26191547 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
    6263             :                 //******************
    6264             :                 //             WATER CONSUMPTION IN m3 OF WATER FOR DIRECT
    6265             :                 //             H2O [m3/s] = Delta W[kgWater/kgDryAir]*Mass Flow Air[kgDryAir/s]
    6266             :                 //                                /RhoWater [kgWater/m3]
    6267             :                 //******************
    6268           0 :                 RhoEvapCondWater = RhoH2O(state.dataVariableSpeedCoils->OutdoorDryBulb_CalcVarSpeedCoilCooling);
    6269           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapWaterConsumpRate =
    6270           0 :                     (CondInletHumRat - state.dataVariableSpeedCoils->OutdoorHumRat_CalcVarSpeedCoilCooling) * CondAirMassFlow / RhoEvapCondWater *
    6271           0 :                     RuntimeFrac;
    6272           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondPumpElecPower =
    6273           0 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondPumpElecNomPower * RuntimeFrac;
    6274             :                 // Calculate basin heater power
    6275           0 :                 CalcBasinHeaterPower(state,
    6276           0 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterPowerFTempDiff,
    6277           0 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterSchedulePtr,
    6278           0 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterSetPointTemp,
    6279           0 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterPower);
    6280           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterPower *= (1.0 - RuntimeFrac);
    6281             :             }
    6282             : 
    6283    26191547 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterPower =
    6284    26191547 :                 state.dataVariableSpeedCoils->CrankcaseHeatingPower_CalcVarSpeedCoilCooling * (1.0 - RuntimeFrac);
    6285             : 
    6286             :             // set water system demand request (if needed)
    6287    26191547 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapWaterSupplyMode == WaterSupplyFromTank) {
    6288           0 :                 state.dataWaterData->WaterStorage(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapWaterSupTankID)
    6289           0 :                     .VdotRequestDemand(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapWaterTankDemandARRID) =
    6290           0 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapWaterConsumpRate;
    6291             :             }
    6292             :         }
    6293             : 
    6294    28312757 :         if ((PartLoadRatio > 0.0 && CyclingScheme == ContFanCycCoil) || (CyclingScheme == CycFanCycCoil)) {
    6295             :             // calculate coil outlet state variables
    6296    27588219 :             state.dataVariableSpeedCoils->LoadSideOutletEnth =
    6297    55176438 :                 state.dataVariableSpeedCoils->LoadSideInletEnth -
    6298    27588219 :                 state.dataVariableSpeedCoils->QLoadTotal / state.dataVariableSpeedCoils->LoadSideMassFlowRate;
    6299    27588219 :             state.dataVariableSpeedCoils->LoadSideOutletDBTemp =
    6300    55176438 :                 state.dataVariableSpeedCoils->LoadSideInletDBTemp -
    6301    27588219 :                 state.dataVariableSpeedCoils->QSensible / (state.dataVariableSpeedCoils->LoadSideMassFlowRate * CpAir);
    6302             : 
    6303    55176438 :             MaxHumRat = PsyWFnTdbRhPb(state,
    6304    27588219 :                                       state.dataVariableSpeedCoils->LoadSideOutletDBTemp,
    6305             :                                       0.9999,
    6306    27588219 :                                       state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirPressure,
    6307             :                                       RoutineName);
    6308    27588219 :             MaxOutletEnth = PsyHFnTdbW(state.dataVariableSpeedCoils->LoadSideOutletDBTemp, MaxHumRat);
    6309    27588219 :             if (state.dataVariableSpeedCoils->LoadSideOutletEnth > MaxOutletEnth) {
    6310      152510 :                 state.dataVariableSpeedCoils->LoadSideOutletEnth = MaxOutletEnth;
    6311             :                 // QLoadTotal = LoadSideMassFlowRate * (LoadSideInletEnth - LoadSideOutletEnth)
    6312             :             }
    6313    27588219 :             state.dataVariableSpeedCoils->LoadSideOutletHumRat =
    6314    27588219 :                 PsyWFnTdbH(state, state.dataVariableSpeedCoils->LoadSideOutletDBTemp, state.dataVariableSpeedCoils->LoadSideOutletEnth, RoutineName);
    6315    27588219 :             if (state.dataVariableSpeedCoils->LoadSideOutletHumRat > MaxHumRat) {
    6316       17141 :                 state.dataVariableSpeedCoils->LoadSideOutletHumRat = MaxHumRat;
    6317             :             }
    6318             :         }
    6319             : 
    6320             :         // Actual outlet conditions are "average" for time step
    6321    28312757 :         if (CyclingScheme == ContFanCycCoil) {
    6322             :             // continuous fan, cycling compressor
    6323    28035380 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirEnthalpy =
    6324    56070760 :                 PartLoadRatio * state.dataVariableSpeedCoils->LoadSideOutletEnth +
    6325    28035380 :                 (1.0 - PartLoadRatio) * state.dataVariableSpeedCoils->LoadSideInletEnth;
    6326    28035380 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirHumRat =
    6327    56070760 :                 PartLoadRatio * state.dataVariableSpeedCoils->LoadSideOutletHumRat +
    6328    28035380 :                 (1.0 - PartLoadRatio) * state.dataVariableSpeedCoils->LoadSideInletHumRat;
    6329    28035380 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirDBTemp =
    6330    28035380 :                 PsyTdbFnHW(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirEnthalpy,
    6331    28035380 :                            state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirHumRat);
    6332    28035380 :             state.dataVariableSpeedCoils->PLRCorrLoadSideMdot = state.dataVariableSpeedCoils->LoadSideMassFlowRate;
    6333             :         } else {
    6334             :             // default to cycling fan, cycling compressor
    6335      277377 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirEnthalpy = state.dataVariableSpeedCoils->LoadSideOutletEnth;
    6336      277377 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirHumRat = state.dataVariableSpeedCoils->LoadSideOutletHumRat;
    6337      277377 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirDBTemp = state.dataVariableSpeedCoils->LoadSideOutletDBTemp;
    6338      277377 :             state.dataVariableSpeedCoils->PLRCorrLoadSideMdot = state.dataVariableSpeedCoils->LoadSideMassFlowRate * PartLoadRatio;
    6339             :         }
    6340             : 
    6341             :         // scale heat transfer rates to PLR and power to RTF
    6342    28312757 :         state.dataVariableSpeedCoils->QLoadTotal *= PartLoadRatio;
    6343    28312757 :         state.dataVariableSpeedCoils->QSensible *= PartLoadRatio;
    6344             :         // count the powr separately
    6345    28312757 :         state.dataVariableSpeedCoils->Winput *= RuntimeFrac; //+ VarSpeedCoil(DXCoilNum)%CrankcaseHeaterPower &
    6346             :         //+ VarSpeedCoil(DXCoilNum)%BasinHeaterPower + VarSpeedCoil(DXCoilNum)%EvapCondPumpElecPower
    6347    28312757 :         state.dataVariableSpeedCoils->QSource *= PartLoadRatio;
    6348    28312757 :         QWasteHeat *= PartLoadRatio;
    6349             : 
    6350             :         //  Add power to global variable so power can be summed by parent object
    6351    28312757 :         state.dataHVACGlobal->DXElecCoolingPower = state.dataVariableSpeedCoils->Winput;
    6352             : 
    6353    28312757 :         ReportingConstant = TimeStepSys * DataGlobalConstants::SecInHour;
    6354             :         // Update heat pump data structure
    6355    28312757 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Power = state.dataVariableSpeedCoils->Winput;
    6356    28312757 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLoadTotal = state.dataVariableSpeedCoils->QLoadTotal;
    6357    28312757 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSensible = state.dataVariableSpeedCoils->QSensible;
    6358    28312757 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLatent =
    6359    28312757 :             state.dataVariableSpeedCoils->QLoadTotal - state.dataVariableSpeedCoils->QSensible;
    6360    28312757 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSource = state.dataVariableSpeedCoils->QSource;
    6361    28312757 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Energy = state.dataVariableSpeedCoils->Winput * ReportingConstant;
    6362    28312757 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLoadTotal = state.dataVariableSpeedCoils->QLoadTotal * ReportingConstant;
    6363    28312757 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergySensible = state.dataVariableSpeedCoils->QSensible * ReportingConstant;
    6364    28312757 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLatent =
    6365    28312757 :             (state.dataVariableSpeedCoils->QLoadTotal - state.dataVariableSpeedCoils->QSensible) * ReportingConstant;
    6366    28312757 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergySource = state.dataVariableSpeedCoils->QSource * ReportingConstant;
    6367    28312757 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterConsumption =
    6368    28312757 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterPower * ReportingConstant;
    6369    28312757 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapWaterConsump =
    6370    28312757 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapWaterConsumpRate * ReportingConstant;
    6371    28312757 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterConsumption =
    6372    28312757 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterPower * ReportingConstant;
    6373    28312757 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondPumpElecConsumption =
    6374    28312757 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondPumpElecPower * ReportingConstant;
    6375    28312757 :         if (RuntimeFrac == 0.0) {
    6376      724538 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).COP = 0.0;
    6377             :         } else {
    6378    27588219 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).COP =
    6379    27588219 :                 state.dataVariableSpeedCoils->QLoadTotal / state.dataVariableSpeedCoils->Winput;
    6380             :         }
    6381    28312757 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac = RuntimeFrac;
    6382    28312757 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PartLoadRatio = PartLoadRatio;
    6383    28312757 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate = state.dataVariableSpeedCoils->PLRCorrLoadSideMdot;
    6384    84938271 :         rhoair = PsyRhoAirFnPbTdbW(state,
    6385    28312757 :                                    state.dataEnvrn->OutBaroPress,
    6386    28312757 :                                    state.dataVariableSpeedCoils->LoadSideInletDBTemp,
    6387    28312757 :                                    state.dataVariableSpeedCoils->LoadSideInletHumRat,
    6388             :                                    RoutineName);
    6389             :         // This seems wrong, initializing mass flow rate to StdRhoAir or actual air density,
    6390             :         // then using that mass flow rate, then back calculating volume using inlet conditions.
    6391             :         // Volume should be constant through a fan and air mass flow rate should vary based on inlet conditions.
    6392    28312757 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirVolFlowRate =
    6393    28312757 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate / rhoair;
    6394             : 
    6395    28312757 :         if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_CoolingAirToAirVariableSpeed) {
    6396    26191547 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterMassFlowRate = 0.0;
    6397    26191547 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletWaterTemp = 0.0;
    6398    26191547 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletWaterEnthalpy = 0.0;
    6399    26191547 :             state.dataHeatBal->HeatReclaimVS_DXCoil(DXCoilNum).AvailCapacity = state.dataVariableSpeedCoils->QSource;
    6400             :         } else {
    6401     2121210 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterMassFlowRate = state.dataVariableSpeedCoils->SourceSideMassFlowRate;
    6402     2121210 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletWaterTemp =
    6403     4242420 :                 state.dataVariableSpeedCoils->SourceSideInletTemp +
    6404     2121210 :                 state.dataVariableSpeedCoils->QSource / (state.dataVariableSpeedCoils->SourceSideMassFlowRate * CpSource);
    6405     2121210 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletWaterEnthalpy =
    6406     4242420 :                 state.dataVariableSpeedCoils->SourceSideInletEnth +
    6407     2121210 :                 state.dataVariableSpeedCoils->QSource / state.dataVariableSpeedCoils->SourceSideMassFlowRate;
    6408             :         }
    6409             : 
    6410    28312757 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QWasteHeat = QWasteHeat;
    6411             : 
    6412    28312757 :         if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondensateCollectMode == CondensateToTank) {
    6413             :             // calculate and report condensation rates  (how much water extracted from the air stream)
    6414             :             // water flow of water in m3/s for water system interactions
    6415           0 :             RhoWater = RhoH2O((state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirDBTemp +
    6416           0 :                                state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirDBTemp) /
    6417             :                               2.0);
    6418             :             //     CR9155 Remove specific humidity calculations
    6419           0 :             SpecHumIn = state.dataVariableSpeedCoils->LoadSideInletHumRat;
    6420           0 :             SpecHumOut = state.dataVariableSpeedCoils->LoadSideOutletHumRat;
    6421             :             //  mdot * del HumRat / rho water
    6422           0 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondensateVdot =
    6423           0 :                 max(0.0, (state.dataVariableSpeedCoils->LoadSideMassFlowRate * (SpecHumIn - SpecHumOut) / RhoWater));
    6424           0 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondensateVol =
    6425           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondensateVdot * ReportingConstant;
    6426             :         }
    6427             :     }
    6428             : 
    6429     1618059 :     void CalcVarSpeedHPWH(EnergyPlusData &state,
    6430             :                           int const DXCoilNum,        // the number of the DX coil to be simulated
    6431             :                           Real64 &RuntimeFrac,        // Runtime Fraction of compressor or percent on time (on-time/cycle time)
    6432             :                           Real64 const PartLoadRatio, // sensible water heating load / full load sensible water heating capacity
    6433             :                           Real64 const SpeedRatio,    // SpeedRatio varies between 1.0 (higher speed) and 0.0 (lower speed)
    6434             :                           int const SpeedNum,         // Speed number, high bound
    6435             :                           int const CyclingScheme     // Continuous fan OR cycling compressor
    6436             :     )
    6437             :     {
    6438             : 
    6439             :         // SUBROUTINE INFORMATION:
    6440             :         //       AUTHOR         Bo Shen, ORNL
    6441             :         //       DATE WRITTEN   12/2014
    6442             : 
    6443             :         // PURPOSE OF THIS SUBROUTINE:
    6444             :         // Calculates the gross cooling capacity of a variable-speed heat pump water heater evaporator and
    6445             :         // heating capacity of the condenser coil given the rated heating capacity and COP.
    6446             : 
    6447             :         // METHODOLOGY EMPLOYED:
    6448             :         // The routine requires the user to enter the total heating capacity and COP for the
    6449             :         // heat pump water heater along with logicals defining if fan and condenser pump are included at numerous speed levels.
    6450             :         // Since manufacturer's can rate their HPWH equipment with or without including condenser
    6451             :         // pump heat, this information is required to accurately determine the condenser's leaving
    6452             :         // water temperature. In addition, knowledge of the fan heat is required to back into
    6453             :         // a compressor COP.
    6454             : 
    6455             :         // Using/Aliasing
    6456             :         using Curve::CurveValue;
    6457             : 
    6458             :         // SUBROUTINE PARAMETER DEFINITIONS:
    6459             :         static constexpr std::string_view RoutineName("CalcVarSpeedHPWH");
    6460             : 
    6461             :         // INTERFACE BLOCK SPECIFICATIONS
    6462             :         // na
    6463             : 
    6464             :         // DERIVED TYPE DEFINITIONS
    6465             :         // na
    6466             : 
    6467             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    6468             :         Real64 OperatingHeatingCapacity; // Water heating operating capacity including the impact of capacity and COP curves (W)
    6469             :         Real64 OperatingHeatingCOP;      // Water heating operating COP including the impact of capacity and COP curves (W/W)
    6470             :         Real64 OperatingHeatingPower;    // Water heating operating Power (W)
    6471             :         Real64 CompressorPower;          // Power consumed by compressor only (W)
    6472             : 
    6473             :         Real64 TotalTankHeatingCapacity; // Water heating capacity corrected for condenser water pump heat (W)
    6474             :         Real64 TankHeatingCOP;           // Water heating COP corrected for fan and condenser water pump power (W/W)
    6475             :         // (these previous 2 variables also include the impact of capacity and COP curves)
    6476             :         Real64 EvapCoolingCapacity;   // Air cooling capacity corrected for evap fan and cond water pump heat (W)
    6477             :         Real64 InletWaterTemp;        // Condenser water inlet temperature (C)
    6478             :         Real64 OutletWaterTemp;       // Condenser water outlet temperature (C)
    6479             :         Real64 EvapInletMassFlowRate; // Evaporator air inlet mass flow rate (m3/s)
    6480             :         Real64 CondInletMassFlowRate; // Condenser water inlet mass flow rate (m3/s)
    6481             :         Real64 CpWater;               // Specific heat of condenser inlet water (J/Kg/k)
    6482             :         Real64 InletAirTemp;          // HPWH inlet air temperature (dry-bulb or wet-bulb) (C)
    6483             :         Real64 AirMassFlowRatio;      // Ratio of evaporator inlet air mass flow rate to rated mass flow rate
    6484             :         Real64 WaterMassFlowRatio;    // Ratio of evaporator inlet water mass flow rate to rated mass flow rate
    6485             :         Real64 PumpHeatToWater;       // Amount of pump heat attributed to heating water
    6486             :         Real64 HPRTF;                 // Heat pump run time fraction
    6487             :         Real64 PLF;                   // part-load function
    6488             :         Real64 CBFSpeed;              // bypass factor as individual speed level
    6489             :         Real64 COPAirFFModFac;        // air flow fraction modification
    6490             :         Real64 COPWaterFFModFac;      // water flow fraction modification
    6491             :         Real64 COPTempModFac;         // total capacity temperature correctio fraction
    6492             :         Real64 TOTCAPAirFFModFac;     // air flow fraction modification
    6493             :         Real64 TOTCAPWaterFFModFac;   // water flow fraction modification
    6494             :         Real64 TOTCAPTempModFac;      // total capacity temperature correctio fraction
    6495             :         Real64 SHR;                   // total capacity temperature correctio fraction
    6496             :         Real64 COP;                   // total capacity temperature correctio fraction
    6497             :         Real64 AoEff;                 // effective air side surface area
    6498             :         Real64 Winput1;               // power consumption at low speed
    6499             :         Real64 Winput2;               // power consumption at high speed
    6500             :         Real64 LoadPressure;          // evaporator inlet pressure
    6501             :         Real64 CrankcaseHeatingPower; // power due to crankcase heater
    6502             :         Real64 hDelta;                // Change in air enthalpy across the cooling coil [J/kg]
    6503             :         Real64 hADP;                  // Apparatus dew point enthalpy [J/kg]
    6504             :         Real64 tADP;                  // Apparatus dew point temperature [C]
    6505             :         Real64 wADP;                  // Apparatus dew point humidity ratio [kg/kg]
    6506             :         Real64 hTinwADP;              // Enthalpy at inlet dry-bulb and wADP [J/kg]
    6507             :         Real64 WHCAP1;                // total heating capacity at low speed [W]
    6508             :         Real64 WHCAP2;                // total heating capacity at high speed [W]
    6509             :         Real64 CpAir;                 // Specific heat of air [J/kg_C]
    6510             :         Real64 MaxHumRat;             // max possible humidity
    6511             :         Real64 MaxOutletEnth;         // max possible outlet enthalpy
    6512             :         Real64 ReportingConstant;
    6513             :         int EvapInletNode;    // Evaporator air inlet node number
    6514             :         int EvapOutletNode;   // Evaporator air outlet node number
    6515             :         int CondInletNode;    // Condenser water inlet node number
    6516             :         int CondOutletNode;   // Condenser water outlet node number
    6517             :         int MaxSpeed;         // maximum speed level
    6518             :         int SpeedCal;         // calculated speed level
    6519     1618059 :         Real64 rhoair(0.0);   // entering air density
    6520     1618059 :         Real64 RhoWater(0.0); // water density
    6521             : 
    6522             :         // note: load side is the evaporator side, and source side is the condenser side
    6523             : 
    6524     1618059 :         CondInletNode = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterInletNodeNum;
    6525     1618059 :         CondOutletNode = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterOutletNodeNum;
    6526             :         // If heat pump water heater is OFF, set outlet to inlet and RETURN
    6527     1618059 :         if (PartLoadRatio == 0.0) {
    6528     1033713 :             state.dataLoopNodes->Node(CondOutletNode) = state.dataLoopNodes->Node(CondInletNode);
    6529     1033713 :             return;
    6530             :         } else {
    6531      584346 :             EvapInletNode = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirInletNodeNum;
    6532      584346 :             EvapOutletNode = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirOutletNodeNum;
    6533      584346 :             InletWaterTemp = state.dataLoopNodes->Node(CondInletNode).Temp;
    6534      584346 :             CondInletMassFlowRate = state.dataLoopNodes->Node(CondInletNode).MassFlowRate;
    6535      584346 :             EvapInletMassFlowRate = state.dataLoopNodes->Node(EvapInletNode).MassFlowRate;
    6536      584346 :             CpWater = CPHW(InletWaterTemp);
    6537      584346 :             CompressorPower = 0.0;
    6538      584346 :             OperatingHeatingPower = 0.0;
    6539      584346 :             TankHeatingCOP = 0.0;
    6540             :         }
    6541             : 
    6542             :         //  LOAD LOCAL VARIABLES FROM DATA STRUCTURE (for code readability)
    6543      584346 :         if (!(CyclingScheme == ContFanCycCoil) && PartLoadRatio > 0.0) {
    6544      584346 :             CondInletMassFlowRate = CondInletMassFlowRate / PartLoadRatio;
    6545      584346 :             EvapInletMassFlowRate = EvapInletMassFlowRate / PartLoadRatio;
    6546             :         }
    6547             : 
    6548      584346 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate = EvapInletMassFlowRate;
    6549      584346 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterMassFlowRate = CondInletMassFlowRate;
    6550             : 
    6551             :         // determine inlet air temperature type for curve objects
    6552      584346 :         if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirTemperatureType == WetBulbIndicator) {
    6553      584346 :             InletAirTemp = state.dataHVACGlobal->HPWHInletWBTemp;
    6554             :         } else {
    6555           0 :             InletAirTemp = state.dataHVACGlobal->HPWHInletDBTemp;
    6556             :         }
    6557             : 
    6558             :         // check if indoor evaporator or outdoor evaporator
    6559      584346 :         CrankcaseHeatingPower = 0.0;
    6560      584346 :         if (EvapInletNode != 0) {
    6561      584346 :             state.dataVariableSpeedCoils->LoadSideInletDBTemp = state.dataLoopNodes->Node(EvapInletNode).Temp;
    6562      584346 :             state.dataVariableSpeedCoils->LoadSideInletHumRat = state.dataLoopNodes->Node(EvapInletNode).HumRat;
    6563      584346 :             LoadPressure = state.dataLoopNodes->Node(EvapInletNode).Press;
    6564             :             // prevent the air pressure not given
    6565      584346 :             if (LoadPressure < 10.0) LoadPressure = state.dataEnvrn->OutBaroPress;
    6566             : 
    6567      584346 :             state.dataVariableSpeedCoils->LoadSideInletWBTemp = state.dataLoopNodes->Node(EvapInletNode).OutAirWetBulb;
    6568      584346 :             state.dataVariableSpeedCoils->LoadSideInletEnth = state.dataLoopNodes->Node(EvapInletNode).Enthalpy;
    6569             :         } else {
    6570           0 :             state.dataVariableSpeedCoils->LoadSideInletDBTemp = state.dataEnvrn->OutDryBulbTemp;
    6571           0 :             state.dataVariableSpeedCoils->LoadSideInletHumRat = state.dataEnvrn->OutHumRat;
    6572           0 :             LoadPressure = state.dataEnvrn->OutBaroPress;
    6573           0 :             state.dataVariableSpeedCoils->LoadSideInletWBTemp = state.dataEnvrn->OutWetBulbTemp;
    6574           0 :             state.dataVariableSpeedCoils->LoadSideInletEnth = state.dataEnvrn->OutEnthalpy;
    6575             : 
    6576             :             // Initialize crankcase heater, operates below OAT defined in input deck for HP DX heating coil
    6577           0 :             if (state.dataEnvrn->OutDryBulbTemp < state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MaxOATCrankcaseHeater) {
    6578           0 :                 CrankcaseHeatingPower = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterCapacity;
    6579             :             };
    6580             :         }
    6581             : 
    6582      584346 :         state.dataVariableSpeedCoils->LoadSideMassFlowRate = EvapInletMassFlowRate;
    6583      584346 :         state.dataVariableSpeedCoils->SourceSideMassFlowRate = CondInletMassFlowRate;
    6584      584346 :         state.dataVariableSpeedCoils->SourceSideInletTemp = InletWaterTemp;
    6585      584346 :         state.dataVariableSpeedCoils->SourceSideInletEnth = state.dataLoopNodes->Node(CondInletNode).Enthalpy;
    6586      584346 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterEnthalpy = state.dataVariableSpeedCoils->SourceSideInletEnth;
    6587             : 
    6588             :         // Check for flows, do not perform simulation if no flow in load side or source side.
    6589      584346 :         if ((state.dataVariableSpeedCoils->SourceSideMassFlowRate <= 0.0) || (state.dataVariableSpeedCoils->LoadSideMassFlowRate <= 0.0)) {
    6590         548 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SimFlag = false;
    6591         548 :             return;
    6592             :         } else {
    6593      583798 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SimFlag = true;
    6594             :         }
    6595             : 
    6596      583798 :         MaxSpeed = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds;
    6597             : 
    6598             :         // must be placed inside the loop, otherwise cause bug in release mode, need to be present at two places
    6599      583798 :         if (SpeedNum > MaxSpeed) {
    6600           0 :             SpeedCal = MaxSpeed;
    6601             :         } else {
    6602      583798 :             SpeedCal = SpeedNum;
    6603             :         }
    6604             : 
    6605             :         // part-load calculation
    6606      583798 :         RuntimeFrac = 1.0;
    6607      583798 :         state.dataHVACGlobal->OnOffFanPartLoadFraction = 1.0;
    6608      583798 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac = 1.0;
    6609      583798 :         if ((SpeedNum == 1) && (PartLoadRatio < 1.0)) {
    6610       15524 :             PLF = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PLFFPLR, PartLoadRatio);
    6611       15524 :             if (PLF < 0.7) {
    6612           0 :                 PLF = 0.7;
    6613             :             }
    6614       15524 :             if (CyclingScheme == CycFanCycCoil)
    6615       15524 :                 state.dataHVACGlobal->OnOffFanPartLoadFraction =
    6616             :                     PLF; // save PLF for fan model, don't change fan power for constant fan mode if coil is off
    6617             :             // calculate the run time fraction
    6618       15524 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac = PartLoadRatio / PLF;
    6619       15524 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PartLoadRatio = PartLoadRatio;
    6620             : 
    6621       15524 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac > 1.0) {
    6622           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac = 1.0; // Reset coil runtime fraction to 1.0
    6623       15524 :             } else if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac < 0.0) {
    6624           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac = 0.0;
    6625             :             }
    6626             : 
    6627       15524 :             RuntimeFrac = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac;
    6628             :         }
    6629             : 
    6630             :         // interpolate between speeds
    6631             :         // must be placed inside the loop, otherwise cause bug in release mode
    6632      583798 :         if (SpeedNum > MaxSpeed) {
    6633           0 :             SpeedCal = MaxSpeed;
    6634             :         } else {
    6635      583798 :             SpeedCal = SpeedNum;
    6636             :         }
    6637             : 
    6638      583798 :         Real64 locFanElecPower = 0.0; // local for fan electric power
    6639      583798 :         if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SupplyFan_TypeNum == DataHVACGlobals::FanType_SystemModelObject) {
    6640      431035 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SupplyFanIndex > -1) {
    6641      431035 :                 locFanElecPower = state.dataHVACFan->fanObjs[state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SupplyFanIndex]->fanPower();
    6642             :             }
    6643             :         } else {
    6644      152763 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SupplyFanIndex > 0) {
    6645       65621 :                 locFanElecPower = Fans::GetFanPower(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SupplyFanIndex);
    6646             :             }
    6647             :         }
    6648             : 
    6649      583798 :         if ((SpeedNum == 1) || (SpeedNum > MaxSpeed) || (SpeedRatio == 1.0)) {
    6650      477998 :             AirMassFlowRatio =
    6651      477998 :                 state.dataVariableSpeedCoils->LoadSideMassFlowRate / state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignAirMassFlowRate;
    6652      477998 :             WaterMassFlowRatio =
    6653      477998 :                 state.dataVariableSpeedCoils->SourceSideMassFlowRate / state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignWaterMassFlowRate;
    6654      477998 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower =
    6655      477998 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWHPumpPower(SpeedCal);
    6656             : 
    6657     1433994 :             COPTempModFac = CurveValue(state,
    6658      477998 :                                        state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(SpeedCal),
    6659             :                                        InletAirTemp,
    6660      477998 :                                        state.dataVariableSpeedCoils->SourceSideInletTemp);
    6661      477998 :             COPAirFFModFac = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(SpeedCal), AirMassFlowRatio);
    6662      477998 :             COPWaterFFModFac = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRWaterFFlow(SpeedCal), WaterMassFlowRatio);
    6663             : 
    6664      477998 :             COP = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedCOP(SpeedCal) * COPTempModFac * COPAirFFModFac * COPWaterFFModFac;
    6665             : 
    6666     1433994 :             TOTCAPTempModFac = CurveValue(state,
    6667      477998 :                                           state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(SpeedCal),
    6668             :                                           InletAirTemp,
    6669      477998 :                                           state.dataVariableSpeedCoils->SourceSideInletTemp);
    6670             :             //   Get capacity modifying factor (function of mass flow) for off-rated conditions
    6671      477998 :             TOTCAPAirFFModFac = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(SpeedCal), AirMassFlowRatio);
    6672             :             // Get capacity modifying factor (function of mass flow) for off-rated conditions
    6673      477998 :             TOTCAPWaterFFModFac =
    6674      955996 :                 CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(SpeedCal), WaterMassFlowRatio);
    6675             : 
    6676      477998 :             OperatingHeatingCapacity = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(SpeedCal) * TOTCAPTempModFac *
    6677             :                                        TOTCAPAirFFModFac * TOTCAPWaterFFModFac;
    6678             : 
    6679      477998 :             state.dataVariableSpeedCoils->Winput = OperatingHeatingCapacity / COP;
    6680      477998 :             OperatingHeatingPower = state.dataVariableSpeedCoils->Winput;
    6681             : 
    6682      477998 :             OperatingHeatingCOP = COP;
    6683      955996 :             PumpHeatToWater = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower *
    6684      477998 :                               state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpFracToWater;
    6685      477998 :             TankHeatingCOP = OperatingHeatingCOP;
    6686             : 
    6687             :             // account for pump heat if not included in total water heating capacity
    6688      477998 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondPumpHeatInCapacity) {
    6689           0 :                 TotalTankHeatingCapacity = OperatingHeatingCapacity;
    6690             :             } else {
    6691      477998 :                 TotalTankHeatingCapacity = OperatingHeatingCapacity + PumpHeatToWater;
    6692             :             }
    6693             : 
    6694      477998 :             HPRTF = RuntimeFrac;
    6695             :             // calculate evaporator total cooling capacity
    6696      477998 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).FanPowerIncludedInCOP) {
    6697       10153 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondPumpPowerInCOP) {
    6698             :                     //       make sure fan power is full load fan power, it isn't though,
    6699           0 :                     CompressorPower = OperatingHeatingPower - locFanElecPower / HPRTF -
    6700           0 :                                       state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower;
    6701           0 :                     if (OperatingHeatingPower > 0.0) TankHeatingCOP = TotalTankHeatingCapacity / OperatingHeatingPower;
    6702             :                 } else {
    6703       10153 :                     CompressorPower = OperatingHeatingPower - locFanElecPower / HPRTF;
    6704       10153 :                     if ((OperatingHeatingPower + state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower) > 0.0)
    6705       10153 :                         TankHeatingCOP = TotalTankHeatingCapacity /
    6706       10153 :                                          (OperatingHeatingPower + state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower);
    6707             :                 }
    6708             :             } else {
    6709      467845 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondPumpPowerInCOP) {
    6710             :                     //       make sure fan power is full load fan power
    6711           0 :                     CompressorPower = OperatingHeatingPower - state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower;
    6712           0 :                     if ((OperatingHeatingPower + locFanElecPower / HPRTF) > 0.0)
    6713           0 :                         TankHeatingCOP = TotalTankHeatingCapacity / (OperatingHeatingPower + locFanElecPower / HPRTF);
    6714             :                 } else {
    6715      467845 :                     CompressorPower = OperatingHeatingPower;
    6716     1403535 :                     if ((OperatingHeatingPower + locFanElecPower / HPRTF +
    6717      935690 :                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower) > 0.0)
    6718      935690 :                         TankHeatingCOP = TotalTankHeatingCapacity / (OperatingHeatingPower + locFanElecPower / HPRTF +
    6719      467845 :                                                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower);
    6720             :                 }
    6721             :             }
    6722             : 
    6723      477998 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondPumpHeatInCapacity) {
    6724           0 :                 EvapCoolingCapacity = TotalTankHeatingCapacity - PumpHeatToWater - CompressorPower;
    6725             :             } else {
    6726      477998 :                 EvapCoolingCapacity = TotalTankHeatingCapacity - CompressorPower;
    6727             :             }
    6728             : 
    6729      955996 :             CBFSpeed = AdjustCBF(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedCBF(SpeedCal),
    6730      477998 :                                  state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedAirMassFlowRate(SpeedCal),
    6731      477998 :                                  state.dataVariableSpeedCoils->LoadSideMassFlowRate);
    6732             : 
    6733             :         } else {
    6734      105800 :             AirMassFlowRatio =
    6735      105800 :                 state.dataVariableSpeedCoils->LoadSideMassFlowRate / state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignAirMassFlowRate;
    6736      105800 :             WaterMassFlowRatio =
    6737      105800 :                 state.dataVariableSpeedCoils->SourceSideMassFlowRate / state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignWaterMassFlowRate;
    6738      211600 :             AoEff = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEffectiveAo(SpeedCal) * SpeedRatio +
    6739      105800 :                     (1.0 - SpeedRatio) * state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEffectiveAo(SpeedCal - 1);
    6740      105800 :             CBFSpeed = std::exp(-AoEff / state.dataVariableSpeedCoils->LoadSideMassFlowRate);
    6741             : 
    6742             :             // calculate low speed
    6743      105800 :             SpeedCal = SpeedNum - 1;
    6744             : 
    6745      105800 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower =
    6746      105800 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWHPumpPower(SpeedCal);
    6747      317400 :             COPTempModFac = CurveValue(state,
    6748      105800 :                                        state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(SpeedCal),
    6749             :                                        InletAirTemp,
    6750      105800 :                                        state.dataVariableSpeedCoils->SourceSideInletTemp);
    6751      105800 :             COPAirFFModFac = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(SpeedCal), AirMassFlowRatio);
    6752      105800 :             COPWaterFFModFac = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRWaterFFlow(SpeedCal), WaterMassFlowRatio);
    6753             : 
    6754      105800 :             COP = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedCOP(SpeedCal) * COPTempModFac * COPAirFFModFac * COPWaterFFModFac;
    6755             : 
    6756      317400 :             TOTCAPTempModFac = CurveValue(state,
    6757      105800 :                                           state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(SpeedCal),
    6758             :                                           InletAirTemp,
    6759      105800 :                                           state.dataVariableSpeedCoils->SourceSideInletTemp);
    6760             :             //   Get capacity modifying factor (function of mass flow) for off-rated conditions
    6761      105800 :             TOTCAPAirFFModFac = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(SpeedCal), AirMassFlowRatio);
    6762             :             // Get capacity modifying factor (function of mass flow) for off-rated conditions
    6763      105800 :             TOTCAPWaterFFModFac =
    6764      211600 :                 CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(SpeedCal), WaterMassFlowRatio);
    6765             : 
    6766      105800 :             OperatingHeatingCapacity = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(SpeedCal) * TOTCAPTempModFac *
    6767             :                                        TOTCAPAirFFModFac * TOTCAPWaterFFModFac;
    6768             : 
    6769      105800 :             state.dataVariableSpeedCoils->Winput = OperatingHeatingCapacity / COP;
    6770      105800 :             OperatingHeatingPower = state.dataVariableSpeedCoils->Winput;
    6771      105800 :             Winput1 = state.dataVariableSpeedCoils->Winput;
    6772      105800 :             WHCAP1 = OperatingHeatingCapacity;
    6773             : 
    6774             :             // calculate upper speed
    6775      105800 :             SpeedCal = SpeedNum;
    6776             : 
    6777      105800 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower =
    6778      105800 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWHPumpPower(SpeedCal);
    6779      317400 :             COPTempModFac = CurveValue(state,
    6780      105800 :                                        state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(SpeedCal),
    6781             :                                        InletAirTemp,
    6782      105800 :                                        state.dataVariableSpeedCoils->SourceSideInletTemp);
    6783      105800 :             COPAirFFModFac = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(SpeedCal), AirMassFlowRatio);
    6784      105800 :             COPWaterFFModFac = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRWaterFFlow(SpeedCal), WaterMassFlowRatio);
    6785             : 
    6786      105800 :             COP = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedCOP(SpeedCal) * COPTempModFac * COPAirFFModFac * COPWaterFFModFac;
    6787             : 
    6788      317400 :             TOTCAPTempModFac = CurveValue(state,
    6789      105800 :                                           state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(SpeedCal),
    6790             :                                           InletAirTemp,
    6791      105800 :                                           state.dataVariableSpeedCoils->SourceSideInletTemp);
    6792             :             //   Get capacity modifying factor (function of mass flow) for off-rated conditions
    6793      105800 :             TOTCAPAirFFModFac = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(SpeedCal), AirMassFlowRatio);
    6794             :             // Get capacity modifying factor (function of mass flow) for off-rated conditions
    6795      105800 :             TOTCAPWaterFFModFac =
    6796      211600 :                 CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(SpeedCal), WaterMassFlowRatio);
    6797             : 
    6798      105800 :             OperatingHeatingCapacity = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(SpeedCal) * TOTCAPTempModFac *
    6799             :                                        TOTCAPAirFFModFac * TOTCAPWaterFFModFac;
    6800             : 
    6801      105800 :             state.dataVariableSpeedCoils->Winput = OperatingHeatingCapacity / COP;
    6802      105800 :             OperatingHeatingPower = state.dataVariableSpeedCoils->Winput;
    6803             : 
    6804      105800 :             Winput2 = state.dataVariableSpeedCoils->Winput;
    6805      105800 :             WHCAP2 = OperatingHeatingCapacity;
    6806             : 
    6807             :             // interpolation
    6808      105800 :             state.dataVariableSpeedCoils->Winput = Winput2 * SpeedRatio + (1.0 - SpeedRatio) * Winput1;
    6809      105800 :             OperatingHeatingPower = state.dataVariableSpeedCoils->Winput;
    6810      105800 :             OperatingHeatingCapacity = WHCAP2 * SpeedRatio + (1.0 - SpeedRatio) * WHCAP1;
    6811      105800 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower =
    6812      211600 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWHPumpPower(SpeedNum) * SpeedRatio +
    6813      105800 :                 (1.0 - SpeedRatio) * state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWHPumpPower(SpeedNum - 1);
    6814             : 
    6815      105800 :             OperatingHeatingCOP = OperatingHeatingCapacity / OperatingHeatingPower;
    6816      105800 :             TankHeatingCOP = OperatingHeatingCOP;
    6817             : 
    6818      211600 :             PumpHeatToWater = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower *
    6819      105800 :                               state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpFracToWater;
    6820             : 
    6821             :             // account for pump heat if not included in total water heating capacity
    6822      105800 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondPumpHeatInCapacity) {
    6823           0 :                 TotalTankHeatingCapacity = OperatingHeatingCapacity;
    6824             :             } else {
    6825      105800 :                 TotalTankHeatingCapacity = OperatingHeatingCapacity + PumpHeatToWater;
    6826             :             }
    6827             : 
    6828      105800 :             HPRTF = RuntimeFrac;
    6829             :             // calculate evaporator total cooling capacity
    6830      105800 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).FanPowerIncludedInCOP) {
    6831        1678 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondPumpPowerInCOP) {
    6832             :                     //       make sure fan power is full load fan power
    6833           0 :                     CompressorPower = OperatingHeatingPower - locFanElecPower / HPRTF -
    6834           0 :                                       state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower;
    6835           0 :                     if (OperatingHeatingPower > 0.0) TankHeatingCOP = TotalTankHeatingCapacity / OperatingHeatingPower;
    6836             :                 } else {
    6837        1678 :                     CompressorPower = OperatingHeatingPower - locFanElecPower / HPRTF;
    6838        1678 :                     if ((OperatingHeatingPower + state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower) > 0.0)
    6839        1678 :                         TankHeatingCOP = TotalTankHeatingCapacity /
    6840        1678 :                                          (OperatingHeatingPower + state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower);
    6841             :                 }
    6842             :             } else {
    6843      104122 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondPumpPowerInCOP) {
    6844             :                     //       make sure fan power is full load fan power
    6845           0 :                     CompressorPower = OperatingHeatingPower - state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower;
    6846           0 :                     if ((OperatingHeatingPower + locFanElecPower / HPRTF) > 0.0)
    6847           0 :                         TankHeatingCOP = TotalTankHeatingCapacity / (OperatingHeatingPower + locFanElecPower / HPRTF);
    6848             :                 } else {
    6849      104122 :                     CompressorPower = OperatingHeatingPower;
    6850      312366 :                     if ((OperatingHeatingPower + locFanElecPower / HPRTF +
    6851      208244 :                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower) > 0.0)
    6852      208244 :                         TankHeatingCOP = TotalTankHeatingCapacity / (OperatingHeatingPower + locFanElecPower / HPRTF +
    6853      104122 :                                                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower);
    6854             :                 }
    6855             :             }
    6856             : 
    6857      105800 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondPumpHeatInCapacity) {
    6858           0 :                 EvapCoolingCapacity = TotalTankHeatingCapacity - PumpHeatToWater - CompressorPower;
    6859             :             } else {
    6860      105800 :                 EvapCoolingCapacity = TotalTankHeatingCapacity - CompressorPower;
    6861             :             }
    6862             :         }
    6863             : 
    6864      583798 :         state.dataVariableSpeedCoils->QSource = TotalTankHeatingCapacity;
    6865      583798 :         state.dataVariableSpeedCoils->QLoadTotal = EvapCoolingCapacity;
    6866      583798 :         state.dataHVACGlobal->DXCoilTotalCapacity = EvapCoolingCapacity; // for standard rating calculation
    6867      583798 :         SHR = 1.0;
    6868             :         // if indoor, calculate SHR
    6869      583798 :         if (EvapInletNode != 0) {
    6870      583798 :             if (CBFSpeed > 0.999) CBFSpeed = 0.999;
    6871             : 
    6872      583798 :             if (CBFSpeed < 0.001) {
    6873         682 :                 SHR = 1.0;
    6874             :             } else {
    6875      583116 :                 hDelta = state.dataVariableSpeedCoils->QLoadTotal / state.dataVariableSpeedCoils->LoadSideMassFlowRate;
    6876      583116 :                 hADP = state.dataVariableSpeedCoils->LoadSideInletEnth - hDelta / (1.0 - CBFSpeed);
    6877      583116 :                 tADP = PsyTsatFnHPb(state, hADP, LoadPressure, RoutineName);
    6878      583116 :                 wADP = PsyWFnTdbH(state, tADP, hADP, RoutineName);
    6879      583116 :                 hTinwADP = PsyHFnTdbW(state.dataVariableSpeedCoils->LoadSideInletDBTemp, wADP);
    6880      583116 :                 if ((state.dataVariableSpeedCoils->LoadSideInletEnth - hADP) > 1.e-10) {
    6881      583116 :                     SHR = min((hTinwADP - hADP) / (state.dataVariableSpeedCoils->LoadSideInletEnth - hADP), 1.0);
    6882             :                 } else {
    6883           0 :                     SHR = 1.0;
    6884             :                 }
    6885             :             }
    6886             :         }
    6887             : 
    6888      583798 :         state.dataVariableSpeedCoils->QSensible = state.dataVariableSpeedCoils->QLoadTotal * SHR;
    6889             : 
    6890             :         // determine condenser water inlet/outlet condition at full capacity
    6891      583798 :         if (CondInletMassFlowRate == 0.0) {
    6892           0 :             OutletWaterTemp = InletWaterTemp;
    6893             :         } else {
    6894      583798 :             OutletWaterTemp = InletWaterTemp + TotalTankHeatingCapacity / (CpWater * CondInletMassFlowRate);
    6895             :         }
    6896             : 
    6897      583798 :         state.dataLoopNodes->Node(CondOutletNode).Temp = OutletWaterTemp;
    6898             : 
    6899      583798 :         state.dataLoopNodes->Node(CondOutletNode).MassFlowRate = state.dataLoopNodes->Node(CondInletNode).MassFlowRate;
    6900             : 
    6901             :         // send heating capacity and COP to water heater module for standards rating calculation
    6902             :         // total heating capacity including condenser pump
    6903      583798 :         state.dataVariableSpeedCoils->VSHPWHHeatingCapacity = TotalTankHeatingCapacity;
    6904             :         // total heating COP including compressor, fan, and condenser pump
    6905      583798 :         state.dataVariableSpeedCoils->VSHPWHHeatingCOP = TankHeatingCOP;
    6906             : 
    6907      583798 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).TotalHeatingEnergyRate = TotalTankHeatingCapacity * PartLoadRatio;
    6908             :         // calculate total compressor plus condenser pump power, fan power reported in fan module
    6909      583798 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).ElecWaterHeatingPower =
    6910      583798 :             (CompressorPower + state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower) * HPRTF;
    6911             : 
    6912             :         // pass the outputs for the cooling coil section
    6913      583798 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterPower = 0.0;
    6914      583798 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterPower = CrankcaseHeatingPower * (1.0 - RuntimeFrac);
    6915             : 
    6916             :         // calculate coil outlet state variables
    6917      583798 :         state.dataVariableSpeedCoils->LoadSideOutletEnth =
    6918     1167596 :             state.dataVariableSpeedCoils->LoadSideInletEnth -
    6919      583798 :             state.dataVariableSpeedCoils->QLoadTotal / state.dataVariableSpeedCoils->LoadSideMassFlowRate;
    6920      583798 :         CpAir = PsyCpAirFnW(state.dataVariableSpeedCoils->LoadSideInletHumRat);
    6921      583798 :         state.dataVariableSpeedCoils->LoadSideOutletDBTemp =
    6922     1167596 :             state.dataVariableSpeedCoils->LoadSideInletDBTemp -
    6923      583798 :             state.dataVariableSpeedCoils->QSensible / (state.dataVariableSpeedCoils->LoadSideMassFlowRate * CpAir);
    6924             : 
    6925     1167596 :         MaxHumRat = PsyWFnTdbRhPb(state,
    6926      583798 :                                   state.dataVariableSpeedCoils->LoadSideOutletDBTemp,
    6927             :                                   0.9999,
    6928      583798 :                                   state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirPressure,
    6929             :                                   RoutineName);
    6930      583798 :         MaxOutletEnth = PsyHFnTdbW(state.dataVariableSpeedCoils->LoadSideOutletDBTemp, MaxHumRat);
    6931      583798 :         if (state.dataVariableSpeedCoils->LoadSideOutletEnth > MaxOutletEnth) {
    6932         682 :             state.dataVariableSpeedCoils->LoadSideOutletEnth = MaxOutletEnth;
    6933             :         }
    6934      583798 :         state.dataVariableSpeedCoils->LoadSideOutletHumRat =
    6935      583798 :             PsyWFnTdbH(state, state.dataVariableSpeedCoils->LoadSideOutletDBTemp, state.dataVariableSpeedCoils->LoadSideOutletEnth, RoutineName);
    6936      583798 :         if (state.dataVariableSpeedCoils->LoadSideOutletHumRat > MaxHumRat) {
    6937         295 :             state.dataVariableSpeedCoils->LoadSideOutletHumRat = MaxHumRat;
    6938             :         }
    6939             : 
    6940             :         // Actual outlet conditions are "average" for time step
    6941      583798 :         if (CyclingScheme == ContFanCycCoil) {
    6942             :             // continuous fan, cycling compressor
    6943           0 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirEnthalpy =
    6944           0 :                 PartLoadRatio * state.dataVariableSpeedCoils->LoadSideOutletEnth +
    6945           0 :                 (1.0 - PartLoadRatio) * state.dataVariableSpeedCoils->LoadSideInletEnth;
    6946           0 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirHumRat =
    6947           0 :                 PartLoadRatio * state.dataVariableSpeedCoils->LoadSideOutletHumRat +
    6948           0 :                 (1.0 - PartLoadRatio) * state.dataVariableSpeedCoils->LoadSideInletHumRat;
    6949           0 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirDBTemp =
    6950           0 :                 PsyTdbFnHW(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirEnthalpy,
    6951           0 :                            state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirHumRat);
    6952           0 :             state.dataVariableSpeedCoils->PLRCorrLoadSideMdot = state.dataVariableSpeedCoils->LoadSideMassFlowRate;
    6953             :         } else {
    6954      583798 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirEnthalpy = state.dataVariableSpeedCoils->LoadSideOutletEnth;
    6955      583798 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirHumRat = state.dataVariableSpeedCoils->LoadSideOutletHumRat;
    6956      583798 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirDBTemp = state.dataVariableSpeedCoils->LoadSideOutletDBTemp;
    6957      583798 :             state.dataVariableSpeedCoils->PLRCorrLoadSideMdot = state.dataVariableSpeedCoils->LoadSideMassFlowRate * PartLoadRatio;
    6958             :         }
    6959             : 
    6960             :         // scale heat transfer rates to PLR and power to RTF
    6961      583798 :         state.dataVariableSpeedCoils->QLoadTotal *= PartLoadRatio;
    6962      583798 :         state.dataVariableSpeedCoils->QSensible *= PartLoadRatio;
    6963             :         // count the powr separately
    6964      583798 :         state.dataVariableSpeedCoils->Winput *= RuntimeFrac; //+ VarSpeedCoil(DXCoilNum)%CrankcaseHeaterPower &
    6965             :         //+ VarSpeedCoil(DXCoilNum)%BasinHeaterPower + VarSpeedCoil(DXCoilNum)%EvapCondPumpElecPower
    6966      583798 :         state.dataVariableSpeedCoils->QSource *= PartLoadRatio;
    6967             : 
    6968             :         //  Add power to global variable so power can be summed by parent object
    6969      583798 :         state.dataHVACGlobal->DXElecCoolingPower = state.dataVariableSpeedCoils->Winput;
    6970             : 
    6971      583798 :         ReportingConstant = state.dataHVACGlobal->TimeStepSys * DataGlobalConstants::SecInHour;
    6972             :         // Update heat pump data structure
    6973      583798 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower =
    6974      583798 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower * RuntimeFrac; // water heating pump power
    6975      583798 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Power = state.dataVariableSpeedCoils->Winput;
    6976      583798 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLoadTotal = state.dataVariableSpeedCoils->QLoadTotal;
    6977      583798 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSensible = state.dataVariableSpeedCoils->QSensible;
    6978      583798 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLatent =
    6979      583798 :             state.dataVariableSpeedCoils->QLoadTotal - state.dataVariableSpeedCoils->QSensible;
    6980      583798 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSource = state.dataVariableSpeedCoils->QSource;
    6981      583798 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Energy = state.dataVariableSpeedCoils->Winput * ReportingConstant;
    6982      583798 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLoadTotal = state.dataVariableSpeedCoils->QLoadTotal * ReportingConstant;
    6983      583798 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergySensible = state.dataVariableSpeedCoils->QSensible * ReportingConstant;
    6984      583798 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLatent =
    6985      583798 :             (state.dataVariableSpeedCoils->QLoadTotal - state.dataVariableSpeedCoils->QSensible) * ReportingConstant;
    6986      583798 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergySource = state.dataVariableSpeedCoils->QSource * ReportingConstant;
    6987      583798 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterConsumption =
    6988      583798 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterPower * ReportingConstant;
    6989      583798 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapWaterConsump = 0.0;
    6990      583798 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).BasinHeaterConsumption = 0.0;
    6991             :         // re-use EvapCondPumpElecConsumption to store WH pump energy consumption
    6992      583798 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EvapCondPumpElecConsumption =
    6993      583798 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPWHCondPumpElecNomPower * ReportingConstant;
    6994      583798 :         if (RuntimeFrac == 0.0) {
    6995           0 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).COP = 0.0;
    6996             :         } else {
    6997      583798 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).COP =
    6998      583798 :                 state.dataVariableSpeedCoils->QLoadTotal / state.dataVariableSpeedCoils->Winput;
    6999             :         }
    7000      583798 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac = RuntimeFrac;
    7001      583798 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PartLoadRatio = PartLoadRatio;
    7002      583798 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate = state.dataVariableSpeedCoils->PLRCorrLoadSideMdot;
    7003     1751394 :         rhoair = PsyRhoAirFnPbTdbW(state,
    7004      583798 :                                    state.dataEnvrn->OutBaroPress,
    7005      583798 :                                    state.dataVariableSpeedCoils->LoadSideInletDBTemp,
    7006      583798 :                                    state.dataVariableSpeedCoils->LoadSideInletHumRat,
    7007             :                                    RoutineName);
    7008      583798 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirVolFlowRate =
    7009      583798 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate / rhoair;
    7010      583798 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterMassFlowRate = state.dataVariableSpeedCoils->SourceSideMassFlowRate;
    7011      583798 :         RhoWater = RhoH2O(InletWaterTemp); // initialize
    7012      583798 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterVolFlowRate =
    7013      583798 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterMassFlowRate / RhoWater;
    7014             : 
    7015      583798 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletWaterTemp =
    7016     1167596 :             state.dataVariableSpeedCoils->SourceSideInletTemp +
    7017      583798 :             state.dataVariableSpeedCoils->QSource / (state.dataVariableSpeedCoils->SourceSideMassFlowRate * CpWater);
    7018      583798 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletWaterEnthalpy =
    7019     1167596 :             state.dataVariableSpeedCoils->SourceSideInletEnth +
    7020      583798 :             state.dataVariableSpeedCoils->QSource / state.dataVariableSpeedCoils->SourceSideMassFlowRate;
    7021      583798 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QWasteHeat = 0.0;
    7022             : 
    7023      583798 :         if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).bIsDesuperheater) // desuperheater doesn't save power and cooling energy variables
    7024             :         {
    7025             :             // source side is the water side; load side is the air side
    7026       82364 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Power = 0.0;
    7027       82364 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLoadTotal = 0.0;
    7028       82364 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSensible = 0.0;
    7029       82364 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLatent = 0.0;
    7030       82364 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Energy = 0.0;
    7031       82364 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLoadTotal = 0.0;
    7032       82364 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergySensible = 0.0;
    7033       82364 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLatent = 0.0;
    7034       82364 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterConsumption = 0.0;
    7035             :         }
    7036             :     }
    7037             : 
    7038           7 :     void setVarSpeedHPWHFanTypeNum(EnergyPlusData &state, int const dXCoilNum, int const fanTypeNum)
    7039             :     {
    7040           7 :         state.dataVariableSpeedCoils->VarSpeedCoil(dXCoilNum).SupplyFan_TypeNum = fanTypeNum;
    7041           7 :     }
    7042             : 
    7043           7 :     void setVarSpeedHPWHFanIndex(EnergyPlusData &state, int const dXCoilNum, int const fanIndex)
    7044             :     {
    7045           7 :         state.dataVariableSpeedCoils->VarSpeedCoil(dXCoilNum).SupplyFanIndex = fanIndex;
    7046           7 :     }
    7047             : 
    7048           0 :     void setVarSpeedFanInfo(EnergyPlusData &state, int const dXCoilNum, std::string const fanName, int const fanIndex, int const fanTypeNum)
    7049             :     {
    7050           0 :         state.dataVariableSpeedCoils->VarSpeedCoil(dXCoilNum).SupplyFanIndex = fanIndex;
    7051           0 :         state.dataVariableSpeedCoils->VarSpeedCoil(dXCoilNum).SupplyFan_TypeNum = fanTypeNum;
    7052           0 :         state.dataVariableSpeedCoils->VarSpeedCoil(dXCoilNum).SupplyFanName = fanName;
    7053           0 :     }
    7054             : 
    7055           0 :     void getCoilTypeAndName(EnergyPlusData &state, int const CoilIndex, std::string &CoilType, std::string &CoilName, bool &ErrorsFound)
    7056             :     {
    7057           0 :         if (state.dataVariableSpeedCoils->GetCoilsInputFlag) { // First time subroutine has been entered
    7058           0 :             GetVarSpeedCoilInput(state);
    7059           0 :             state.dataVariableSpeedCoils->GetCoilsInputFlag = false;
    7060             :         }
    7061             : 
    7062           0 :         if (CoilIndex == 0) {
    7063           0 :             ShowSevereError(state, "getCoilTypeAndName: Could not find Coil");
    7064           0 :             ErrorsFound = true;
    7065             :         } else {
    7066           0 :             CoilName = state.dataVariableSpeedCoils->VarSpeedCoil(CoilIndex).Name;
    7067           0 :             CoilType = state.dataVariableSpeedCoils->VarSpeedCoil(CoilIndex).VarSpeedCoilType;
    7068             :         }
    7069           0 :     }
    7070             : 
    7071     5319754 :     void CalcVarSpeedCoilHeating(EnergyPlusData &state,
    7072             :                                  int const DXCoilNum,                      // Heat Pump Number
    7073             :                                  int const CyclingScheme,                  // Fan/Compressor cycling scheme indicator
    7074             :                                  Real64 &RuntimeFrac,                      // Runtime Fraction of compressor or percent on time (on-time/cycle time)
    7075             :                                  [[maybe_unused]] Real64 const SensDemand, // Cooling Sensible Demand [W] !unused1208
    7076             :                                  CompressorOperation const CompressorOp,   // compressor operation flag
    7077             :                                  Real64 const PartLoadRatio,               // compressor part load ratio
    7078             :                                  [[maybe_unused]] Real64 const OnOffAirFlowRatio, // ratio of compressor on flow to average flow over time step
    7079             :                                  Real64 const SpeedRatio, // SpeedRatio varies between 1.0 (higher speed) and 0.0 (lower speed)
    7080             :                                  int const SpeedNum       // Speed number, high bound, i.e. SpeedNum - 1 is the other side
    7081             :     )
    7082             :     {
    7083             : 
    7084             :         //       AUTHOR         Bo Shen, based on WaterToAirHeatPumpSimple:CalcHPHeatingSimple
    7085             :         //       DATE WRITTEN   March 2012
    7086             :         //       MODIFIED       na
    7087             :         //       RE-ENGINEERED  na
    7088             : 
    7089             :         // PURPOSE OF THIS SUBROUTINE:
    7090             :         // This subroutine is for simulating the heating mode of the Variable Speed Water to Air HP Simple
    7091             : 
    7092             :         // METHODOLOGY EMPLOYED:
    7093             :         // Simulate the heat pump performance using the coefficients and rated conditions
    7094             :         // Finally, adjust the heat pump outlet conditions based on the PartLoadRatio
    7095             :         // and RuntimeFrac.
    7096             : 
    7097             :         // Using/Aliasing
    7098             :         using Curve::CurveValue;
    7099     5319754 :         auto &TimeStepSys = state.dataHVACGlobal->TimeStepSys;
    7100             :         using FluidProperties::GetSpecificHeatGlycol;
    7101             :         using Psychrometrics::PsyCpAirFnW;
    7102             :         using Psychrometrics::PsyHFnTdbW;
    7103             :         using Psychrometrics::PsyRhoAirFnPbTdbW;
    7104             :         using Psychrometrics::PsyTdbFnHW;
    7105             :         using Psychrometrics::PsyTwbFnTdbWPb;
    7106             :         using Psychrometrics::PsyWFnTdbH;
    7107             :         using Psychrometrics::PsyWFnTdbTwbPb;
    7108             : 
    7109             :         // Locals
    7110             :         // SUBROUTINE ARGUMENT DEFINITIONS:
    7111             : 
    7112             :         // SUBROUTINE PARAMETER DEFINITIONS:
    7113             :         static constexpr std::string_view RoutineName("CalcVarSpeedCoilHeating");
    7114             :         static constexpr std::string_view RoutineNameSourceSideInletTemp("CalcVarSpeedCoilHeating:SourceSideInletTemp");
    7115             : 
    7116             :         // INTERFACE BLOCK SPECIFICATIONS
    7117             :         // na
    7118             : 
    7119             :         // DERIVED TYPE DEFINITIONS
    7120             :         // na
    7121             : 
    7122             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    7123             :         Real64 CpSource;            // Specific heat of water [J/kg_C]
    7124             :         Real64 CpAir;               // Specific heat of air [J/kg_C]
    7125             :         Real64 AirMassFlowRatio;    // airflow ratio at low speed
    7126             :         Real64 WaterMassFlowRatio;  // airflow ratio at high speed
    7127             :         Real64 TotCapAirFFModFac;   // air flow fraction modification
    7128             :         Real64 TotCapWaterFFModFac; // water flow fraction modification
    7129             :         Real64 TotCapTempModFac;    // total capacity temperature correction fraction
    7130             :         Real64 EIRAirFFModFac;      // air flow fraction modification
    7131             :         Real64 EIRWaterFFModFac;    // water flow fraction modification
    7132             :         Real64 EIRTempModFac;       // total capacity temperature correction fraction
    7133             :         Real64 EIR;                 // total capacity temperature correction fraction
    7134             :         int MaxSpeed;               // maximum speed level
    7135             :         int SpeedCal;               // calculated speed level
    7136             :         Real64 QLoadTotal1;         // heating capacity at low speed
    7137             :         Real64 QLoadTotal2;         // heating capacity at high speed
    7138             :         Real64 Winput1;             // power consumption at low speed
    7139             :         Real64 Winput2;             // power consumption at high speed
    7140             :         Real64 QWasteHeat;          // recoverable waste heat
    7141             :         Real64 QWasteHeat1;         // recoverable waste heat at low speed
    7142             :         Real64 QWasteHeat2;         // recoverable waste heat at high speed
    7143             :         Real64 PLF;                 // part-load function
    7144             :         Real64 ReportingConstant;
    7145     5319754 :         Real64 rhoair(0.0); // entering air density
    7146             : 
    7147             :         // ADDED VARIABLES FOR air source coil
    7148     5319754 :         MaxSpeed = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).NumOfSpeeds;
    7149             : 
    7150             :         //  LOAD LOCAL VARIABLES FROM DATA STRUCTURE (for code readability)
    7151     5319754 :         if (!(CyclingScheme == ContFanCycCoil) && PartLoadRatio > 0.0) {
    7152      147443 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate =
    7153      147443 :                 state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirInletNodeNum).MassFlowRate / PartLoadRatio;
    7154             :         }
    7155             : 
    7156     5319754 :         state.dataVariableSpeedCoils->LoadSideMassFlowRate = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate;
    7157     5319754 :         state.dataVariableSpeedCoils->LoadSideInletDBTemp = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirDBTemp;
    7158     5319754 :         state.dataVariableSpeedCoils->LoadSideInletHumRat = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirHumRat;
    7159             : 
    7160    15959262 :         state.dataVariableSpeedCoils->LoadSideInletWBTemp = PsyTwbFnTdbWPb(state,
    7161     5319754 :                                                                            state.dataVariableSpeedCoils->LoadSideInletDBTemp,
    7162     5319754 :                                                                            state.dataVariableSpeedCoils->LoadSideInletHumRat,
    7163     5319754 :                                                                            state.dataEnvrn->OutBaroPress,
    7164             :                                                                            RoutineName);
    7165     5319754 :         state.dataVariableSpeedCoils->LoadSideInletEnth = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirEnthalpy;
    7166     5319754 :         CpAir = PsyCpAirFnW(state.dataVariableSpeedCoils->LoadSideInletHumRat);
    7167             : 
    7168     5319754 :         if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_HeatingAirToAirVariableSpeed) {
    7169             :             // Get condenser outdoor node info from DX Heating Coil
    7170      816091 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum != 0) {
    7171           0 :                 state.dataVariableSpeedCoils->OutdoorDryBulb =
    7172           0 :                     state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum).Temp;
    7173           0 :                 state.dataVariableSpeedCoils->OutdoorHumRat =
    7174           0 :                     state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum).HumRat;
    7175           0 :                 state.dataVariableSpeedCoils->OutdoorPressure =
    7176           0 :                     state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum).Press;
    7177           0 :                 state.dataVariableSpeedCoils->OutdoorWetBulb =
    7178           0 :                     state.dataLoopNodes->Node(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CondenserInletNodeNum).OutAirWetBulb;
    7179             :             } else {
    7180      816091 :                 state.dataVariableSpeedCoils->OutdoorDryBulb = state.dataEnvrn->OutDryBulbTemp;
    7181      816091 :                 state.dataVariableSpeedCoils->OutdoorHumRat = state.dataEnvrn->OutHumRat;
    7182      816091 :                 state.dataVariableSpeedCoils->OutdoorPressure = state.dataEnvrn->OutBaroPress;
    7183      816091 :                 state.dataVariableSpeedCoils->OutdoorWetBulb = state.dataEnvrn->OutWetBulbTemp;
    7184             :             }
    7185      816091 :             state.dataVariableSpeedCoils->SourceSideMassFlowRate = 1.0; // not used and avoid divided by zero
    7186      816091 :             state.dataVariableSpeedCoils->SourceSideInletTemp = state.dataVariableSpeedCoils->OutdoorDryBulb;
    7187      816091 :             state.dataVariableSpeedCoils->SourceSideInletEnth =
    7188      816091 :                 PsyHFnTdbW(state.dataVariableSpeedCoils->OutdoorDryBulb, state.dataVariableSpeedCoils->OutdoorHumRat);
    7189      816091 :             CpSource = PsyCpAirFnW(state.dataEnvrn->OutHumRat);
    7190             : 
    7191             :             // Initialize crankcase heater, operates below OAT defined in input deck for HP DX heating coil
    7192      816091 :             if (state.dataVariableSpeedCoils->OutdoorDryBulb < state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MaxOATCrankcaseHeater) {
    7193      284331 :                 state.dataVariableSpeedCoils->CrankcaseHeatingPower = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterCapacity;
    7194             :             } else {
    7195      531760 :                 state.dataVariableSpeedCoils->CrankcaseHeatingPower = 0.0;
    7196             :             }
    7197             :         } else {
    7198     4503663 :             state.dataVariableSpeedCoils->SourceSideMassFlowRate = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterMassFlowRate;
    7199     4503663 :             state.dataVariableSpeedCoils->SourceSideInletTemp = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterTemp;
    7200     4503663 :             state.dataVariableSpeedCoils->SourceSideInletEnth = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterEnthalpy;
    7201     4503663 :             CpSource =
    7202    13510989 :                 GetSpecificHeatGlycol(state,
    7203     4503663 :                                       state.dataPlnt->PlantLoop(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).plantLoc.loopNum).FluidName,
    7204     4503663 :                                       state.dataVariableSpeedCoils->SourceSideInletTemp,
    7205     4503663 :                                       state.dataPlnt->PlantLoop(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).plantLoc.loopNum).FluidIndex,
    7206             :                                       RoutineNameSourceSideInletTemp);
    7207             :         }
    7208             : 
    7209             :         // Check for flows, do not perform simulation if no flow in load side or source side.
    7210     5319754 :         if ((state.dataVariableSpeedCoils->SourceSideMassFlowRate <= 0.0) || (state.dataVariableSpeedCoils->LoadSideMassFlowRate <= 0.0)) {
    7211     3948095 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SimFlag = false;
    7212     3948095 :             return;
    7213             :         } else {
    7214     1371659 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SimFlag = true;
    7215             :         }
    7216             : 
    7217     1527923 :         if ((state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_HeatingAirToAirVariableSpeed) &&
    7218      156264 :             (state.dataVariableSpeedCoils->OutdoorDryBulb < state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MinOATCompressor)) {
    7219       88653 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SimFlag = false;
    7220       88653 :             return;
    7221             :         }
    7222             : 
    7223     1283006 :         if (CompressorOp == CompressorOperation::Off) {
    7224        2042 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SimFlag = false;
    7225        2042 :             return;
    7226             :         }
    7227             : 
    7228     1280964 :         if (SpeedNum > MaxSpeed) {
    7229           0 :             SpeedCal = MaxSpeed;
    7230             :         } else {
    7231     1280964 :             SpeedCal = SpeedNum;
    7232             :         }
    7233             : 
    7234     1280964 :         RuntimeFrac = 1.0;
    7235     1280964 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac = 1.0;
    7236     1280964 :         state.dataHVACGlobal->OnOffFanPartLoadFraction = 1.0;
    7237     1280964 :         if ((SpeedNum == 1) && (PartLoadRatio < 1.0)) {
    7238      134458 :             PLF = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PLFFPLR, PartLoadRatio);
    7239      134458 :             if (PLF < 0.7) {
    7240           0 :                 PLF = 0.7;
    7241             :             }
    7242      134458 :             if (CyclingScheme == CycFanCycCoil)
    7243       20320 :                 state.dataHVACGlobal->OnOffFanPartLoadFraction =
    7244             :                     PLF; // save PLF for fan model, don't change fan power for constant fan mode if coil is off
    7245             :             // calculate the run time fraction
    7246      134458 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac = PartLoadRatio / PLF;
    7247      134458 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PartLoadRatio = PartLoadRatio;
    7248             : 
    7249      134458 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac > 1.0) {
    7250           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac = 1.0; // Reset coil runtime fraction to 1.0
    7251      134458 :             } else if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac < 0.0) {
    7252           0 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac = 0.0;
    7253             :             }
    7254             : 
    7255      134458 :             RuntimeFrac = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac;
    7256             :         }
    7257             : 
    7258     1280964 :         if ((SpeedNum == 1) || (SpeedNum > MaxSpeed) || (SpeedRatio == 1.0)) {
    7259     1009423 :             AirMassFlowRatio =
    7260     1009423 :                 state.dataVariableSpeedCoils->LoadSideMassFlowRate / state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignAirMassFlowRate;
    7261             : 
    7262     1009423 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_HeatingAirToAirVariableSpeed) {
    7263       58510 :                 WaterMassFlowRatio = 1.0;
    7264             :             } else {
    7265     1901826 :                 WaterMassFlowRatio = state.dataVariableSpeedCoils->SourceSideMassFlowRate /
    7266      950913 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignWaterMassFlowRate;
    7267             :             }
    7268             : 
    7269     4037692 :             TotCapTempModFac = CurveValue(state,
    7270     1009423 :                                           state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(SpeedCal),
    7271     1009423 :                                           state.dataVariableSpeedCoils->LoadSideInletDBTemp,
    7272     1009423 :                                           state.dataVariableSpeedCoils->SourceSideInletTemp);
    7273     1009423 :             TotCapAirFFModFac = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(SpeedCal), AirMassFlowRatio);
    7274             : 
    7275     1009423 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_HeatingAirToAirVariableSpeed) {
    7276       58510 :                 TotCapWaterFFModFac = 1.0;
    7277             :             } else {
    7278      950913 :                 TotCapWaterFFModFac =
    7279     1901826 :                     CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(SpeedCal), WaterMassFlowRatio);
    7280             :             }
    7281             : 
    7282     2018846 :             state.dataVariableSpeedCoils->QLoadTotal = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(SpeedCal) *
    7283     1009423 :                                                        TotCapTempModFac * TotCapAirFFModFac * TotCapWaterFFModFac;
    7284     1009423 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).capModFacTotal = TotCapTempModFac * TotCapAirFFModFac * TotCapWaterFFModFac;
    7285     1009423 :             state.dataVariableSpeedCoils->TotRatedCapacity =
    7286     1009423 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(SpeedCal); // for defrosting power cal
    7287             : 
    7288     4037692 :             EIRTempModFac = CurveValue(state,
    7289     1009423 :                                        state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(SpeedCal),
    7290     1009423 :                                        state.dataVariableSpeedCoils->LoadSideInletDBTemp,
    7291     1009423 :                                        state.dataVariableSpeedCoils->SourceSideInletTemp);
    7292     1009423 :             EIRAirFFModFac = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(SpeedCal), AirMassFlowRatio);
    7293             : 
    7294     1009423 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_HeatingAirToAirVariableSpeed) {
    7295       58510 :                 EIRWaterFFModFac = 1.0;
    7296             :             } else {
    7297      950913 :                 EIRWaterFFModFac =
    7298     1901826 :                     CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRWaterFFlow(SpeedCal), WaterMassFlowRatio);
    7299             :             }
    7300             : 
    7301     1009423 :             EIR = (1.0 / state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedCOP(SpeedCal)) * EIRTempModFac * EIRAirFFModFac *
    7302             :                   EIRWaterFFModFac;
    7303     1009423 :             state.dataVariableSpeedCoils->Winput = state.dataVariableSpeedCoils->QLoadTotal * EIR;
    7304             : 
    7305     2018846 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_HeatingAirToAirVariableSpeed) {
    7306       58510 :                 QWasteHeat = 0.0;
    7307             :             } else {
    7308      950913 :                 QWasteHeat = state.dataVariableSpeedCoils->Winput * state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeatFrac(SpeedCal);
    7309     3803652 :                 QWasteHeat *= CurveValue(state,
    7310      950913 :                                          state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeat(SpeedCal),
    7311      950913 :                                          state.dataVariableSpeedCoils->LoadSideInletDBTemp,
    7312      950913 :                                          state.dataVariableSpeedCoils->SourceSideInletTemp);
    7313             :             }
    7314             : 
    7315             :         } else {
    7316      271541 :             AirMassFlowRatio =
    7317      271541 :                 state.dataVariableSpeedCoils->LoadSideMassFlowRate / state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignAirMassFlowRate;
    7318             : 
    7319      271541 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_HeatingAirToAirVariableSpeed) {
    7320        8203 :                 WaterMassFlowRatio = 1.0;
    7321             :             } else {
    7322      526676 :                 WaterMassFlowRatio = state.dataVariableSpeedCoils->SourceSideMassFlowRate /
    7323      263338 :                                      state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DesignWaterMassFlowRate;
    7324             :             }
    7325             : 
    7326      271541 :             SpeedCal = SpeedNum - 1;
    7327     1086164 :             TotCapTempModFac = CurveValue(state,
    7328      271541 :                                           state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(SpeedCal),
    7329      271541 :                                           state.dataVariableSpeedCoils->LoadSideInletDBTemp,
    7330      271541 :                                           state.dataVariableSpeedCoils->SourceSideInletTemp);
    7331      271541 :             TotCapAirFFModFac = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(SpeedCal), AirMassFlowRatio);
    7332             : 
    7333      271541 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_HeatingAirToAirVariableSpeed) {
    7334        8203 :                 TotCapWaterFFModFac = 1.0;
    7335             :             } else {
    7336      263338 :                 TotCapWaterFFModFac =
    7337      526676 :                     CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(SpeedCal), WaterMassFlowRatio);
    7338             :             }
    7339             : 
    7340      271541 :             QLoadTotal1 = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(SpeedCal) * TotCapTempModFac * TotCapAirFFModFac *
    7341             :                           TotCapWaterFFModFac;
    7342             : 
    7343     1086164 :             EIRTempModFac = CurveValue(state,
    7344      271541 :                                        state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(SpeedCal),
    7345      271541 :                                        state.dataVariableSpeedCoils->LoadSideInletDBTemp,
    7346      271541 :                                        state.dataVariableSpeedCoils->SourceSideInletTemp);
    7347      271541 :             EIRAirFFModFac = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(SpeedCal), AirMassFlowRatio);
    7348             : 
    7349      271541 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_HeatingAirToAirVariableSpeed) {
    7350        8203 :                 EIRWaterFFModFac = 1.0;
    7351             :             } else {
    7352      263338 :                 EIRWaterFFModFac =
    7353      526676 :                     CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRWaterFFlow(SpeedCal), WaterMassFlowRatio);
    7354             :             }
    7355             : 
    7356      271541 :             EIR = (1.0 / state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedCOP(SpeedCal)) * EIRTempModFac * EIRAirFFModFac *
    7357             :                   EIRWaterFFModFac;
    7358      271541 :             Winput1 = QLoadTotal1 * EIR;
    7359             : 
    7360      271541 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_HeatingAirToAirVariableSpeed) {
    7361        8203 :                 QWasteHeat1 = 0.0;
    7362             :             } else {
    7363      263338 :                 QWasteHeat1 = Winput1 * state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeatFrac(SpeedCal);
    7364     1053352 :                 QWasteHeat1 *= CurveValue(state,
    7365      263338 :                                           state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeat(SpeedCal),
    7366      263338 :                                           state.dataVariableSpeedCoils->LoadSideInletDBTemp,
    7367      263338 :                                           state.dataVariableSpeedCoils->SourceSideInletTemp);
    7368             :             }
    7369             : 
    7370      271541 :             SpeedCal = SpeedNum;
    7371     1086164 :             TotCapTempModFac = CurveValue(state,
    7372      271541 :                                           state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapFTemp(SpeedCal),
    7373      271541 :                                           state.dataVariableSpeedCoils->LoadSideInletDBTemp,
    7374      271541 :                                           state.dataVariableSpeedCoils->SourceSideInletTemp);
    7375      271541 :             TotCapAirFFModFac = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapAirFFlow(SpeedCal), AirMassFlowRatio);
    7376             : 
    7377      271541 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_HeatingAirToAirVariableSpeed) {
    7378        8203 :                 TotCapWaterFFModFac = 1.0;
    7379             :             } else {
    7380      263338 :                 TotCapWaterFFModFac =
    7381      526676 :                     CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSCCapWaterFFlow(SpeedCal), WaterMassFlowRatio);
    7382             :             }
    7383             : 
    7384      271541 :             QLoadTotal2 = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(SpeedCal) * TotCapTempModFac * TotCapAirFFModFac *
    7385             :                           TotCapWaterFFModFac;
    7386             : 
    7387     1086164 :             EIRTempModFac = CurveValue(state,
    7388      271541 :                                        state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRFTemp(SpeedCal),
    7389      271541 :                                        state.dataVariableSpeedCoils->LoadSideInletDBTemp,
    7390      271541 :                                        state.dataVariableSpeedCoils->SourceSideInletTemp);
    7391      271541 :             EIRAirFFModFac = CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRAirFFlow(SpeedCal), AirMassFlowRatio);
    7392             : 
    7393      271541 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_HeatingAirToAirVariableSpeed) {
    7394        8203 :                 EIRWaterFFModFac = 1.0;
    7395             :             } else {
    7396      263338 :                 EIRWaterFFModFac =
    7397      526676 :                     CurveValue(state, state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSEIRWaterFFlow(SpeedCal), WaterMassFlowRatio);
    7398             :             }
    7399             : 
    7400      271541 :             EIR = (1.0 / state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedCOP(SpeedCal)) * EIRTempModFac * EIRAirFFModFac *
    7401             :                   EIRWaterFFModFac;
    7402      271541 :             Winput2 = QLoadTotal2 * EIR;
    7403             : 
    7404      271541 :             if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_HeatingAirToAirVariableSpeed) {
    7405        8203 :                 QWasteHeat2 = 0.0;
    7406             :             } else {
    7407      263338 :                 QWasteHeat2 = Winput2 * state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeatFrac(SpeedCal);
    7408     1053352 :                 QWasteHeat2 *= CurveValue(state,
    7409      263338 :                                           state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSWasteHeat(SpeedCal),
    7410      263338 :                                           state.dataVariableSpeedCoils->LoadSideInletDBTemp,
    7411      263338 :                                           state.dataVariableSpeedCoils->SourceSideInletTemp);
    7412             :             }
    7413             : 
    7414      271541 :             state.dataVariableSpeedCoils->QLoadTotal = QLoadTotal2 * SpeedRatio + (1.0 - SpeedRatio) * QLoadTotal1;
    7415      271541 :             state.dataVariableSpeedCoils->Winput = Winput2 * SpeedRatio + (1.0 - SpeedRatio) * Winput1;
    7416      271541 :             QWasteHeat = QWasteHeat2 * SpeedRatio + (1.0 - SpeedRatio) * QWasteHeat1;
    7417      271541 :             state.dataVariableSpeedCoils->TotRatedCapacity =
    7418      543082 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(SpeedCal) * SpeedRatio +
    7419      271541 :                 (1.0 - SpeedRatio) * state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MSRatedTotCap(SpeedCal - 1);
    7420             :         }
    7421             : 
    7422     1280964 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterPower = 0.0; // necessary to clear zero for water source coils
    7423     1280964 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostPower = 0.0;         // clear the defrost power
    7424     1280964 :         if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_HeatingAirToAirVariableSpeed) {
    7425             :             // Calculating adjustment factors for defrost
    7426             :             // Calculate delta w through outdoor coil by assuming a coil temp of 0.82*DBT-9.7(F) per DOE2.1E
    7427       66713 :             state.dataVariableSpeedCoils->OutdoorCoilT = 0.82 * state.dataVariableSpeedCoils->OutdoorDryBulb - 8.589;
    7428       66713 :             state.dataVariableSpeedCoils->OutdoorCoildw =
    7429       66713 :                 max(1.0e-6,
    7430       66713 :                     (state.dataVariableSpeedCoils->OutdoorHumRat -
    7431      133426 :                      PsyWFnTdpPb(state, state.dataVariableSpeedCoils->OutdoorCoilT, state.dataVariableSpeedCoils->OutdoorPressure)));
    7432             : 
    7433             :             // Initializing defrost adjustment factors
    7434       66713 :             state.dataVariableSpeedCoils->LoadDueToDefrost = 0.0;
    7435       66713 :             state.dataVariableSpeedCoils->HeatingCapacityMultiplier = 1.0;
    7436       66713 :             state.dataVariableSpeedCoils->FractionalDefrostTime = 0.0;
    7437       66713 :             state.dataVariableSpeedCoils->InputPowerMultiplier = 1.0;
    7438             :             // Check outdoor temperature to determine of defrost is active
    7439       66713 :             if (state.dataVariableSpeedCoils->OutdoorDryBulb <= state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MaxOATDefrost) {
    7440             :                 // Calculate defrost adjustment factors depending on defrost control type
    7441           0 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostControl == Timed) {
    7442           0 :                     state.dataVariableSpeedCoils->FractionalDefrostTime = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostTime;
    7443           0 :                     state.dataVariableSpeedCoils->HeatingCapacityMultiplier = 0.909 - 107.33 * state.dataVariableSpeedCoils->OutdoorCoildw;
    7444           0 :                     state.dataVariableSpeedCoils->InputPowerMultiplier = 0.90 - 36.45 * state.dataVariableSpeedCoils->OutdoorCoildw;
    7445             :                 } else { // else defrost control is on-demand
    7446           0 :                     state.dataVariableSpeedCoils->FractionalDefrostTime = 1.0 / (1.0 + 0.01446 / state.dataVariableSpeedCoils->OutdoorCoildw);
    7447           0 :                     state.dataVariableSpeedCoils->HeatingCapacityMultiplier = 0.875 * (1.0 - state.dataVariableSpeedCoils->FractionalDefrostTime);
    7448           0 :                     state.dataVariableSpeedCoils->InputPowerMultiplier = 0.954 * (1.0 - state.dataVariableSpeedCoils->FractionalDefrostTime);
    7449             :                 }
    7450             :                 // correction fractional defrost time shorten by runtime fraction
    7451           0 :                 state.dataVariableSpeedCoils->FractionalDefrostTime *= RuntimeFrac;
    7452             : 
    7453           0 :                 if (state.dataVariableSpeedCoils->FractionalDefrostTime > 0.0) {
    7454             :                     // Calculate defrost adjustment factors depending on defrost control strategy
    7455           0 :                     if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostStrategy == ReverseCycle) {
    7456           0 :                         state.dataVariableSpeedCoils->LoadDueToDefrost = (0.01 * state.dataVariableSpeedCoils->FractionalDefrostTime) *
    7457           0 :                                                                          (7.222 - state.dataVariableSpeedCoils->OutdoorDryBulb) *
    7458           0 :                                                                          (state.dataVariableSpeedCoils->TotRatedCapacity / 1.01667);
    7459           0 :                         state.dataVariableSpeedCoils->DefrostEIRTempModFac =
    7460           0 :                             CurveValue(state,
    7461           0 :                                        state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostEIRFT,
    7462           0 :                                        max(15.555, state.dataVariableSpeedCoils->LoadSideInletWBTemp),
    7463           0 :                                        max(15.555, state.dataVariableSpeedCoils->OutdoorDryBulb));
    7464           0 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostPower =
    7465           0 :                             state.dataVariableSpeedCoils->DefrostEIRTempModFac * (state.dataVariableSpeedCoils->TotRatedCapacity / 1.01667) *
    7466           0 :                             state.dataVariableSpeedCoils->FractionalDefrostTime;
    7467             :                     } else { // Defrost strategy is resistive
    7468           0 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostPower =
    7469           0 :                             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostCapacity *
    7470           0 :                             state.dataVariableSpeedCoils->FractionalDefrostTime;
    7471             :                     }
    7472             :                 } else { // Defrost is not active because (OutDryBulbTemp > VarSpeedCoil(DXCoilNum).MaxOATDefrost)
    7473           0 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostPower = 0.0;
    7474             :                 }
    7475             :             }
    7476             : 
    7477       66713 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterPower =
    7478       66713 :                 state.dataVariableSpeedCoils->CrankcaseHeatingPower * (1.0 - RuntimeFrac);
    7479             :             //! Modify total heating capacity based on defrost heating capacity multiplier
    7480             :             //! MaxHeatCap passed from parent object VRF Condenser and is used to limit capacity of TU's to that available from condenser
    7481             :             //  IF(PRESENT(MaxHeatCap))THEN
    7482             :             //    TotCap = MIN(MaxHeatCap,TotCap * HeatingCapacityMultiplier)
    7483             :             //  ELSE
    7484             :             //    TotCap = TotCap * HeatingCapacityMultiplier
    7485             :             //  END IF
    7486       66713 :             state.dataVariableSpeedCoils->QLoadTotal =
    7487      133426 :                 state.dataVariableSpeedCoils->QLoadTotal * state.dataVariableSpeedCoils->HeatingCapacityMultiplier -
    7488       66713 :                 state.dataVariableSpeedCoils->LoadDueToDefrost;
    7489             :             // count the powr separately
    7490       66713 :             state.dataVariableSpeedCoils->Winput *= state.dataVariableSpeedCoils->InputPowerMultiplier; //+ VarSpeedCoil(DXCoilNum)%DefrostPower
    7491             :         }
    7492             : 
    7493     1280964 :         state.dataVariableSpeedCoils->QSource = state.dataVariableSpeedCoils->QLoadTotal + QWasteHeat - state.dataVariableSpeedCoils->Winput;
    7494     1280964 :         state.dataVariableSpeedCoils->QSensible = state.dataVariableSpeedCoils->QLoadTotal;
    7495             : 
    7496     1280964 :         if (state.dataVariableSpeedCoils->QSource < 0) {
    7497           0 :             state.dataVariableSpeedCoils->QSource = 0.0;
    7498           0 :             QWasteHeat = state.dataVariableSpeedCoils->Winput - state.dataVariableSpeedCoils->QLoadTotal;
    7499             :         }
    7500             : 
    7501             :         // calculate coil outlet state variables
    7502     1280964 :         state.dataVariableSpeedCoils->LoadSideOutletEnth =
    7503     2561928 :             state.dataVariableSpeedCoils->LoadSideInletEnth +
    7504     1280964 :             state.dataVariableSpeedCoils->QLoadTotal / state.dataVariableSpeedCoils->LoadSideMassFlowRate;
    7505     1280964 :         state.dataVariableSpeedCoils->LoadSideOutletDBTemp =
    7506     2561928 :             state.dataVariableSpeedCoils->LoadSideInletDBTemp +
    7507     1280964 :             state.dataVariableSpeedCoils->QSensible / (state.dataVariableSpeedCoils->LoadSideMassFlowRate * CpAir);
    7508     1280964 :         state.dataVariableSpeedCoils->LoadSideOutletHumRat =
    7509     1280964 :             PsyWFnTdbH(state, state.dataVariableSpeedCoils->LoadSideOutletDBTemp, state.dataVariableSpeedCoils->LoadSideOutletEnth, RoutineName);
    7510             : 
    7511             :         // Actual outlet conditions are "average" for time step
    7512     1280964 :         if (CyclingScheme == ContFanCycCoil) {
    7513             :             // continuous fan, cycling compressor
    7514     1218099 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirEnthalpy =
    7515     2436198 :                 PartLoadRatio * state.dataVariableSpeedCoils->LoadSideOutletEnth +
    7516     1218099 :                 (1.0 - PartLoadRatio) * state.dataVariableSpeedCoils->LoadSideInletEnth;
    7517     1218099 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirHumRat =
    7518     2436198 :                 PartLoadRatio * state.dataVariableSpeedCoils->LoadSideOutletHumRat +
    7519     1218099 :                 (1.0 - PartLoadRatio) * state.dataVariableSpeedCoils->LoadSideInletHumRat;
    7520     1218099 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirDBTemp =
    7521     1218099 :                 PsyTdbFnHW(state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirEnthalpy,
    7522     1218099 :                            state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirHumRat);
    7523     1218099 :             state.dataVariableSpeedCoils->PLRCorrLoadSideMdot = state.dataVariableSpeedCoils->LoadSideMassFlowRate;
    7524             :         } else {
    7525             :             // default to cycling fan, cycling compressor
    7526       62865 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirEnthalpy = state.dataVariableSpeedCoils->LoadSideOutletEnth;
    7527       62865 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirHumRat = state.dataVariableSpeedCoils->LoadSideOutletHumRat;
    7528       62865 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirDBTemp = state.dataVariableSpeedCoils->LoadSideOutletDBTemp;
    7529       62865 :             state.dataVariableSpeedCoils->PLRCorrLoadSideMdot = state.dataVariableSpeedCoils->LoadSideMassFlowRate * PartLoadRatio;
    7530             :         }
    7531             : 
    7532             :         // scale heat transfer rates to PLR and power to RTF
    7533     1280964 :         state.dataVariableSpeedCoils->QLoadTotal *= PartLoadRatio;
    7534     1280964 :         state.dataVariableSpeedCoils->QSensible *= PartLoadRatio;
    7535             :         // count the powr separately
    7536     1280964 :         state.dataVariableSpeedCoils->Winput *= RuntimeFrac; //+ VarSpeedCoil(DXCoilNum)%CrankcaseHeaterPower
    7537     1280964 :         state.dataVariableSpeedCoils->QSource *= PartLoadRatio;
    7538     1280964 :         QWasteHeat *= PartLoadRatio;
    7539             : 
    7540             :         //  Add power to global variable so power can be summed by parent object
    7541     1280964 :         state.dataHVACGlobal->DXElecHeatingPower = state.dataVariableSpeedCoils->Winput;
    7542             : 
    7543     1280964 :         ReportingConstant = TimeStepSys * DataGlobalConstants::SecInHour;
    7544             :         // Update heat pump data structure
    7545     1280964 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Power = state.dataVariableSpeedCoils->Winput;
    7546     1280964 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLoadTotal = state.dataVariableSpeedCoils->QLoadTotal;
    7547     1280964 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSensible = state.dataVariableSpeedCoils->QSensible;
    7548     1280964 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSource = state.dataVariableSpeedCoils->QSource;
    7549     1280964 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Energy = state.dataVariableSpeedCoils->Winput * ReportingConstant;
    7550     1280964 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLoadTotal = state.dataVariableSpeedCoils->QLoadTotal * ReportingConstant;
    7551     1280964 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergySensible = state.dataVariableSpeedCoils->QSensible * ReportingConstant;
    7552     1280964 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLatent = 0.0;
    7553     1280964 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergySource = state.dataVariableSpeedCoils->QSource * ReportingConstant;
    7554     1280964 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterConsumption =
    7555     1280964 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).CrankcaseHeaterPower * ReportingConstant;
    7556     1280964 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostConsumption =
    7557     1280964 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).DefrostPower * ReportingConstant;
    7558     1280964 :         if (RuntimeFrac == 0.0) {
    7559       31736 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).COP = 0.0;
    7560             :         } else {
    7561     1249228 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).COP =
    7562     1249228 :                 state.dataVariableSpeedCoils->QLoadTotal / state.dataVariableSpeedCoils->Winput;
    7563             :         }
    7564     1280964 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac = RuntimeFrac;
    7565     1280964 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PartLoadRatio = PartLoadRatio;
    7566     1280964 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate = state.dataVariableSpeedCoils->PLRCorrLoadSideMdot;
    7567     3842892 :         rhoair = PsyRhoAirFnPbTdbW(state,
    7568     1280964 :                                    state.dataEnvrn->OutBaroPress,
    7569     1280964 :                                    state.dataVariableSpeedCoils->LoadSideInletDBTemp,
    7570     1280964 :                                    state.dataVariableSpeedCoils->LoadSideInletHumRat,
    7571             :                                    RoutineName);
    7572     1280964 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirVolFlowRate =
    7573     1280964 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirMassFlowRate / rhoair;
    7574             : 
    7575     1280964 :         if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_HeatingAirToAirVariableSpeed) {
    7576       66713 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterMassFlowRate = 0.0;
    7577       66713 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletWaterTemp = 0.0;
    7578       66713 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletWaterEnthalpy = 0.0;
    7579             :         } else {
    7580     1214251 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterMassFlowRate = state.dataVariableSpeedCoils->SourceSideMassFlowRate;
    7581     1214251 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletWaterTemp =
    7582     2428502 :                 state.dataVariableSpeedCoils->SourceSideInletTemp -
    7583     1214251 :                 state.dataVariableSpeedCoils->QSource / (state.dataVariableSpeedCoils->SourceSideMassFlowRate * CpSource);
    7584     1214251 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletWaterEnthalpy =
    7585     2428502 :                 state.dataVariableSpeedCoils->SourceSideInletEnth -
    7586     1214251 :                 state.dataVariableSpeedCoils->QSource / state.dataVariableSpeedCoils->SourceSideMassFlowRate;
    7587             :         }
    7588             : 
    7589     1280964 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QWasteHeat = QWasteHeat;
    7590             :     }
    7591             : 
    7592          57 :     Real64 GetCoilCapacityVariableSpeed(EnergyPlusData &state,
    7593             :                                         std::string const &CoilType, // must match coil types in this module
    7594             :                                         std::string const &CoilName, // must match coil names for the coil type
    7595             :                                         bool &ErrorsFound            // set to true if problem
    7596             :     )
    7597             :     {
    7598             : 
    7599             :         // FUNCTION INFORMATION:
    7600             :         //       AUTHOR         Bo Shen, based on WaterToAirHeatPumpSimple:GetCoilCapacity
    7601             :         //       DATE WRITTEN   March 2012
    7602             :         //       MODIFIED       na
    7603             :         //       RE-ENGINEERED  na
    7604             : 
    7605             :         // PURPOSE OF THIS FUNCTION:
    7606             :         // This function looks up the rated coil capacity at the nominal speed level for the given coil and returns it.  If
    7607             :         // incorrect coil type or name is given, ErrorsFound is returned as true and capacity is returned
    7608             :         // as negative.
    7609             : 
    7610             :         // Using/Aliasing
    7611             :         using FluidProperties::FindGlycol;
    7612             : 
    7613             :         // Return value
    7614             :         Real64 CoilCapacity; // returned capacity of matched coil
    7615             : 
    7616             :         // FUNCTION LOCAL VARIABLE DECLARATIONS:
    7617             :         int WhichCoil;
    7618             : 
    7619             :         // Obtains and Allocates WatertoAirHP related parameters from input file
    7620          57 :         if (state.dataVariableSpeedCoils->GetCoilsInputFlag) { // First time subroutine has been entered
    7621           0 :             GetVarSpeedCoilInput(state);
    7622             :             //    WaterIndex=FindGlycol('WATER') !Initialize the WaterIndex once
    7623           0 :             state.dataVariableSpeedCoils->GetCoilsInputFlag = false;
    7624             :         }
    7625             : 
    7626         154 :         if (UtilityRoutines::SameString(CoilType, "COIL:COOLING:WATERTOAIRHEATPUMP:VARIABLESPEEDEQUATIONFIT") ||
    7627         123 :             UtilityRoutines::SameString(CoilType, "COIL:HEATING:WATERTOAIRHEATPUMP:VARIABLESPEEDEQUATIONFIT") ||
    7628          92 :             UtilityRoutines::SameString(CoilType, "COIL:COOLING:DX:VARIABLESPEED") ||
    7629         130 :             UtilityRoutines::SameString(CoilType, "COIL:HEATING:DX:VARIABLESPEED") ||
    7630          64 :             UtilityRoutines::SameString(CoilType, "COIL:WATERHEATING:AIRTOWATERHEATPUMP:VARIABLESPEED")) {
    7631          57 :             WhichCoil = UtilityRoutines::FindItemInList(CoilName, state.dataVariableSpeedCoils->VarSpeedCoil);
    7632          57 :             if (WhichCoil != 0) {
    7633         157 :                 if (UtilityRoutines::SameString(CoilType, "COIL:HEATING:WATERTOAIRHEATPUMP:VARIABLESPEEDEQUATIONFIT") ||
    7634         100 :                     UtilityRoutines::SameString(CoilType, "COIL:HEATING:DX:VARIABLESPEED")) {
    7635          16 :                     CoilCapacity = state.dataVariableSpeedCoils->VarSpeedCoil(WhichCoil).RatedCapHeat;
    7636          41 :                 } else if (UtilityRoutines::SameString(CoilType, "COIL:WATERHEATING:AIRTOWATERHEATPUMP:VARIABLESPEED")) {
    7637           7 :                     CoilCapacity = state.dataVariableSpeedCoils->VarSpeedCoil(WhichCoil).RatedCapWH;
    7638             :                 } else {
    7639          34 :                     CoilCapacity = state.dataVariableSpeedCoils->VarSpeedCoil(WhichCoil).RatedCapCoolTotal;
    7640             :                 }
    7641             :             }
    7642             :         } else {
    7643           0 :             WhichCoil = 0;
    7644             :         }
    7645             : 
    7646          57 :         if (WhichCoil == 0) {
    7647           0 :             ShowSevereError(state, "GetCoilCapacityVariableSpeed: Could not find CoilType=\"" + CoilType + "\" with Name=\"" + CoilName + "\"");
    7648           0 :             ErrorsFound = true;
    7649           0 :             CoilCapacity = -1000.0;
    7650             :         }
    7651             : 
    7652          57 :         return CoilCapacity;
    7653             :     }
    7654             : 
    7655          73 :     int GetCoilIndexVariableSpeed(EnergyPlusData &state,
    7656             :                                   std::string const &CoilType, // must match coil types in this module
    7657             :                                   std::string const &CoilName, // must match coil names for the coil type
    7658             :                                   bool &ErrorsFound            // set to true if problem
    7659             :     )
    7660             :     {
    7661             : 
    7662             :         // FUNCTION INFORMATION:
    7663             :         //       AUTHOR         Bo Shen, based on WaterToAirHeatPumpSimple:GetCoilIndex
    7664             :         //       DATE WRITTEN   March 2012
    7665             :         //       MODIFIED       na
    7666             :         //       RE-ENGINEERED  na
    7667             : 
    7668             :         // PURPOSE OF THIS FUNCTION:
    7669             :         // This function looks up the coil index for the given coil and returns it.  If
    7670             :         // incorrect coil type or name is given, ErrorsFound is returned as true and index is returned
    7671             :         // as zero.
    7672             : 
    7673             :         // Using/Aliasing
    7674             :         using FluidProperties::FindGlycol;
    7675             : 
    7676             :         // Return value
    7677             :         int IndexNum; // returned index of matched coil
    7678             : 
    7679             :         // Obtains and Allocates WatertoAirHP related parameters from input file
    7680          73 :         if (state.dataVariableSpeedCoils->GetCoilsInputFlag) { // First time subroutine has been entered
    7681          15 :             GetVarSpeedCoilInput(state);
    7682             :             //    WaterIndex=FindGlycol('WATER') !Initialize the WaterIndex once
    7683          15 :             state.dataVariableSpeedCoils->GetCoilsInputFlag = false;
    7684             :         }
    7685             : 
    7686          73 :         IndexNum = UtilityRoutines::FindItemInList(CoilName, state.dataVariableSpeedCoils->VarSpeedCoil);
    7687             : 
    7688          73 :         if (IndexNum == 0) {
    7689           0 :             ShowSevereError(state, "GetCoilIndexVariableSpeed: Could not find CoilType=\"" + CoilType + "\" with Name=\"" + CoilName + "\"");
    7690           0 :             ErrorsFound = true;
    7691             :         }
    7692             : 
    7693          73 :         return IndexNum;
    7694             :     }
    7695             : 
    7696          37 :     Real64 GetCoilAirFlowRateVariableSpeed(EnergyPlusData &state,
    7697             :                                            std::string const &CoilType, // must match coil types in this module
    7698             :                                            std::string const &CoilName, // must match coil names for the coil type
    7699             :                                            bool &ErrorsFound            // set to true if problem
    7700             :     )
    7701             :     {
    7702             : 
    7703             :         // FUNCTION INFORMATION:
    7704             :         //       AUTHOR         Bo Shen, based on WaterToAirHeatPumpSimple:GetCoilAirFlowRate
    7705             :         //       DATE WRITTEN   March 2012
    7706             :         //       MODIFIED       na
    7707             :         //       RE-ENGINEERED  na
    7708             : 
    7709             :         // PURPOSE OF THIS FUNCTION:
    7710             :         // This function looks up the max coil air flow rate for the given coil and returns it.  If
    7711             :         // incorrect coil type or name is given, ErrorsFound is returned as true and capacity is returned
    7712             :         // as negative.
    7713             : 
    7714             :         // Return value
    7715             :         Real64 CoilAirFlowRate; // returned air volume flow rate of matched coil
    7716             : 
    7717             :         // FUNCTION LOCAL VARIABLE DECLARATIONS:
    7718             :         int WhichCoil;
    7719             : 
    7720             :         // Obtains and Allocates WatertoAirHP related parameters from input file
    7721          37 :         if (state.dataVariableSpeedCoils->GetCoilsInputFlag) { // First time subroutine has been entered
    7722           0 :             GetVarSpeedCoilInput(state);
    7723             :             //    WaterIndex=FindGlycol('WATER') !Initialize the WaterIndex once
    7724           0 :             state.dataVariableSpeedCoils->GetCoilsInputFlag = false;
    7725             :         }
    7726             : 
    7727          97 :         if (UtilityRoutines::SameString(CoilType, "COIL:COOLING:WATERTOAIRHEATPUMP:VARIABLESPEEDEQUATIONFIT") ||
    7728          69 :             UtilityRoutines::SameString(CoilType, "COIL:HEATING:WATERTOAIRHEATPUMP:VARIABLESPEEDEQUATIONFIT") ||
    7729          48 :             UtilityRoutines::SameString(CoilType, "COIL:COOLING:DX:VARIABLESPEED") ||
    7730          76 :             UtilityRoutines::SameString(CoilType, "COIL:HEATING:DX:VARIABLESPEED") ||
    7731          37 :             UtilityRoutines::SameString(CoilType, "COIL:WATERHEATING:AIRTOWATERHEATPUMP:VARIABLESPEED")) {
    7732          37 :             WhichCoil = UtilityRoutines::FindItemInList(CoilName, state.dataVariableSpeedCoils->VarSpeedCoil);
    7733          37 :             if (WhichCoil != 0) {
    7734             :                 // CoilAirFlowRate=VarSpeedCoil(WhichCoil)%RatedAirVolFlowRate
    7735          37 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(WhichCoil).RatedAirVolFlowRate == AutoSize) { // means autosize
    7736           5 :                     CoilAirFlowRate = state.dataVariableSpeedCoils->VarSpeedCoil(WhichCoil).RatedAirVolFlowRate;
    7737             :                 } else {
    7738          96 :                     CoilAirFlowRate = state.dataVariableSpeedCoils->VarSpeedCoil(WhichCoil).MSRatedAirVolFlowRate(
    7739          64 :                                           state.dataVariableSpeedCoils->VarSpeedCoil(WhichCoil).NumOfSpeeds) /
    7740          64 :                                       state.dataVariableSpeedCoils->VarSpeedCoil(WhichCoil).MSRatedAirVolFlowRate(
    7741          32 :                                           state.dataVariableSpeedCoils->VarSpeedCoil(WhichCoil).NormSpedLevel) *
    7742          32 :                                       state.dataVariableSpeedCoils->VarSpeedCoil(WhichCoil).RatedAirVolFlowRate;
    7743             :                 } // use largest air flow rate
    7744             :             }
    7745             :         } else {
    7746           0 :             WhichCoil = 0;
    7747             :         }
    7748             : 
    7749          37 :         if (WhichCoil == 0) {
    7750           0 :             ShowSevereError(state, "GetCoilAirFlowRateVariableSpeed: Could not find CoilType=\"" + CoilType + "\" with Name=\"" + CoilName + "\"");
    7751           0 :             ErrorsFound = true;
    7752           0 :             CoilAirFlowRate = -1000.0;
    7753             :         }
    7754             : 
    7755          37 :         return CoilAirFlowRate;
    7756             :     }
    7757             : 
    7758           7 :     int GetVSCoilPLFFPLR(EnergyPlusData &state,
    7759             :                          std::string const &CoilType, // must match coil types in this module
    7760             :                          std::string const &CoilName, // must match coil names for the coil type
    7761             :                          bool &ErrorsFound            // set to true if problem
    7762             :     )
    7763             :     {
    7764             : 
    7765             :         // FUNCTION INFORMATION:
    7766             :         //       AUTHOR         Bo Shen
    7767             :         //       DATE WRITTEN   12/2014
    7768             :         //       MODIFIED       na
    7769             :         //       RE-ENGINEERED  na
    7770             : 
    7771             :         // PURPOSE OF THIS FUNCTION:
    7772             :         // This function looks up the given coil and returns PLR curve index.  If
    7773             :         // incorrect coil type or name is given, ErrorsFound is returned as true and value is returned
    7774             :         // as zero.
    7775             : 
    7776             :         // Return value
    7777             :         int PLRNumber; // returned outlet node of matched coil
    7778             : 
    7779             :         // FUNCTION LOCAL VARIABLE DECLARATIONS:
    7780             :         int WhichCoil;
    7781             : 
    7782             :         // Obtains and Allocates WatertoAirHP related parameters from input file
    7783           7 :         if (state.dataVariableSpeedCoils->GetCoilsInputFlag) { // First time subroutine has been entered
    7784           0 :             GetVarSpeedCoilInput(state);
    7785             :             //    WaterIndex=FindGlycol('WATER') !Initialize the WaterIndex once
    7786           0 :             state.dataVariableSpeedCoils->GetCoilsInputFlag = false;
    7787             :         }
    7788             : 
    7789           7 :         WhichCoil = UtilityRoutines::FindItemInList(CoilName, state.dataVariableSpeedCoils->VarSpeedCoil);
    7790           7 :         if (WhichCoil != 0) {
    7791           7 :             PLRNumber = state.dataVariableSpeedCoils->VarSpeedCoil(WhichCoil).PLFFPLR;
    7792             :         }
    7793             : 
    7794           7 :         if (WhichCoil == 0) {
    7795           0 :             ShowSevereError(state, "GetVSCoilPLFFPLR: Could not find CoilType=\"" + CoilType + "\" with Name=\"" + CoilName + "\"");
    7796           0 :             ErrorsFound = true;
    7797           0 :             PLRNumber = 0;
    7798             :         }
    7799             : 
    7800           7 :         return PLRNumber;
    7801             :     }
    7802             : 
    7803          11 :     int GetVSCoilCapFTCurveIndex(EnergyPlusData &state,
    7804             :                                  int const CoilIndex, // must match coil names for the coil type
    7805             :                                  bool &ErrorsFound    // set to true if problem
    7806             :     )
    7807             :     {
    7808             : 
    7809             :         // FUNCTION INFORMATION:
    7810             :         //       AUTHOR         Richard Raustad
    7811             :         //       DATE WRITTEN   7/2017
    7812             : 
    7813             :         // PURPOSE OF THIS FUNCTION:
    7814             :         // This function looks up the given coil and returns CapFT curve index.  If
    7815             :         // incorrect coil index is given, ErrorsFound is returned as true and value is returned
    7816             :         // as zero.
    7817             : 
    7818             :         // Return value
    7819             :         int CapFTIndex; // returned CapFT curve index of matched coil
    7820             : 
    7821             :         // Obtains and Allocates WatertoAirHP related parameters from input file
    7822          11 :         if (state.dataVariableSpeedCoils->GetCoilsInputFlag) { // First time subroutine has been entered
    7823           0 :             GetVarSpeedCoilInput(state);
    7824           0 :             state.dataVariableSpeedCoils->GetCoilsInputFlag = false;
    7825             :         }
    7826             : 
    7827          11 :         if (CoilIndex == 0) {
    7828           0 :             ShowSevereError(state, "GetVSCoilCapFTCurveIndex: Could not find Coil");
    7829           0 :             ErrorsFound = true;
    7830           0 :             CapFTIndex = 0;
    7831             :         } else {
    7832          11 :             CapFTIndex =
    7833          11 :                 state.dataVariableSpeedCoils->VarSpeedCoil(CoilIndex).MSCCapFTemp(state.dataVariableSpeedCoils->VarSpeedCoil(CoilIndex).NumOfSpeeds);
    7834             :         }
    7835             : 
    7836          11 :         return CapFTIndex;
    7837             :     }
    7838             : 
    7839        2454 :     int GetCoilInletNodeVariableSpeed(EnergyPlusData &state,
    7840             :                                       std::string const &CoilType, // must match coil types in this module
    7841             :                                       std::string const &CoilName, // must match coil names for the coil type
    7842             :                                       bool &ErrorsFound            // set to true if problem
    7843             :     )
    7844             :     {
    7845             : 
    7846             :         // FUNCTION INFORMATION:
    7847             :         //       AUTHOR         Bo Shen, based on WaterToAirHeatPumpSimple:GetCoilInletNode
    7848             :         //       DATE WRITTEN   March 2012
    7849             :         //       MODIFIED       na
    7850             :         //       RE-ENGINEERED  na
    7851             : 
    7852             :         // PURPOSE OF THIS FUNCTION:
    7853             :         // This function looks up the given coil and returns the inlet node.  If
    7854             :         // incorrect coil type or name is given, ErrorsFound is returned as true and value is returned
    7855             :         // as zero.
    7856             : 
    7857             :         // Using/Aliasing
    7858             :         using FluidProperties::FindGlycol;
    7859             : 
    7860             :         // Return value
    7861             :         int NodeNumber; // returned outlet node of matched coil
    7862             : 
    7863             :         // FUNCTION LOCAL VARIABLE DECLARATIONS:
    7864             :         int WhichCoil;
    7865             : 
    7866             :         // Obtains and Allocates WatertoAirHP related parameters from input file
    7867        2454 :         if (state.dataVariableSpeedCoils->GetCoilsInputFlag) { // First time subroutine has been entered
    7868           2 :             GetVarSpeedCoilInput(state);
    7869             :             //    WaterIndex=FindGlycol('WATER') !Initialize the WaterIndex once
    7870           2 :             state.dataVariableSpeedCoils->GetCoilsInputFlag = false;
    7871             :         }
    7872             : 
    7873        2454 :         WhichCoil = UtilityRoutines::FindItemInList(CoilName, state.dataVariableSpeedCoils->VarSpeedCoil);
    7874        2454 :         if (WhichCoil != 0) {
    7875        2454 :             NodeNumber = state.dataVariableSpeedCoils->VarSpeedCoil(WhichCoil).AirInletNodeNum;
    7876             :         }
    7877             : 
    7878        2454 :         if (WhichCoil == 0) {
    7879           0 :             ShowSevereError(state, "GetCoilInletNodeVariableSpeed: Could not find CoilType=\"" + CoilType + "\" with Name=\"" + CoilName + "\"");
    7880           0 :             ErrorsFound = true;
    7881           0 :             NodeNumber = 0;
    7882             :         }
    7883             : 
    7884        2454 :         return NodeNumber;
    7885             :     }
    7886             : 
    7887        2452 :     int GetCoilOutletNodeVariableSpeed(EnergyPlusData &state,
    7888             :                                        std::string const &CoilType, // must match coil types in this module
    7889             :                                        std::string const &CoilName, // must match coil names for the coil type
    7890             :                                        bool &ErrorsFound            // set to true if problem
    7891             :     )
    7892             :     {
    7893             : 
    7894             :         // FUNCTION INFORMATION:
    7895             :         //       AUTHOR         Bo Shen, based on WaterToAirHeatPumpSimple:GetCoilOutletNode
    7896             :         //       DATE WRITTEN   March 2012
    7897             :         //       MODIFIED       na
    7898             :         //       RE-ENGINEERED  na
    7899             : 
    7900             :         // PURPOSE OF THIS FUNCTION:
    7901             :         // This function looks up the given coil and returns the outlet node.  If
    7902             :         // incorrect coil type or name is given, ErrorsFound is returned as true and value is returned
    7903             :         // as zero.
    7904             : 
    7905             :         // Using/Aliasing
    7906             :         using FluidProperties::FindGlycol;
    7907             : 
    7908             :         // Return value
    7909             :         int NodeNumber; // returned outlet node of matched coil
    7910             : 
    7911             :         // FUNCTION LOCAL VARIABLE DECLARATIONS:
    7912             :         int WhichCoil;
    7913             : 
    7914             :         // Obtains and Allocates WatertoAirHP related parameters from input file
    7915        2452 :         if (state.dataVariableSpeedCoils->GetCoilsInputFlag) { // First time subroutine has been entered
    7916           2 :             GetVarSpeedCoilInput(state);
    7917             :             //    WaterIndex=FindGlycol('WATER') !Initialize the WaterIndex once
    7918           2 :             state.dataVariableSpeedCoils->GetCoilsInputFlag = false;
    7919             :         }
    7920             : 
    7921        2452 :         WhichCoil = UtilityRoutines::FindItemInList(CoilName, state.dataVariableSpeedCoils->VarSpeedCoil);
    7922        2452 :         if (WhichCoil != 0) {
    7923        2452 :             NodeNumber = state.dataVariableSpeedCoils->VarSpeedCoil(WhichCoil).AirOutletNodeNum;
    7924             :         }
    7925             : 
    7926        2452 :         if (WhichCoil == 0) {
    7927           0 :             ShowSevereError(state, "GetCoilOutletNodeVariableSpeed: Could not find CoilType=\"" + CoilType + "\" with Name=\"" + CoilName + "\"");
    7928           0 :             ErrorsFound = true;
    7929           0 :             NodeNumber = 0;
    7930             :         }
    7931             : 
    7932        2452 :         return NodeNumber;
    7933             :     }
    7934             : 
    7935          21 :     int GetVSCoilCondenserInletNode(EnergyPlusData &state,
    7936             :                                     std::string const &CoilName, // must match coil names for the coil type
    7937             :                                     bool &ErrorsFound            // set to true if problem
    7938             :     )
    7939             :     {
    7940             : 
    7941             :         // FUNCTION INFORMATION:
    7942             :         //       AUTHOR         Bo Shen, based on DXCoil:GetCoilCondenserInletNode
    7943             :         //       DATE WRITTEN   July 2012
    7944             :         //       MODIFIED       na
    7945             :         //       RE-ENGINEERED  na
    7946             : 
    7947             :         // PURPOSE OF THIS FUNCTION:
    7948             :         // This function looks up the given coil and returns the condenser inlet node.  If
    7949             :         // incorrect coil  name is given, ErrorsFound is returned as true.
    7950             : 
    7951             :         // Return value
    7952             :         int CondNode; // returned condenser node number of matched coil
    7953             : 
    7954             :         // FUNCTION LOCAL VARIABLE DECLARATIONS:
    7955             :         int WhichCoil;
    7956             : 
    7957             :         // Obtains and Allocates WatertoAirHP related parameters from input file
    7958          21 :         if (state.dataVariableSpeedCoils->GetCoilsInputFlag) { // First time subroutine has been entered
    7959           0 :             GetVarSpeedCoilInput(state);
    7960             :             //    WaterIndex=FindGlycol('WATER') !Initialize the WaterIndex once
    7961           0 :             state.dataVariableSpeedCoils->GetCoilsInputFlag = false;
    7962             :         }
    7963             : 
    7964          21 :         WhichCoil = UtilityRoutines::FindItemInList(CoilName, state.dataVariableSpeedCoils->VarSpeedCoil);
    7965          21 :         if (WhichCoil != 0) {
    7966          21 :             CondNode = state.dataVariableSpeedCoils->VarSpeedCoil(WhichCoil).CondenserInletNodeNum;
    7967             :         } else {
    7968           0 :             ShowSevereError(state, "GetCoilCondenserInletNode: Invalid VS DX Coil, Type= VS DX Cooling Name=\"" + CoilName + "\"");
    7969           0 :             ErrorsFound = true;
    7970           0 :             CondNode = 0;
    7971             :         }
    7972             : 
    7973          21 :         return CondNode;
    7974             :     }
    7975             : 
    7976          21 :     Real64 GetVSCoilMinOATCompressor(EnergyPlusData &state,
    7977             :                                      int const CoilIndex, // index to cooling coil
    7978             :                                      bool &ErrorsFound    // set to true if problem
    7979             :     )
    7980             :     {
    7981             :         // Obtains and Allocates WatertoAirHP related parameters from input file
    7982          21 :         if (state.dataVariableSpeedCoils->GetCoilsInputFlag) { // First time subroutine has been entered
    7983           0 :             GetVarSpeedCoilInput(state);
    7984           0 :             state.dataVariableSpeedCoils->GetCoilsInputFlag = false;
    7985             :         }
    7986             : 
    7987          21 :         if (CoilIndex == 0) {
    7988           0 :             ShowSevereError(state, "GetVSCoilMinOATCompressor: Index passed = 0");
    7989           0 :             ShowContinueError(state, "... returning Min OAT as -1000.");
    7990           0 :             ErrorsFound = true;
    7991           0 :             return -1000.0;
    7992             :         } else {
    7993          21 :             return state.dataVariableSpeedCoils->VarSpeedCoil(CoilIndex).MinOATCompressor;
    7994             :         }
    7995             :     }
    7996             : 
    7997       21398 :     int GetVSCoilNumOfSpeeds(EnergyPlusData &state,
    7998             :                              std::string const &CoilName, // must match coil names for the coil type
    7999             :                              bool &ErrorsFound            // set to true if problem
    8000             :     )
    8001             :     {
    8002             : 
    8003             :         // FUNCTION INFORMATION:
    8004             :         //       AUTHOR         Richard Raustad, FSEC
    8005             :         //       DATE WRITTEN   March 2013
    8006             :         //       MODIFIED       na
    8007             :         //       RE-ENGINEERED  na
    8008             : 
    8009             :         // PURPOSE OF THIS FUNCTION:
    8010             :         // This function looks up the given coil and returns number of speeds.  If
    8011             :         // incorrect coil name is given, ErrorsFound is returned as true.
    8012             : 
    8013             :         // Return value
    8014             :         int Speeds; // returned number of speeds
    8015             : 
    8016             :         // FUNCTION LOCAL VARIABLE DECLARATIONS:
    8017             :         int WhichCoil;
    8018             : 
    8019             :         // Obtains and Allocates WatertoAirHP related parameters from input file
    8020       21398 :         if (state.dataVariableSpeedCoils->GetCoilsInputFlag) { // First time subroutine has been entered
    8021           0 :             GetVarSpeedCoilInput(state);
    8022           0 :             state.dataVariableSpeedCoils->GetCoilsInputFlag = false;
    8023             :         }
    8024             : 
    8025       21398 :         WhichCoil = UtilityRoutines::FindItemInList(CoilName, state.dataVariableSpeedCoils->VarSpeedCoil);
    8026       21398 :         if (WhichCoil != 0) {
    8027       21398 :             Speeds = state.dataVariableSpeedCoils->VarSpeedCoil(WhichCoil).NumOfSpeeds;
    8028             :         } else {
    8029           0 :             ShowSevereError(state, "GetVSCoilNumOfSpeeds: Invalid VS DX Coil, Type= VS DX Coil Name=\"" + CoilName + "\"");
    8030           0 :             ErrorsFound = true;
    8031           0 :             Speeds = 0;
    8032             :         }
    8033             : 
    8034       21398 :         return Speeds;
    8035             :     }
    8036             : 
    8037          88 :     Real64 GetVSCoilRatedSourceTemp(EnergyPlusData &state, int const CoilIndex)
    8038             :     {
    8039          88 :         Real64 RatedSourceTemp = 0.0;
    8040          88 :         switch (state.dataVariableSpeedCoils->VarSpeedCoil(CoilIndex).VSCoilType) {
    8041          21 :         case DataHVACGlobals::Coil_CoolingWaterToAirHPVSEquationFit: {
    8042          21 :             RatedSourceTemp = RatedInletWaterTemp;
    8043          21 :         } break;
    8044          19 :         case DataHVACGlobals::Coil_HeatingWaterToAirHPVSEquationFit: {
    8045          19 :             RatedSourceTemp = RatedInletWaterTempHeat;
    8046          19 :         } break;
    8047          16 :         case DataHVACGlobals::CoilDX_HeatPumpWaterHeaterVariableSpeed: {
    8048          16 :             RatedSourceTemp = state.dataVariableSpeedCoils->VarSpeedCoil(CoilIndex).WHRatedInletWaterTemp;
    8049          16 :         } break;
    8050          22 :         case DataHVACGlobals::Coil_CoolingAirToAirVariableSpeed: {
    8051          22 :             RatedSourceTemp = RatedAmbAirTemp;
    8052          22 :         } break;
    8053          10 :         case DataHVACGlobals::Coil_HeatingAirToAirVariableSpeed: {
    8054          10 :             RatedSourceTemp = RatedAmbAirTempHeat;
    8055          10 :         } break;
    8056           0 :         default: {
    8057           0 :             assert(false);
    8058             :         } break;
    8059             :         }
    8060          88 :         return RatedSourceTemp;
    8061             :     }
    8062             : 
    8063          33 :     void SetVarSpeedCoilData(EnergyPlusData &state,
    8064             :                              int const WSHPNum,                    // Number of OA Controller
    8065             :                              bool &ErrorsFound,                    // Set to true if certain errors found
    8066             :                              Optional_int CompanionCoolingCoilNum, // Index to cooling coil for heating coil = SimpleWSHPNum
    8067             :                              Optional_int CompanionHeatingCoilNum, // Index to heating coil for cooling coil = SimpleWSHPNum
    8068             :                              Optional_int MSHPDesignSpecIndex      // index to UnitarySystemPerformance:Multispeed object
    8069             :     )
    8070             :     {
    8071             : 
    8072             :         // SUBROUTINE INFORMATION:
    8073             :         //       AUTHOR         Bo Shen, based on WaterToAirHeatPumpSimple:SetWSHPData
    8074             :         //       DATE WRITTEN   March 2012
    8075             :         //       MODIFIED       na
    8076             :         //       RE-ENGINEERED  na
    8077             : 
    8078             :         // PURPOSE OF THIS SUBROUTINE:
    8079             :         // This routine was designed to "push" information from a parent object to
    8080             :         // this WSHP coil object.
    8081             : 
    8082             :         // Using/Aliasing
    8083             :         using FluidProperties::FindGlycol;
    8084             : 
    8085             :         // Obtains and Allocates WatertoAirHP related parameters from input file
    8086          33 :         if (state.dataVariableSpeedCoils->GetCoilsInputFlag) { // First time subroutine has been entered
    8087           0 :             GetVarSpeedCoilInput(state);
    8088             :             //    WaterIndex=FindGlycol('WATER') !Initialize the WaterIndex once
    8089           0 :             state.dataVariableSpeedCoils->GetCoilsInputFlag = false;
    8090             :         }
    8091             : 
    8092          33 :         if (WSHPNum <= 0 || WSHPNum > state.dataVariableSpeedCoils->NumVarSpeedCoils) {
    8093           0 :             ShowSevereError(state,
    8094           0 :                             format("SetVarSpeedCoilData: called with VS WSHP Coil Number out of range={} should be >0 and <{}",
    8095             :                                    WSHPNum,
    8096           0 :                                    state.dataVariableSpeedCoils->NumVarSpeedCoils));
    8097           0 :             ErrorsFound = true;
    8098           0 :             return;
    8099             :         }
    8100             : 
    8101          33 :         if (present(CompanionCoolingCoilNum)) {
    8102           0 :             state.dataVariableSpeedCoils->VarSpeedCoil(WSHPNum).CompanionCoolingCoilNum = CompanionCoolingCoilNum;
    8103           0 :             state.dataVariableSpeedCoils->VarSpeedCoil(WSHPNum).FindCompanionUpStreamCoil = true;
    8104           0 :             state.dataVariableSpeedCoils->VarSpeedCoil(CompanionCoolingCoilNum).CompanionHeatingCoilNum = WSHPNum;
    8105             :         }
    8106             : 
    8107          33 :         if (present(CompanionHeatingCoilNum)) {
    8108          21 :             state.dataVariableSpeedCoils->VarSpeedCoil(WSHPNum).CompanionHeatingCoilNum = CompanionHeatingCoilNum;
    8109          21 :             state.dataVariableSpeedCoils->VarSpeedCoil(CompanionHeatingCoilNum).CompanionCoolingCoilNum = WSHPNum;
    8110             :         }
    8111             : 
    8112          33 :         if (present(MSHPDesignSpecIndex)) {
    8113          12 :             state.dataVariableSpeedCoils->VarSpeedCoil(WSHPNum).MSHPDesignSpecIndex = MSHPDesignSpecIndex;
    8114             :         }
    8115             :     }
    8116             : 
    8117    43381475 :     void UpdateVarSpeedCoil(EnergyPlusData &state, int const DXCoilNum)
    8118             :     {
    8119             :         // SUBROUTINE INFORMATION:
    8120             :         //       AUTHOR         Bo Shen, based on WaterToAirHeatPumpSimple:UpdateSimpleWSHP
    8121             :         //       DATE WRITTEN   March 2012
    8122             :         //       MODIFIED       na
    8123             :         //       RE-ENGINEERED  na
    8124             : 
    8125             :         // PURPOSE OF THIS SUBROUTINE:
    8126             :         // This subroutine updates the Water to Air Heat Pump outlet nodes.
    8127             : 
    8128             :         // METHODOLOGY EMPLOYED:
    8129             :         // Data is moved from the HP data structure to the HP outlet nodes.
    8130             : 
    8131             :         // Using/Aliasing
    8132    43381475 :         auto &TimeStepSys = state.dataHVACGlobal->TimeStepSys;
    8133             :         using PlantUtilities::SafeCopyPlantNode;
    8134             : 
    8135             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    8136             :         int AirInletNode;
    8137             :         int WaterInletNode;
    8138             :         int AirOutletNode;
    8139             :         int WaterOutletNode;
    8140             :         Real64 ReportingConstant;
    8141             : 
    8142             :         // WatertoAirHP(DXCoilNum)%SimFlag=.FALSE.
    8143    43381475 :         if (!state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).SimFlag) {
    8144             :             // Heatpump is off; just pass through conditions
    8145    12170466 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Power = 0.0;
    8146    12170466 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLoadTotal = 0.0;
    8147    12170466 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSensible = 0.0;
    8148    12170466 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLatent = 0.0;
    8149    12170466 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSource = 0.0;
    8150    12170466 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Energy = 0.0;
    8151    12170466 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLoadTotal = 0.0;
    8152    12170466 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergySensible = 0.0;
    8153    12170466 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLatent = 0.0;
    8154    12170466 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergySource = 0.0;
    8155    12170466 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).COP = 0.0;
    8156    12170466 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RunFrac = 0.0;
    8157    12170466 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PartLoadRatio = 0.0;
    8158             : 
    8159    12170466 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirDBTemp =
    8160    12170466 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirDBTemp;
    8161    12170466 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirHumRat =
    8162    12170466 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirHumRat;
    8163    12170466 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirEnthalpy =
    8164    12170466 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletAirEnthalpy;
    8165    12170466 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletWaterTemp =
    8166    12170466 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterTemp;
    8167    12170466 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletWaterEnthalpy =
    8168    12170466 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).InletWaterEnthalpy;
    8169             :         }
    8170             : 
    8171    43381475 :         AirInletNode = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirInletNodeNum;
    8172    43381475 :         WaterInletNode = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterInletNodeNum;
    8173    43381475 :         AirOutletNode = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).AirOutletNodeNum;
    8174    43381475 :         WaterOutletNode = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).WaterOutletNodeNum;
    8175             : 
    8176             :         // Set the air outlet  nodes of the WatertoAirHPSimple
    8177    43381475 :         state.dataLoopNodes->Node(AirOutletNode).MassFlowRate = state.dataLoopNodes->Node(AirInletNode).MassFlowRate; // LoadSideMassFlowRate
    8178    43381475 :         state.dataLoopNodes->Node(AirOutletNode).Temp = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirDBTemp;
    8179    43381475 :         state.dataLoopNodes->Node(AirOutletNode).HumRat = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirHumRat;
    8180    43381475 :         state.dataLoopNodes->Node(AirOutletNode).Enthalpy = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletAirEnthalpy;
    8181             : 
    8182             :         // Set the air outlet nodes for properties that just pass through & not used
    8183    43381475 :         state.dataLoopNodes->Node(AirOutletNode).Quality = state.dataLoopNodes->Node(AirInletNode).Quality;
    8184    43381475 :         state.dataLoopNodes->Node(AirOutletNode).Press = state.dataLoopNodes->Node(AirInletNode).Press;
    8185    43381475 :         state.dataLoopNodes->Node(AirOutletNode).MassFlowRateMin = state.dataLoopNodes->Node(AirInletNode).MassFlowRateMin;
    8186    43381475 :         state.dataLoopNodes->Node(AirOutletNode).MassFlowRateMax = state.dataLoopNodes->Node(AirInletNode).MassFlowRateMax; // LoadSideMassFlowRate
    8187    43381475 :         state.dataLoopNodes->Node(AirOutletNode).MassFlowRateMinAvail = state.dataLoopNodes->Node(AirInletNode).MassFlowRateMinAvail;
    8188    43381475 :         state.dataLoopNodes->Node(AirOutletNode).MassFlowRateMaxAvail =
    8189    43381475 :             state.dataLoopNodes->Node(AirInletNode).MassFlowRateMaxAvail; // LoadSideMassFlowRate
    8190             : 
    8191             :         // Set the water outlet node of the WatertoAirHPSimple
    8192             :         // Set the water outlet nodes for properties that just pass through & not used
    8193    43381475 :         if (WaterInletNode != 0 && WaterOutletNode != 0) {
    8194    10625351 :             SafeCopyPlantNode(state, WaterInletNode, WaterOutletNode);
    8195    10625351 :             state.dataLoopNodes->Node(WaterOutletNode).Temp = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletWaterTemp;
    8196    10625351 :             state.dataLoopNodes->Node(WaterOutletNode).Enthalpy = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).OutletWaterEnthalpy;
    8197             :         }
    8198             : 
    8199    43381475 :         ReportingConstant = TimeStepSys * DataGlobalConstants::SecInHour;
    8200    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Energy =
    8201    43381475 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Power * ReportingConstant;
    8202    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLoadTotal =
    8203    43381475 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLoadTotal * ReportingConstant;
    8204    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergySensible =
    8205    43381475 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSensible * ReportingConstant;
    8206    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergyLatent =
    8207    43381475 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QLatent * ReportingConstant;
    8208    43381475 :         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).EnergySource =
    8209    43381475 :             state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).QSource * ReportingConstant;
    8210             : 
    8211    43381475 :         if (state.dataContaminantBalance->Contaminant.CO2Simulation) {
    8212           0 :             state.dataLoopNodes->Node(AirOutletNode).CO2 = state.dataLoopNodes->Node(AirInletNode).CO2;
    8213             :         }
    8214             : 
    8215    43381475 :         if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).reportCoilFinalSizes) {
    8216     4582320 :             if (!state.dataGlobal->WarmupFlag && !state.dataGlobal->DoingHVACSizingSimulations && !state.dataGlobal->DoingSizing) {
    8217         127 :                 if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_CoolingWaterToAirHPVSEquationFit ||
    8218          55 :                     state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_CoolingAirToAirVariableSpeed) { // cooling coil
    8219         259 :                     state.dataRptCoilSelection->coilSelectionReportObj->setCoilFinalSizes(
    8220             :                         state,
    8221          37 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    8222          37 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VarSpeedCoilType,
    8223          37 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedCapCoolTotal,
    8224          37 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedCapCoolSens,
    8225          37 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedAirVolFlowRate,
    8226          37 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedWaterMassFlowRate);
    8227          53 :                 } else if (state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_HeatingWaterToAirHPVSEquationFit ||
    8228          18 :                            state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VSCoilType == Coil_HeatingAirToAirVariableSpeed) { // heating coil
    8229         175 :                     state.dataRptCoilSelection->coilSelectionReportObj->setCoilFinalSizes(
    8230             :                         state,
    8231          25 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Name,
    8232          25 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).VarSpeedCoilType,
    8233          25 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedCapHeat,
    8234          25 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedCapHeat,
    8235          25 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedAirVolFlowRate,
    8236          25 :                         state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).RatedWaterMassFlowRate);
    8237             :                 }
    8238          72 :                 state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).reportCoilFinalSizes = false;
    8239             :             }
    8240             :         }
    8241    43381475 :     }
    8242             : 
    8243       17388 :     Real64 CalcEffectiveSHR(EnergyPlusData &state,
    8244             :                             int const DXCoilNum,     // Index number for cooling coil
    8245             :                             Real64 const SHRss,      // Steady-state sensible heat ratio
    8246             :                             int const CyclingScheme, // Fan/compressor cycling scheme indicator
    8247             :                             Real64 const RTF,        // Compressor run-time fraction
    8248             :                             Real64 const QLatRated,  // Rated latent capacity
    8249             :                             Real64 const QLatActual, // Actual latent capacity
    8250             :                             Real64 const EnteringDB, // Entering air dry-bulb temperature
    8251             :                             Real64 const EnteringWB  // Entering air wet-bulb temperature
    8252             :     )
    8253             :     {
    8254             : 
    8255             :         // FUNCTION INFORMATION:
    8256             :         //    AUTHOR         Bo Shen, based on WaterToAirHeatPumpSimple:CalcEffectiveSHR
    8257             :         //    DATE WRITTEN   March 2012
    8258             : 
    8259             :         // PURPOSE OF THIS FUNCTION:
    8260             :         //    Adjust sensible heat ratio to account for degradation of DX coil latent
    8261             :         //    capacity at part-load (cycling) conditions.
    8262             : 
    8263             :         // METHODOLOGY EMPLOYED:
    8264             :         //    With model parameters entered by the user, the part-load latent performance
    8265             :         //    of a DX cooling coil is determined for a constant air flow system with
    8266             :         //    a cooling coil that cycles on/off. The model calculates the time
    8267             :         //    required for condensate to begin falling from the cooling coil.
    8268             :         //    Runtimes greater than this are integrated to a "part-load" latent
    8269             :         //    capacity which is used to determine the "part-load" sensible heat ratio.
    8270             :         //    See reference below for additional details (linear decay model, Eq. 8b).
    8271             : 
    8272             :         //    For cycling fan operation, a modified version of Henderson and Rengarajan (1996)
    8273             :         //    model is used by ultilizing the fan delay time as the time-off (or time duration
    8274             :         //    for the re-evaporation of moisture from time coil). Refer to Tang, C.C. (2005)
    8275             : 
    8276             :         // REFERENCES:
    8277             :         // na
    8278             : 
    8279             :         // Return value
    8280             :         Real64 SHReff; // Effective sensible heat ratio, includes degradation due to cycling effects
    8281             : 
    8282             :         // FUNCTION LOCAL VARIABLE DECLARATIONS:
    8283             :         Real64 Twet; // Nominal time for condensate to begin leaving the coil's condensate drain line
    8284             :         // at the current operating conditions (sec)
    8285             :         Real64 Gamma; // Initial moisture evaporation rate divided by steady-state AC latent capacity
    8286             :         // at the current operating conditions
    8287             :         Real64 Twet_Rated;            // Twet at rated conditions (coil air flow rate and air temperatures), sec
    8288             :         Real64 Gamma_Rated;           // Gamma at rated conditions (coil air flow rate and air temperatures)
    8289             :         Real64 Twet_max;              // Maximum allowed value for Twet
    8290             :         Real64 MaxONOFFCyclesperHour; // Maximum cycling rate of heat pump [cycles/hr]
    8291             :         Real64 HPTimeConstant;        // Heat pump time constant [s]
    8292             :         Real64 FanDelayTime;          // Fan delay time, time delay for the HP's fan to
    8293             :         // shut off after compressor cycle off  [s]
    8294             :         Real64 Ton;     // Coil on time (sec)
    8295             :         Real64 Toff;    // Coil off time (sec)
    8296             :         Real64 Toffa;   // Actual coil off time (sec). Equations valid for Toff <= (2.0 * Twet/Gamma)
    8297             :         Real64 aa;      // Intermediate variable
    8298             :         Real64 To1;     // Intermediate variable (first guess at To). To = time to the start of moisture removal
    8299             :         Real64 To2;     // Intermediate variable (second guess at To). To = time to the start of moisture removal
    8300             :         Real64 Error;   // Error for iteration (DO) loop
    8301             :         Real64 LHRmult; // Latent Heat Ratio (LHR) multiplier. The effective latent heat ratio LHR = (1-SHRss)*LHRmult
    8302             : 
    8303       17388 :         Twet_Rated = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Twet_Rated;
    8304       17388 :         Gamma_Rated = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).Gamma_Rated;
    8305       17388 :         MaxONOFFCyclesperHour = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).MaxONOFFCyclesperHour;
    8306       17388 :         HPTimeConstant = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).HPTimeConstant;
    8307       17388 :         FanDelayTime = state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).FanDelayTime;
    8308             : 
    8309             :         //  No moisture evaporation (latent degradation) occurs for runtime fraction of 1.0
    8310             :         //  All latent degradation model parameters cause divide by 0.0 if not greater than 0.0
    8311             :         //  Latent degradation model parameters initialize to 0.0 meaning no evaporation model used.
    8312       17388 :         if ((RTF >= 1.0) || (QLatRated == 0.0) || (QLatActual == 0.0) || (Twet_Rated <= 0.0) || (Gamma_Rated <= 0.0) ||
    8313       11725 :             (MaxONOFFCyclesperHour <= 0.0) || (HPTimeConstant <= 0.0) || (RTF <= 0.0)) {
    8314        5663 :             SHReff = SHRss;
    8315        5663 :             return SHReff;
    8316             :         }
    8317             : 
    8318       11725 :         Twet_max = 9999.0; // high limit for Twet
    8319             : 
    8320             :         //  Calculate the model parameters at the actual operating conditions
    8321       11725 :         Twet = min(Twet_Rated * QLatRated / (QLatActual + 1.e-10), Twet_max);
    8322       11725 :         Gamma = Gamma_Rated * QLatRated * (EnteringDB - EnteringWB) / ((26.7 - 19.4) * QLatActual + 1.e-10);
    8323             : 
    8324             :         //  Calculate the compressor on and off times using a converntional thermostat curve
    8325       11725 :         Ton = 3600.0 / (4.0 * MaxONOFFCyclesperHour * (1.0 - RTF)); // duration of cooling coil on-cycle (sec)
    8326             : 
    8327       11725 :         if ((CyclingScheme == CycFanCycCoil) && (FanDelayTime != 0.0)) {
    8328             :             // For CycFanCycCoil, moisture is evaporated from the cooling coil back to the air stream
    8329             :             // until the fan cycle off. Assume no evaporation from the coil after the fan shuts off.
    8330           0 :             Toff = FanDelayTime;
    8331             :         } else {
    8332             :             // For ContFanCycCoil, moisture is evaporated from the cooling coil back to the air stream
    8333             :             // for the entire heat pump off-cycle.
    8334       11725 :             Toff = 3600.0 / (4.0 * MaxONOFFCyclesperHour * RTF); // duration of cooling coil off-cycle (sec)
    8335             :         }
    8336             : 
    8337             :         //  Cap Toff to meet the equation restriction
    8338       11725 :         if (Gamma > 0.0) {
    8339       11725 :             Toffa = min(Toff, 2.0 * Twet / Gamma);
    8340             :         } else {
    8341           0 :             Toffa = Toff;
    8342             :         }
    8343             : 
    8344             :         //  Use sucessive substitution to solve for To
    8345       11725 :         aa = (Gamma * Toffa) - (0.25 / Twet) * pow_2(Gamma) * pow_2(Toffa);
    8346             : 
    8347       11725 :         To1 = aa + HPTimeConstant;
    8348       11725 :         Error = 1.0;
    8349       35175 :         while (Error > 0.001) {
    8350       11725 :             To2 = aa - HPTimeConstant * (std::exp(-To1 / HPTimeConstant) - 1.0);
    8351       11725 :             Error = std::abs((To2 - To1) / To1);
    8352       11725 :             To1 = To2;
    8353             :         }
    8354             : 
    8355             :         //  Adjust Sensible Heat Ratio (SHR) using Latent Heat Ratio (LHR) multiplier
    8356             :         //  Floating underflow errors occur when -Ton/HPTimeConstant is a large negative number.
    8357             :         //  Cap lower limit at -700 to avoid the underflow errors.
    8358       11725 :         aa = std::exp(max(-700.0, -Ton / HPTimeConstant));
    8359             :         //  Calculate latent heat ratio multiplier
    8360       11725 :         LHRmult = max(((Ton - To2) / (Ton + HPTimeConstant * (aa - 1.0))), 0.0);
    8361             : 
    8362             :         //  Calculate part-load or "effective" sensible heat ratio
    8363       11725 :         SHReff = 1.0 - (1.0 - SHRss) * LHRmult;
    8364             : 
    8365       11725 :         if (SHReff < SHRss) SHReff = SHRss; // Effective SHR can be less than the steady-state SHR
    8366       11725 :         if (SHReff > 1.0) SHReff = 1.0;     // Effective sensible heat ratio can't be greater than 1.0
    8367             : 
    8368       11725 :         return SHReff;
    8369             :     }
    8370             : 
    8371    49730933 :     void CalcTotCapSHR_VSWSHP(EnergyPlusData &state,
    8372             :                               Real64 const InletDryBulb,       // inlet air dry bulb temperature [C]
    8373             :                               Real64 const InletHumRat,        // inlet air humidity ratio [kg water / kg dry air]
    8374             :                               Real64 const InletEnthalpy,      // inlet air specific enthalpy [J/kg]
    8375             :                               Real64 &InletWetBulb,            // inlet air wet bulb temperature [C]
    8376             :                               Real64 const AirMassFlowRatio,   // Ratio of actual air mass flow to nominal air mass flow
    8377             :                               Real64 const WaterMassFlowRatio, // Ratio of actual water mass flow to nominal water mass flow
    8378             :                               Real64 const AirMassFlow,        // actual mass flow for capacity and SHR calculation
    8379             :                               Real64 const CBF,                // coil bypass factor
    8380             :                               Real64 const TotCapNom1,         // nominal total capacity at low speed [W]
    8381             :                               int const CCapFTemp1,            // capacity modifier curve index, function of entering wetbulb at low speed
    8382             :                               int const CCapAirFFlow1,         // capacity modifier curve, function of actual air flow vs rated flow at low speed
    8383             :                               int const CCapWaterFFlow1,       // capacity modifier curve, function of actual water flow vs rated flow at low speed
    8384             :                               Real64 const TotCapNom2,         // nominal total capacity at high speed [W]
    8385             :                               int const CCapFTemp2,            // capacity modifier curve index, function of entering wetbulb at high speed
    8386             :                               int const CCapAirFFlow2,         // capacity modifier curve, function of actual air flow vs rated flow at high speed
    8387             :                               int const CCapWaterFFlow2,       // capacity modifier curve, function of actual water flow vs rated flow at high speed
    8388             :                               Real64 &TotCap1,                 // total capacity at the given conditions [W] at low speed
    8389             :                               Real64 &TotCap2,                 // total capacity at the given conditions [W] at high speed
    8390             :                               Real64 &TotCapSpeed,             // integrated total capacity corresponding to the speed ratio
    8391             :                               Real64 &SHR,                     // sensible heat ratio at the given conditions
    8392             :                               Real64 const CondInletTemp,      // Condenser inlet temperature [C]
    8393             :                               Real64 const Pressure,           // air pressure [Pa]
    8394             :                               Real64 const SpeedRatio,         // from 0.0 to 1.0
    8395             :                               int const NumSpeeds,             // number of speeds for input
    8396             :                               Real64 &TotCapModFac             // capacity modification factor, func of temp and func of flow
    8397             :     )
    8398             :     {
    8399             : 
    8400             :         // SUBROUTINE INFORMATION:
    8401             :         //       AUTHOR         Bo Shen, , based on DX:CalcTotCapSHR, introducing two speed levels
    8402             :         //       DATE WRITTEN   March 2012
    8403             : 
    8404             :         // PURPOSE OF THIS SUBROUTINE:
    8405             :         // Calculates total capacity and sensible heat ratio of a DX coil at the specified conditions
    8406             : 
    8407             :         // METHODOLOGY EMPLOYED:
    8408             :         // With the rated performance data entered by the user, the model employs some of the
    8409             :         // DOE-2.1E curve fits to adjust the capacity and SHR of the unit as a function
    8410             :         // of entering air temperatures and supply air flow rate (actual vs rated flow). The model
    8411             :         // does NOT employ the exact same methodology to calculate performance as DOE-2, although
    8412             :         // some of the DOE-2 curve fits are employed by this model.
    8413             : 
    8414             :         // The model checks for coil dryout conditions, and adjusts the calculated performance
    8415             :         // appropriately.
    8416             : 
    8417             :         // REFERENCES:
    8418             :         // ASHRAE HVAC 2 Toolkit page 4-81.
    8419             :         // Henderson, H.I. Jr., K. Rengarajan and D.B. Shirey, III. 1992.The impact of comfort
    8420             :         // control on air conditioner energy use in humid climates. ASHRAE Transactions 98(2):
    8421             :         // 104-113.
    8422             :         // Henderson, H.I. Jr., Danny Parker and Y.J. Huang. 2000.Improving DOE-2's RESYS routine:
    8423             :         // User Defined Functions to Provide More Accurate Part Load Energy Use and Humidity
    8424             :         // Predictions. Proceedings of ACEEE Conference.
    8425             : 
    8426             :         // Using/Aliasing
    8427             :         using Curve::CurveValue;
    8428             : 
    8429             :         // SUBROUTINE PARAMETER DEFINITIONS:
    8430             :         static constexpr std::string_view RoutineName("CalcTotCapSHR_VSWSHP");
    8431    49730933 :         constexpr int MaxIter(30);        // Maximum number of iterations for dry evaporator calculations
    8432    49730933 :         constexpr Real64 Tolerance(0.01); // Error tolerance for dry evaporator iterations
    8433             : 
    8434             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    8435             :         Real64 TotCapWaterFlowModFac1; // Total capacity modifier (function of actual supply water flow vs nominal flow) at low speed
    8436             :         Real64 TotCapTempModFac2;      // Total capacity modifier (function of entering wetbulb, outside water inlet temp) at high speed
    8437             :         Real64 TotCapAirFlowModFac2;   // Total capacity modifier (function of actual supply air flow vs nominal flow) at high speed
    8438             :         Real64 TotCapWaterFlowModFac2; // Total capacity modifier (function of actual supply water flow vs nominal flow) at high speed
    8439             :         Real64 TotCapCalc;             // temporary calculated value of total capacity [W]
    8440             :         Real64 TotCapCalc1;            // temporary calculated value of total capacity [W] at low speed
    8441             :         Real64 TotCapCalc2;            // temporary calculated value of total capacity [W] at high speed
    8442             : 
    8443    49730933 :         int Counter = 0;                        // Error tolerance for dry evaporator iterations
    8444    49730933 :         Real64 RF = 0.4;                        // Relaxation factor for dry evaporator iterations
    8445    49730933 :         Real64 werror = 0.0;                    // Deviation of humidity ratio in dry evaporator iteration loop
    8446    49730933 :         Real64 SHRCalc = SHR;                   // initialize temporary calculated value of SHR
    8447    49730933 :         Real64 InletWetBulbCalc = InletWetBulb; // calculated inlet wetbulb temperature used for finding dry coil point [C]
    8448    49730933 :         Real64 InletHumRatCalc = InletHumRat;   // calculated inlet humidity ratio used for finding dry coil point [kg water / kg dry air]
    8449    49730933 :         bool LoopOn = true;                     // flag to control the loop iteration
    8450             : 
    8451             :         //  LOOP WHILE (ABS(werror) .gt. Tolerance .OR. Counter == 0)
    8452   149243601 :         while (LoopOn) {
    8453             :             //   Get capacity modifying factor (function of inlet wetbulb & condenser inlet temp) for off-rated conditions
    8454    49756334 :             Real64 TotCapTempModFac1 = CurveValue(state, CCapFTemp1, InletWetBulbCalc, CondInletTemp);
    8455             :             //   Get capacity modifying factor (function of mass flow) for off-rated conditions
    8456    49756334 :             Real64 TotCapAirFlowModFac1 = CurveValue(state, CCapAirFFlow1, AirMassFlowRatio);
    8457             :             // Get capacity modifying factor (function of mass flow) for off-rated conditions
    8458    49756334 :             if (CCapWaterFFlow1 == 0) {
    8459    45842281 :                 TotCapWaterFlowModFac1 = 1.0;
    8460             :             } else {
    8461     3914053 :                 TotCapWaterFlowModFac1 = CurveValue(state, CCapWaterFFlow1, WaterMassFlowRatio);
    8462             :             }
    8463             : 
    8464             :             //   Get total capacity
    8465    49756334 :             if (NumSpeeds < 2) { // ONLY ONE SPEED
    8466    42826112 :                 TotCapCalc = TotCapNom1 * TotCapAirFlowModFac1 * TotCapWaterFlowModFac1 * TotCapTempModFac1;
    8467    42826112 :                 TotCapCalc1 = TotCapCalc;
    8468    42826112 :                 TotCapCalc2 = 0.0;
    8469    42826112 :                 TotCapModFac = TotCapAirFlowModFac1 * TotCapWaterFlowModFac1 * TotCapTempModFac1;
    8470             :             } else {
    8471     6930222 :                 TotCapTempModFac2 = CurveValue(state, CCapFTemp2, InletWetBulbCalc, CondInletTemp);
    8472     6930222 :                 TotCapAirFlowModFac2 = CurveValue(state, CCapAirFFlow2, AirMassFlowRatio);
    8473             : 
    8474     6930222 :                 if (CCapWaterFFlow2 == 0) {
    8475     6594578 :                     TotCapWaterFlowModFac2 = 1.0;
    8476             :                 } else {
    8477      335644 :                     TotCapWaterFlowModFac2 = CurveValue(state, CCapWaterFFlow2, WaterMassFlowRatio);
    8478             :                 }
    8479             : 
    8480     6930222 :                 TotCapCalc1 = TotCapNom1 * TotCapAirFlowModFac1 * TotCapWaterFlowModFac1 * TotCapTempModFac1;
    8481     6930222 :                 TotCapCalc2 = TotCapNom2 * TotCapAirFlowModFac2 * TotCapWaterFlowModFac2 * TotCapTempModFac2;
    8482             : 
    8483     6930222 :                 TotCapCalc = TotCapCalc2 * SpeedRatio + (1.0 - SpeedRatio) * TotCapCalc1;
    8484    13860444 :                 TotCapModFac = (TotCapAirFlowModFac2 * TotCapWaterFlowModFac2 * TotCapTempModFac2) * SpeedRatio +
    8485     6930222 :                                (1.0 - SpeedRatio) * (TotCapAirFlowModFac1 * TotCapWaterFlowModFac1 * TotCapTempModFac1);
    8486             :             }
    8487             : 
    8488    49756334 :             Real64 localCBF = max(0.0, CBF); // negative coil bypass factor is physically impossible
    8489             : 
    8490             :             //   Calculate apparatus dew point conditions using TotCap and CBF
    8491    49756334 :             Real64 hDelta = TotCapCalc / AirMassFlow;                       // Change in air enthalpy across the cooling coil [J/kg]
    8492    49756334 :             Real64 hADP = InletEnthalpy - hDelta / (1.0 - localCBF);        // Apparatus dew point enthalpy [J/kg]
    8493    49756334 :             Real64 tADP = PsyTsatFnHPb(state, hADP, Pressure, RoutineName); // Apparatus dew point temperature [C]
    8494    49756334 :             Real64 wADP = PsyWFnTdbH(state, tADP, hADP, RoutineName);       // Apparatus dew point humidity ratio [kg/kg]
    8495    49756334 :             Real64 hTinwADP = PsyHFnTdbW(InletDryBulb, wADP);               // Enthalpy at inlet dry-bulb and wADP [J/kg]
    8496    49756334 :             SHRCalc = min((hTinwADP - hADP) / (InletEnthalpy - hADP), 1.0); // temporary calculated value of SHR
    8497             : 
    8498             :             //   Check for dry evaporator conditions (win < wadp)
    8499    49756334 :             if (wADP > InletHumRatCalc || (Counter >= 1 && Counter < MaxIter)) {
    8500       34082 :                 if (InletHumRatCalc == 0.0) InletHumRatCalc = 0.00001;
    8501       34082 :                 werror = (InletHumRatCalc - wADP) / InletHumRatCalc;
    8502             :                 //     Increase InletHumRatCalc at constant inlet air temp to find coil dry-out point. Then use the
    8503             :                 //     capacity at the dry-out point to determine exiting conditions from coil. This is required
    8504             :                 //     since the TotCapTempModFac doesn't work properly with dry-coil conditions.
    8505       34082 :                 InletHumRatCalc = RF * wADP + (1.0 - RF) * InletHumRatCalc;
    8506       34082 :                 InletWetBulbCalc = PsyTwbFnTdbWPb(state, InletDryBulb, InletHumRatCalc, Pressure);
    8507       34082 :                 ++Counter;
    8508       68164 :                 if (std::abs(werror) > Tolerance) {
    8509       25401 :                     LoopOn = true; // Recalculate with modified inlet conditions
    8510             :                 } else {
    8511        8681 :                     LoopOn = false;
    8512             :                 }
    8513             :             } else {
    8514    49722252 :                 LoopOn = false;
    8515             :             }
    8516             :         } // END LOOP
    8517             : 
    8518             :         //  Calculate full load output conditions
    8519    49730933 :         if (SHRCalc > 1.0 || Counter > 0) SHRCalc = 1.0; // if Counter > 0 means a dry coil so SHR = 1
    8520             : 
    8521    49730933 :         SHR = SHRCalc;
    8522    49730933 :         TotCap1 = TotCapCalc1;
    8523    49730933 :         TotCap2 = TotCapCalc2;
    8524    49730933 :         TotCapSpeed = TotCapCalc;
    8525    49730933 :         InletWetBulb = InletWetBulbCalc;
    8526    49730933 :     }
    8527             : 
    8528       21396 :     Real64 getVarSpeedPartLoadRatio(EnergyPlusData &state, int const DXCoilNum)
    8529             :     {
    8530       21396 :         return state.dataVariableSpeedCoils->VarSpeedCoil(DXCoilNum).PartLoadRatio;
    8531             :     }
    8532             : 
    8533             : } // namespace VariableSpeedCoils
    8534             : 
    8535        2313 : } // namespace EnergyPlus

Generated by: LCOV version 1.13