LCOV - code coverage report
Current view: top level - EnergyPlus - WaterToAirHeatPumpSimple.cc (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 1501 2102 71.4 %
Date: 2024-08-23 23:50:59 Functions: 14 15 93.3 %

          Line data    Source code
       1             : // EnergyPlus, Copyright (c) 1996-2024, The Board of Trustees of the University of Illinois,
       2             : // The Regents of the University of California, through Lawrence Berkeley National Laboratory
       3             : // (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge
       4             : // National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other
       5             : // contributors. All rights reserved.
       6             : //
       7             : // NOTICE: This Software was developed under funding from the U.S. Department of Energy and the
       8             : // U.S. Government consequently retains certain rights. As such, the U.S. Government has been
       9             : // granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable,
      10             : // worldwide license in the Software to reproduce, distribute copies to the public, prepare
      11             : // derivative works, and perform publicly and display publicly, and to permit others to do so.
      12             : //
      13             : // Redistribution and use in source and binary forms, with or without modification, are permitted
      14             : // provided that the following conditions are met:
      15             : //
      16             : // (1) Redistributions of source code must retain the above copyright notice, this list of
      17             : //     conditions and the following disclaimer.
      18             : //
      19             : // (2) Redistributions in binary form must reproduce the above copyright notice, this list of
      20             : //     conditions and the following disclaimer in the documentation and/or other materials
      21             : //     provided with the distribution.
      22             : //
      23             : // (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory,
      24             : //     the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be
      25             : //     used to endorse or promote products derived from this software without specific prior
      26             : //     written permission.
      27             : //
      28             : // (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form
      29             : //     without changes from the version obtained under this License, or (ii) Licensee makes a
      30             : //     reference solely to the software portion of its product, Licensee must refer to the
      31             : //     software as "EnergyPlus version X" software, where "X" is the version number Licensee
      32             : //     obtained under this License and may not use a different name for the software. Except as
      33             : //     specifically required in this Section (4), Licensee shall not use in a company name, a
      34             : //     product name, in advertising, publicity, or other promotional activities any name, trade
      35             : //     name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly
      36             : //     similar designation, without the U.S. Department of Energy's prior written consent.
      37             : //
      38             : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
      39             : // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
      40             : // AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
      41             : // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
      42             : // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
      43             : // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
      44             : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
      45             : // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
      46             : // POSSIBILITY OF SUCH DAMAGE.
      47             : 
      48             : // C++ Headers
      49             : #include <cmath>
      50             : 
      51             : // ObjexxFCL Headers
      52             : #include <ObjexxFCL/Array.functions.hh>
      53             : #include <ObjexxFCL/Fmath.hh>
      54             : 
      55             : // EnergyPlus Headers
      56             : #include <EnergyPlus/Autosizing/Base.hh>
      57             : #include <EnergyPlus/BranchNodeConnections.hh>
      58             : #include <EnergyPlus/CurveManager.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/DataHeatBalance.hh>
      64             : #include <EnergyPlus/DataLoopNode.hh>
      65             : #include <EnergyPlus/DataPrecisionGlobals.hh>
      66             : #include <EnergyPlus/DataSizing.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/InputProcessing/InputProcessor.hh>
      73             : #include <EnergyPlus/NodeInputManager.hh>
      74             : #include <EnergyPlus/OutputProcessor.hh>
      75             : #include <EnergyPlus/OutputReportPredefined.hh>
      76             : #include <EnergyPlus/PlantUtilities.hh>
      77             : #include <EnergyPlus/Psychrometrics.hh>
      78             : #include <EnergyPlus/UtilityRoutines.hh>
      79             : #include <EnergyPlus/WaterThermalTanks.hh>
      80             : #include <EnergyPlus/WaterToAirHeatPumpSimple.hh>
      81             : 
      82             : namespace EnergyPlus {
      83             : 
      84             : namespace WaterToAirHeatPumpSimple {
      85             : 
      86             :     // Module containing the Water to Air Heat Pump simulation routines
      87             : 
      88             :     // MODULE INFORMATION:
      89             :     //       AUTHOR         Arun Shenoy
      90             :     //       DATE WRITTEN   Nov 2003
      91             :     //       MODIFIED       Brent Griffith, Sept 2010 plant upgrades
      92             :     //       RE-ENGINEERED  Kenneth Tang (Jan 2005)
      93             : 
      94             :     // PURPOSE OF THIS MODULE:
      95             :     // To encapsulate the data and algorithms required to
      96             :     // manage the Water to Air Heat Pump Simple Component
      97             : 
      98             :     // METHODOLOGY EMPLOYED:
      99             : 
     100             :     // REFERENCES:
     101             :     // (1) Lash.T.A.,1992.Simulation and Analysis of a Water Loop Heat Pump System.
     102             :     // M.S. Thesis, University of Illinois at Urbana Champaign.
     103             :     // (2) Shenoy, Arun. 2004. Simulation, Modeling and Analysis of Water to Air Heat Pump.
     104             :     // State Energy Simulation Program. M.S. Thesis, Department of Mechanical and Aerospace Engineering,
     105             :     // Oklahoma State University. (downloadable from www.hvac.okstate.edu)
     106             :     // (3) Tang,C.C.. 2005. Modeling Packaged Heat Pumps in a Quasi-Steady
     107             :     // State Energy Simulation Program. M.S. Thesis, Department of Mechanical and Aerospace Engineering,
     108             :     // Oklahoma State University. (downloadable from www.hvac.okstate.edu)
     109             : 
     110             :     constexpr std::array<std::string_view, static_cast<int>(WatertoAirHP::Num)> WatertoAirHPNamesUC{"HEATING", "COOLING"};
     111             : 
     112    43852909 :     void SimWatertoAirHPSimple(EnergyPlusData &state,
     113             :                                std::string_view CompName, // Coil Name
     114             :                                int &CompIndex,            // Index for Component name
     115             :                                Real64 const SensLoad,     // Sensible demand load [W]
     116             :                                Real64 const LatentLoad,   // Latent demand load [W]
     117             :                                HVAC::FanOp const fanOp,   // Continuous fan OR cycling compressor
     118             :                                HVAC::CompressorOp const compressorOp,
     119             :                                Real64 const PartLoadRatio,
     120             :                                bool const FirstHVACIteration,
     121             :                                Real64 const OnOffAirFlowRatio // ratio of comp on to comp off air flow rate
     122             :     )
     123             :     {
     124             : 
     125             :         //       AUTHOR         Arun Shenoy
     126             :         //       DATE WRITTEN   Nov 2003
     127             :         //       RE-ENGINEERED  Kenneth Tang (Jan 2005)
     128             : 
     129             :         // PURPOSE OF THIS SUBROUTINE:
     130             :         // This subroutine manages Simple Water to Air Heat Pump component simulation.
     131             : 
     132             :         // REFERENCES:
     133             :         // (1) Lash.T.A.,1992.Simulation and Analysis of a Water Loop Heat Pump System.
     134             :         // M.S. Thesis, University of Illinois at Urbana Champaign.
     135             :         // (2) Shenoy, Arun. 2004. Simulation, Modeling and Analysis of Water to Air Heat Pump.
     136             :         // State Energy Simulation Program. M.S. Thesis, Department of Mechanical and Aerospace Engineering,
     137             :         // Oklahoma State University. (downloadable from www.hvac.okstate.edu)
     138             :         // (3) Tang,C.C.. 2005. Modeling Packaged Heat Pumps in a Quasi-Steady
     139             :         // State Energy Simulation Program. M.S. Thesis, Department of Mechanical and Aerospace Engineering,
     140             :         // Oklahoma State University. (downloadable from www.hvac.okstate.edu)
     141             : 
     142             :         // percent on-time (on-time/cycle time)
     143             :         // shut off after compressor cycle off  [s]
     144             : 
     145             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     146             :         int HPNum; // The WatertoAirHP that you are currently loading input into
     147             : 
     148             :         // Obtains and Allocates WatertoAirHP related parameters from input file
     149    43852909 :         if (state.dataWaterToAirHeatPumpSimple->GetCoilsInputFlag) { // First time subroutine has been entered
     150           0 :             GetSimpleWatertoAirHPInput(state);
     151           0 :             state.dataWaterToAirHeatPumpSimple->GetCoilsInputFlag = false;
     152             :         }
     153             : 
     154    43852909 :         if (CompIndex == 0) {
     155           0 :             HPNum = Util::FindItemInList(CompName, state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP);
     156           0 :             if (HPNum == 0) {
     157           0 :                 ShowFatalError(state, format("WaterToAirHPSimple not found= {}", CompName));
     158             :             }
     159           0 :             CompIndex = HPNum;
     160             :         } else {
     161    43852909 :             HPNum = CompIndex;
     162    43852909 :             if (HPNum > state.dataWaterToAirHeatPumpSimple->NumWatertoAirHPs || HPNum < 1) {
     163           0 :                 ShowFatalError(state,
     164           0 :                                format("SimWatertoAirHPSimple: Invalid CompIndex passed={}, Number of Water to Air HPs={}, WaterToAir HP name={}",
     165             :                                       HPNum,
     166           0 :                                       state.dataWaterToAirHeatPumpSimple->NumWatertoAirHPs,
     167             :                                       CompName));
     168             :             }
     169    43852909 :             if (!CompName.empty() && CompName != state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(HPNum).Name) {
     170           0 :                 ShowFatalError(
     171             :                     state,
     172           0 :                     format("SimWatertoAirHPSimple: Invalid CompIndex passed={}, WaterToAir HP name={}, stored WaterToAir HP Name for that index={}",
     173             :                            HPNum,
     174             :                            CompName,
     175           0 :                            state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(HPNum).Name));
     176             :             }
     177             :         }
     178             : 
     179    43852909 :         auto &simpleWAHP(state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(HPNum));
     180             : 
     181    43852909 :         if (simpleWAHP.WAHPPlantType == DataPlant::PlantEquipmentType::CoilWAHPCoolingEquationFit) {
     182             :             // Cooling mode
     183    21926434 :             InitSimpleWatertoAirHP(state, HPNum, SensLoad, LatentLoad, fanOp, OnOffAirFlowRatio, FirstHVACIteration);
     184    21926434 :             CalcHPCoolingSimple(state, HPNum, fanOp, SensLoad, LatentLoad, compressorOp, PartLoadRatio, OnOffAirFlowRatio);
     185    21926434 :             UpdateSimpleWatertoAirHP(state, HPNum);
     186    21926475 :         } else if (simpleWAHP.WAHPPlantType == DataPlant::PlantEquipmentType::CoilWAHPHeatingEquationFit) {
     187             :             // Heating mode
     188    21926475 :             InitSimpleWatertoAirHP(state, HPNum, SensLoad, DataPrecisionGlobals::constant_zero, fanOp, OnOffAirFlowRatio, FirstHVACIteration);
     189    21926475 :             CalcHPHeatingSimple(state, HPNum, fanOp, SensLoad, compressorOp, PartLoadRatio, OnOffAirFlowRatio);
     190    21926475 :             UpdateSimpleWatertoAirHP(state, HPNum);
     191             :         } else {
     192           0 :             ShowFatalError(state, "SimWatertoAirHPSimple: WatertoAir heatpump not in either HEATING or COOLING mode");
     193             :         }
     194    43852909 :     }
     195             : 
     196          18 :     void GetSimpleWatertoAirHPInput(EnergyPlusData &state)
     197             :     {
     198             : 
     199             :         // SUBROUTINE INFORMATION:
     200             :         //       AUTHOR         Arun Shenoy
     201             :         //       DATE WRITTEN   Nov 2003
     202             :         //       RE-ENGINEERED  Kenneth Tang (Jan 2005)
     203             : 
     204             :         // PURPOSE OF THIS SUBROUTINE:
     205             :         // Obtains input data for HPs and stores it in HP data structures
     206             : 
     207             :         // METHODOLOGY EMPLOYED:
     208             :         // Uses "Get" routines to read in data.
     209             : 
     210             :         // REFERENCES:
     211             :         // (1) Lash.T.A.,1992.Simulation and Analysis of a Water loop Heat Pump System.
     212             :         // M.S. Thesis, University of Illinois at Urbana Champaign.
     213             :         // (2) Shenoy, Arun. 2004. Simulation, Modeling and Analysis of Water to Air Heat Pump.
     214             :         // State Energy Simulation Program. M.S. Thesis, Department of Mechanical and Aerospace Engineering,
     215             :         // Oklahoma State University. (downloadable from www.hvac.okstate.edu)
     216             :         // (3) Tang,C.C.. 2005. Modeling Packaged Heat Pumps in a Quasi-Steady
     217             :         // State Energy Simulation Program. M.S. Thesis, Department of Mechanical and Aerospace Engineering,
     218             :         // Oklahoma State University. (downloadable from www.hvac.okstate.edu)
     219             : 
     220             :         // SUBROUTINE PARAMETER DEFINITIONS:
     221             :         static constexpr std::string_view RoutineName("GetSimpleWatertoAirHPInput: "); // include trailing blank space
     222             : 
     223             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     224             :         int HPNum;           // The Water to Air HP that you are currently loading input into
     225             :         int NumCool;         // Counter for cooling coil
     226             :         int NumHeat;         // Counter for heating coil
     227             :         int WatertoAirHPNum; // Counter
     228             :         int NumAlphas;       // Number of variables in String format
     229             :         int NumNums;         // Number of variables in Numeric format
     230             :         int NumParams;       // Total number of input fields
     231          18 :         int MaxNums(0);      // Maximum number of numeric input fields
     232          18 :         int MaxAlphas(0);    // Maximum number of alpha input fields
     233             :         int IOStat;
     234          18 :         bool ErrorsFound(false);         // If errors detected in input
     235          18 :         std::string CurrentModuleObject; // for ease in getting objects
     236          18 :         Array1D_string AlphArray;        // Alpha input items for object
     237          18 :         Array1D_string cAlphaFields;     // Alpha field names
     238          18 :         Array1D_string cNumericFields;   // Numeric field names
     239          18 :         Array1D<Real64> NumArray;        // Numeric input items for object
     240          18 :         Array1D_bool lAlphaBlanks;       // Logical array, alpha field input BLANK = .TRUE.
     241          18 :         Array1D_bool lNumericBlanks;     // Logical array, numeric field input BLANK = .TRUE.
     242             : 
     243          18 :         NumCool = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Coil:Cooling:WaterToAirHeatPump:EquationFit");
     244          18 :         NumHeat = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Coil:Heating:WaterToAirHeatPump:EquationFit");
     245          18 :         state.dataWaterToAirHeatPumpSimple->NumWatertoAirHPs = NumCool + NumHeat;
     246          18 :         HPNum = 0;
     247             : 
     248          18 :         if (state.dataWaterToAirHeatPumpSimple->NumWatertoAirHPs <= 0) {
     249           0 :             ShowSevereError(state, "No Equipment found in SimWatertoAirHPSimple");
     250           0 :             ErrorsFound = true;
     251             :         }
     252             : 
     253             :         // Allocate Arrays
     254          18 :         if (state.dataWaterToAirHeatPumpSimple->NumWatertoAirHPs > 0) {
     255          18 :             state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP.allocate(state.dataWaterToAirHeatPumpSimple->NumWatertoAirHPs);
     256          18 :             state.dataWaterToAirHeatPumpSimple->SimpleHPTimeStepFlag.dimension(state.dataWaterToAirHeatPumpSimple->NumWatertoAirHPs, true);
     257          18 :             state.dataHeatBal->HeatReclaimSimple_WAHPCoil.allocate(state.dataWaterToAirHeatPumpSimple->NumWatertoAirHPs);
     258             :         }
     259             : 
     260          18 :         state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     261             :             state, "Coil:Cooling:WaterToAirHeatPump:EquationFit", NumParams, NumAlphas, NumNums);
     262          18 :         MaxNums = max(MaxNums, NumNums);
     263          18 :         MaxAlphas = max(MaxAlphas, NumAlphas);
     264          18 :         state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     265             :             state, "Coil:Heating:WaterToAirHeatPump:EquationFit", NumParams, NumAlphas, NumNums);
     266          18 :         MaxNums = max(MaxNums, NumNums);
     267          18 :         MaxAlphas = max(MaxAlphas, NumAlphas);
     268          18 :         AlphArray.allocate(MaxAlphas);
     269          18 :         cAlphaFields.allocate(MaxAlphas);
     270          18 :         lAlphaBlanks.dimension(MaxAlphas, true);
     271          18 :         cNumericFields.allocate(MaxNums);
     272          18 :         lNumericBlanks.dimension(MaxNums, true);
     273          18 :         NumArray.dimension(MaxNums, 0.0);
     274             : 
     275             :         // Get the data for cooling coil
     276          18 :         CurrentModuleObject = "Coil:Cooling:WaterToAirHeatPump:EquationFit";
     277             : 
     278         155 :         for (WatertoAirHPNum = 1; WatertoAirHPNum <= NumCool; ++WatertoAirHPNum) {
     279             : 
     280         137 :             ++HPNum;
     281         137 :             auto &simpleWAHP(state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(HPNum));
     282         137 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
     283             :                                                                      CurrentModuleObject,
     284             :                                                                      HPNum,
     285             :                                                                      AlphArray,
     286             :                                                                      NumAlphas,
     287             :                                                                      NumArray,
     288             :                                                                      NumNums,
     289             :                                                                      IOStat,
     290             :                                                                      lNumericBlanks,
     291             :                                                                      lAlphaBlanks,
     292             :                                                                      cAlphaFields,
     293             :                                                                      cNumericFields);
     294             :             // ErrorsFound will be set to True if problem was found, left untouched otherwise
     295         137 :             GlobalNames::VerifyUniqueCoilName(state, CurrentModuleObject, AlphArray(1), ErrorsFound, format("{} Name", CurrentModuleObject));
     296         137 :             simpleWAHP.Name = AlphArray(1);
     297         137 :             simpleWAHP.WAHPType = WatertoAirHP::Cooling;
     298         137 :             simpleWAHP.WAHPPlantType = DataPlant::PlantEquipmentType::CoilWAHPCoolingEquationFit;
     299         137 :             simpleWAHP.RatedAirVolFlowRate = NumArray(1);
     300         137 :             simpleWAHP.RatedWaterVolFlowRate = NumArray(2);
     301         137 :             simpleWAHP.RatedCapCoolTotal = NumArray(3);
     302         137 :             simpleWAHP.RatedCapCoolSens = NumArray(4);
     303         137 :             simpleWAHP.RatedCOPCoolAtRatedCdts = NumArray(5);
     304         137 :             simpleWAHP.RatedEntWaterTemp = NumArray(6);
     305         137 :             simpleWAHP.RatedEntAirDrybulbTemp = NumArray(7);
     306         137 :             simpleWAHP.RatedEntAirWetbulbTemp = NumArray(8);
     307         137 :             simpleWAHP.TotalCoolCapCurveIndex = Curve::GetCurveIndex(state, AlphArray(6)); // convert curve name to number
     308         137 :             simpleWAHP.SensCoolCapCurveIndex = Curve::GetCurveIndex(state, AlphArray(7));  // convert curve name to number
     309         137 :             simpleWAHP.CoolPowCurveIndex = Curve::GetCurveIndex(state, AlphArray(8));      // convert curve name to number
     310         137 :             if (simpleWAHP.TotalCoolCapCurveIndex == 0) {
     311           0 :                 if (lAlphaBlanks(6)) {
     312           0 :                     ShowSevereError(state, format("{}{}=\"{}\", missing", RoutineName, CurrentModuleObject, simpleWAHP.Name));
     313           0 :                     ShowContinueError(state, format("...required {} is blank.", cAlphaFields(6)));
     314             :                 } else {
     315           0 :                     ShowSevereError(state, format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, simpleWAHP.Name));
     316           0 :                     ShowContinueError(state, format("...not found {}=\"{}\"", cAlphaFields(6), AlphArray(6)));
     317             :                 }
     318           0 :                 ErrorsFound = true;
     319             :             } else {
     320         137 :                 ErrorsFound |= Curve::CheckCurveDims(state,
     321             :                                                      simpleWAHP.TotalCoolCapCurveIndex,
     322             :                                                      {4},
     323             :                                                      RoutineName,
     324             :                                                      CurrentModuleObject,
     325             :                                                      simpleWAHP.Name,
     326             :                                                      "Total Cooling Capacity Curve Name");
     327             :             }
     328         137 :             if (simpleWAHP.SensCoolCapCurveIndex == 0) {
     329           0 :                 if (lAlphaBlanks(7)) {
     330           0 :                     ShowSevereError(state, format("{}{}=\"{}\", missing", RoutineName, CurrentModuleObject, simpleWAHP.Name));
     331           0 :                     ShowContinueError(state, format("...required {} is blank.", cAlphaFields(7)));
     332             :                 } else {
     333           0 :                     ShowSevereError(state, format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, simpleWAHP.Name));
     334           0 :                     ShowContinueError(state, format("...not found {}=\"{}\"", cAlphaFields(7), AlphArray(7)));
     335             :                 }
     336           0 :                 ErrorsFound = true;
     337             :             } else {
     338         137 :                 ErrorsFound |= Curve::CheckCurveDims(state,
     339             :                                                      simpleWAHP.SensCoolCapCurveIndex,
     340             :                                                      {5},
     341             :                                                      RoutineName,
     342             :                                                      CurrentModuleObject,
     343             :                                                      simpleWAHP.Name,
     344             :                                                      "Sensible Cooling Capacity Curve Name");
     345             :             }
     346         137 :             if (simpleWAHP.CoolPowCurveIndex == 0) {
     347           0 :                 if (lAlphaBlanks(8)) {
     348           0 :                     ShowSevereError(state, format("{}{}=\"{}\", missing", RoutineName, CurrentModuleObject, simpleWAHP.Name));
     349           0 :                     ShowContinueError(state, format("...required {} is blank.", cAlphaFields(8)));
     350             :                 } else {
     351           0 :                     ShowSevereError(state, format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, simpleWAHP.Name));
     352           0 :                     ShowContinueError(state, format("...not found {}=\"{}\"", cAlphaFields(8), AlphArray(8)));
     353             :                 }
     354           0 :                 ErrorsFound = true;
     355             :             } else {
     356         137 :                 ErrorsFound |= Curve::CheckCurveDims(state,
     357             :                                                      simpleWAHP.CoolPowCurveIndex,
     358             :                                                      {4},
     359             :                                                      RoutineName,
     360             :                                                      CurrentModuleObject,
     361             :                                                      simpleWAHP.Name,
     362             :                                                      "Cooling Power Consumption Curve Name");
     363             :             }
     364         137 :             simpleWAHP.PLFCurveIndex = Curve::GetCurveIndex(state, AlphArray(9)); // convert curve name to number
     365             : 
     366         137 :             if (simpleWAHP.PLFCurveIndex == 0) {
     367           0 :                 if (lAlphaBlanks(9)) {
     368           0 :                     ShowSevereError(state, format("{}{}=\"{}\", missing", RoutineName, CurrentModuleObject, simpleWAHP.Name));
     369           0 :                     ShowContinueError(state, format("...required {} is blank.", cAlphaFields(9)));
     370             :                 } else {
     371           0 :                     ShowSevereError(state, format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, simpleWAHP.Name));
     372           0 :                     ShowContinueError(state, format("...not found {}=\"{}\".", cAlphaFields(9), AlphArray(9)));
     373             :                 }
     374           0 :                 ErrorsFound = true;
     375             :             } else {
     376             :                 // Verify Curve Object, only legal types are Quadratic or Cubic
     377         137 :                 ErrorsFound |= Curve::CheckCurveDims(state,
     378             :                                                      simpleWAHP.PLFCurveIndex, // Curve index
     379             :                                                      {1},                      // Valid dimensions
     380             :                                                      RoutineName,              // Routine name
     381             :                                                      CurrentModuleObject,      // Object Type
     382             :                                                      simpleWAHP.Name,          // Object Name
     383         137 :                                                      cAlphaFields(9));         // Field Name
     384             : 
     385         137 :                 if (!ErrorsFound) {
     386             :                     //     Test PLF curve minimum and maximum. Cap if less than 0.7 or greater than 1.0.
     387         137 :                     Real64 MinCurveVal = 999.0;
     388         137 :                     Real64 MaxCurveVal = -999.0;
     389         137 :                     Real64 CurveInput = 0.0;
     390         137 :                     Real64 MinCurvePLR{0.0};
     391         137 :                     Real64 MaxCurvePLR{0.0};
     392             : 
     393       13837 :                     while (CurveInput <= 1.0) {
     394       13700 :                         Real64 CurveVal = Curve::CurveValue(state, simpleWAHP.PLFCurveIndex, CurveInput);
     395       13700 :                         if (CurveVal < MinCurveVal) {
     396         137 :                             MinCurveVal = CurveVal;
     397         137 :                             MinCurvePLR = CurveInput;
     398             :                         }
     399       13700 :                         if (CurveVal > MaxCurveVal) {
     400       13700 :                             MaxCurveVal = CurveVal;
     401       13700 :                             MaxCurvePLR = CurveInput;
     402             :                         }
     403       13700 :                         CurveInput += 0.01;
     404             :                     }
     405         137 :                     if (MinCurveVal < 0.7) {
     406           0 :                         ShowWarningError(state, format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, simpleWAHP.Name));
     407           0 :                         ShowContinueError(state, format("...{}=\"{}\" has out of range values.", cAlphaFields(9), AlphArray(9)));
     408           0 :                         ShowContinueError(state,
     409           0 :                                           format("...Curve minimum must be >= 0.7, curve min at PLR = {:.2T} is {:.3T}", MinCurvePLR, MinCurveVal));
     410           0 :                         ShowContinueError(state, "...Setting curve minimum to 0.7 and simulation continues.");
     411           0 :                         Curve::SetCurveOutputMinValue(state, simpleWAHP.PLFCurveIndex, ErrorsFound, 0.7);
     412             :                     }
     413             : 
     414         137 :                     if (MaxCurveVal > 1.0) {
     415           0 :                         ShowWarningError(state, format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, simpleWAHP.Name));
     416           0 :                         ShowContinueError(state, format("...{} = {} has out of range value.", cAlphaFields(9), AlphArray(9)));
     417           0 :                         ShowContinueError(state,
     418           0 :                                           format("...Curve maximum must be <= 1.0, curve max at PLR = {:.2T} is {:.3T}", MaxCurvePLR, MaxCurveVal));
     419           0 :                         ShowContinueError(state, "...Setting curve maximum to 1.0 and simulation continues.");
     420           0 :                         Curve::SetCurveOutputMaxValue(state, simpleWAHP.PLFCurveIndex, ErrorsFound, 1.0);
     421             :                     }
     422             :                 }
     423             :             }
     424             : 
     425         137 :             CheckSimpleWAHPRatedCurvesOutputs(state, simpleWAHP.Name);
     426         137 :             simpleWAHP.Twet_Rated = NumArray(9);
     427         137 :             simpleWAHP.Gamma_Rated = NumArray(10);
     428         137 :             simpleWAHP.MaxONOFFCyclesperHour = NumArray(11);
     429         137 :             simpleWAHP.LatentCapacityTimeConstant = NumArray(12);
     430         137 :             simpleWAHP.FanDelayTime = NumArray(13);
     431             : 
     432         137 :             state.dataHeatBal->HeatReclaimSimple_WAHPCoil(WatertoAirHPNum).Name = simpleWAHP.Name;
     433         137 :             state.dataHeatBal->HeatReclaimSimple_WAHPCoil(WatertoAirHPNum).SourceType = CurrentModuleObject;
     434             : 
     435         137 :             simpleWAHP.WaterInletNodeNum = GetOnlySingleNode(state,
     436         137 :                                                              AlphArray(2),
     437             :                                                              ErrorsFound,
     438             :                                                              DataLoopNode::ConnectionObjectType::CoilCoolingWaterToAirHeatPumpEquationFit,
     439         137 :                                                              simpleWAHP.Name,
     440             :                                                              DataLoopNode::NodeFluidType::Water,
     441             :                                                              DataLoopNode::ConnectionType::Inlet,
     442             :                                                              NodeInputManager::CompFluidStream::Secondary,
     443             :                                                              DataLoopNode::ObjectIsNotParent);
     444         137 :             simpleWAHP.WaterOutletNodeNum = GetOnlySingleNode(state,
     445         137 :                                                               AlphArray(3),
     446             :                                                               ErrorsFound,
     447             :                                                               DataLoopNode::ConnectionObjectType::CoilCoolingWaterToAirHeatPumpEquationFit,
     448         137 :                                                               simpleWAHP.Name,
     449             :                                                               DataLoopNode::NodeFluidType::Water,
     450             :                                                               DataLoopNode::ConnectionType::Outlet,
     451             :                                                               NodeInputManager::CompFluidStream::Secondary,
     452             :                                                               DataLoopNode::ObjectIsNotParent);
     453         137 :             simpleWAHP.AirInletNodeNum = GetOnlySingleNode(state,
     454         137 :                                                            AlphArray(4),
     455             :                                                            ErrorsFound,
     456             :                                                            DataLoopNode::ConnectionObjectType::CoilCoolingWaterToAirHeatPumpEquationFit,
     457         137 :                                                            simpleWAHP.Name,
     458             :                                                            DataLoopNode::NodeFluidType::Air,
     459             :                                                            DataLoopNode::ConnectionType::Inlet,
     460             :                                                            NodeInputManager::CompFluidStream::Primary,
     461             :                                                            DataLoopNode::ObjectIsNotParent);
     462         137 :             simpleWAHP.AirOutletNodeNum = GetOnlySingleNode(state,
     463         137 :                                                             AlphArray(5),
     464             :                                                             ErrorsFound,
     465             :                                                             DataLoopNode::ConnectionObjectType::CoilCoolingWaterToAirHeatPumpEquationFit,
     466         137 :                                                             simpleWAHP.Name,
     467             :                                                             DataLoopNode::NodeFluidType::Air,
     468             :                                                             DataLoopNode::ConnectionType::Outlet,
     469             :                                                             NodeInputManager::CompFluidStream::Primary,
     470             :                                                             DataLoopNode::ObjectIsNotParent);
     471             : 
     472         137 :             BranchNodeConnections::TestCompSet(state, CurrentModuleObject, simpleWAHP.Name, AlphArray(2), AlphArray(3), "Water Nodes");
     473         137 :             BranchNodeConnections::TestCompSet(state, CurrentModuleObject, simpleWAHP.Name, AlphArray(4), AlphArray(5), "Air Nodes");
     474             : 
     475             :             // Setup Report variables for the cooling coil
     476             :             // CurrentModuleObject = "Coil:Cooling:WaterToAirHeatPump:EquationFit"
     477         274 :             SetupOutputVariable(state,
     478             :                                 "Cooling Coil Electricity Energy",
     479             :                                 Constant::Units::J,
     480         137 :                                 simpleWAHP.Energy,
     481             :                                 OutputProcessor::TimeStepType::System,
     482             :                                 OutputProcessor::StoreType::Sum,
     483         137 :                                 simpleWAHP.Name,
     484             :                                 Constant::eResource::Electricity,
     485             :                                 OutputProcessor::Group::HVAC,
     486             :                                 OutputProcessor::EndUseCat::Cooling);
     487         274 :             SetupOutputVariable(state,
     488             :                                 "Cooling Coil Total Cooling Energy",
     489             :                                 Constant::Units::J,
     490         137 :                                 simpleWAHP.EnergyLoadTotal,
     491             :                                 OutputProcessor::TimeStepType::System,
     492             :                                 OutputProcessor::StoreType::Sum,
     493         137 :                                 simpleWAHP.Name,
     494             :                                 Constant::eResource::EnergyTransfer,
     495             :                                 OutputProcessor::Group::HVAC,
     496             :                                 OutputProcessor::EndUseCat::CoolingCoils);
     497         274 :             SetupOutputVariable(state,
     498             :                                 "Cooling Coil Sensible Cooling Energy",
     499             :                                 Constant::Units::J,
     500         137 :                                 simpleWAHP.EnergySensible,
     501             :                                 OutputProcessor::TimeStepType::System,
     502             :                                 OutputProcessor::StoreType::Sum,
     503         137 :                                 simpleWAHP.Name);
     504         274 :             SetupOutputVariable(state,
     505             :                                 "Cooling Coil Latent Cooling Energy",
     506             :                                 Constant::Units::J,
     507         137 :                                 simpleWAHP.EnergyLatent,
     508             :                                 OutputProcessor::TimeStepType::System,
     509             :                                 OutputProcessor::StoreType::Sum,
     510         137 :                                 simpleWAHP.Name);
     511         274 :             SetupOutputVariable(state,
     512             :                                 "Cooling Coil Source Side Heat Transfer Energy",
     513             :                                 Constant::Units::J,
     514         137 :                                 simpleWAHP.EnergySource,
     515             :                                 OutputProcessor::TimeStepType::System,
     516             :                                 OutputProcessor::StoreType::Sum,
     517         137 :                                 simpleWAHP.Name,
     518             :                                 Constant::eResource::PlantLoopCoolingDemand,
     519             :                                 OutputProcessor::Group::HVAC,
     520             :                                 OutputProcessor::EndUseCat::CoolingCoils);
     521             : 
     522             :             // create predefined report entries
     523         137 :             OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoolCoilType, simpleWAHP.Name, CurrentModuleObject);
     524         274 :             OutputReportPredefined::PreDefTableEntry(
     525         137 :                 state, state.dataOutRptPredefined->pdchCoolCoilTotCap, simpleWAHP.Name, simpleWAHP.RatedCapCoolTotal);
     526         274 :             OutputReportPredefined::PreDefTableEntry(
     527         137 :                 state, state.dataOutRptPredefined->pdchCoolCoilSensCap, simpleWAHP.Name, simpleWAHP.RatedCapCoolSens);
     528         274 :             OutputReportPredefined::PreDefTableEntry(
     529         137 :                 state, state.dataOutRptPredefined->pdchCoolCoilLatCap, simpleWAHP.Name, simpleWAHP.RatedCapCoolTotal - simpleWAHP.RatedCapCoolSens);
     530         274 :             OutputReportPredefined::PreDefTableEntry(
     531         137 :                 state, state.dataOutRptPredefined->pdchCoolCoilSHR, simpleWAHP.Name, simpleWAHP.RatedCapCoolSens / simpleWAHP.RatedCapCoolTotal);
     532         274 :             OutputReportPredefined::PreDefTableEntry(
     533         137 :                 state, state.dataOutRptPredefined->pdchCoolCoilNomEff, simpleWAHP.Name, simpleWAHP.RatedPowerCool / simpleWAHP.RatedCapCoolTotal);
     534             : 
     535         137 :             OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchWAHPType, simpleWAHP.Name, CurrentModuleObject);
     536             :         }
     537             : 
     538             :         // Get the data for heating coil
     539          18 :         CurrentModuleObject = "Coil:Heating:WaterToAirHeatPump:EquationFit";
     540             : 
     541         155 :         for (WatertoAirHPNum = 1; WatertoAirHPNum <= NumHeat; ++WatertoAirHPNum) {
     542             : 
     543         137 :             ++HPNum;
     544         137 :             auto &simpleWAHP(state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(HPNum));
     545         137 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
     546             :                                                                      CurrentModuleObject,
     547             :                                                                      WatertoAirHPNum,
     548             :                                                                      AlphArray,
     549             :                                                                      NumAlphas,
     550             :                                                                      NumArray,
     551             :                                                                      NumNums,
     552             :                                                                      IOStat,
     553             :                                                                      lNumericBlanks,
     554             :                                                                      lAlphaBlanks,
     555             :                                                                      cAlphaFields,
     556             :                                                                      cNumericFields);
     557             :             // ErrorsFound will be set to True if problem was found, left untouched otherwise
     558         137 :             GlobalNames::VerifyUniqueCoilName(state, CurrentModuleObject, AlphArray(1), ErrorsFound, format("{} Name", CurrentModuleObject));
     559         137 :             simpleWAHP.Name = AlphArray(1);
     560         137 :             simpleWAHP.WAHPType = WatertoAirHP::Heating;
     561         137 :             simpleWAHP.WAHPPlantType = DataPlant::PlantEquipmentType::CoilWAHPHeatingEquationFit;
     562         137 :             simpleWAHP.RatedAirVolFlowRate = NumArray(1);
     563         137 :             simpleWAHP.RatedWaterVolFlowRate = NumArray(2);
     564         137 :             simpleWAHP.RatedCapHeat = NumArray(3);
     565         137 :             simpleWAHP.RatedCOPHeatAtRatedCdts = NumArray(4);
     566         137 :             simpleWAHP.RatedEntWaterTemp = NumArray(5);
     567         137 :             simpleWAHP.RatedEntAirDrybulbTemp = NumArray(6);
     568         137 :             simpleWAHP.RatioRatedHeatRatedTotCoolCap = NumArray(7);
     569         137 :             simpleWAHP.HeatCapCurveIndex = Curve::GetCurveIndex(state, AlphArray(6)); // convert curve name to number
     570         137 :             simpleWAHP.HeatPowCurveIndex = Curve::GetCurveIndex(state, AlphArray(7)); // convert curve name to number
     571         137 :             if (simpleWAHP.HeatCapCurveIndex == 0) {
     572           0 :                 if (lAlphaBlanks(6)) {
     573           0 :                     ShowSevereError(state, format("{}{}=\"{}\", missing", RoutineName, CurrentModuleObject, simpleWAHP.Name));
     574           0 :                     ShowContinueError(state, format("...required {} is blank.", cAlphaFields(6)));
     575             :                 } else {
     576           0 :                     ShowSevereError(state, format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, simpleWAHP.Name));
     577           0 :                     ShowContinueError(state, format("...not found {}=\"{}\"", cAlphaFields(6), AlphArray(6)));
     578             :                 }
     579           0 :                 ErrorsFound = true;
     580             :             } else {
     581         137 :                 ErrorsFound |= Curve::CheckCurveDims(
     582             :                     state, simpleWAHP.HeatCapCurveIndex, {4}, RoutineName, CurrentModuleObject, simpleWAHP.Name, "Heating Capacity Curve Name");
     583             :             }
     584         137 :             if (simpleWAHP.HeatPowCurveIndex == 0) {
     585           0 :                 if (lAlphaBlanks(7)) {
     586           0 :                     ShowSevereError(state, format("{}{}=\"{}\", missing", RoutineName, CurrentModuleObject, simpleWAHP.Name));
     587           0 :                     ShowContinueError(state, format("...required {} is blank.", cAlphaFields(7)));
     588             :                 } else {
     589           0 :                     ShowSevereError(state, format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, simpleWAHP.Name));
     590           0 :                     ShowContinueError(state, format("...not found {}=\"{}\"", cAlphaFields(7), AlphArray(7)));
     591             :                 }
     592           0 :                 ErrorsFound = true;
     593             :             } else {
     594         137 :                 ErrorsFound |= Curve::CheckCurveDims(state,
     595             :                                                      simpleWAHP.HeatPowCurveIndex,
     596             :                                                      {4},
     597             :                                                      RoutineName,
     598             :                                                      CurrentModuleObject,
     599             :                                                      simpleWAHP.Name,
     600             :                                                      "Heating Power Consumption Curve Name");
     601             :             }
     602             : 
     603         137 :             simpleWAHP.PLFCurveIndex = Curve::GetCurveIndex(state, AlphArray(8)); // convert curve name to number
     604             : 
     605         137 :             if (simpleWAHP.PLFCurveIndex == 0) {
     606           0 :                 if (lAlphaBlanks(8)) {
     607           0 :                     ShowSevereError(state, format("{}{}=\"{}\", missing", RoutineName, CurrentModuleObject, simpleWAHP.Name));
     608           0 :                     ShowContinueError(state, format("...required {} is blank.", cAlphaFields(8)));
     609             :                 } else {
     610           0 :                     ShowSevereError(state, format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, simpleWAHP.Name));
     611           0 :                     ShowContinueError(state, format("...not found {}=\"{}\".", cAlphaFields(8), AlphArray(8)));
     612             :                 }
     613           0 :                 ErrorsFound = true;
     614             :             } else {
     615             :                 // Verify Curve Object, only legal types are Quadratic or Cubic
     616         137 :                 ErrorsFound |= Curve::CheckCurveDims(state,
     617             :                                                      simpleWAHP.PLFCurveIndex, // Curve index
     618             :                                                      {1},                      // Valid dimensions
     619             :                                                      RoutineName,              // Routine name
     620             :                                                      CurrentModuleObject,      // Object Type
     621             :                                                      simpleWAHP.Name,          // Object Name
     622         137 :                                                      cAlphaFields(8));         // Field Name
     623             : 
     624         137 :                 if (!ErrorsFound) {
     625             :                     //     Test PLF curve minimum and maximum. Cap if less than 0.7 or greater than 1.0.
     626         137 :                     Real64 MinCurveVal = 999.0;
     627         137 :                     Real64 MaxCurveVal = -999.0;
     628         137 :                     Real64 CurveInput = 0.0;
     629         137 :                     Real64 MinCurvePLR{0.0};
     630         137 :                     Real64 MaxCurvePLR{0.0};
     631             : 
     632       13837 :                     while (CurveInput <= 1.0) {
     633       13700 :                         Real64 CurveVal = Curve::CurveValue(state, simpleWAHP.PLFCurveIndex, CurveInput);
     634       13700 :                         if (CurveVal < MinCurveVal) {
     635         137 :                             MinCurveVal = CurveVal;
     636         137 :                             MinCurvePLR = CurveInput;
     637             :                         }
     638       13700 :                         if (CurveVal > MaxCurveVal) {
     639       13700 :                             MaxCurveVal = CurveVal;
     640       13700 :                             MaxCurvePLR = CurveInput;
     641             :                         }
     642       13700 :                         CurveInput += 0.01;
     643             :                     }
     644         137 :                     if (MinCurveVal < 0.7) {
     645           0 :                         ShowWarningError(state, format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, simpleWAHP.Name));
     646           0 :                         ShowContinueError(state, format("...{}=\"{}\" has out of range values.", cAlphaFields(8), AlphArray(8)));
     647           0 :                         ShowContinueError(state,
     648           0 :                                           format("...Curve minimum must be >= 0.7, curve min at PLR = {:.2T} is {:.3T}", MinCurvePLR, MinCurveVal));
     649           0 :                         ShowContinueError(state, "...Setting curve minimum to 0.7 and simulation continues.");
     650           0 :                         Curve::SetCurveOutputMinValue(state, simpleWAHP.PLFCurveIndex, ErrorsFound, 0.7);
     651             :                     }
     652             : 
     653         137 :                     if (MaxCurveVal > 1.0) {
     654           0 :                         ShowWarningError(state, format("{}{}=\"{}\", invalid", RoutineName, CurrentModuleObject, simpleWAHP.Name));
     655           0 :                         ShowContinueError(state, format("...{} = {} has out of range value.", cAlphaFields(8), AlphArray(8)));
     656           0 :                         ShowContinueError(state,
     657           0 :                                           format("...Curve maximum must be <= 1.0, curve max at PLR = {:.2T} is {:.3T}", MaxCurvePLR, MaxCurveVal));
     658           0 :                         ShowContinueError(state, "...Setting curve maximum to 1.0 and simulation continues.");
     659           0 :                         Curve::SetCurveOutputMaxValue(state, simpleWAHP.PLFCurveIndex, ErrorsFound, 1.0);
     660             :                     }
     661             :                 }
     662             :             }
     663             : 
     664         137 :             CheckSimpleWAHPRatedCurvesOutputs(state, simpleWAHP.Name);
     665         137 :             simpleWAHP.WaterInletNodeNum = GetOnlySingleNode(state,
     666         137 :                                                              AlphArray(2),
     667             :                                                              ErrorsFound,
     668             :                                                              DataLoopNode::ConnectionObjectType::CoilHeatingWaterToAirHeatPumpEquationFit,
     669         137 :                                                              simpleWAHP.Name,
     670             :                                                              DataLoopNode::NodeFluidType::Water,
     671             :                                                              DataLoopNode::ConnectionType::Inlet,
     672             :                                                              NodeInputManager::CompFluidStream::Secondary,
     673             :                                                              DataLoopNode::ObjectIsNotParent);
     674         137 :             simpleWAHP.WaterOutletNodeNum = GetOnlySingleNode(state,
     675         137 :                                                               AlphArray(3),
     676             :                                                               ErrorsFound,
     677             :                                                               DataLoopNode::ConnectionObjectType::CoilHeatingWaterToAirHeatPumpEquationFit,
     678         137 :                                                               simpleWAHP.Name,
     679             :                                                               DataLoopNode::NodeFluidType::Water,
     680             :                                                               DataLoopNode::ConnectionType::Outlet,
     681             :                                                               NodeInputManager::CompFluidStream::Secondary,
     682             :                                                               DataLoopNode::ObjectIsNotParent);
     683         137 :             simpleWAHP.AirInletNodeNum = GetOnlySingleNode(state,
     684         137 :                                                            AlphArray(4),
     685             :                                                            ErrorsFound,
     686             :                                                            DataLoopNode::ConnectionObjectType::CoilHeatingWaterToAirHeatPumpEquationFit,
     687         137 :                                                            simpleWAHP.Name,
     688             :                                                            DataLoopNode::NodeFluidType::Air,
     689             :                                                            DataLoopNode::ConnectionType::Inlet,
     690             :                                                            NodeInputManager::CompFluidStream::Primary,
     691             :                                                            DataLoopNode::ObjectIsNotParent);
     692         137 :             simpleWAHP.AirOutletNodeNum = GetOnlySingleNode(state,
     693         137 :                                                             AlphArray(5),
     694             :                                                             ErrorsFound,
     695             :                                                             DataLoopNode::ConnectionObjectType::CoilHeatingWaterToAirHeatPumpEquationFit,
     696         137 :                                                             simpleWAHP.Name,
     697             :                                                             DataLoopNode::NodeFluidType::Air,
     698             :                                                             DataLoopNode::ConnectionType::Outlet,
     699             :                                                             NodeInputManager::CompFluidStream::Primary,
     700             :                                                             DataLoopNode::ObjectIsNotParent);
     701             : 
     702         137 :             BranchNodeConnections::TestCompSet(state, CurrentModuleObject, simpleWAHP.Name, AlphArray(2), AlphArray(3), "Water Nodes");
     703         137 :             BranchNodeConnections::TestCompSet(state, CurrentModuleObject, simpleWAHP.Name, AlphArray(4), AlphArray(5), "Air Nodes");
     704             : 
     705             :             // CurrentModuleObject = "Coil:Cooling:WaterToAirHeatPump:EquationFit"
     706         274 :             SetupOutputVariable(state,
     707             :                                 "Heating Coil Electricity Energy",
     708             :                                 Constant::Units::J,
     709         137 :                                 simpleWAHP.Energy,
     710             :                                 OutputProcessor::TimeStepType::System,
     711             :                                 OutputProcessor::StoreType::Sum,
     712         137 :                                 simpleWAHP.Name,
     713             :                                 Constant::eResource::Electricity,
     714             :                                 OutputProcessor::Group::HVAC,
     715             :                                 OutputProcessor::EndUseCat::Heating);
     716         274 :             SetupOutputVariable(state,
     717             :                                 "Heating Coil Heating Energy",
     718             :                                 Constant::Units::J,
     719         137 :                                 simpleWAHP.EnergyLoadTotal,
     720             :                                 OutputProcessor::TimeStepType::System,
     721             :                                 OutputProcessor::StoreType::Sum,
     722         137 :                                 simpleWAHP.Name,
     723             :                                 Constant::eResource::EnergyTransfer,
     724             :                                 OutputProcessor::Group::HVAC,
     725             :                                 OutputProcessor::EndUseCat::HeatingCoils);
     726         274 :             SetupOutputVariable(state,
     727             :                                 "Heating Coil Source Side Heat Transfer Energy",
     728             :                                 Constant::Units::J,
     729         137 :                                 simpleWAHP.EnergySource,
     730             :                                 OutputProcessor::TimeStepType::System,
     731             :                                 OutputProcessor::StoreType::Sum,
     732         137 :                                 simpleWAHP.Name,
     733             :                                 Constant::eResource::PlantLoopHeatingDemand,
     734             :                                 OutputProcessor::Group::HVAC,
     735             :                                 OutputProcessor::EndUseCat::HeatingCoils);
     736             : 
     737             :             // create predefined report entries
     738         137 :             OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchHeatCoilType, simpleWAHP.Name, CurrentModuleObject);
     739         137 :             OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchHeatCoilNomCap, simpleWAHP.Name, simpleWAHP.RatedCapHeat);
     740         274 :             OutputReportPredefined::PreDefTableEntry(
     741         137 :                 state, state.dataOutRptPredefined->pdchHeatCoilNomEff, simpleWAHP.Name, simpleWAHP.RatedPowerHeat / simpleWAHP.RatedCapHeat);
     742             : 
     743         137 :             OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchWAHPType, simpleWAHP.Name, CurrentModuleObject);
     744             :         }
     745             : 
     746          18 :         AlphArray.deallocate();
     747          18 :         cAlphaFields.deallocate();
     748          18 :         lAlphaBlanks.deallocate();
     749          18 :         cNumericFields.deallocate();
     750          18 :         lNumericBlanks.deallocate();
     751          18 :         NumArray.deallocate();
     752             : 
     753          18 :         if (ErrorsFound) {
     754           0 :             ShowFatalError(state, format("{} Errors found getting input. Program terminates.", RoutineName));
     755             :         }
     756             : 
     757         292 :         for (HPNum = 1; HPNum <= state.dataWaterToAirHeatPumpSimple->NumWatertoAirHPs; ++HPNum) {
     758         274 :             auto &simpleWAHP(state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(HPNum));
     759         274 :             if (simpleWAHP.WAHPPlantType == DataPlant::PlantEquipmentType::CoilWAHPCoolingEquationFit) {
     760             :                 // COOLING COIL  Setup Report variables for the Heat Pump
     761         274 :                 SetupOutputVariable(state,
     762             :                                     "Cooling Coil Electricity Rate",
     763             :                                     Constant::Units::W,
     764         137 :                                     simpleWAHP.Power,
     765             :                                     OutputProcessor::TimeStepType::System,
     766             :                                     OutputProcessor::StoreType::Average,
     767         137 :                                     simpleWAHP.Name);
     768         274 :                 SetupOutputVariable(state,
     769             :                                     "Cooling Coil Total Cooling Rate",
     770             :                                     Constant::Units::W,
     771         137 :                                     simpleWAHP.QLoadTotal,
     772             :                                     OutputProcessor::TimeStepType::System,
     773             :                                     OutputProcessor::StoreType::Average,
     774         137 :                                     simpleWAHP.Name);
     775         274 :                 SetupOutputVariable(state,
     776             :                                     "Cooling Coil Sensible Cooling Rate",
     777             :                                     Constant::Units::W,
     778         137 :                                     simpleWAHP.QSensible,
     779             :                                     OutputProcessor::TimeStepType::System,
     780             :                                     OutputProcessor::StoreType::Average,
     781         137 :                                     simpleWAHP.Name);
     782         274 :                 SetupOutputVariable(state,
     783             :                                     "Cooling Coil Latent Cooling Rate",
     784             :                                     Constant::Units::W,
     785         137 :                                     simpleWAHP.QLatent,
     786             :                                     OutputProcessor::TimeStepType::System,
     787             :                                     OutputProcessor::StoreType::Average,
     788         137 :                                     simpleWAHP.Name);
     789         274 :                 SetupOutputVariable(state,
     790             :                                     "Cooling Coil Source Side Heat Transfer Rate",
     791             :                                     Constant::Units::W,
     792         137 :                                     simpleWAHP.QSource,
     793             :                                     OutputProcessor::TimeStepType::System,
     794             :                                     OutputProcessor::StoreType::Average,
     795         137 :                                     simpleWAHP.Name);
     796         274 :                 SetupOutputVariable(state,
     797             :                                     "Cooling Coil Part Load Ratio",
     798             :                                     Constant::Units::None,
     799         137 :                                     simpleWAHP.PartLoadRatio,
     800             :                                     OutputProcessor::TimeStepType::System,
     801             :                                     OutputProcessor::StoreType::Average,
     802         137 :                                     simpleWAHP.Name);
     803         274 :                 SetupOutputVariable(state,
     804             :                                     "Cooling Coil Runtime Fraction",
     805             :                                     Constant::Units::None,
     806         137 :                                     simpleWAHP.RunFrac,
     807             :                                     OutputProcessor::TimeStepType::System,
     808             :                                     OutputProcessor::StoreType::Average,
     809         137 :                                     simpleWAHP.Name);
     810             : 
     811         274 :                 SetupOutputVariable(state,
     812             :                                     "Cooling Coil Air Mass Flow Rate",
     813             :                                     Constant::Units::kg_s,
     814         137 :                                     simpleWAHP.AirMassFlowRate,
     815             :                                     OutputProcessor::TimeStepType::System,
     816             :                                     OutputProcessor::StoreType::Average,
     817         137 :                                     simpleWAHP.Name);
     818         274 :                 SetupOutputVariable(state,
     819             :                                     "Cooling Coil Air Inlet Temperature",
     820             :                                     Constant::Units::C,
     821         137 :                                     simpleWAHP.InletAirDBTemp,
     822             :                                     OutputProcessor::TimeStepType::System,
     823             :                                     OutputProcessor::StoreType::Average,
     824         137 :                                     simpleWAHP.Name);
     825         274 :                 SetupOutputVariable(state,
     826             :                                     "Cooling Coil Air Inlet Humidity Ratio",
     827             :                                     Constant::Units::kgWater_kgDryAir,
     828         137 :                                     simpleWAHP.InletAirHumRat,
     829             :                                     OutputProcessor::TimeStepType::System,
     830             :                                     OutputProcessor::StoreType::Average,
     831         137 :                                     simpleWAHP.Name);
     832         274 :                 SetupOutputVariable(state,
     833             :                                     "Cooling Coil Air Outlet Temperature",
     834             :                                     Constant::Units::C,
     835         137 :                                     simpleWAHP.OutletAirDBTemp,
     836             :                                     OutputProcessor::TimeStepType::System,
     837             :                                     OutputProcessor::StoreType::Average,
     838         137 :                                     simpleWAHP.Name);
     839         274 :                 SetupOutputVariable(state,
     840             :                                     "Cooling Coil Air Outlet Humidity Ratio",
     841             :                                     Constant::Units::kgWater_kgDryAir,
     842         137 :                                     simpleWAHP.OutletAirHumRat,
     843             :                                     OutputProcessor::TimeStepType::System,
     844             :                                     OutputProcessor::StoreType::Average,
     845         137 :                                     simpleWAHP.Name);
     846         274 :                 SetupOutputVariable(state,
     847             :                                     "Cooling Coil Source Side Mass Flow Rate",
     848             :                                     Constant::Units::kg_s,
     849         137 :                                     simpleWAHP.WaterMassFlowRate,
     850             :                                     OutputProcessor::TimeStepType::System,
     851             :                                     OutputProcessor::StoreType::Average,
     852         137 :                                     simpleWAHP.Name);
     853         274 :                 SetupOutputVariable(state,
     854             :                                     "Cooling Coil Source Side Inlet Temperature",
     855             :                                     Constant::Units::C,
     856         137 :                                     simpleWAHP.InletWaterTemp,
     857             :                                     OutputProcessor::TimeStepType::System,
     858             :                                     OutputProcessor::StoreType::Average,
     859         137 :                                     simpleWAHP.Name);
     860         274 :                 SetupOutputVariable(state,
     861             :                                     "Cooling Coil Source Side Outlet Temperature",
     862             :                                     Constant::Units::C,
     863         137 :                                     simpleWAHP.OutletWaterTemp,
     864             :                                     OutputProcessor::TimeStepType::System,
     865             :                                     OutputProcessor::StoreType::Average,
     866         137 :                                     simpleWAHP.Name);
     867             : 
     868         137 :             } else if (simpleWAHP.WAHPPlantType == DataPlant::PlantEquipmentType::CoilWAHPHeatingEquationFit) {
     869             :                 // HEATING COIL Setup Report variables for the Heat Pump
     870         274 :                 SetupOutputVariable(state,
     871             :                                     "Heating Coil Electricity Rate",
     872             :                                     Constant::Units::W,
     873         137 :                                     simpleWAHP.Power,
     874             :                                     OutputProcessor::TimeStepType::System,
     875             :                                     OutputProcessor::StoreType::Average,
     876         137 :                                     simpleWAHP.Name);
     877         274 :                 SetupOutputVariable(state,
     878             :                                     "Heating Coil Heating Rate",
     879             :                                     Constant::Units::W,
     880         137 :                                     simpleWAHP.QLoadTotal,
     881             :                                     OutputProcessor::TimeStepType::System,
     882             :                                     OutputProcessor::StoreType::Average,
     883         137 :                                     simpleWAHP.Name);
     884         274 :                 SetupOutputVariable(state,
     885             :                                     "Heating Coil Sensible Heating Rate",
     886             :                                     Constant::Units::W,
     887         137 :                                     simpleWAHP.QSensible,
     888             :                                     OutputProcessor::TimeStepType::System,
     889             :                                     OutputProcessor::StoreType::Average,
     890         137 :                                     simpleWAHP.Name);
     891             : 
     892         274 :                 SetupOutputVariable(state,
     893             :                                     "Heating Coil Source Side Heat Transfer Rate",
     894             :                                     Constant::Units::W,
     895         137 :                                     simpleWAHP.QSource,
     896             :                                     OutputProcessor::TimeStepType::System,
     897             :                                     OutputProcessor::StoreType::Average,
     898         137 :                                     simpleWAHP.Name);
     899         274 :                 SetupOutputVariable(state,
     900             :                                     "Heating Coil Part Load Ratio",
     901             :                                     Constant::Units::None,
     902         137 :                                     simpleWAHP.PartLoadRatio,
     903             :                                     OutputProcessor::TimeStepType::System,
     904             :                                     OutputProcessor::StoreType::Average,
     905         137 :                                     simpleWAHP.Name);
     906         274 :                 SetupOutputVariable(state,
     907             :                                     "Heating Coil Runtime Fraction",
     908             :                                     Constant::Units::None,
     909         137 :                                     simpleWAHP.RunFrac,
     910             :                                     OutputProcessor::TimeStepType::System,
     911             :                                     OutputProcessor::StoreType::Average,
     912         137 :                                     simpleWAHP.Name);
     913             : 
     914         274 :                 SetupOutputVariable(state,
     915             :                                     "Heating Coil Air Mass Flow Rate",
     916             :                                     Constant::Units::kg_s,
     917         137 :                                     simpleWAHP.AirMassFlowRate,
     918             :                                     OutputProcessor::TimeStepType::System,
     919             :                                     OutputProcessor::StoreType::Average,
     920         137 :                                     simpleWAHP.Name);
     921         274 :                 SetupOutputVariable(state,
     922             :                                     "Heating Coil Air Inlet Temperature",
     923             :                                     Constant::Units::C,
     924         137 :                                     simpleWAHP.InletAirDBTemp,
     925             :                                     OutputProcessor::TimeStepType::System,
     926             :                                     OutputProcessor::StoreType::Average,
     927         137 :                                     simpleWAHP.Name);
     928         274 :                 SetupOutputVariable(state,
     929             :                                     "Heating Coil Air Inlet Humidity Ratio",
     930             :                                     Constant::Units::kgWater_kgDryAir,
     931         137 :                                     simpleWAHP.InletAirHumRat,
     932             :                                     OutputProcessor::TimeStepType::System,
     933             :                                     OutputProcessor::StoreType::Average,
     934         137 :                                     simpleWAHP.Name);
     935         274 :                 SetupOutputVariable(state,
     936             :                                     "Heating Coil Air Outlet Temperature",
     937             :                                     Constant::Units::C,
     938         137 :                                     simpleWAHP.OutletAirDBTemp,
     939             :                                     OutputProcessor::TimeStepType::System,
     940             :                                     OutputProcessor::StoreType::Average,
     941         137 :                                     simpleWAHP.Name);
     942         274 :                 SetupOutputVariable(state,
     943             :                                     "Heating Coil Air Outlet Humidity Ratio",
     944             :                                     Constant::Units::kgWater_kgDryAir,
     945         137 :                                     simpleWAHP.OutletAirHumRat,
     946             :                                     OutputProcessor::TimeStepType::System,
     947             :                                     OutputProcessor::StoreType::Average,
     948         137 :                                     simpleWAHP.Name);
     949         274 :                 SetupOutputVariable(state,
     950             :                                     "Heating Coil Source Side Mass Flow Rate",
     951             :                                     Constant::Units::kg_s,
     952         137 :                                     simpleWAHP.WaterMassFlowRate,
     953             :                                     OutputProcessor::TimeStepType::System,
     954             :                                     OutputProcessor::StoreType::Average,
     955         137 :                                     simpleWAHP.Name);
     956         274 :                 SetupOutputVariable(state,
     957             :                                     "Heating Coil Source Side Inlet Temperature",
     958             :                                     Constant::Units::C,
     959         137 :                                     simpleWAHP.InletWaterTemp,
     960             :                                     OutputProcessor::TimeStepType::System,
     961             :                                     OutputProcessor::StoreType::Average,
     962         137 :                                     simpleWAHP.Name);
     963         274 :                 SetupOutputVariable(state,
     964             :                                     "Heating Coil Source Side Outlet Temperature",
     965             :                                     Constant::Units::C,
     966         137 :                                     simpleWAHP.OutletWaterTemp,
     967             :                                     OutputProcessor::TimeStepType::System,
     968             :                                     OutputProcessor::StoreType::Average,
     969         137 :                                     simpleWAHP.Name);
     970             :             }
     971             :         }
     972          18 :     }
     973             : 
     974             :     // Beginning Initialization Section of the Module
     975             :     //******************************************************************************
     976             : 
     977    43852909 :     void InitSimpleWatertoAirHP(EnergyPlusData &state,
     978             :                                 int const HPNum,                                 // Current HPNum under simulation
     979             :                                 Real64 const SensLoad,                           // Control zone sensible load[W]
     980             :                                 Real64 const LatentLoad,                         // Control zone latent load[W]
     981             :                                 [[maybe_unused]] HVAC::FanOp const fanOp,        // fan operating mode
     982             :                                 [[maybe_unused]] Real64 const OnOffAirFlowRatio, // ratio of compressor on flow to average flow over time step
     983             :                                 bool const FirstHVACIteration                    // Iteration flag
     984             :     )
     985             :     {
     986             : 
     987             :         // SUBROUTINE INFORMATION:
     988             :         //       AUTHOR         Arun Shenoy
     989             :         //       DATE WRITTEN   Nov 2003
     990             :         //       RE-ENGINEERED  Kenneth Tang (Jan 2005)
     991             : 
     992             :         // PURPOSE OF THIS SUBROUTINE:
     993             :         // This subroutine is for initializations of the Simple Water to Air HP Components.
     994             : 
     995             :         // METHODOLOGY EMPLOYED:
     996             :         // Uses the status flags to trigger initializations.
     997             : 
     998             :         // SUBROUTINE PARAMETER DEFINITIONS:
     999             :         static constexpr std::string_view RoutineName("InitSimpleWatertoAirHP");
    1000             : 
    1001             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    1002             :         int AirInletNode;            // Node Number of the air inlet
    1003             :         int WaterInletNode;          // Node Number of the Water inlet
    1004             :         Real64 RatedAirMassFlowRate; // coil rated air mass flow rates
    1005             :         Real64 rho;                  // local fluid density
    1006             :         bool errFlag;
    1007             : 
    1008    43852909 :         if (state.dataWaterToAirHeatPumpSimple->MyOneTimeFlag) {
    1009             :             // initialize the environment and sizing flags
    1010          18 :             state.dataWaterToAirHeatPumpSimple->MySizeFlag.allocate(state.dataWaterToAirHeatPumpSimple->NumWatertoAirHPs);
    1011          18 :             state.dataWaterToAirHeatPumpSimple->MyEnvrnFlag.allocate(state.dataWaterToAirHeatPumpSimple->NumWatertoAirHPs);
    1012          18 :             state.dataWaterToAirHeatPumpSimple->MyPlantScanFlag.allocate(state.dataWaterToAirHeatPumpSimple->NumWatertoAirHPs);
    1013          18 :             state.dataWaterToAirHeatPumpSimple->MySizeFlag = true;
    1014          18 :             state.dataWaterToAirHeatPumpSimple->MyEnvrnFlag = true;
    1015          18 :             state.dataWaterToAirHeatPumpSimple->MyPlantScanFlag = true;
    1016          18 :             state.dataWaterToAirHeatPumpSimple->MyOneTimeFlag = false;
    1017             :         }
    1018             : 
    1019    43852909 :         auto &simpleWatertoAirHP(state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(HPNum));
    1020             : 
    1021    43852909 :         if (state.dataWaterToAirHeatPumpSimple->MyPlantScanFlag(HPNum) && allocated(state.dataPlnt->PlantLoop)) {
    1022         274 :             errFlag = false;
    1023         548 :             PlantUtilities::ScanPlantLoopsForObject(
    1024         274 :                 state, simpleWatertoAirHP.Name, simpleWatertoAirHP.WAHPPlantType, simpleWatertoAirHP.plantLoc, errFlag, _, _, _, _, _);
    1025         274 :             if (errFlag) {
    1026           0 :                 ShowFatalError(state, "InitSimpleWatertoAirHP: Program terminated for previous conditions.");
    1027             :             }
    1028         274 :             state.dataWaterToAirHeatPumpSimple->MyPlantScanFlag(HPNum) = false;
    1029             :         }
    1030             : 
    1031    43852909 :         if (state.dataWaterToAirHeatPumpSimple->MySizeFlag(HPNum)) {
    1032         335 :             if (!state.dataGlobal->SysSizingCalc && !state.dataWaterToAirHeatPumpSimple->MyPlantScanFlag(HPNum)) {
    1033             :                 // do the sizing once.
    1034         274 :                 SizeHVACWaterToAir(state, HPNum);
    1035         274 :                 state.dataWaterToAirHeatPumpSimple->MySizeFlag(HPNum) = false;
    1036             :             }
    1037             :         }
    1038             : 
    1039    43852909 :         if (FirstHVACIteration) {
    1040     1549943 :             if (state.dataWaterToAirHeatPumpSimple->SimpleHPTimeStepFlag(HPNum)) {
    1041      291894 :                 if (simpleWatertoAirHP.WAHPPlantType == DataPlant::PlantEquipmentType::CoilWAHPCoolingEquationFit) {
    1042      291894 :                     if (simpleWatertoAirHP.CompanionHeatingCoilNum > 0) {
    1043      291894 :                         if (simpleWatertoAirHP.WaterFlowMode) {
    1044      159277 :                             simpleWatertoAirHP.LastOperatingMode = HVAC::Cooling;
    1045      159277 :                             state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(simpleWatertoAirHP.CompanionHeatingCoilNum).LastOperatingMode =
    1046             :                                 HVAC::Cooling;
    1047      132617 :                         } else if (state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(simpleWatertoAirHP.CompanionHeatingCoilNum).WaterFlowMode) {
    1048       76713 :                             simpleWatertoAirHP.LastOperatingMode = HVAC::Heating;
    1049       76713 :                             state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(simpleWatertoAirHP.CompanionHeatingCoilNum).LastOperatingMode =
    1050             :                                 HVAC::Heating;
    1051             :                         }
    1052      291894 :                         state.dataWaterToAirHeatPumpSimple->SimpleHPTimeStepFlag(simpleWatertoAirHP.CompanionHeatingCoilNum) = false;
    1053             :                     } else {
    1054           0 :                         if (simpleWatertoAirHP.WaterFlowMode) {
    1055           0 :                             simpleWatertoAirHP.LastOperatingMode = HVAC::Cooling;
    1056             :                         }
    1057             :                     }
    1058      291894 :                     state.dataWaterToAirHeatPumpSimple->SimpleHPTimeStepFlag(HPNum) = false;
    1059             :                 } else {
    1060             :                     // it is a heating coil
    1061           0 :                     if (simpleWatertoAirHP.CompanionCoolingCoilNum > 0) {
    1062           0 :                         if (simpleWatertoAirHP.WaterFlowMode) {
    1063           0 :                             simpleWatertoAirHP.LastOperatingMode = HVAC::Heating;
    1064           0 :                             state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(simpleWatertoAirHP.CompanionCoolingCoilNum).LastOperatingMode =
    1065             :                                 HVAC::Heating;
    1066           0 :                         } else if (state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(simpleWatertoAirHP.CompanionCoolingCoilNum).WaterFlowMode) {
    1067           0 :                             simpleWatertoAirHP.LastOperatingMode = HVAC::Cooling;
    1068           0 :                             state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(simpleWatertoAirHP.CompanionCoolingCoilNum).LastOperatingMode =
    1069             :                                 HVAC::Cooling;
    1070             :                         }
    1071           0 :                         state.dataWaterToAirHeatPumpSimple->SimpleHPTimeStepFlag(simpleWatertoAirHP.CompanionCoolingCoilNum) = false;
    1072             :                     } else {
    1073           0 :                         if (simpleWatertoAirHP.WaterFlowMode) {
    1074           0 :                             simpleWatertoAirHP.LastOperatingMode = HVAC::Heating;
    1075             :                         }
    1076             :                     }
    1077           0 :                     state.dataWaterToAirHeatPumpSimple->SimpleHPTimeStepFlag(HPNum) = false;
    1078             :                 }
    1079             :             }
    1080             :         } else {
    1081    42302966 :             state.dataWaterToAirHeatPumpSimple->SimpleHPTimeStepFlag(HPNum) = true;
    1082    42302966 :             if (simpleWatertoAirHP.WAHPPlantType == DataPlant::PlantEquipmentType::CoilWAHPCoolingEquationFit) {
    1083    21151483 :                 if (simpleWatertoAirHP.CompanionHeatingCoilNum > 0)
    1084    21151483 :                     state.dataWaterToAirHeatPumpSimple->SimpleHPTimeStepFlag(simpleWatertoAirHP.CompanionHeatingCoilNum) = true;
    1085             :             } else {
    1086    21151483 :                 if (simpleWatertoAirHP.CompanionCoolingCoilNum > 0)
    1087    21151483 :                     state.dataWaterToAirHeatPumpSimple->SimpleHPTimeStepFlag(simpleWatertoAirHP.CompanionCoolingCoilNum) = true;
    1088             :             }
    1089             :         }
    1090             : 
    1091             :         // Do the Begin Environment initializations
    1092    43852909 :         if (state.dataGlobal->BeginEnvrnFlag) {
    1093             : 
    1094       72378 :             if (state.dataWaterToAirHeatPumpSimple->MyEnvrnFlag(HPNum) && !state.dataWaterToAirHeatPumpSimple->MyPlantScanFlag(HPNum)) {
    1095             : 
    1096             :                 // Do the initializations to start simulation
    1097             : 
    1098        1824 :                 AirInletNode = simpleWatertoAirHP.AirInletNodeNum;
    1099        1824 :                 WaterInletNode = simpleWatertoAirHP.WaterInletNodeNum;
    1100             : 
    1101             :                 // Initialize all report variables to a known state at beginning of simulation
    1102        1824 :                 simpleWatertoAirHP.AirVolFlowRate = 0.0;
    1103        1824 :                 simpleWatertoAirHP.InletAirDBTemp = 0.0;
    1104        1824 :                 simpleWatertoAirHP.InletAirHumRat = 0.0;
    1105        1824 :                 simpleWatertoAirHP.OutletAirDBTemp = 0.0;
    1106        1824 :                 simpleWatertoAirHP.OutletAirHumRat = 0.0;
    1107        1824 :                 simpleWatertoAirHP.WaterVolFlowRate = 0.0;
    1108        1824 :                 simpleWatertoAirHP.WaterMassFlowRate = 0.0;
    1109        1824 :                 simpleWatertoAirHP.InletWaterTemp = 0.0;
    1110        1824 :                 simpleWatertoAirHP.InletWaterEnthalpy = 0.0;
    1111        1824 :                 simpleWatertoAirHP.OutletWaterEnthalpy = 0.0;
    1112        1824 :                 simpleWatertoAirHP.OutletWaterTemp = 0.0;
    1113        1824 :                 simpleWatertoAirHP.Power = 0.0;
    1114        1824 :                 simpleWatertoAirHP.QLoadTotal = 0.0;
    1115        1824 :                 simpleWatertoAirHP.QLoadTotalReport = 0.0;
    1116        1824 :                 simpleWatertoAirHP.QSensible = 0.0;
    1117        1824 :                 simpleWatertoAirHP.QLatent = 0.0;
    1118        1824 :                 simpleWatertoAirHP.QSource = 0.0;
    1119        1824 :                 simpleWatertoAirHP.Energy = 0.0;
    1120        1824 :                 simpleWatertoAirHP.EnergyLoadTotal = 0.0;
    1121        1824 :                 simpleWatertoAirHP.EnergySensible = 0.0;
    1122        1824 :                 simpleWatertoAirHP.EnergyLatent = 0.0;
    1123        1824 :                 simpleWatertoAirHP.EnergySource = 0.0;
    1124        1824 :                 simpleWatertoAirHP.COP = 0.0;
    1125        1824 :                 simpleWatertoAirHP.RunFrac = 0.0;
    1126        1824 :                 simpleWatertoAirHP.PartLoadRatio = 0.0;
    1127             : 
    1128        1824 :                 if (simpleWatertoAirHP.RatedWaterVolFlowRate != DataSizing::AutoSize) {
    1129        1702 :                     rho = FluidProperties::GetDensityGlycol(state,
    1130        1702 :                                                             state.dataPlnt->PlantLoop(simpleWatertoAirHP.plantLoc.loopNum).FluidName,
    1131             :                                                             Constant::InitConvTemp,
    1132        1702 :                                                             state.dataPlnt->PlantLoop(simpleWatertoAirHP.plantLoc.loopNum).FluidIndex,
    1133             :                                                             RoutineName);
    1134             : 
    1135        1702 :                     simpleWatertoAirHP.DesignWaterMassFlowRate = rho * simpleWatertoAirHP.RatedWaterVolFlowRate;
    1136        1702 :                     PlantUtilities::InitComponentNodes(state,
    1137             :                                                        0.0,
    1138             :                                                        simpleWatertoAirHP.DesignWaterMassFlowRate,
    1139             :                                                        simpleWatertoAirHP.WaterInletNodeNum,
    1140             :                                                        simpleWatertoAirHP.WaterOutletNodeNum);
    1141             : 
    1142        1702 :                     if (simpleWatertoAirHP.WAHPType == WatertoAirHP::Heating && simpleWatertoAirHP.CompanionCoolingCoilNum > 0) {
    1143         912 :                         state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(simpleWatertoAirHP.CompanionCoolingCoilNum).DesignWaterMassFlowRate =
    1144         912 :                             rho *
    1145         912 :                             state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(simpleWatertoAirHP.CompanionCoolingCoilNum).RatedWaterVolFlowRate;
    1146        2736 :                         PlantUtilities::InitComponentNodes(
    1147             :                             state,
    1148             :                             0.0,
    1149         912 :                             state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(simpleWatertoAirHP.CompanionCoolingCoilNum)
    1150             :                                 .DesignWaterMassFlowRate,
    1151         912 :                             state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(simpleWatertoAirHP.CompanionCoolingCoilNum).WaterInletNodeNum,
    1152         912 :                             state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(simpleWatertoAirHP.CompanionCoolingCoilNum).WaterOutletNodeNum);
    1153             :                     }
    1154             :                 }
    1155             : 
    1156        1824 :                 simpleWatertoAirHP.SimFlag = true;
    1157             : 
    1158        1824 :                 state.dataWaterToAirHeatPumpSimple->MyEnvrnFlag(HPNum) = false;
    1159             :             }
    1160             : 
    1161             :         } // End If for the Begin Environment initializations
    1162             : 
    1163    43852909 :         if (!state.dataGlobal->BeginEnvrnFlag) {
    1164    43780531 :             state.dataWaterToAirHeatPumpSimple->MyEnvrnFlag(HPNum) = true;
    1165             :         }
    1166             : 
    1167             :         // Do the following initializations (every time step): This should be the info from
    1168             :         // the previous components outlets or the node data in this section.
    1169             :         // First set the conditions for the air into the heat pump model
    1170             : 
    1171             :         // Set water and air inlet nodes
    1172             : 
    1173    43852909 :         AirInletNode = simpleWatertoAirHP.AirInletNodeNum;
    1174    43852909 :         WaterInletNode = simpleWatertoAirHP.WaterInletNodeNum;
    1175             : 
    1176    43852909 :         if ((SensLoad != 0.0 || LatentLoad != 0.0) && (state.dataLoopNodes->Node(AirInletNode).MassFlowRate > 0.0)) {
    1177    16318693 :             simpleWatertoAirHP.WaterMassFlowRate = simpleWatertoAirHP.DesignWaterMassFlowRate;
    1178             : 
    1179    16318693 :             simpleWatertoAirHP.AirMassFlowRate = state.dataLoopNodes->Node(AirInletNode).MassFlowRate;
    1180             :             // If air flow is less than 25% rated flow. Then throw warning
    1181    16318693 :             RatedAirMassFlowRate =
    1182    16318693 :                 simpleWatertoAirHP.RatedAirVolFlowRate * Psychrometrics::PsyRhoAirFnPbTdbW(state,
    1183    16318693 :                                                                                            state.dataEnvrn->StdBaroPress,
    1184    16318693 :                                                                                            state.dataLoopNodes->Node(AirInletNode).Temp,
    1185    16318693 :                                                                                            state.dataLoopNodes->Node(AirInletNode).HumRat,
    1186             :                                                                                            RoutineName);
    1187    16318693 :             if (simpleWatertoAirHP.AirMassFlowRate < 0.25 * RatedAirMassFlowRate) {
    1188     1163708 :                 ShowRecurringWarningErrorAtEnd(state,
    1189             :                                                "Actual air mass flow rate is smaller than 25% of water-to-air heat pump coil rated air flow rate.",
    1190      581854 :                                                state.dataWaterToAirHeatPumpSimple->AirflowErrPointer,
    1191      581854 :                                                simpleWatertoAirHP.AirMassFlowRate,
    1192      581854 :                                                simpleWatertoAirHP.AirMassFlowRate);
    1193             :             }
    1194    16318693 :             simpleWatertoAirHP.WaterFlowMode = true;
    1195             :         } else { // heat pump is off
    1196    27534216 :             simpleWatertoAirHP.WaterFlowMode = false;
    1197    27534216 :             simpleWatertoAirHP.WaterMassFlowRate = 0.0;
    1198    27534216 :             simpleWatertoAirHP.AirMassFlowRate = 0.0;
    1199    27534216 :             if ((simpleWatertoAirHP.WaterCyclingMode) == HVAC::WaterFlow::Constant) {
    1200           0 :                 if (simpleWatertoAirHP.WAHPPlantType == DataPlant::PlantEquipmentType::CoilWAHPCoolingEquationFit) {
    1201           0 :                     if (simpleWatertoAirHP.CompanionHeatingCoilNum > 0) {
    1202           0 :                         if (state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(simpleWatertoAirHP.CompanionHeatingCoilNum).QLoadTotal > 0.0) {
    1203             :                             // do nothing, there will be flow through this coil
    1204           0 :                         } else if (simpleWatertoAirHP.LastOperatingMode == HVAC::Cooling) {
    1205             :                             // set the flow rate to full design flow
    1206           0 :                             simpleWatertoAirHP.WaterMassFlowRate = simpleWatertoAirHP.DesignWaterMassFlowRate;
    1207             :                         }
    1208             :                     } else {
    1209           0 :                         if (simpleWatertoAirHP.LastOperatingMode == HVAC::Cooling) {
    1210             :                             // set the flow rate to full design flow
    1211           0 :                             simpleWatertoAirHP.WaterMassFlowRate = simpleWatertoAirHP.DesignWaterMassFlowRate;
    1212             :                         }
    1213             :                     }
    1214           0 :                 } else if (simpleWatertoAirHP.WAHPPlantType == DataPlant::PlantEquipmentType::CoilWAHPHeatingEquationFit) {
    1215             :                     // It's a heating coil
    1216           0 :                     if (simpleWatertoAirHP.CompanionCoolingCoilNum > 0) {
    1217           0 :                         if (state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(simpleWatertoAirHP.CompanionCoolingCoilNum).QLoadTotal > 0.0) {
    1218             :                             // do nothing, there will be flow through this coil
    1219           0 :                         } else if (simpleWatertoAirHP.LastOperatingMode == HVAC::Heating) {
    1220             :                             // set the flow rate to full design flow
    1221           0 :                             simpleWatertoAirHP.WaterMassFlowRate = simpleWatertoAirHP.DesignWaterMassFlowRate;
    1222             :                         }
    1223             :                     } else {
    1224           0 :                         if (simpleWatertoAirHP.LastOperatingMode == HVAC::Heating) {
    1225             :                             // set the flow rate to full design flow
    1226           0 :                             simpleWatertoAirHP.WaterMassFlowRate = simpleWatertoAirHP.DesignWaterMassFlowRate;
    1227             :                         }
    1228             :                     }
    1229             :                 }
    1230             :             }
    1231             :         }
    1232             : 
    1233    43852909 :         PlantUtilities::SetComponentFlowRate(state,
    1234    43852909 :                                              simpleWatertoAirHP.WaterMassFlowRate,
    1235             :                                              simpleWatertoAirHP.WaterInletNodeNum,
    1236             :                                              simpleWatertoAirHP.WaterOutletNodeNum,
    1237    43852909 :                                              simpleWatertoAirHP.plantLoc);
    1238             : 
    1239    43852909 :         simpleWatertoAirHP.InletAirDBTemp = state.dataLoopNodes->Node(AirInletNode).Temp;
    1240    43852909 :         simpleWatertoAirHP.InletAirHumRat = state.dataLoopNodes->Node(AirInletNode).HumRat;
    1241    43852909 :         simpleWatertoAirHP.InletAirEnthalpy = state.dataLoopNodes->Node(AirInletNode).Enthalpy;
    1242    43852909 :         simpleWatertoAirHP.InletWaterTemp = state.dataLoopNodes->Node(WaterInletNode).Temp;
    1243    43852909 :         simpleWatertoAirHP.InletWaterEnthalpy = state.dataLoopNodes->Node(WaterInletNode).Enthalpy;
    1244    43852909 :         simpleWatertoAirHP.OutletWaterTemp = simpleWatertoAirHP.InletWaterTemp;
    1245    43852909 :         simpleWatertoAirHP.OutletWaterEnthalpy = simpleWatertoAirHP.InletWaterEnthalpy;
    1246             : 
    1247             :         // Outlet variables
    1248    43852909 :         simpleWatertoAirHP.Power = 0.0;
    1249    43852909 :         simpleWatertoAirHP.QLoadTotal = 0.0;
    1250    43852909 :         simpleWatertoAirHP.QLoadTotalReport = 0.0;
    1251    43852909 :         simpleWatertoAirHP.QSensible = 0.0;
    1252    43852909 :         simpleWatertoAirHP.QLatent = 0.0;
    1253    43852909 :         simpleWatertoAirHP.QSource = 0.0;
    1254    43852909 :         simpleWatertoAirHP.Energy = 0.0;
    1255    43852909 :         simpleWatertoAirHP.EnergyLoadTotal = 0.0;
    1256    43852909 :         simpleWatertoAirHP.EnergySensible = 0.0;
    1257    43852909 :         simpleWatertoAirHP.EnergyLatent = 0.0;
    1258    43852909 :         simpleWatertoAirHP.EnergySource = 0.0;
    1259    43852909 :         simpleWatertoAirHP.COP = 0.0;
    1260    43852909 :         state.dataHeatBal->HeatReclaimSimple_WAHPCoil(HPNum).AvailCapacity = 0.0;
    1261    43852909 :     }
    1262             : 
    1263         274 :     void SizeHVACWaterToAir(EnergyPlusData &state, int const HPNum)
    1264             :     {
    1265             : 
    1266             :         // SUBROUTINE INFORMATION:
    1267             :         //       AUTHOR         Richard Raustad, FSEC
    1268             :         //       DATE WRITTEN   June 2009
    1269             :         //       MODIFIED       August 2013 Daeho Kang, add component sizing table entries
    1270             : 
    1271             :         // PURPOSE OF THIS SUBROUTINE:
    1272             :         // This subroutine is for sizing WSHP Components for which nominal capacities
    1273             :         // and flow rates have not been specified in the input
    1274             : 
    1275             :         // METHODOLOGY EMPLOYED:
    1276             :         // Obtains heating capacities and flow rates from the zone or system sizing arrays.
    1277             : 
    1278         274 :         auto &ZoneEqSizing(state.dataSize->ZoneEqSizing);
    1279         274 :         auto &simpleWatertoAirHP(state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(HPNum));
    1280             : 
    1281             :         // SUBROUTINE PARAMETER DEFINITIONS:
    1282             :         static constexpr std::string_view RoutineName("SizeWaterToAirCoil");
    1283             :         static constexpr std::string_view RoutineNameAlt("SizeHVACWaterToAir");
    1284             : 
    1285             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    1286             :         Real64 rhoair;
    1287             :         Real64 MixTemp;                   // Mixed air temperature at cooling design conditions
    1288             :         Real64 MixTempSys;                // Mixed air temperature at cooling design conditions at system air flow
    1289             :         Real64 HeatMixTemp;               // Mixed air temperature at heating design conditions
    1290             :         Real64 HeatMixTempSys;            // Mixed air temperature at heating design conditions at system air flow
    1291             :         Real64 MixHumRat;                 // Mixed air humidity ratio at cooling design conditions
    1292             :         Real64 MixHumRatSys;              // Mixed air humidity ratio at cooling design conditions at system air flow
    1293             :         Real64 HeatMixHumRat;             // Mixed air humidity ratio at heating design conditions
    1294             :         Real64 HeatMixHumRatSys;          // Mixed air humidity ratio at heating design conditions at system air flow
    1295             :         Real64 MixEnth;                   // Mixed air enthalpy at cooling design conditions
    1296             :         Real64 MixEnthSys;                // Mixed air enthalpy at cooling design conditions at system air flow
    1297             :         Real64 MixWetBulb;                // Mixed air wet-bulb temperature at cooling design conditions
    1298         274 :         Real64 RatedMixWetBulb = 0.0;     // Rated mixed air wetbulb temperature
    1299         274 :         Real64 RatedMixDryBulb = 0.0;     // Rated mixed air drybulb temperature
    1300         274 :         Real64 RatedHeatMixDryBulb = 0.0; // Rated mixed air drybulb temperature at heating design conditions
    1301             :         Real64 SupTemp;                   // Supply air temperature at cooling design conditions
    1302             :         Real64 HeatSupTemp;               // Supply air temperature at heating design conditions
    1303             :         Real64 SupHumRat;                 // Supply air humidity ratio at cooling design conditions
    1304             :         Real64 SupEnth;                   // Supply air enthalpy at cooling design conditions
    1305             :         Real64 OutTemp;                   // Outdoor aur dry-bulb temperature at cooling design conditions
    1306             :         Real64 ratioTDB;                  // Load-side dry-bulb temperature ratio at cooling design conditions
    1307             :         Real64 HeatratioTDB;              // Load-side dry-bulb temperature ratio at heating design conditions
    1308             :         Real64 ratioTWB;                  // Load-side wet-bulb temperature ratio at cooling design conditions
    1309             :         Real64 ratioTS;                   // Source-side temperature ratio at cooling design conditions
    1310             :         Real64 HeatratioTS;               // Source-side temperature ratio at heating design conditions
    1311             :         Real64 RatedratioTDB;             // Rated cooling load-side dry-bulb temperature ratio
    1312         274 :         Real64 RatedHeatratioTDB = 0.0;   // Rated cooling load-side dry-bulb temperature ratio
    1313             :         Real64 RatedratioTWB;             // Rated cooling load-side wet-bulb temperature ratio
    1314             :         Real64 RatedratioTS;              // Rated cooling source-side temperature ratio
    1315             :         Real64 RatedHeatratioTS;          // Rated heating source-side temperature ratio
    1316             :         Real64 OutAirFrac;                // Outdoor air fraction at cooling design conditions
    1317             :         Real64 OutAirFracSys;             // Outdoor air fraction at cooling design conditions at system air flow
    1318             :         Real64 HeatOutAirFrac;            // Outdoor air fraction at heating design conditions
    1319             :         Real64 HeatOutAirFracSys;         // Outdoor air fraction at heating design conditions at system air flow
    1320             :         Real64 VolFlowRate;
    1321             :         Real64 CoolCapAtPeak;                  // Load on the cooling coil at cooling design conditions
    1322             :         Real64 HeatCapAtPeak;                  // Load on the heating coil at heating design conditions
    1323         274 :         Real64 PeakTotCapTempModFac = 1.0;     // Peak total cooling capacity curve modifier
    1324         274 :         Real64 RatedTotCapTempModFac = 1.0;    // Rated total cooling capacity curve modifier
    1325         274 :         Real64 PeakHeatCapTempModFac = 1.0;    // Peak heating capacity curve modifier
    1326             :         Real64 DesignEntWaterTemp;             // Design entering coil water temperature
    1327             :         Real64 SensCapAtPeak;                  // Sensible load on the cooling coil at cooling design conditions
    1328         274 :         Real64 PeakSensCapTempModFac = 1.0;    // Peak sensible cooling capacity curve modifier
    1329         274 :         Real64 RatedSensCapTempModFac = 1.0;   // Rated sensible cooling capacity curve modifier
    1330         274 :         Real64 RatedHeatCapTempModFac = 1.0;   // Rated heating capacity curve modifier
    1331         274 :         Real64 RatedCoolPowerTempModFac = 1.0; // Rated cooling power curve modifier
    1332         274 :         Real64 RatedHeatPowerTempModFac = 1.0; // Rated heating power curve modifier
    1333             :         Real64 RatedCapCoolTotalDesCDD;        // Rated total cooling coil capacity determined at cooling design conditions
    1334         274 :         constexpr Real64 Tref(283.15);         // Refrence Temperature for performance curves,10C [K]
    1335             :         int TimeStepNumAtMax;
    1336             :         int DDNum;
    1337             :         int PltSizNum;
    1338             :         bool RatedCapCoolTotalAutoSized;
    1339             :         bool RatedCapCoolSensAutoSized;
    1340             :         bool ErrorsFound;
    1341         274 :         Real64 SystemCapacity = 0.0;
    1342             :         Real64 rho;
    1343             :         Real64 Cp;
    1344             :         bool IsAutoSize;                  // Indicator to autosize
    1345             :         bool HardSizeNoDesRun;            // Indicator to hardsize and no sizing run
    1346             :         Real64 RatedAirVolFlowRateDes;    // Autosized rated air flow for reporting
    1347             :         Real64 CoolingAirVolFlowRateDes;  // Cooling desing day air flow
    1348             :         Real64 HeatingAirVolFlowRateDes;  // Heating design day air flow
    1349             :         Real64 RatedAirVolFlowRateUser;   // Hardsized rated air flow for reporting
    1350             :         Real64 RatedCapCoolTotalDes;      // Autosized rated cooling capacity for reporting
    1351             :         Real64 RatedCapCoolTotalUser;     // Hardsized rated cooling capacity for reporting
    1352             :         Real64 RatedCapCoolSensDes;       // Autosized rated sensible cooling capacity for reporting
    1353             :         Real64 RatedCapCoolSensUser;      // Hardsized rated sensible cooling capacity for reporting
    1354             :         Real64 RatedCapHeatDes;           // Autosized rated heating capacity for reporting
    1355             :         Real64 RatedCapHeatUser;          // Hardsized rated heating capacity for reporting
    1356             :         Real64 RatedWaterVolFlowRateDes;  // Autosized rated water flow rate for reporting
    1357             :         Real64 RatedWaterVolFlowRateUser; // Hardsized rated water flow rate for reporting
    1358             :         Real64 RatedCapCoolHeatDD;        // Rated cooling coil capacity based on heating design conditions
    1359             :         bool SizingDesRunThisAirSys;      // true if a particular air system had a Sizing:System object and system sizing done
    1360             :         bool SizingDesRunThisZone;        // true if a particular zone had a Sizing:Zone object and zone sizing was done
    1361         274 :         Real64 HeatdTratio = 1.0;         // Temperature difference across coil adjustment factor
    1362         274 :         Real64 dHratio = 1.0;             // Enthalpy difference across coil adjustment factor
    1363             :         Real64 HeatOAFrac;                // Outdoor air fraction at heating design conditions
    1364             :         Real64 HeatOAFracSys;             // Outdoor air fraction at heating design conditions at system air flow
    1365             :         Real64 HeatOATemp;                // Outdoor air temperature at heating design conditions
    1366             :         Real64 OAFrac;                    // Outdooor air fraction
    1367             :         Real64 OAFracSys;                 // Outdoor air fraction at system air flow
    1368             :         Real64 OATemp;                    // Outdoor air temperature at cooling design conditions
    1369             :         Real64 OAHumRat;                  // Humidity ratio at cooling design conditions
    1370             : 
    1371         274 :         PltSizNum = 0;
    1372         274 :         ErrorsFound = false;
    1373         274 :         IsAutoSize = false;
    1374         274 :         if (state.dataSize->SysSizingRunDone || state.dataSize->ZoneSizingRunDone) {
    1375         244 :             HardSizeNoDesRun = false;
    1376             :         } else {
    1377          30 :             HardSizeNoDesRun = true;
    1378             :         }
    1379         274 :         if (state.dataSize->CurSysNum > 0) {
    1380         224 :             CheckThisAirSystemForSizing(state, state.dataSize->CurSysNum, SizingDesRunThisAirSys);
    1381             :         } else {
    1382          50 :             SizingDesRunThisAirSys = false;
    1383             :         }
    1384         274 :         if (state.dataSize->CurZoneEqNum > 0) {
    1385          50 :             CheckThisZoneForSizing(state, state.dataSize->CurZoneEqNum, SizingDesRunThisZone);
    1386             :         } else {
    1387         224 :             SizingDesRunThisZone = false;
    1388             :         }
    1389         274 :         RatedAirVolFlowRateDes = 0.0;
    1390         274 :         RatedAirVolFlowRateUser = 0.0;
    1391         274 :         CoolingAirVolFlowRateDes = 0.0;
    1392         274 :         HeatingAirVolFlowRateDes = 0.0;
    1393         274 :         RatedCapCoolTotalDes = 0.0;
    1394         274 :         RatedCapCoolTotalUser = 0.0;
    1395         274 :         RatedCapCoolSensDes = 0.0;
    1396         274 :         RatedCapCoolSensUser = 0.0;
    1397         274 :         RatedCapHeatDes = 0.0;
    1398         274 :         RatedCapHeatUser = 0.0;
    1399         274 :         RatedWaterVolFlowRateDes = 0.0;
    1400         274 :         RatedWaterVolFlowRateUser = 0.0;
    1401         274 :         std::string CompType = format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)]);
    1402             : 
    1403         274 :         if (simpleWatertoAirHP.RatedAirVolFlowRate == DataSizing::AutoSize) {
    1404         244 :             IsAutoSize = true;
    1405             :         }
    1406         274 :         if (state.dataSize->CurSysNum > 0) {
    1407         224 :             if (!IsAutoSize && !SizingDesRunThisAirSys) { // Simulation continue
    1408          30 :                 HardSizeNoDesRun = true;
    1409          30 :                 if (simpleWatertoAirHP.RatedAirVolFlowRate > 0.0) {
    1410          90 :                     BaseSizer::reportSizerOutput(
    1411             :                         state,
    1412          60 :                         format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)]),
    1413             :                         simpleWatertoAirHP.Name,
    1414             :                         "User-Specified Rated Air Flow Rate [m3/s]",
    1415             :                         simpleWatertoAirHP.RatedAirVolFlowRate);
    1416             :                 }
    1417             :             } else {
    1418         194 :                 CheckSysSizing(state,
    1419         388 :                                format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)]),
    1420         194 :                                simpleWatertoAirHP.Name);
    1421         194 :                 if (state.dataSize->FinalSysSizing(state.dataSize->CurSysNum).DesMainVolFlow >= HVAC::SmallAirVolFlow) {
    1422         194 :                     RatedAirVolFlowRateDes = state.dataSize->FinalSysSizing(state.dataSize->CurSysNum).DesMainVolFlow;
    1423         194 :                     CoolingAirVolFlowRateDes = state.dataSize->CalcSysSizing(state.dataSize->CurSysNum).DesCoolVolFlow;
    1424         194 :                     HeatingAirVolFlowRateDes = state.dataSize->CalcSysSizing(state.dataSize->CurSysNum).DesHeatVolFlow;
    1425             :                 } else {
    1426           0 :                     RatedAirVolFlowRateDes = 0.0;
    1427             :                 }
    1428             :             }
    1429          50 :         } else if (state.dataSize->CurZoneEqNum > 0) {
    1430          50 :             if (!IsAutoSize && !SizingDesRunThisZone) { // Simulation continue
    1431           0 :                 HardSizeNoDesRun = true;
    1432           0 :                 if (simpleWatertoAirHP.RatedAirVolFlowRate > 0.0) {
    1433           0 :                     BaseSizer::reportSizerOutput(
    1434             :                         state,
    1435           0 :                         format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)]),
    1436             :                         simpleWatertoAirHP.Name,
    1437             :                         "User-Specified Rated Air Flow Rate [m3/s]",
    1438             :                         simpleWatertoAirHP.RatedAirVolFlowRate);
    1439             :                 }
    1440             :             } else {
    1441         100 :                 CheckZoneSizing(state,
    1442         100 :                                 format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)]),
    1443             :                                 simpleWatertoAirHP.Name);
    1444          50 :                 RatedAirVolFlowRateDes = max(state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).DesCoolVolFlow,
    1445          50 :                                              state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).DesHeatVolFlow);
    1446          50 :                 CoolingAirVolFlowRateDes = state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).DesCoolVolFlow;
    1447          50 :                 HeatingAirVolFlowRateDes = state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).DesHeatVolFlow;
    1448          50 :                 if (RatedAirVolFlowRateDes < HVAC::SmallAirVolFlow) {
    1449           0 :                     RatedAirVolFlowRateDes = 0.0;
    1450             :                 }
    1451             :             }
    1452             :         }
    1453         274 :         if (!HardSizeNoDesRun) {
    1454         244 :             if (IsAutoSize) {
    1455         244 :                 simpleWatertoAirHP.RatedAirVolFlowRate = RatedAirVolFlowRateDes;
    1456         732 :                 BaseSizer::reportSizerOutput(
    1457             :                     state,
    1458         488 :                     format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)]),
    1459             :                     simpleWatertoAirHP.Name,
    1460             :                     "Design Size Rated Air Flow Rate [m3/s]",
    1461             :                     RatedAirVolFlowRateDes);
    1462             :             } else {
    1463           0 :                 if (simpleWatertoAirHP.RatedAirVolFlowRate > 0.0 && RatedAirVolFlowRateDes > 0.0 && !HardSizeNoDesRun) {
    1464           0 :                     RatedAirVolFlowRateUser = simpleWatertoAirHP.RatedAirVolFlowRate;
    1465           0 :                     BaseSizer::reportSizerOutput(
    1466             :                         state,
    1467           0 :                         format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)]),
    1468             :                         simpleWatertoAirHP.Name,
    1469             :                         "Design Size Rated Air Flow Rate [m3/s]",
    1470             :                         RatedAirVolFlowRateDes,
    1471             :                         "User-Specified Rated Air Flow Rate [m3/s]",
    1472             :                         RatedAirVolFlowRateUser);
    1473           0 :                     if (state.dataGlobal->DisplayExtraWarnings) {
    1474           0 :                         if ((std::abs(RatedAirVolFlowRateDes - RatedAirVolFlowRateUser) / RatedAirVolFlowRateUser) >
    1475           0 :                             state.dataSize->AutoVsHardSizingThreshold) {
    1476           0 :                             ShowMessage(
    1477             :                                 state,
    1478           0 :                                 format("SizeHVACWaterToAir: Potential issue with equipment sizing for coil {}:WATERTOAIRHEATPUMP:EQUATIONFIT \"{}\"",
    1479           0 :                                        WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)],
    1480           0 :                                        simpleWatertoAirHP.Name));
    1481           0 :                             ShowContinueError(state, format("User-Specified Rated Air Volume Flow Rate of {:.5R} [m3/s]", RatedAirVolFlowRateUser));
    1482           0 :                             ShowContinueError(state,
    1483           0 :                                               format("differs from Design Size Rated Air Volume Flow Rate of {:.5R} [m3/s]", RatedAirVolFlowRateDes));
    1484           0 :                             ShowContinueError(state, "This may, or may not, indicate mismatched component sizes.");
    1485           0 :                             ShowContinueError(state, "Verify that the value entered is intended and is consistent with other components.");
    1486             :                         }
    1487             :                     }
    1488             :                 }
    1489             :             }
    1490             :         }
    1491             : 
    1492         274 :         RatedCapCoolTotalAutoSized = false;
    1493         274 :         RatedCapCoolSensAutoSized = false;
    1494             : 
    1495         274 :         Real64 FanCoolLoad = 0.0;
    1496         274 :         Real64 FanHeatLoad = FanCoolLoad;
    1497         274 :         if (simpleWatertoAirHP.WAHPType == WatertoAirHP::Cooling) {
    1498             :             // size rated total cooling capacity
    1499         137 :             if (simpleWatertoAirHP.RatedCapCoolTotal == DataSizing::AutoSize) {
    1500         122 :                 RatedCapCoolTotalAutoSized = true;
    1501             :             }
    1502         137 :             if (SizingDesRunThisAirSys || SizingDesRunThisZone) HardSizeNoDesRun = false;
    1503         137 :             if (state.dataSize->CurSysNum > 0) {
    1504         112 :                 if (!RatedCapCoolTotalAutoSized && !SizingDesRunThisAirSys) { // Simulation continue
    1505          15 :                     HardSizeNoDesRun = true;
    1506          15 :                     if (simpleWatertoAirHP.RatedCapCoolTotal > 0.0) {
    1507          45 :                         BaseSizer::reportSizerOutput(
    1508             :                             state,
    1509          30 :                             format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)]),
    1510             :                             simpleWatertoAirHP.Name,
    1511             :                             "User-Specified Rated Total Cooling Capacity [W]",
    1512             :                             simpleWatertoAirHP.RatedCapCoolTotal);
    1513             :                     }
    1514             :                 } else {
    1515          97 :                     CheckSysSizing(
    1516             :                         state,
    1517         194 :                         format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)]),
    1518          97 :                         simpleWatertoAirHP.Name);
    1519          97 :                     if (CoolingAirVolFlowRateDes > 0.0) {
    1520          97 :                         VolFlowRate = CoolingAirVolFlowRateDes;
    1521             :                     } else {
    1522           0 :                         VolFlowRate = HeatingAirVolFlowRateDes; // system air flow
    1523             :                     }
    1524             :                     // cooling design day calculations
    1525          97 :                     if (VolFlowRate >= HVAC::SmallAirVolFlow) {
    1526          97 :                         auto &finalSysSizing(state.dataSize->FinalSysSizing(state.dataSize->CurSysNum));
    1527          97 :                         if (state.dataSize->CurOASysNum > 0) { // coil is in the OA stream
    1528           0 :                             MixTemp = finalSysSizing.OutTempAtCoolPeak;
    1529           0 :                             MixHumRat = finalSysSizing.OutHumRatAtCoolPeak;
    1530           0 :                             SupTemp = finalSysSizing.PrecoolTemp;
    1531           0 :                             SupHumRat = finalSysSizing.PrecoolHumRat;
    1532           0 :                             MixTempSys = MixTemp;
    1533           0 :                             MixHumRatSys = MixHumRat;
    1534             :                         } else { // coil is on the main air loop
    1535          97 :                             SupTemp = finalSysSizing.CoolSupTemp;
    1536          97 :                             SupHumRat = finalSysSizing.CoolSupHumRat;
    1537          97 :                             if (VolFlowRate > 0.0) {
    1538          97 :                                 OutAirFrac = finalSysSizing.DesOutAirVolFlow / VolFlowRate;
    1539          97 :                                 OutAirFracSys = finalSysSizing.DesOutAirVolFlow / RatedAirVolFlowRateDes;
    1540             :                             } else {
    1541           0 :                                 OutAirFrac = 1.0;
    1542           0 :                                 OutAirFracSys = OutAirFrac;
    1543             :                             }
    1544          97 :                             OutAirFrac = min(1.0, max(0.0, OutAirFrac));
    1545          97 :                             OutAirFracSys = min(1.0, max(0.0, OutAirFracSys));
    1546          97 :                             if (state.dataAirSystemsData->PrimaryAirSystems(state.dataSize->CurSysNum).NumOACoolCoils ==
    1547             :                                 0) { // there is no precooling of the OA stream
    1548          97 :                                 MixTemp = finalSysSizing.MixTempAtCoolPeak;
    1549          97 :                                 MixHumRat = finalSysSizing.MixHumRatAtCoolPeak;
    1550             :                                 // calculate mixed air temperature with system airflow
    1551          97 :                                 MixTempSys =
    1552          97 :                                     OutAirFracSys * finalSysSizing.OutTempAtCoolPeak + (1.0 - OutAirFracSys) * finalSysSizing.RetTempAtCoolPeak;
    1553          97 :                                 MixHumRatSys =
    1554          97 :                                     OutAirFracSys * finalSysSizing.OutHumRatAtCoolPeak + (1.0 - OutAirFracSys) * finalSysSizing.RetHumRatAtCoolPeak;
    1555             :                             } else { // there is precooling of OA stream
    1556           0 :                                 MixTemp = OutAirFrac * finalSysSizing.PrecoolTemp + (1.0 - OutAirFrac) * finalSysSizing.RetTempAtCoolPeak;
    1557           0 :                                 MixHumRat = OutAirFrac * finalSysSizing.PrecoolHumRat + (1.0 - OutAirFrac) * finalSysSizing.RetHumRatAtCoolPeak;
    1558             :                                 // calculate mixed air temperature with system airflow
    1559           0 :                                 MixTempSys = OutAirFracSys * finalSysSizing.PrecoolTemp + (1.0 - OutAirFracSys) * finalSysSizing.RetTempAtCoolPeak;
    1560           0 :                                 MixHumRatSys =
    1561           0 :                                     OutAirFracSys * finalSysSizing.PrecoolHumRat + (1.0 - OutAirFracSys) * finalSysSizing.RetHumRatAtCoolPeak;
    1562             :                             }
    1563             :                         }
    1564             :                         // supply air condition is capped with that of mixed air to avoid SHR > 1.0
    1565          97 :                         SupTemp = min(MixTemp, SupTemp);
    1566          97 :                         SupHumRat = min(MixHumRat, SupHumRat);
    1567          97 :                         rhoair = Psychrometrics::PsyRhoAirFnPbTdbW(state, state.dataEnvrn->StdBaroPress, MixTemp, MixHumRat, RoutineName);
    1568          97 :                         MixEnth = Psychrometrics::PsyHFnTdbW(MixTemp, MixHumRat);
    1569          97 :                         MixEnthSys = Psychrometrics::PsyHFnTdbW(MixTempSys, MixHumRatSys);
    1570          97 :                         SupEnth = Psychrometrics::PsyHFnTdbW(SupTemp, SupHumRat);
    1571             :                         // determine the coil ratio of coil dT with system air flow to design heating air flow
    1572          97 :                         dHratio = (SupEnth - MixEnthSys) / (SupEnth - MixEnth);
    1573          97 :                         Real64 FanCoolLoad = 0.0;
    1574          97 :                         if (state.dataSize->DataFanType != HVAC::FanType::Invalid && state.dataSize->DataFanIndex > 0) { // add fan heat to coil load
    1575          97 :                             FanCoolLoad = state.dataFans->fans(state.dataSize->DataFanIndex)->getDesignHeatGain(state, VolFlowRate);
    1576             : 
    1577          97 :                             Real64 CpAir = Psychrometrics::PsyCpAirFnW(MixHumRat);
    1578          97 :                             if (state.dataAirSystemsData->PrimaryAirSystems(state.dataSize->CurSysNum).supFanPlace == HVAC::FanPlace::BlowThru) {
    1579          97 :                                 MixTemp += FanCoolLoad / (CpAir * rhoair * VolFlowRate); // this is now the temperature entering the coil
    1580           0 :                             } else if (state.dataAirSystemsData->PrimaryAirSystems(state.dataSize->CurSysNum).supFanPlace ==
    1581             :                                        HVAC::FanPlace::DrawThru) {
    1582           0 :                                 SupTemp -= FanCoolLoad / (CpAir * rhoair * VolFlowRate); // this is now the temperature leaving the coil
    1583             :                             }
    1584             :                         }
    1585          97 :                         CoolCapAtPeak = (rhoair * VolFlowRate * (MixEnth - SupEnth)) +
    1586             :                                         FanCoolLoad; // load on the cooling coil which includes ventilation load and fan heat
    1587          97 :                         CoolCapAtPeak = max(0.0, CoolCapAtPeak);
    1588          97 :                         MixWetBulb = Psychrometrics::PsyTwbFnTdbWPb(state, MixTemp, MixHumRat, state.dataEnvrn->StdBaroPress, RoutineName);
    1589          97 :                         RatedMixWetBulb = simpleWatertoAirHP.RatedEntAirWetbulbTemp;
    1590             :                         // calculate temperatue ratio at design day peak conditions
    1591          97 :                         ratioTWB = (MixWetBulb + state.dataWaterToAirHeatPumpSimple->CelsiustoKelvin) / Tref;
    1592         194 :                         PltSizNum = PlantUtilities::MyPlantSizingIndex(
    1593             :                             state,
    1594         194 :                             format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)]),
    1595             :                             simpleWatertoAirHP.Name,
    1596             :                             simpleWatertoAirHP.WaterInletNodeNum,
    1597             :                             simpleWatertoAirHP.WaterOutletNodeNum,
    1598             :                             ErrorsFound,
    1599             :                             false);
    1600          97 :                         if (PltSizNum > 0) {
    1601          97 :                             DesignEntWaterTemp = state.dataSize->PlantSizData(PltSizNum).ExitTemp;
    1602          97 :                             ratioTS = (DesignEntWaterTemp + state.dataWaterToAirHeatPumpSimple->CelsiustoKelvin) / Tref;
    1603             :                         } else {
    1604           0 :                             ShowSevereError(state, "Autosizing of total cooling capacity requires a loop Sizing:Plant object");
    1605           0 :                             ShowContinueError(state, "Autosizing also requires physical connection to a plant or condenser loop.");
    1606           0 :                             ShowContinueError(state,
    1607           0 :                                               format("Occurs in COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT Object={}",
    1608           0 :                                                      WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)],
    1609           0 :                                                      simpleWatertoAirHP.Name));
    1610           0 :                             ratioTS = 0.0; // Clang complains it is used uninitialized if you don't give it a value
    1611           0 :                             ErrorsFound = true;
    1612             :                         }
    1613             :                         // calculate temperatue ratio at rated conditions
    1614          97 :                         RatedratioTWB = (RatedMixWetBulb + state.dataWaterToAirHeatPumpSimple->CelsiustoKelvin) / Tref;
    1615          97 :                         RatedratioTS = (simpleWatertoAirHP.RatedEntWaterTemp + state.dataWaterToAirHeatPumpSimple->CelsiustoKelvin) / Tref;
    1616             :                         // determine curve modifiers at peak and rated conditions
    1617          97 :                         PeakTotCapTempModFac = Curve::CurveValue(state, simpleWatertoAirHP.TotalCoolCapCurveIndex, ratioTWB, ratioTS, 1.0, 1.0);
    1618          97 :                         RatedTotCapTempModFac =
    1619          97 :                             Curve::CurveValue(state, simpleWatertoAirHP.TotalCoolCapCurveIndex, RatedratioTWB, RatedratioTS, 1.0, 1.0);
    1620             :                         RatedCoolPowerTempModFac =
    1621          97 :                             Curve::CurveValue(state, simpleWatertoAirHP.CoolPowCurveIndex, RatedratioTWB, RatedratioTS, 1.0, 1.0);
    1622             :                         // calculate the rated total capacity based on peak conditions
    1623             :                         // note: the rated total capacity can be different than the total capacity at
    1624             :                         // rated conditions if the capacity curve isn't normalized at the rated
    1625             :                         // conditions
    1626          97 :                         RatedCapCoolTotalDes = (PeakTotCapTempModFac > 0.0) ? CoolCapAtPeak / PeakTotCapTempModFac : CoolCapAtPeak;
    1627             :                         // reporting
    1628          97 :                         state.dataRptCoilSelection->coilSelectionReportObj->setCoilEntAirTemp(
    1629          97 :                             state, simpleWatertoAirHP.Name, CompType, MixTemp, state.dataSize->CurSysNum, state.dataSize->CurZoneEqNum);
    1630          97 :                         state.dataRptCoilSelection->coilSelectionReportObj->setCoilEntAirHumRat(state, simpleWatertoAirHP.Name, CompType, MixHumRat);
    1631          97 :                         state.dataRptCoilSelection->coilSelectionReportObj->setCoilLvgAirTemp(state, simpleWatertoAirHP.Name, CompType, SupTemp);
    1632          97 :                         state.dataRptCoilSelection->coilSelectionReportObj->setCoilLvgAirHumRat(state, simpleWatertoAirHP.Name, CompType, SupHumRat);
    1633             :                     } else {
    1634           0 :                         RatedCapCoolTotalDes = 0.0;
    1635             :                     }
    1636             :                 }
    1637          25 :             } else if (state.dataSize->CurZoneEqNum > 0) {
    1638          25 :                 if (!RatedCapCoolTotalAutoSized && !SizingDesRunThisZone) { // Simulation continue
    1639           0 :                     HardSizeNoDesRun = true;
    1640           0 :                     if (simpleWatertoAirHP.RatedCapCoolTotal > 0.0) {
    1641           0 :                         BaseSizer::reportSizerOutput(
    1642             :                             state,
    1643           0 :                             format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)]),
    1644             :                             simpleWatertoAirHP.Name,
    1645             :                             "User-Specified Rated Total Cooling Capacity [W]",
    1646             :                             simpleWatertoAirHP.RatedCapCoolTotal);
    1647             :                     }
    1648             :                 } else {
    1649          50 :                     CheckZoneSizing(
    1650             :                         state,
    1651          50 :                         format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)]),
    1652             :                         simpleWatertoAirHP.Name);
    1653          25 :                     if (CoolingAirVolFlowRateDes > 0.0) {
    1654          23 :                         VolFlowRate = CoolingAirVolFlowRateDes;
    1655             :                     } else {
    1656           2 :                         VolFlowRate = HeatingAirVolFlowRateDes; // system air flow
    1657             :                     }
    1658          25 :                     if (VolFlowRate >= HVAC::SmallAirVolFlow) {
    1659             :                         // cooling design calculations
    1660          25 :                         if (state.dataSize->ZoneEqDXCoil) {
    1661          25 :                             if (ZoneEqSizing(state.dataSize->CurZoneEqNum).OAVolFlow > 0.0) {
    1662           7 :                                 MixTemp = state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).DesCoolCoilInTemp;
    1663           7 :                                 MixHumRat = state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).DesCoolCoilInHumRat;
    1664             :                                 // calculate mixed air temperature and humidity with system airflow
    1665           7 :                                 OAFrac = state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).MinOA / CoolingAirVolFlowRateDes;
    1666           7 :                                 OAFracSys = state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).MinOA / RatedAirVolFlowRateDes;
    1667           7 :                                 OATemp = (state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).DesCoolCoilInTemp -
    1668           7 :                                           (1.0 - OAFrac) * state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).ZoneTempAtCoolPeak) /
    1669             :                                          OAFrac;
    1670           7 :                                 OAHumRat = (state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).DesHeatCoilInHumRat -
    1671           7 :                                             (1.0 - OAFrac) * state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).ZoneHumRatAtHeatPeak) /
    1672             :                                            OAFrac;
    1673          14 :                                 MixTempSys = OAFracSys * OATemp +
    1674           7 :                                              (1.0 - OAFracSys) * state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).ZoneTempAtCoolPeak;
    1675          14 :                                 MixHumRatSys = OAFracSys * OAHumRat +
    1676           7 :                                                (1.0 - OAFracSys) * state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).ZoneHumRatAtHeatPeak;
    1677             :                             } else {
    1678          18 :                                 MixTemp = state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).ZoneRetTempAtCoolPeak;
    1679          18 :                                 MixHumRat = state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).ZoneHumRatAtCoolPeak;
    1680          18 :                                 MixTempSys = MixTemp;
    1681          18 :                                 MixHumRatSys = MixHumRat;
    1682             :                             }
    1683             :                         } else {
    1684           0 :                             MixTemp = state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).DesCoolCoilInTemp;
    1685           0 :                             MixHumRat = state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).DesCoolCoilInHumRat;
    1686           0 :                             MixTempSys = MixTemp;
    1687           0 :                             MixHumRatSys = MixHumRat;
    1688             :                         }
    1689          25 :                         SupTemp = state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).CoolDesTemp;
    1690          25 :                         SupHumRat = state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).CoolDesHumRat;
    1691             :                         // supply air condition is capped with that of mixed air to avoid SHR > 1.0
    1692          25 :                         SupTemp = min(MixTemp, SupTemp);
    1693          25 :                         SupHumRat = min(MixHumRat, SupHumRat);
    1694          25 :                         TimeStepNumAtMax = state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).TimeStepNumAtCoolMax;
    1695          25 :                         DDNum = state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).CoolDDNum;
    1696          25 :                         if (DDNum > 0 && TimeStepNumAtMax > 0) {
    1697          25 :                             OutTemp = state.dataSize->DesDayWeath(DDNum).Temp(TimeStepNumAtMax);
    1698             :                         } else {
    1699           0 :                             OutTemp = 0.0;
    1700             :                         }
    1701          25 :                         rhoair = Psychrometrics::PsyRhoAirFnPbTdbW(state, state.dataEnvrn->StdBaroPress, MixTemp, MixHumRat, RoutineName);
    1702          25 :                         MixEnth = Psychrometrics::PsyHFnTdbW(MixTemp, MixHumRat);
    1703          25 :                         MixEnthSys = Psychrometrics::PsyHFnTdbW(MixTempSys, MixHumRatSys);
    1704          25 :                         SupEnth = Psychrometrics::PsyHFnTdbW(SupTemp, SupHumRat);
    1705             :                         // determine the coil ratio of coil dH with system air flow to design heating air flow
    1706          25 :                         dHratio = (SupEnth - MixEnthSys) / (SupEnth - MixEnth);
    1707          25 :                         if (state.dataSize->DataFanType != HVAC::FanType::Invalid && state.dataSize->DataFanIndex > 0) { // add fan heat to coil load
    1708          25 :                             FanCoolLoad = state.dataFans->fans(state.dataSize->DataFanIndex)->getDesignHeatGain(state, VolFlowRate);
    1709             : 
    1710          25 :                             Real64 CpAir = Psychrometrics::PsyCpAirFnW(MixHumRat);
    1711          25 :                             if (state.dataSize->DataFanPlacement == HVAC::FanPlace::BlowThru) {
    1712          18 :                                 MixTemp += FanCoolLoad / (CpAir * rhoair * VolFlowRate); // this is now the temperature entering the coil
    1713             :                             } else {
    1714           7 :                                 SupTemp -= FanCoolLoad / (CpAir * rhoair * VolFlowRate); // this is now the temperature leaving the coil
    1715             :                             }
    1716             :                         }
    1717          25 :                         CoolCapAtPeak = (rhoair * VolFlowRate * (MixEnth - SupEnth)) +
    1718             :                                         FanCoolLoad; // load on the cooling coil which includes ventilation load and fan heat
    1719          25 :                         CoolCapAtPeak = max(0.0, CoolCapAtPeak);
    1720          25 :                         MixWetBulb = Psychrometrics::PsyTwbFnTdbWPb(state, MixTemp, MixHumRat, state.dataEnvrn->StdBaroPress, RoutineName);
    1721          25 :                         RatedMixWetBulb = simpleWatertoAirHP.RatedEntAirWetbulbTemp;
    1722             :                         // calculate temperatue ratio at design day peak conditions
    1723          25 :                         ratioTWB = (MixWetBulb + state.dataWaterToAirHeatPumpSimple->CelsiustoKelvin) / Tref;
    1724          50 :                         PltSizNum = PlantUtilities::MyPlantSizingIndex(
    1725             :                             state,
    1726          50 :                             format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)]),
    1727             :                             simpleWatertoAirHP.Name,
    1728             :                             simpleWatertoAirHP.WaterInletNodeNum,
    1729             :                             simpleWatertoAirHP.WaterOutletNodeNum,
    1730             :                             ErrorsFound,
    1731             :                             false);
    1732          25 :                         if (PltSizNum > 0) {
    1733          25 :                             DesignEntWaterTemp = state.dataSize->PlantSizData(PltSizNum).ExitTemp;
    1734          25 :                             ratioTS = (DesignEntWaterTemp + state.dataWaterToAirHeatPumpSimple->CelsiustoKelvin) / Tref;
    1735             :                         } else {
    1736           0 :                             ShowSevereError(state, "Autosizing of total cooling capacity requires a loop Sizing:Plant object");
    1737           0 :                             ShowContinueError(state, "Autosizing also requires physical connection to a plant or condenser loop.");
    1738           0 :                             ShowContinueError(state,
    1739           0 :                                               format("Occurs in COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT Object={}",
    1740           0 :                                                      WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)],
    1741           0 :                                                      simpleWatertoAirHP.Name));
    1742           0 :                             ratioTS = 0.0; // Clang complains it is used uninitialized if you don't give it a value
    1743           0 :                             ErrorsFound = true;
    1744             :                         }
    1745             :                         // calculate temperatue ratio at rated conditions
    1746          25 :                         RatedratioTWB = (RatedMixWetBulb + state.dataWaterToAirHeatPumpSimple->CelsiustoKelvin) / Tref;
    1747          25 :                         RatedratioTS = (simpleWatertoAirHP.RatedEntWaterTemp + state.dataWaterToAirHeatPumpSimple->CelsiustoKelvin) / Tref;
    1748             :                         // determine curve modifiers at peak and rated conditions
    1749          25 :                         PeakTotCapTempModFac = Curve::CurveValue(state, simpleWatertoAirHP.TotalCoolCapCurveIndex, ratioTWB, ratioTS, 1.0, 1.0);
    1750          25 :                         RatedTotCapTempModFac =
    1751          25 :                             Curve::CurveValue(state, simpleWatertoAirHP.TotalCoolCapCurveIndex, RatedratioTWB, RatedratioTS, 1.0, 1.0);
    1752             :                         RatedCoolPowerTempModFac =
    1753          25 :                             Curve::CurveValue(state, simpleWatertoAirHP.CoolPowCurveIndex, RatedratioTWB, RatedratioTS, 1.0, 1.0);
    1754             :                         // calculate the rated total capacity based on peak conditions
    1755             :                         // note: the rated total capacity can be different than the total capacity at
    1756             :                         // rated conditions if the capacity curve isn't normalized at the rated
    1757             :                         // conditions
    1758          25 :                         RatedCapCoolTotalDes = (PeakTotCapTempModFac > 0.0) ? CoolCapAtPeak / PeakTotCapTempModFac : CoolCapAtPeak;
    1759             :                         // reporting
    1760          25 :                         state.dataRptCoilSelection->coilSelectionReportObj->setCoilEntAirTemp(
    1761          25 :                             state, simpleWatertoAirHP.Name, CompType, MixTemp, state.dataSize->CurSysNum, state.dataSize->CurZoneEqNum);
    1762          25 :                         state.dataRptCoilSelection->coilSelectionReportObj->setCoilEntAirHumRat(state, simpleWatertoAirHP.Name, CompType, MixHumRat);
    1763          25 :                         state.dataRptCoilSelection->coilSelectionReportObj->setCoilLvgAirTemp(state, simpleWatertoAirHP.Name, CompType, SupTemp);
    1764          25 :                         state.dataRptCoilSelection->coilSelectionReportObj->setCoilLvgAirHumRat(state, simpleWatertoAirHP.Name, CompType, SupHumRat);
    1765             :                     } else {
    1766           0 :                         RatedCapCoolTotalDes = 0.0;
    1767             :                     }
    1768             :                 }
    1769          25 :                 if (RatedCapCoolTotalDes < HVAC::SmallLoad) {
    1770           0 :                     RatedCapCoolTotalDes = 0.0;
    1771             :                 }
    1772             :             }
    1773             :             // size rated sensible cooling capacity
    1774         137 :             if (simpleWatertoAirHP.RatedCapCoolSens == DataSizing::AutoSize && simpleWatertoAirHP.WAHPType == WatertoAirHP::Cooling) {
    1775         122 :                 RatedCapCoolSensAutoSized = true;
    1776             :             }
    1777         137 :             if (SizingDesRunThisAirSys || SizingDesRunThisZone) HardSizeNoDesRun = false;
    1778         137 :             if (state.dataSize->CurSysNum > 0) {
    1779         112 :                 if (!RatedCapCoolSensAutoSized && !SizingDesRunThisAirSys) { // Simulation continue
    1780          15 :                     HardSizeNoDesRun = true;
    1781          15 :                     if (simpleWatertoAirHP.RatedCapCoolSens > 0.0) {
    1782          45 :                         BaseSizer::reportSizerOutput(
    1783             :                             state,
    1784          30 :                             format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)]),
    1785             :                             simpleWatertoAirHP.Name,
    1786             :                             "User-Specified Rated Sensible Cooling Capacity [W]",
    1787             :                             simpleWatertoAirHP.RatedCapCoolSens);
    1788             :                     }
    1789             :                 } else {
    1790          97 :                     CheckSysSizing(
    1791             :                         state,
    1792         194 :                         format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)]),
    1793          97 :                         simpleWatertoAirHP.Name);
    1794          97 :                     if (CoolingAirVolFlowRateDes > 0.0) {
    1795          97 :                         VolFlowRate = CoolingAirVolFlowRateDes;
    1796             :                     } else {
    1797           0 :                         VolFlowRate = HeatingAirVolFlowRateDes; // system air flow
    1798             :                     }
    1799          97 :                     if (VolFlowRate >= HVAC::SmallAirVolFlow) {
    1800          97 :                         auto &finalSysSizing(state.dataSize->FinalSysSizing(state.dataSize->CurSysNum));
    1801          97 :                         if (state.dataSize->CurOASysNum > 0) { // coil is in the OA stream
    1802           0 :                             MixTemp = finalSysSizing.OutTempAtCoolPeak;
    1803           0 :                             MixHumRat = finalSysSizing.OutHumRatAtCoolPeak;
    1804           0 :                             SupTemp = finalSysSizing.PrecoolTemp;
    1805           0 :                             SupHumRat = finalSysSizing.PrecoolHumRat;
    1806             :                         } else { // coil is on the main air loop
    1807          97 :                             SupTemp = finalSysSizing.CoolSupTemp;
    1808          97 :                             SupHumRat = finalSysSizing.CoolSupHumRat;
    1809          97 :                             if (state.dataAirSystemsData->PrimaryAirSystems(state.dataSize->CurSysNum).NumOACoolCoils ==
    1810             :                                 0) { // there is no precooling of the OA stream
    1811          97 :                                 MixTemp = finalSysSizing.MixTempAtCoolPeak;
    1812          97 :                                 MixHumRat = finalSysSizing.MixHumRatAtCoolPeak;
    1813             :                             } else { // there is precooling of OA stream
    1814           0 :                                 if (VolFlowRate > 0.0) {
    1815           0 :                                     OutAirFrac = finalSysSizing.DesOutAirVolFlow / VolFlowRate;
    1816             :                                 } else {
    1817           0 :                                     OutAirFrac = 1.0;
    1818             :                                 }
    1819           0 :                                 OutAirFrac = min(1.0, max(0.0, OutAirFrac));
    1820           0 :                                 MixTemp = OutAirFrac * finalSysSizing.PrecoolTemp + (1.0 - OutAirFrac) * finalSysSizing.RetTempAtCoolPeak;
    1821           0 :                                 MixHumRat = OutAirFrac * finalSysSizing.PrecoolHumRat + (1.0 - OutAirFrac) * finalSysSizing.RetHumRatAtCoolPeak;
    1822             :                             }
    1823             :                         }
    1824             :                         // supply air condition is capped with that of mixed air to avoid SHR > 1.0
    1825          97 :                         SupTemp = min(MixTemp, SupTemp);
    1826          97 :                         SupHumRat = min(MixHumRat, SupHumRat);
    1827          97 :                         OutTemp = finalSysSizing.OutTempAtCoolPeak;
    1828          97 :                         rhoair = Psychrometrics::PsyRhoAirFnPbTdbW(state, state.dataEnvrn->StdBaroPress, MixTemp, MixHumRat, RoutineName);
    1829          97 :                         MixEnth = Psychrometrics::PsyHFnTdbW(MixTemp, MixHumRat);
    1830          97 :                         SupEnth = Psychrometrics::PsyHFnTdbW(SupTemp, MixHumRat);
    1831          97 :                         Real64 FanCoolLoad = 0.0;
    1832          97 :                         if (state.dataSize->DataFanType != HVAC::FanType::Invalid && state.dataSize->DataFanIndex > 0) { // add fan heat to coil load
    1833          97 :                             FanCoolLoad = state.dataFans->fans(state.dataSize->DataFanIndex)->getDesignHeatGain(state, VolFlowRate);
    1834             : 
    1835          97 :                             Real64 CpAir = Psychrometrics::PsyCpAirFnW(MixHumRat);
    1836          97 :                             if (state.dataAirSystemsData->PrimaryAirSystems(state.dataSize->CurSysNum).supFanPlace == HVAC::FanPlace::BlowThru) {
    1837          97 :                                 MixTemp += FanCoolLoad / (CpAir * rhoair * VolFlowRate); // this is now the temperature entering the coil
    1838           0 :                             } else if (state.dataAirSystemsData->PrimaryAirSystems(state.dataSize->CurSysNum).supFanPlace ==
    1839             :                                        HVAC::FanPlace::DrawThru) {
    1840           0 :                                 SupTemp -= FanCoolLoad / (CpAir * rhoair * VolFlowRate); // this is now the temperature leaving the coil
    1841             :                             }
    1842             :                         }
    1843             :                         // Sensible capacity is calculated from enthalpy difference with constant humidity ratio, i.e.,
    1844             :                         // there is only temperature difference between entering and leaving air enthalpy. Previously
    1845             :                         // it was calculated using m.cp.dT
    1846          97 :                         SensCapAtPeak = (rhoair * VolFlowRate * (MixEnth - SupEnth)) +
    1847             :                                         FanCoolLoad; // load on the cooling coil which includes ventilation load and fan heat (sensible)
    1848          97 :                         SensCapAtPeak = max(0.0, SensCapAtPeak);
    1849          97 :                         MixWetBulb = Psychrometrics::PsyTwbFnTdbWPb(state, MixTemp, MixHumRat, state.dataEnvrn->StdBaroPress, RoutineName);
    1850          97 :                         RatedMixWetBulb = simpleWatertoAirHP.RatedEntAirWetbulbTemp;
    1851          97 :                         RatedMixDryBulb = simpleWatertoAirHP.RatedEntAirDrybulbTemp;
    1852             :                         // calculate temperature ratios at design day peak conditions
    1853          97 :                         ratioTDB = (MixTemp + state.dataWaterToAirHeatPumpSimple->CelsiustoKelvin) / Tref;
    1854          97 :                         ratioTWB = (MixWetBulb + state.dataWaterToAirHeatPumpSimple->CelsiustoKelvin) / Tref;
    1855         194 :                         PltSizNum = PlantUtilities::MyPlantSizingIndex(
    1856             :                             state,
    1857         194 :                             format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)]),
    1858             :                             simpleWatertoAirHP.Name,
    1859             :                             simpleWatertoAirHP.WaterInletNodeNum,
    1860             :                             simpleWatertoAirHP.WaterOutletNodeNum,
    1861             :                             ErrorsFound,
    1862             :                             false);
    1863          97 :                         if (PltSizNum > 0) {
    1864          97 :                             DesignEntWaterTemp = state.dataSize->PlantSizData(PltSizNum).ExitTemp;
    1865          97 :                             ratioTS = (DesignEntWaterTemp + state.dataWaterToAirHeatPumpSimple->CelsiustoKelvin) / Tref;
    1866             :                         } else {
    1867           0 :                             ShowSevereError(state, "Autosizing of sensible cooling capacity requires a loop Sizing:Plant object");
    1868           0 :                             ShowContinueError(state, "Autosizing also requires physical connection to a plant or condenser loop.");
    1869           0 :                             ShowContinueError(state,
    1870           0 :                                               format("Occurs in COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT Object={}",
    1871           0 :                                                      WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)],
    1872           0 :                                                      simpleWatertoAirHP.Name));
    1873           0 :                             ErrorsFound = true;
    1874             :                         }
    1875             :                         // calculate temperatue ratio at rated conditions
    1876          97 :                         RatedratioTDB = (RatedMixDryBulb + state.dataWaterToAirHeatPumpSimple->CelsiustoKelvin) / Tref;
    1877          97 :                         RatedratioTWB = (RatedMixWetBulb + state.dataWaterToAirHeatPumpSimple->CelsiustoKelvin) / Tref;
    1878          97 :                         RatedratioTS = (simpleWatertoAirHP.RatedEntWaterTemp + state.dataWaterToAirHeatPumpSimple->CelsiustoKelvin) / Tref;
    1879             :                         // determine curve modifiers at peak and rated conditions
    1880          97 :                         PeakSensCapTempModFac =
    1881          97 :                             Curve::CurveValue(state, simpleWatertoAirHP.SensCoolCapCurveIndex, ratioTDB, ratioTWB, ratioTS, 1.0, 1.0);
    1882          97 :                         RatedSensCapTempModFac =
    1883          97 :                             Curve::CurveValue(state, simpleWatertoAirHP.SensCoolCapCurveIndex, RatedratioTDB, RatedratioTWB, RatedratioTS, 1.0, 1.0);
    1884             :                         // calculate the rated sensible capacity based on peak conditions
    1885             :                         // note: the rated sensible capacity can be different than the sensible capacity
    1886             :                         // at rated conditions if the capacity curve isn't normalized at the rated
    1887             :                         // conditions
    1888          97 :                         RatedCapCoolSensDes = (PeakSensCapTempModFac > 0.0) ? SensCapAtPeak / PeakSensCapTempModFac : SensCapAtPeak;
    1889             :                     } else {
    1890           0 :                         RatedCapCoolSensDes = 0.0;
    1891             :                     }
    1892             :                 }
    1893          25 :             } else if (state.dataSize->CurZoneEqNum > 0) {
    1894          25 :                 if (!RatedCapCoolSensAutoSized && !SizingDesRunThisZone) { // Simulation continue
    1895           0 :                     HardSizeNoDesRun = true;
    1896           0 :                     if (simpleWatertoAirHP.RatedCapCoolSens > 0.0) {
    1897           0 :                         BaseSizer::reportSizerOutput(
    1898             :                             state,
    1899           0 :                             format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)]),
    1900             :                             simpleWatertoAirHP.Name,
    1901             :                             "User-Specified Rated Sensible Cooling Capacity [W]",
    1902             :                             simpleWatertoAirHP.RatedCapCoolSens);
    1903             :                     }
    1904             :                 } else {
    1905          50 :                     CheckZoneSizing(
    1906             :                         state,
    1907          50 :                         format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)]),
    1908             :                         simpleWatertoAirHP.Name);
    1909          25 :                     if (CoolingAirVolFlowRateDes > 0.0) {
    1910          23 :                         VolFlowRate = CoolingAirVolFlowRateDes;
    1911             :                     } else {
    1912           2 :                         VolFlowRate = HeatingAirVolFlowRateDes; // system air flow
    1913             :                     }
    1914          25 :                     if (VolFlowRate >= HVAC::SmallAirVolFlow) {
    1915          25 :                         if (state.dataSize->ZoneEqDXCoil) {
    1916          25 :                             if (ZoneEqSizing(state.dataSize->CurZoneEqNum).OAVolFlow > 0.0) {
    1917           7 :                                 MixTemp = state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).DesCoolCoilInTemp;
    1918           7 :                                 MixHumRat = state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).DesCoolCoilInHumRat;
    1919             :                             } else {
    1920          18 :                                 MixTemp = state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).ZoneRetTempAtCoolPeak;
    1921          18 :                                 MixHumRat = state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).ZoneHumRatAtCoolPeak;
    1922             :                             }
    1923             :                         } else {
    1924           0 :                             MixTemp = state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).DesCoolCoilInTemp;
    1925           0 :                             MixHumRat = state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).DesCoolCoilInHumRat;
    1926             :                         }
    1927          25 :                         SupTemp = state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).CoolDesTemp;
    1928          25 :                         SupHumRat = state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).CoolDesHumRat;
    1929             :                         // supply air condition is capped with that of mixed air to avoid SHR > 1.0
    1930          25 :                         SupTemp = min(MixTemp, SupTemp);
    1931          25 :                         SupHumRat = min(MixHumRat, SupHumRat);
    1932          25 :                         TimeStepNumAtMax = state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).TimeStepNumAtCoolMax;
    1933          25 :                         DDNum = state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).CoolDDNum;
    1934          25 :                         if (DDNum > 0 && TimeStepNumAtMax > 0) {
    1935          25 :                             OutTemp = state.dataSize->DesDayWeath(DDNum).Temp(TimeStepNumAtMax);
    1936             :                         } else {
    1937           0 :                             OutTemp = 0.0;
    1938             :                         }
    1939          25 :                         rhoair = Psychrometrics::PsyRhoAirFnPbTdbW(state, state.dataEnvrn->StdBaroPress, MixTemp, MixHumRat, RoutineName);
    1940          25 :                         MixEnth = Psychrometrics::PsyHFnTdbW(MixTemp, MixHumRat);
    1941          25 :                         SupEnth = Psychrometrics::PsyHFnTdbW(SupTemp, MixHumRat);
    1942          25 :                         Real64 FanCoolLoad = 0.0;
    1943          25 :                         if (state.dataSize->DataFanType != HVAC::FanType::Invalid && state.dataSize->DataFanIndex > 0) { // add fan heat to coil load
    1944          25 :                             FanCoolLoad = state.dataFans->fans(state.dataSize->DataFanIndex)->getDesignHeatGain(state, VolFlowRate);
    1945             : 
    1946          25 :                             Real64 CpAir = Psychrometrics::PsyCpAirFnW(MixHumRat);
    1947          25 :                             if (state.dataSize->DataFanPlacement == HVAC::FanPlace::BlowThru) {
    1948          18 :                                 MixTemp += FanCoolLoad / (CpAir * rhoair * VolFlowRate); // this is now the temperature entering the coil
    1949             :                             } else {
    1950           7 :                                 SupTemp -= FanCoolLoad / (CpAir * rhoair * VolFlowRate); // this is now the temperature leaving the coil
    1951             :                             }
    1952             :                         }
    1953             :                         // Sensible capacity is calculated from enthalpy difference with constant humidity ratio, i.e.,
    1954             :                         // there is only temperature difference between entering and leaving air enthalpy. Previously
    1955             :                         // it was calculated using m.cp.dT
    1956          25 :                         SensCapAtPeak = (rhoair * VolFlowRate * (MixEnth - SupEnth)) +
    1957             :                                         FanCoolLoad; // load on the cooling coil which includes ventilation load and fan heat (sensible)
    1958          25 :                         SensCapAtPeak = max(0.0, SensCapAtPeak);
    1959          25 :                         MixWetBulb = Psychrometrics::PsyTwbFnTdbWPb(state, MixTemp, MixHumRat, state.dataEnvrn->StdBaroPress, RoutineName);
    1960          25 :                         RatedMixWetBulb = simpleWatertoAirHP.RatedEntAirWetbulbTemp;
    1961          25 :                         RatedMixDryBulb = simpleWatertoAirHP.RatedEntAirDrybulbTemp;
    1962             :                         // calculate temperature ratios at design day peak conditions
    1963          25 :                         ratioTDB = (MixTemp + state.dataWaterToAirHeatPumpSimple->CelsiustoKelvin) / Tref;
    1964          25 :                         ratioTWB = (MixWetBulb + state.dataWaterToAirHeatPumpSimple->CelsiustoKelvin) / Tref;
    1965          50 :                         PltSizNum = PlantUtilities::MyPlantSizingIndex(
    1966             :                             state,
    1967          50 :                             format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)]),
    1968             :                             simpleWatertoAirHP.Name,
    1969             :                             simpleWatertoAirHP.WaterInletNodeNum,
    1970             :                             simpleWatertoAirHP.WaterOutletNodeNum,
    1971             :                             ErrorsFound,
    1972             :                             false);
    1973          25 :                         if (PltSizNum > 0) {
    1974          25 :                             DesignEntWaterTemp = state.dataSize->PlantSizData(PltSizNum).ExitTemp;
    1975          25 :                             ratioTS = (DesignEntWaterTemp + state.dataWaterToAirHeatPumpSimple->CelsiustoKelvin) / Tref;
    1976             :                         } else {
    1977           0 :                             ShowSevereError(state, "Autosizing of sensible cooling capacity requires a loop Sizing:Plant object");
    1978           0 :                             ShowContinueError(state, "Autosizing also requires physical connection to a plant or condenser loop.");
    1979           0 :                             ShowContinueError(state,
    1980           0 :                                               format("Occurs in COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT Object={}",
    1981           0 :                                                      WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)],
    1982           0 :                                                      simpleWatertoAirHP.Name));
    1983           0 :                             ErrorsFound = true;
    1984             :                         }
    1985             :                         // calculate temperatue ratio at rated conditions
    1986          25 :                         RatedratioTDB = (RatedMixDryBulb + state.dataWaterToAirHeatPumpSimple->CelsiustoKelvin) / Tref;
    1987          25 :                         RatedratioTWB = (RatedMixWetBulb + state.dataWaterToAirHeatPumpSimple->CelsiustoKelvin) / Tref;
    1988          25 :                         RatedratioTS = (simpleWatertoAirHP.RatedEntWaterTemp + state.dataWaterToAirHeatPumpSimple->CelsiustoKelvin) / Tref;
    1989          25 :                         PeakSensCapTempModFac =
    1990          25 :                             Curve::CurveValue(state, simpleWatertoAirHP.SensCoolCapCurveIndex, ratioTDB, ratioTWB, ratioTS, 1.0, 1.0);
    1991          25 :                         RatedSensCapTempModFac =
    1992          25 :                             Curve::CurveValue(state, simpleWatertoAirHP.SensCoolCapCurveIndex, RatedratioTDB, RatedratioTWB, RatedratioTS, 1.0, 1.0);
    1993             :                         // Check curve output when rated mixed air wetbulb is the design mixed air wetbulb
    1994             :                         // calculate the rated sensible capacity based on peak conditions
    1995             :                         // note: the rated sensible capacity can be different than the sensible capacity
    1996             :                         // at rated conditions if the capacity curve isn't normalized at the rated
    1997             :                         // conditions
    1998          25 :                         RatedCapCoolSensDes = (PeakSensCapTempModFac > 0.0) ? SensCapAtPeak / PeakSensCapTempModFac : SensCapAtPeak;
    1999             :                     } else {
    2000           0 :                         RatedCapCoolSensDes = 0.0;
    2001             :                     }
    2002             :                 }
    2003             :             }
    2004         137 :             if (RatedCapCoolSensDes < HVAC::SmallLoad) {
    2005          15 :                 RatedCapCoolSensDes = 0.0;
    2006             :             }
    2007         137 :             if (RatedCapCoolTotalAutoSized && RatedCapCoolSensAutoSized) {
    2008         122 :                 if (RatedCapCoolSensDes > RatedCapCoolTotalDes) {
    2009           0 :                     RatedCapCoolTotalDes = RatedCapCoolSensDes;
    2010             :                 }
    2011             :             }
    2012         137 :             if (!HardSizeNoDesRun) {
    2013         122 :                 if (RatedCapCoolTotalAutoSized) {
    2014         122 :                     if (simpleWatertoAirHP.CompanionHeatingCoilNum > 0) {
    2015             :                         auto &companionHeatingCoil(
    2016         122 :                             state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(simpleWatertoAirHP.CompanionHeatingCoilNum));
    2017         122 :                         if (companionHeatingCoil.WAHPPlantType == DataPlant::PlantEquipmentType::CoilWAHPHeatingEquationFit &&
    2018         122 :                             companionHeatingCoil.RatedCapHeat > 0) {
    2019             :                             // case 1: companion heating coil has a user-specified capacity
    2020             :                             // or has already been sized
    2021           0 :                             RatedCapCoolTotalDesCDD = RatedCapCoolTotalDes;
    2022           0 :                             RatedCapCoolHeatDD = companionHeatingCoil.RatedCapHeatAtRatedCdts / companionHeatingCoil.RatioRatedHeatRatedTotCoolCap /
    2023             :                                                  RatedTotCapTempModFac;
    2024           0 :                             if (RatedCapCoolHeatDD > RatedCapCoolTotalDesCDD) {
    2025             :                                 // re-base the cooling capacity
    2026           0 :                                 RatedCapCoolTotalDes = RatedCapCoolHeatDD;
    2027             : 
    2028             :                                 // adjust for system air flow -- capacity is based on heating design day calcs
    2029             :                                 // adjust by ratio of system to heating air flow rate and temperature delta across the coil at these different airflow
    2030           0 :                                 if (HeatingAirVolFlowRateDes > 0) {
    2031           0 :                                     RatedCapCoolTotalDes *= (RatedAirVolFlowRateDes / HeatingAirVolFlowRateDes) * HeatdTratio;
    2032             :                                 }
    2033             : 
    2034           0 :                                 if (RatedCapCoolSensAutoSized) {
    2035             :                                     // adjust sensible capacity assuming that the SHR is constant
    2036           0 :                                     RatedCapCoolSensDes *= RatedCapCoolTotalDes / RatedCapCoolTotalDesCDD;
    2037             :                                 }
    2038             : 
    2039           0 :                                 simpleWatertoAirHP.RatedCapCoolTotal = RatedCapCoolTotalDes;
    2040           0 :                                 OutputReportPredefined::PreDefTableEntry(
    2041           0 :                                     state, state.dataOutRptPredefined->pdchWAHPDD, simpleWatertoAirHP.Name, "Heating");
    2042             :                             } else {
    2043             :                                 // adjust for system air flow -- capacity is based on cooling design day calcs
    2044             :                                 // adjust by ratio of system to cooling air flow rate and enthalpy delta across the coil at these different airflow
    2045           0 :                                 RatedCapCoolTotalDes *= (RatedAirVolFlowRateDes / CoolingAirVolFlowRateDes) * dHratio;
    2046             : 
    2047           0 :                                 simpleWatertoAirHP.RatedCapCoolTotal = RatedCapCoolTotalDes;
    2048           0 :                                 OutputReportPredefined::PreDefTableEntry(
    2049           0 :                                     state, state.dataOutRptPredefined->pdchWAHPDD, simpleWatertoAirHP.Name, "Cooling");
    2050             :                             }
    2051             :                             // Set the global DX cooling coil capacity variable for use by other objects
    2052           0 :                             state.dataSize->DXCoolCap = simpleWatertoAirHP.RatedCapCoolTotal;
    2053         122 :                         } else if (companionHeatingCoil.WAHPPlantType == DataPlant::PlantEquipmentType::CoilWAHPHeatingEquationFit &&
    2054         122 :                                    companionHeatingCoil.RatedCapHeat == DataSizing::AutoSize) {
    2055             :                             // case 2: companion heating coil has not already been sized
    2056             :                             // we only pass the rated total cooling capacity determined
    2057             :                             // based on cooling design day which is used to decide if the
    2058             :                             // coil needs to be sized of the heating coil size
    2059             :                             //
    2060             :                             // no capcity adjustment based on system flow because the capacity could change
    2061             :                             // once the heating coil has been sized
    2062         122 :                             state.dataSize->DXCoolCap = RatedCapCoolTotalDes;
    2063           0 :                         } else if (companionHeatingCoil.WAHPPlantType != DataPlant::PlantEquipmentType::CoilWAHPHeatingEquationFit) {
    2064             :                             // case 3: companion heating coil is not of the "equationfit" type and hence doesn't use the rated heating to cooling
    2065             :                             // coil capacity ratio
    2066             :                             // adjust for system air flow -- capacity is based on cooling design day calcs
    2067             :                             // adjust by ratio of system to cooling air flow rate and enthalpy delta across the coil at these different airflow
    2068           0 :                             RatedCapCoolTotalDes *= (RatedAirVolFlowRateDes / CoolingAirVolFlowRateDes) * dHratio;
    2069           0 :                             simpleWatertoAirHP.RatedCapCoolTotal = RatedCapCoolTotalDes;
    2070             :                             // Set the global DX cooling coil capacity variable for use by other objects
    2071           0 :                             state.dataSize->DXCoolCap = simpleWatertoAirHP.RatedCapCoolTotal;
    2072             :                         }
    2073             :                     } else {
    2074             :                         // adjust for system air flow -- capacity is based on cooling design day calcs
    2075             :                         // adjust by ratio of system to cooling air flow rate and enthalpy delta across the coil at these different airflow
    2076           0 :                         RatedCapCoolTotalDes *= (RatedAirVolFlowRateDes / CoolingAirVolFlowRateDes) * dHratio;
    2077             : 
    2078           0 :                         simpleWatertoAirHP.RatedCapCoolTotal = RatedCapCoolTotalDes;
    2079           0 :                         state.dataSize->DXCoolCap = simpleWatertoAirHP.RatedCapCoolTotal;
    2080             :                     }
    2081             :                     // size power
    2082         122 :                     simpleWatertoAirHP.RatedCapCoolAtRatedCdts = RatedCapCoolTotalDes * RatedTotCapTempModFac;
    2083         122 :                     simpleWatertoAirHP.RatedPowerCoolAtRatedCdts =
    2084         122 :                         simpleWatertoAirHP.RatedCapCoolAtRatedCdts / simpleWatertoAirHP.RatedCOPCoolAtRatedCdts;
    2085         122 :                     simpleWatertoAirHP.RatedPowerCool = simpleWatertoAirHP.RatedPowerCoolAtRatedCdts / RatedCoolPowerTempModFac;
    2086         122 :                     if (simpleWatertoAirHP.RatedCapCoolTotal != DataSizing::AutoSize) {
    2087           0 :                         BaseSizer::reportSizerOutput(
    2088             :                             state,
    2089           0 :                             format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)]),
    2090             :                             simpleWatertoAirHP.Name,
    2091             :                             "Design Size Rated Total Cooling Capacity [W]",
    2092             :                             simpleWatertoAirHP.RatedCapCoolTotal);
    2093             :                     }
    2094         244 :                     OutputReportPredefined::PreDefTableEntry(
    2095         122 :                         state, state.dataOutRptPredefined->pdchWAHPRatedAirDBT, simpleWatertoAirHP.Name, RatedMixDryBulb);
    2096         244 :                     OutputReportPredefined::PreDefTableEntry(
    2097         122 :                         state, state.dataOutRptPredefined->pdchWAHPRatedAirWBT, simpleWatertoAirHP.Name, RatedMixWetBulb);
    2098         244 :                     OutputReportPredefined::PreDefTableEntry(
    2099         122 :                         state, state.dataOutRptPredefined->pdchWAHPRatedWtrT, simpleWatertoAirHP.Name, simpleWatertoAirHP.RatedEntWaterTemp);
    2100             :                 } else { // Hardsized with sizing data
    2101           0 :                     if (simpleWatertoAirHP.RatedCapCoolTotal > 0.0 && RatedCapCoolTotalDes > 0.0) {
    2102           0 :                         RatedCapCoolTotalUser = simpleWatertoAirHP.RatedCapCoolTotal;
    2103           0 :                         state.dataSize->DXCoolCap = simpleWatertoAirHP.RatedCapCoolTotal;
    2104           0 :                         simpleWatertoAirHP.RatedPowerCool = simpleWatertoAirHP.RatedCapCoolTotal / simpleWatertoAirHP.RatedCOPCoolAtRatedCdts;
    2105           0 :                         BaseSizer::reportSizerOutput(
    2106             :                             state,
    2107           0 :                             format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)]),
    2108             :                             simpleWatertoAirHP.Name,
    2109             :                             "Design Size Rated Total Cooling Capacity [W]",
    2110             :                             RatedCapCoolTotalDes,
    2111             :                             "User-Specified Rated Total Cooling Capacity [W]",
    2112             :                             RatedCapCoolTotalUser);
    2113           0 :                         if (state.dataGlobal->DisplayExtraWarnings) {
    2114           0 :                             if ((std::abs(RatedCapCoolTotalDes - RatedCapCoolTotalUser) / RatedCapCoolTotalUser) >
    2115           0 :                                 state.dataSize->AutoVsHardSizingThreshold) {
    2116           0 :                                 ShowMessage(
    2117             :                                     state,
    2118           0 :                                     format("SizeHVACWaterToAir: Potential issue with equipment sizing for coil {}:WATERTOAIRHEATPUMP:EQUATIONFIT {}",
    2119           0 :                                            WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)],
    2120           0 :                                            simpleWatertoAirHP.Name));
    2121           0 :                                 ShowContinueError(state, format("User-Specified Rated Total Cooling Capacity of {:.2R} [W]", RatedCapCoolTotalUser));
    2122           0 :                                 ShowContinueError(
    2123           0 :                                     state, format("differs from Design Size Rated Total Cooling Capacity of {:.2R} [W]", RatedCapCoolTotalDes));
    2124           0 :                                 ShowContinueError(state, "This may, or may not, indicate mismatched component sizes.");
    2125           0 :                                 ShowContinueError(state, "Verify that the value entered is intended and is consistent with other components.");
    2126             :                             }
    2127             :                         }
    2128             :                     }
    2129             :                 }
    2130             :             } else {
    2131          15 :                 state.dataSize->DXCoolCap = simpleWatertoAirHP.RatedCapCoolTotal;
    2132             :                 // user provided inputs are assumed to be at rated conditions
    2133          15 :                 simpleWatertoAirHP.RatedPowerCool = simpleWatertoAirHP.RatedCapCoolTotal / simpleWatertoAirHP.RatedCOPCoolAtRatedCdts;
    2134          15 :                 simpleWatertoAirHP.RatedCapCoolAtRatedCdts = 0;
    2135          15 :                 simpleWatertoAirHP.RatedPowerCoolAtRatedCdts = 0;
    2136             :             }
    2137         137 :             if (simpleWatertoAirHP.RatedCapCoolTotal !=
    2138             :                 DataSizing::AutoSize) { // all cases except case 2 mentioned above (when EquationFit companion heating coil has not yet been sized)
    2139          30 :                 OutputReportPredefined::PreDefTableEntry(
    2140          15 :                     state, state.dataOutRptPredefined->pdchCoolCoilTotCap, simpleWatertoAirHP.Name, simpleWatertoAirHP.RatedCapCoolTotal);
    2141          30 :                 OutputReportPredefined::PreDefTableEntry(state,
    2142          15 :                                                          state.dataOutRptPredefined->pdchCoolCoilLatCap,
    2143             :                                                          simpleWatertoAirHP.Name,
    2144          15 :                                                          simpleWatertoAirHP.RatedCapCoolTotal - simpleWatertoAirHP.RatedCapCoolSens);
    2145          15 :                 if (simpleWatertoAirHP.RatedCapCoolTotal > 0) {
    2146          30 :                     OutputReportPredefined::PreDefTableEntry(state,
    2147          15 :                                                              state.dataOutRptPredefined->pdchCoolCoilSHR,
    2148             :                                                              simpleWatertoAirHP.Name,
    2149          15 :                                                              simpleWatertoAirHP.RatedCapCoolSens / simpleWatertoAirHP.RatedCapCoolTotal);
    2150             :                 } else {
    2151           0 :                     OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoolCoilSHR, simpleWatertoAirHP.Name, 0.0);
    2152             :                 }
    2153          15 :                 if (RatedCapCoolTotalAutoSized) {
    2154           0 :                     OutputReportPredefined::PreDefTableEntry(state,
    2155           0 :                                                              state.dataOutRptPredefined->pdchWAHPRatedCapAtRatedCdts,
    2156             :                                                              simpleWatertoAirHP.Name,
    2157             :                                                              simpleWatertoAirHP.RatedCapCoolAtRatedCdts);
    2158           0 :                     if (simpleWatertoAirHP.CompanionHeatingCoilNum > 0) {
    2159             :                         auto &companionHeatingCoil(
    2160           0 :                             state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(simpleWatertoAirHP.CompanionHeatingCoilNum));
    2161           0 :                         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchWAHPDD, companionHeatingCoil.Name, "Cooling");
    2162             :                     }
    2163             :                 }
    2164             :             } else {
    2165             :                 // set temporarily until companion heating coil is sized
    2166         122 :                 OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoolCoilTotCap, simpleWatertoAirHP.Name, 0.0);
    2167         122 :                 OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoolCoilLatCap, simpleWatertoAirHP.Name, 0.0);
    2168         122 :                 OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoolCoilSHR, simpleWatertoAirHP.Name, 0.0);
    2169         122 :                 OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoolCoilNomEff, simpleWatertoAirHP.Name, 0.0);
    2170             :             }
    2171         137 :             if (simpleWatertoAirHP.RatedCapCoolTotal != DataSizing::AutoSize) {
    2172          15 :                 state.dataRptCoilSelection->coilSelectionReportObj->setCoilCoolingCapacity(state,
    2173          15 :                                                                                            simpleWatertoAirHP.Name,
    2174             :                                                                                            CompType,
    2175             :                                                                                            simpleWatertoAirHP.RatedCapCoolTotal,
    2176             :                                                                                            RatedCapCoolTotalAutoSized,
    2177          15 :                                                                                            state.dataSize->CurSysNum,
    2178          15 :                                                                                            state.dataSize->CurZoneEqNum,
    2179          15 :                                                                                            state.dataSize->CurOASysNum,
    2180             :                                                                                            FanCoolLoad,
    2181             :                                                                                            PeakTotCapTempModFac,
    2182             :                                                                                            -999.0,
    2183             :                                                                                            -999.0);
    2184             :             }
    2185         137 :             if (!HardSizeNoDesRun) {
    2186         122 :                 if (RatedCapCoolSensAutoSized) {
    2187         122 :                     simpleWatertoAirHP.RatedCapCoolSens = RatedCapCoolSensDes;
    2188         122 :                     simpleWatertoAirHP.RatedCapCoolSensDesAtRatedCdts = RatedCapCoolSensDes * RatedSensCapTempModFac;
    2189         122 :                     if (simpleWatertoAirHP.RatedCapCoolTotal != DataSizing::AutoSize) {
    2190           0 :                         BaseSizer::reportSizerOutput(
    2191             :                             state,
    2192           0 :                             format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)]),
    2193             :                             simpleWatertoAirHP.Name,
    2194             :                             "Design Size Rated Sensible Cooling Capacity [W]",
    2195             :                             RatedCapCoolSensDes);
    2196             :                     }
    2197             :                 } else {
    2198           0 :                     if (simpleWatertoAirHP.RatedCapCoolSens > 0.0 && RatedCapCoolSensDes > 0.0) {
    2199           0 :                         RatedCapCoolSensUser = simpleWatertoAirHP.RatedCapCoolSens;
    2200           0 :                         BaseSizer::reportSizerOutput(
    2201             :                             state,
    2202           0 :                             format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)]),
    2203             :                             simpleWatertoAirHP.Name,
    2204             :                             "Design Size Rated Sensible Cooling Capacity [W]",
    2205             :                             RatedCapCoolSensDes,
    2206             :                             "User-Specified Rated Sensible Cooling Capacity [W]",
    2207             :                             RatedCapCoolSensUser);
    2208           0 :                         if (state.dataGlobal->DisplayExtraWarnings) {
    2209           0 :                             if ((std::abs(RatedCapCoolSensDes - RatedCapCoolSensUser) / RatedCapCoolSensUser) >
    2210           0 :                                 state.dataSize->AutoVsHardSizingThreshold) {
    2211           0 :                                 ShowMessage(
    2212             :                                     state,
    2213           0 :                                     format("SizeHVACWaterToAir: Potential issue with equipment sizing for coil {}:WATERTOAIRHEATPUMP:EQUATIONFIT {}",
    2214           0 :                                            WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)],
    2215           0 :                                            simpleWatertoAirHP.Name));
    2216           0 :                                 ShowContinueError(state,
    2217           0 :                                                   format("User-Specified Rated Sensible Cooling Capacity of {:.2R} [W]", RatedCapCoolSensUser));
    2218           0 :                                 ShowContinueError(
    2219           0 :                                     state, format("differs from Design Size Rated Sensible Cooling Capacity of {:.2R} [W]", RatedCapCoolSensDes));
    2220           0 :                                 ShowContinueError(state, "This may, or may not, indicate mismatched component sizes.");
    2221           0 :                                 ShowContinueError(state, "Verify that the value entered is intended and is consistent with other components.");
    2222             :                             }
    2223             :                         }
    2224             :                     }
    2225             :                 }
    2226             :             }
    2227         274 :             OutputReportPredefined::PreDefTableEntry(
    2228         137 :                 state, state.dataOutRptPredefined->pdchCoolCoilSensCap, simpleWatertoAirHP.Name, simpleWatertoAirHP.RatedCapCoolSens);
    2229         274 :             OutputReportPredefined::PreDefTableEntry(state,
    2230         137 :                                                      state.dataOutRptPredefined->pdchCoolCoilLatCap,
    2231             :                                                      simpleWatertoAirHP.Name,
    2232         137 :                                                      state.dataSize->DXCoolCap - simpleWatertoAirHP.RatedCapCoolSens);
    2233         137 :             if (RatedCapCoolSensAutoSized) {
    2234             : 
    2235         244 :                 OutputReportPredefined::PreDefTableEntry(state,
    2236         122 :                                                          state.dataOutRptPredefined->pdchWAHPRatedSensCapAtRatedCdts,
    2237             :                                                          simpleWatertoAirHP.Name,
    2238             :                                                          simpleWatertoAirHP.RatedCapCoolSensDesAtRatedCdts);
    2239             :             }
    2240         137 :             if (simpleWatertoAirHP.RatedCapCoolTotal != 0.0) {
    2241         274 :                 OutputReportPredefined::PreDefTableEntry(state,
    2242         137 :                                                          state.dataOutRptPredefined->pdchCoolCoilSHR,
    2243             :                                                          simpleWatertoAirHP.Name,
    2244         137 :                                                          simpleWatertoAirHP.RatedCapCoolSens / state.dataSize->DXCoolCap);
    2245             :             } else {
    2246           0 :                 OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoolCoilSHR, simpleWatertoAirHP.Name, 0.0);
    2247             :             }
    2248             :             // test autosized sensible and total cooling capacity for total > sensible
    2249         137 :             if ((RatedCapCoolSensAutoSized && RatedCapCoolTotalAutoSized) || RatedCapCoolSensAutoSized) {
    2250         122 :                 if (simpleWatertoAirHP.RatedCapCoolSensDesAtRatedCdts > simpleWatertoAirHP.RatedCapCoolAtRatedCdts) {
    2251           0 :                     ShowWarningError(state,
    2252           0 :                                      format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT \"{}\"",
    2253           0 :                                             WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)],
    2254           0 :                                             simpleWatertoAirHP.Name));
    2255           0 :                     ShowContinueError(state, format("{}: Rated Sensible Cooling Capacity > Rated Total Cooling Capacity", RoutineName));
    2256           0 :                     ShowContinueError(state, "Both of these capacity inputs have been autosized.");
    2257           0 :                     ShowContinueError(
    2258             :                         state,
    2259           0 :                         format("Rated Sensible Cooling Capacity at Rated Conditions = {:.2T} W", simpleWatertoAirHP.RatedCapCoolSensDesAtRatedCdts));
    2260           0 :                     ShowContinueError(
    2261           0 :                         state, format("Rated Total Cooling Capacity at Rated Conditions    = {:.2T} W", simpleWatertoAirHP.RatedCapCoolAtRatedCdts));
    2262           0 :                     ShowContinueError(state, "See eio file for further details.");
    2263           0 :                     ShowContinueError(state, "Check Total and Sensible Cooling Capacity coefficients in curves to ensure they are accurate.");
    2264           0 :                     ShowContinueError(state, "Check Zone and System Sizing objects to verify sizing inputs.");
    2265           0 :                     ShowContinueError(state, "Sizing statistics:");
    2266           0 :                     ShowContinueError(state, format("Rated entering Air Wet-Bulb Temperature = {:.3T} C", RatedMixWetBulb));
    2267           0 :                     ShowContinueError(state, format("Peak entering Air Wet-Bulb Temperature = {:.3T} C", MixWetBulb));
    2268           0 :                     ShowContinueError(state, format("Entering Water Temperature used = {:.3T} C", simpleWatertoAirHP.RatedEntWaterTemp));
    2269           0 :                     ShowContinueError(state, "Design air and water flow rates = 1.0");
    2270           0 :                     ShowContinueError(
    2271           0 :                         state, format("Rated ratio of load-side air wet-bulb temperature to 283.15 C (Rated ratioTWB) = {:.3T}", RatedratioTWB));
    2272           0 :                     ShowContinueError(
    2273           0 :                         state, format("Rated ratio of source-side inlet water temperature to 283.15 C (Rated ratioTS)  = {:.3T}", RatedratioTS));
    2274           0 :                     ShowContinueError(state,
    2275           0 :                                       format("Peak ratio of load-side air wet-bulb temperature to 283.15 C (Peak ratioTWB) = {:.3T}", ratioTWB));
    2276           0 :                     ShowContinueError(state,
    2277           0 :                                       format("Peak ratio of source-side inlet water temperature to 283.15 C (Peak ratioTS)  = {:.3T}", ratioTS));
    2278           0 :                     ShowContinueError(state, format("Rated Total Cooling Capacity Modifier = {:.5T}", RatedTotCapTempModFac));
    2279           0 :                     ShowContinueError(state, format("Peak Design Total Cooling Capacity Modifier = {:.5T}", PeakTotCapTempModFac));
    2280           0 :                     ShowContinueError(state, format("Rated Sensible Cooling Capacity Modifier = {:.5T}", RatedSensCapTempModFac));
    2281           0 :                     ShowContinueError(state, format("Peak Design Sensible Cooling Capacity Modifier = {:.5T}", PeakSensCapTempModFac));
    2282           0 :                     ShowContinueError(state,
    2283             :                                       "...Rated Total Cooling Capacity at Rated Conditions = Total Peak Design Load * Rated Total "
    2284             :                                       "Cooling Capacity Modifier  / "
    2285             :                                       "Peak Design Total Cooling Capacity Modifier");
    2286           0 :                     ShowContinueError(state,
    2287             :                                       "...Rated Sensible Cooling Capacity at Rated Conditions = Peak Design Sensible Load * Rated "
    2288             :                                       "Sensible Cooling "
    2289             :                                       "Capacity Modifier  / Peak Design Sensible Cooling Capacity Modifier");
    2290           0 :                     ShowContinueError(state, "Carefully review the Load Side Total, Sensible, and Latent heat transfer rates");
    2291           0 :                     ShowContinueError(state, "... to ensure they meet the expected manufacturers performance specifications.");
    2292             :                 }
    2293          15 :             } else if (RatedCapCoolTotalAutoSized) {
    2294           0 :                 if (simpleWatertoAirHP.RatedCapCoolSensDesAtRatedCdts > simpleWatertoAirHP.RatedCapCoolAtRatedCdts) {
    2295           0 :                     ShowWarningError(state,
    2296           0 :                                      format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT \"{}\"",
    2297           0 :                                             WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)],
    2298           0 :                                             simpleWatertoAirHP.Name));
    2299           0 :                     ShowContinueError(state, format("{}: Rated Sensible Cooling Capacity > Rated Total Cooling Capacity", RoutineName));
    2300           0 :                     ShowContinueError(state, "Only the Rated total capacity input is autosized, consider autosizing both inputs.");
    2301           0 :                     ShowContinueError(state, format("Rated Sensible Cooling Capacity = {:.2T} W", simpleWatertoAirHP.RatedCapCoolSensDesAtRatedCdts));
    2302           0 :                     ShowContinueError(state, format("Rated Total Cooling Capacity    = {:.2T} W", simpleWatertoAirHP.RatedCapCoolAtRatedCdts));
    2303           0 :                     ShowContinueError(state, "See eio file for further details.");
    2304           0 :                     ShowContinueError(state, "Check Total and Sensible Cooling Capacity coefficients in curves to ensure they are accurate.");
    2305           0 :                     ShowContinueError(state, "Check Zone and System Sizing objects to verify sizing inputs.");
    2306           0 :                     ShowContinueError(state, "Sizing statistics for Total Cooling Capacity:");
    2307           0 :                     ShowContinueError(state, format("Rated entering Air Wet-Bulb Temperature = {:.3T} C", RatedMixWetBulb));
    2308           0 :                     ShowContinueError(state, format("Peak entering Air Wet-Bulb Temperature = {:.3T} C", MixWetBulb));
    2309           0 :                     ShowContinueError(state, format("Entering Water Temperature used = {:.3T} C", simpleWatertoAirHP.RatedEntWaterTemp));
    2310           0 :                     ShowContinueError(state, "Design air and water flow rates = 1.0");
    2311           0 :                     ShowContinueError(
    2312           0 :                         state, format("Rated ratio of load-side air wet-bulb temperature to 283.15 C (Rated ratioTWB) = {:.3T}", RatedratioTWB));
    2313           0 :                     ShowContinueError(
    2314           0 :                         state, format("Rated ratio of source-side inlet water temperature to 283.15 C (Rated ratioTS)  = {:.3T}", RatedratioTS));
    2315           0 :                     ShowContinueError(state,
    2316           0 :                                       format("Peak ratio of load-side air wet-bulb temperature to 283.15 C (Peak ratioTWB) = {:.3T}", ratioTWB));
    2317           0 :                     ShowContinueError(state,
    2318           0 :                                       format("Peak ratio of source-side inlet water temperature to 283.15 C (Peak ratioTS)  = {:.3T}", ratioTS));
    2319           0 :                     ShowContinueError(state, format("Rated Total Cooling Capacity Modifier = {:.5T}", RatedTotCapTempModFac));
    2320           0 :                     ShowContinueError(state, format("Peak Design Total Cooling Capacity Modifier = {:.5T}", PeakTotCapTempModFac));
    2321           0 :                     ShowContinueError(state,
    2322             :                                       "...Rated Total Cooling Capacity at Rated Conditions = Total Peak Design Load * Rated Total "
    2323             :                                       "Cooling Capacity Modifier  / "
    2324             :                                       "Peak Design Total Cooling Capacity Modifier");
    2325           0 :                     ShowContinueError(state,
    2326             :                                       "...Rated Sensible Cooling Capacity at Rated Conditions = Peak Design Sensible Load * Rated "
    2327             :                                       "Sensible Cooling "
    2328             :                                       "Capacity Modifier  / Peak Design Sensible Cooling Capacity Modifier");
    2329           0 :                     ShowContinueError(state, "Carefully review the Load Side Total, Sensible, and Latent heat transfer rates");
    2330           0 :                     ShowContinueError(state, "... to ensure they meet the expected manufacturers performance specifications.");
    2331             :                 }
    2332             :             }
    2333             : 
    2334             :         } // Cooling Coil
    2335             : 
    2336         274 :         if (simpleWatertoAirHP.WAHPType == WatertoAirHP::Heating) {
    2337             :             // size rated heating capacity
    2338         137 :             IsAutoSize = false;
    2339         137 :             if (simpleWatertoAirHP.RatedCapHeat == DataSizing::AutoSize) {
    2340         122 :                 IsAutoSize = true;
    2341             :             }
    2342         137 :             if (SizingDesRunThisAirSys || SizingDesRunThisZone) HardSizeNoDesRun = false;
    2343         137 :             if (IsAutoSize) {
    2344         122 :                 if (state.dataSize->CurSysNum > 0) {
    2345          97 :                     CheckSysSizing(
    2346             :                         state,
    2347         194 :                         format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)]),
    2348          97 :                         simpleWatertoAirHP.Name);
    2349          97 :                     if (HeatingAirVolFlowRateDes > 0.0) {
    2350          97 :                         VolFlowRate = HeatingAirVolFlowRateDes;
    2351             :                     } else {
    2352           0 :                         VolFlowRate = CoolingAirVolFlowRateDes; // system air flow
    2353             :                     }
    2354             :                     // heating design day calculations
    2355          97 :                     if (VolFlowRate >= HVAC::SmallAirVolFlow) {
    2356          97 :                         auto &finalSysSizing(state.dataSize->FinalSysSizing(state.dataSize->CurSysNum));
    2357          97 :                         if (state.dataSize->CurOASysNum > 0) { // coil is in the OA stream
    2358           0 :                             HeatMixTemp = finalSysSizing.HeatOutTemp;
    2359           0 :                             HeatMixHumRat = finalSysSizing.HeatOutHumRat;
    2360           0 :                             HeatSupTemp = finalSysSizing.PreheatTemp;
    2361             :                         } else { // coil is on the main air loop
    2362          97 :                             if (VolFlowRate > 0.0) {
    2363          97 :                                 HeatOutAirFrac = finalSysSizing.DesOutAirVolFlow / VolFlowRate;
    2364          97 :                                 HeatOutAirFracSys = finalSysSizing.DesOutAirVolFlow / RatedAirVolFlowRateDes;
    2365             :                             } else {
    2366           0 :                                 HeatOutAirFrac = 1.0;
    2367           0 :                                 HeatOutAirFracSys = HeatOutAirFrac;
    2368             :                             }
    2369          97 :                             HeatOutAirFrac = min(1.0, max(0.0, HeatOutAirFrac));
    2370          97 :                             HeatOutAirFracSys = min(1.0, max(0.0, HeatOutAirFracSys));
    2371          97 :                             HeatSupTemp = finalSysSizing.HeatSupTemp;
    2372          97 :                             if (state.dataAirSystemsData->PrimaryAirSystems(state.dataSize->CurSysNum).NumOAHeatCoils ==
    2373             :                                 0) { // there is no preheating of the OA stream
    2374          97 :                                 HeatMixTemp = HeatOutAirFrac * finalSysSizing.HeatOutTemp + (1.0 - HeatOutAirFrac) * finalSysSizing.HeatRetTemp;
    2375          97 :                                 HeatMixHumRat = HeatOutAirFrac * finalSysSizing.HeatOutHumRat + (1.0 - HeatOutAirFrac) * finalSysSizing.HeatRetHumRat;
    2376             :                                 // calculate mixed air temperature with system airflow
    2377          97 :                                 HeatMixTempSys =
    2378          97 :                                     HeatOutAirFracSys * finalSysSizing.HeatOutTemp + (1.0 - HeatOutAirFracSys) * finalSysSizing.HeatRetTemp;
    2379          97 :                                 HeatMixHumRatSys =
    2380          97 :                                     HeatOutAirFracSys * finalSysSizing.HeatOutHumRat + (1.0 - HeatOutAirFracSys) * finalSysSizing.HeatRetHumRat;
    2381             :                             } else { // there is preheating of OA stream
    2382           0 :                                 HeatOutAirFrac = min(1.0, max(0.0, HeatOutAirFrac));
    2383           0 :                                 HeatMixTemp = HeatOutAirFrac * finalSysSizing.PreheatTemp + (1.0 - HeatOutAirFrac) * finalSysSizing.HeatRetTemp;
    2384           0 :                                 HeatMixHumRat = HeatOutAirFrac * finalSysSizing.PreheatHumRat + (1.0 - HeatOutAirFrac) * finalSysSizing.HeatRetHumRat;
    2385             :                                 // calculate mixed air temperature with system airflow
    2386           0 :                                 HeatMixTempSys =
    2387           0 :                                     HeatOutAirFracSys * finalSysSizing.PreheatTemp + (1.0 - HeatOutAirFracSys) * finalSysSizing.HeatRetTemp;
    2388           0 :                                 HeatMixHumRatSys =
    2389           0 :                                     HeatOutAirFracSys * finalSysSizing.PreheatHumRat + (1.0 - HeatOutAirFracSys) * finalSysSizing.HeatRetHumRat;
    2390             :                             }
    2391             :                             // determine the coil ratio of coil dT with system air flow to design heating air flow
    2392          97 :                             HeatdTratio = (HeatSupTemp - HeatMixTempSys) / (HeatSupTemp - HeatMixTemp);
    2393             :                         }
    2394          97 :                         rhoair = Psychrometrics::PsyRhoAirFnPbTdbW(state, state.dataEnvrn->StdBaroPress, HeatMixTemp, HeatMixHumRat, RoutineName);
    2395          97 :                         HeatCapAtPeak = rhoair * VolFlowRate * Psychrometrics::PsyCpAirFnW(DataPrecisionGlobals::constant_zero) *
    2396          97 :                                         (HeatSupTemp - HeatMixTemp); // heating coil load
    2397         194 :                         if (state.dataSize->DataFanType != HVAC::FanType::Invalid &&
    2398          97 :                             state.dataSize->DataFanIndex > 0) { // remove fan heat to coil load
    2399          97 :                             FanHeatLoad = state.dataFans->fans(state.dataSize->DataFanIndex)->getDesignHeatGain(state, VolFlowRate);
    2400             : 
    2401          97 :                             Real64 CpAir = Psychrometrics::PsyCpAirFnW(HeatMixHumRat);
    2402          97 :                             if (state.dataAirSystemsData->PrimaryAirSystems(state.dataSize->CurSysNum).supFanPlace == HVAC::FanPlace::BlowThru) {
    2403          97 :                                 HeatMixTemp += FanHeatLoad / (CpAir * rhoair * VolFlowRate); // this is now the temperature entering the coil
    2404           0 :                             } else if (state.dataAirSystemsData->PrimaryAirSystems(state.dataSize->CurSysNum).supFanPlace ==
    2405             :                                        HVAC::FanPlace::DrawThru) {
    2406           0 :                                 HeatSupTemp -= FanHeatLoad / (CpAir * rhoair * VolFlowRate); // this is now the temperature leaving the coil
    2407             :                             }
    2408             :                         }
    2409          97 :                         HeatCapAtPeak -= FanHeatLoad; // remove fan heat from heating coil load
    2410          97 :                         HeatCapAtPeak = max(0.0, HeatCapAtPeak);
    2411          97 :                         RatedHeatMixDryBulb = simpleWatertoAirHP.RatedEntAirDrybulbTemp;
    2412             :                         // calculate temperatue ratio at design day peak conditions
    2413          97 :                         HeatratioTDB = (HeatMixTemp + state.dataWaterToAirHeatPumpSimple->CelsiustoKelvin) / Tref;
    2414         194 :                         PltSizNum = PlantUtilities::MyPlantSizingIndex(
    2415             :                             state,
    2416         194 :                             format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)]),
    2417             :                             simpleWatertoAirHP.Name,
    2418             :                             simpleWatertoAirHP.WaterInletNodeNum,
    2419             :                             simpleWatertoAirHP.WaterOutletNodeNum,
    2420             :                             ErrorsFound,
    2421             :                             false);
    2422          97 :                         if (PltSizNum > 0) {
    2423          97 :                             DesignEntWaterTemp = state.dataSize->PlantSizData(PltSizNum).ExitTemp;
    2424          97 :                             HeatratioTS = (DesignEntWaterTemp + state.dataWaterToAirHeatPumpSimple->CelsiustoKelvin) / Tref;
    2425             :                         } else {
    2426           0 :                             ShowSevereError(state, "Autosizing of heating capacity requires a loop Sizing:Plant object");
    2427           0 :                             ShowContinueError(state, "Autosizing also requires physical connection to a plant or condenser loop.");
    2428           0 :                             ShowContinueError(state,
    2429           0 :                                               format("Occurs in COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT Object={}",
    2430           0 :                                                      WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)],
    2431           0 :                                                      simpleWatertoAirHP.Name));
    2432           0 :                             HeatratioTS = 0.0; // Clang complains it is used uninitialized if you don't give it a value
    2433           0 :                             ErrorsFound = true;
    2434             :                         }
    2435             :                         // calculate temperatue ratio at refrence conditions
    2436          97 :                         RatedHeatratioTDB = (RatedHeatMixDryBulb + state.dataWaterToAirHeatPumpSimple->CelsiustoKelvin) / Tref;
    2437          97 :                         RatedHeatratioTS = (simpleWatertoAirHP.RatedEntWaterTemp + state.dataWaterToAirHeatPumpSimple->CelsiustoKelvin) / Tref;
    2438             :                         // determine curve modifiers at peak and rated conditions
    2439          97 :                         PeakHeatCapTempModFac = Curve::CurveValue(state, simpleWatertoAirHP.HeatCapCurveIndex, HeatratioTDB, HeatratioTS, 1.0, 1.0);
    2440          97 :                         RatedHeatCapTempModFac =
    2441          97 :                             Curve::CurveValue(state, simpleWatertoAirHP.HeatCapCurveIndex, RatedHeatratioTDB, RatedHeatratioTS, 1.0, 1.0);
    2442             :                         // Check curve output when rated mixed air wetbulb is the design mixed air wetbulb
    2443          97 :                         if (RatedHeatMixDryBulb == HeatMixTemp) {
    2444           0 :                             if (RatedHeatCapTempModFac > 1.02 || RatedHeatCapTempModFac < 0.98) {
    2445           0 :                                 ShowWarningError(state,
    2446           0 :                                                  format("{} Coil:Heating:WaterToAirHeatPump:EquationFit={}", RoutineName, simpleWatertoAirHP.Name));
    2447           0 :                                 ShowContinueError(state,
    2448             :                                                   "Heating capacity as a function of temperature curve output is not equal to 1.0 (+ or - 2%) "
    2449             :                                                   "at rated conditions.");
    2450           0 :                                 ShowContinueError(state, format("Curve output at rated conditions = {:.3T}", RatedHeatCapTempModFac));
    2451             :                             }
    2452             :                         }
    2453             :                         // calculate the rated capacity based on peak conditions
    2454             :                         // note: the rated capacity can be different than the capacity at
    2455             :                         // rated conditions if the capacity curve isn't normalized at the
    2456             :                         // rated conditions
    2457          97 :                         RatedCapHeatDes = (PeakHeatCapTempModFac > 0.0) ? HeatCapAtPeak / PeakHeatCapTempModFac : HeatCapAtPeak;
    2458             :                     } else {
    2459           0 :                         RatedCapHeatDes = 0.0;
    2460           0 :                         RatedHeatratioTS = 0.0; // Clang complains it is used uninitialized if you don't give it a value
    2461             :                     }
    2462          25 :                 } else if (state.dataSize->CurZoneEqNum > 0) {
    2463          50 :                     CheckZoneSizing(
    2464             :                         state,
    2465          50 :                         format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)]),
    2466             :                         simpleWatertoAirHP.Name);
    2467          25 :                     if (HeatingAirVolFlowRateDes > 0.0) {
    2468          25 :                         VolFlowRate = HeatingAirVolFlowRateDes;
    2469             :                     } else {
    2470           0 :                         VolFlowRate = CoolingAirVolFlowRateDes; // system air flow
    2471             :                     }
    2472          25 :                     if (VolFlowRate >= HVAC::SmallAirVolFlow) {
    2473          25 :                         if (state.dataSize->ZoneEqDXCoil) {
    2474          25 :                             if (ZoneEqSizing(state.dataSize->CurZoneEqNum).OAVolFlow > 0.0) {
    2475           7 :                                 HeatMixTemp = state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).DesHeatCoilInTemp;
    2476           7 :                                 HeatMixHumRat = state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).DesHeatCoilInHumRat;
    2477             :                                 // calculate mixed air temperature with system airflow
    2478           7 :                                 HeatOAFrac = state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).MinOA / HeatingAirVolFlowRateDes;
    2479           7 :                                 HeatOAFracSys = state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).MinOA / RatedAirVolFlowRateDes;
    2480           7 :                                 HeatOAFrac = min(1.0, max(0.0, HeatOAFrac));
    2481           7 :                                 HeatOAFracSys = min(1.0, max(0.0, HeatOAFracSys));
    2482           7 :                                 HeatOATemp = (state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).DesHeatCoilInTemp -
    2483           7 :                                               (1.0 - HeatOAFrac) * state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).ZoneTempAtHeatPeak) /
    2484             :                                              HeatOAFrac;
    2485           7 :                                 HeatMixTempSys =
    2486           7 :                                     HeatOAFracSys * HeatOATemp +
    2487           7 :                                     (1.0 - HeatOAFracSys) * state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).ZoneTempAtHeatPeak;
    2488             :                             } else {
    2489          18 :                                 HeatMixTemp = state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).ZoneRetTempAtHeatPeak;
    2490          18 :                                 HeatMixHumRat = state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).ZoneHumRatAtHeatPeak;
    2491          18 :                                 HeatMixTempSys = HeatMixTemp;
    2492             :                             }
    2493             :                         } else {
    2494           0 :                             HeatMixTemp = state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).DesHeatCoilInTemp;
    2495           0 :                             HeatMixHumRat = state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).DesHeatCoilInHumRat;
    2496           0 :                             HeatMixTempSys = HeatMixTemp;
    2497             :                         }
    2498          25 :                         HeatSupTemp = state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).HeatDesTemp;
    2499             :                         // determine the coil ratio of coil dT with system air flow to design heating air flow
    2500          25 :                         HeatdTratio = (HeatSupTemp - HeatMixTempSys) / (HeatSupTemp - HeatMixTemp);
    2501          25 :                         rhoair = Psychrometrics::PsyRhoAirFnPbTdbW(state, state.dataEnvrn->StdBaroPress, HeatMixTemp, HeatMixHumRat, RoutineName);
    2502          25 :                         HeatCapAtPeak = rhoair * VolFlowRate * Psychrometrics::PsyCpAirFnW(DataPrecisionGlobals::constant_zero) *
    2503          25 :                                         (HeatSupTemp - HeatMixTemp);                                                     // heating coil load
    2504          25 :                         if (state.dataSize->DataFanType != HVAC::FanType::Invalid && state.dataSize->DataFanIndex > 0) { // add fan heat to coil load
    2505          25 :                             FanHeatLoad = state.dataFans->fans(state.dataSize->DataFanIndex)->getDesignHeatGain(state, VolFlowRate);
    2506             : 
    2507          25 :                             Real64 CpAir = Psychrometrics::PsyCpAirFnW(HeatMixHumRat);
    2508          25 :                             if (state.dataSize->DataFanPlacement == HVAC::FanPlace::BlowThru) {
    2509          18 :                                 HeatMixTemp += FanHeatLoad / (CpAir * rhoair * VolFlowRate); // this is now the temperature entering the coil
    2510             :                             } else {
    2511           7 :                                 HeatSupTemp -= FanHeatLoad / (CpAir * rhoair * VolFlowRate); // this is now the temperature leaving the coil
    2512             :                             }
    2513             :                         }
    2514          25 :                         HeatCapAtPeak -= FanHeatLoad; // remove fan heat from heating coil load
    2515          25 :                         HeatCapAtPeak = max(0.0, HeatCapAtPeak);
    2516          25 :                         RatedHeatMixDryBulb = simpleWatertoAirHP.RatedEntAirDrybulbTemp;
    2517             :                         // calculate temperatue ratio at design day peak conditions
    2518          25 :                         HeatratioTDB = (HeatMixTemp + state.dataWaterToAirHeatPumpSimple->CelsiustoKelvin) / Tref;
    2519          50 :                         PltSizNum = PlantUtilities::MyPlantSizingIndex(
    2520             :                             state,
    2521          50 :                             format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)]),
    2522             :                             simpleWatertoAirHP.Name,
    2523             :                             simpleWatertoAirHP.WaterInletNodeNum,
    2524             :                             simpleWatertoAirHP.WaterOutletNodeNum,
    2525             :                             ErrorsFound,
    2526             :                             false);
    2527          25 :                         if (PltSizNum > 0) {
    2528          25 :                             DesignEntWaterTemp = state.dataSize->PlantSizData(PltSizNum).ExitTemp;
    2529          25 :                             HeatratioTS = (DesignEntWaterTemp + state.dataWaterToAirHeatPumpSimple->CelsiustoKelvin) / Tref;
    2530             :                         } else {
    2531           0 :                             ShowSevereError(state, "Autosizing of heating capacity requires a loop Sizing:Plant object");
    2532           0 :                             ShowContinueError(state, "Autosizing also requires physical connection to a plant or condenser loop.");
    2533           0 :                             ShowContinueError(state,
    2534           0 :                                               format("Occurs in COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT Object={}",
    2535           0 :                                                      WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)],
    2536           0 :                                                      simpleWatertoAirHP.Name));
    2537           0 :                             HeatratioTS = 0.0; // Clang complains it is used uninitialized if you don't give it a value
    2538           0 :                             ErrorsFound = true;
    2539             :                         }
    2540             :                         // calculate temperatue ratio at refrence conditions
    2541          25 :                         RatedHeatratioTDB = (RatedHeatMixDryBulb + state.dataWaterToAirHeatPumpSimple->CelsiustoKelvin) / Tref;
    2542          25 :                         RatedHeatratioTS = (simpleWatertoAirHP.RatedEntWaterTemp + state.dataWaterToAirHeatPumpSimple->CelsiustoKelvin) / Tref;
    2543             :                         // determine curve modifiers at peak and rated conditions
    2544          25 :                         PeakHeatCapTempModFac = Curve::CurveValue(state, simpleWatertoAirHP.HeatCapCurveIndex, HeatratioTDB, HeatratioTS, 1.0, 1.0);
    2545          25 :                         RatedHeatCapTempModFac =
    2546          25 :                             Curve::CurveValue(state, simpleWatertoAirHP.HeatCapCurveIndex, RatedHeatratioTDB, RatedHeatratioTS, 1.0, 1.0);
    2547          25 :                         RatedHeatPowerTempModFac =
    2548          25 :                             Curve::CurveValue(state, simpleWatertoAirHP.HeatPowCurveIndex, RatedHeatratioTDB, RatedHeatratioTS, 1.0, 1.0);
    2549             :                         // Check curve output when rated mixed air wetbulb is the design mixed air wetbulb
    2550          25 :                         if (RatedHeatMixDryBulb == HeatMixTemp) {
    2551           0 :                             if (RatedHeatCapTempModFac > 1.02 || RatedHeatCapTempModFac < 0.98) {
    2552           0 :                                 ShowWarningError(state,
    2553           0 :                                                  format("{} Coil:Heating:WaterToAirHeatPump:EquationFit={}", RoutineName, simpleWatertoAirHP.Name));
    2554           0 :                                 ShowContinueError(state,
    2555             :                                                   "Heating capacity as a function of temperature curve output is not equal to 1.0 (+ or - 2%) "
    2556             :                                                   "at rated conditions.");
    2557           0 :                                 ShowContinueError(state, format("Curve output at rated conditions = {:.3T}", RatedHeatCapTempModFac));
    2558             :                             }
    2559           0 :                             if (RatedHeatPowerTempModFac > 1.02 || RatedHeatPowerTempModFac < 0.98) {
    2560           0 :                                 ShowWarningError(state,
    2561           0 :                                                  format("{} Coil:Heating:WaterToAirHeatPump:EquationFit={}", RoutineName, simpleWatertoAirHP.Name));
    2562           0 :                                 ShowContinueError(state,
    2563             :                                                   "Heating power consumption as a function of temperature curve output is not equal to "
    2564             :                                                   "1.0 (+ or - 2%) at rated conditions.");
    2565           0 :                                 ShowContinueError(state, format("Curve output at rated conditions = {:.3T}", RatedHeatPowerTempModFac));
    2566             :                             }
    2567             :                         }
    2568             :                         // calculate the rated capacity based on peak conditions
    2569             :                         // note: the rated capacity can be different than the capacity at
    2570             :                         // rated conditions if the capacity curve isn't normalized at the
    2571             :                         // rated conditions
    2572          25 :                         RatedCapHeatDes = (PeakHeatCapTempModFac > 0.0) ? HeatCapAtPeak / PeakHeatCapTempModFac : HeatCapAtPeak;
    2573             :                     } else {
    2574           0 :                         RatedHeatratioTS = 0.0; // Clang complains it is used uninitialized if you don't give it a value
    2575           0 :                         RatedCapHeatDes = 0.0;
    2576             :                     }
    2577             :                 } else {
    2578           0 :                     RatedHeatratioTS = 0.0; // Clang complains it is used uninitialized if you don't give it a value
    2579             :                 }
    2580             : 
    2581             :                 // determine adjusted cooling and heating coil capacity
    2582         122 :                 simpleWatertoAirHP.RatedCapHeatAtRatedCdts = RatedCapHeatDes * RatedHeatCapTempModFac;
    2583         122 :                 auto &companionCoolingCoil(state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(simpleWatertoAirHP.CompanionCoolingCoilNum));
    2584         122 :                 if (companionCoolingCoil.WAHPPlantType == DataPlant::PlantEquipmentType::CoilWAHPCoolingEquationFit &&
    2585         122 :                     companionCoolingCoil.RatedCapCoolTotal == DataSizing::AutoSize) {
    2586             :                     // case 1: companion coil is also of EquationFit type and is being autosized
    2587         122 :                     RatedCapCoolTotalDes = state.dataSize->DXCoolCap;
    2588         122 :                     RatedTotCapTempModFac = companionCoolingCoil.RatedCapCoolAtRatedCdts / RatedCapCoolTotalDes;
    2589         122 :                     RatedCapCoolHeatDD =
    2590         122 :                         simpleWatertoAirHP.RatedCapHeatAtRatedCdts / simpleWatertoAirHP.RatioRatedHeatRatedTotCoolCap / RatedTotCapTempModFac;
    2591         122 :                     RatedCoolPowerTempModFac = companionCoolingCoil.RatedPowerCoolAtRatedCdts / companionCoolingCoil.RatedPowerCool;
    2592         122 :                     if (RatedCapCoolHeatDD > RatedCapCoolTotalDes) {
    2593             :                         // total cooling capacity
    2594           9 :                         RatedCapCoolTotalDes = RatedCapCoolHeatDD;
    2595             :                         // adjust for system air flow -- capacity is based on heating design day calcs
    2596             :                         // adjust by ratio of system to heating air flow rate and temperature delta across the coil at these different airflow
    2597           9 :                         if (HeatingAirVolFlowRateDes > 0) {
    2598           9 :                             RatedCapCoolTotalDes *= (RatedAirVolFlowRateDes / HeatingAirVolFlowRateDes) * HeatdTratio;
    2599             :                         }
    2600             :                         // calculate ajustment factor over previous capacity for sensible capacity adjustment
    2601           9 :                         Real64 CapCoolAdjFac = RatedCapCoolTotalDes / state.dataSize->DXCoolCap;
    2602             :                         // update cooling coil rated capacity after adjustments based on heating coil size
    2603           9 :                         state.dataSize->DXCoolCap = RatedCapCoolTotalDes;
    2604             :                         // sensible cooling capacity
    2605           9 :                         RatedCapCoolSensDes = companionCoolingCoil.RatedCapCoolSens * CapCoolAdjFac; // Assume that SHR stays the same
    2606           9 :                         companionCoolingCoil.RatedCapCoolSensDesAtRatedCdts *= CapCoolAdjFac;
    2607           9 :                         companionCoolingCoil.RatedCapCoolSens = RatedCapCoolSensDes;
    2608             :                         // update Water-to-Air Heat Pumps output reports
    2609          18 :                         OutputReportPredefined::PreDefTableEntry(state,
    2610           9 :                                                                  state.dataOutRptPredefined->pdchWAHPRatedSensCapAtRatedCdts,
    2611             :                                                                  companionCoolingCoil.Name,
    2612             :                                                                  companionCoolingCoil.RatedCapCoolSensDesAtRatedCdts);
    2613           9 :                         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchWAHPDD, companionCoolingCoil.Name, "Heating");
    2614           9 :                         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchWAHPDD, simpleWatertoAirHP.Name, "Heating");
    2615             :                         // update Cooling Coils output reports
    2616          18 :                         OutputReportPredefined::PreDefTableEntry(state,
    2617           9 :                                                                  state.dataOutRptPredefined->pdchCoolCoilLatCap,
    2618             :                                                                  companionCoolingCoil.Name,
    2619             :                                                                  RatedCapCoolTotalDes - RatedCapCoolSensDes);
    2620          18 :                         OutputReportPredefined::PreDefTableEntry(state,
    2621           9 :                                                                  state.dataOutRptPredefined->pdchCoolCoilSHR,
    2622             :                                                                  companionCoolingCoil.Name,
    2623             :                                                                  RatedCapCoolSensDes / RatedCapCoolTotalDes);
    2624          18 :                         OutputReportPredefined::PreDefTableEntry(
    2625           9 :                             state, state.dataOutRptPredefined->pdchCoolCoilSensCap, companionCoolingCoil.Name, RatedCapCoolSensDes);
    2626             :                     } else {
    2627         113 :                         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchWAHPDD, companionCoolingCoil.Name, "Cooling");
    2628         113 :                         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchWAHPDD, simpleWatertoAirHP.Name, "Cooling");
    2629             :                     }
    2630         122 :                     RatedCapHeatDes =
    2631         122 :                         RatedCapCoolTotalDes * RatedTotCapTempModFac * simpleWatertoAirHP.RatioRatedHeatRatedTotCoolCap / RatedHeatCapTempModFac;
    2632         122 :                     companionCoolingCoil.RatedCapCoolTotal = RatedCapCoolTotalDes;
    2633         122 :                     companionCoolingCoil.RatedCapCoolAtRatedCdts = RatedCapCoolTotalDes * RatedTotCapTempModFac;
    2634         122 :                     companionCoolingCoil.RatedPowerCoolAtRatedCdts =
    2635         122 :                         companionCoolingCoil.RatedCapCoolAtRatedCdts / companionCoolingCoil.RatedCOPCoolAtRatedCdts;
    2636         122 :                     companionCoolingCoil.RatedPowerCool = companionCoolingCoil.RatedPowerCoolAtRatedCdts / RatedCoolPowerTempModFac;
    2637             :                     // update Water-to-Air Heat Pumps output reports
    2638         244 :                     OutputReportPredefined::PreDefTableEntry(state,
    2639         122 :                                                              state.dataOutRptPredefined->pdchWAHPRatedCapAtRatedCdts,
    2640             :                                                              companionCoolingCoil.Name,
    2641             :                                                              companionCoolingCoil.RatedCapCoolAtRatedCdts);
    2642             :                     // update Cooling Coils output reports
    2643         244 :                     OutputReportPredefined::PreDefTableEntry(
    2644         122 :                         state, state.dataOutRptPredefined->pdchCoolCoilTotCap, companionCoolingCoil.Name, RatedCapCoolTotalDes);
    2645         366 :                     BaseSizer::reportSizerOutput(
    2646             :                         state,
    2647         244 :                         format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast<int>(companionCoolingCoil.WAHPType)]),
    2648             :                         companionCoolingCoil.Name,
    2649             :                         "Design Size Rated Total Cooling Capacity [W]",
    2650             :                         companionCoolingCoil.RatedCapCoolTotal);
    2651         366 :                     BaseSizer::reportSizerOutput(
    2652             :                         state,
    2653         244 :                         format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast<int>(companionCoolingCoil.WAHPType)]),
    2654             :                         companionCoolingCoil.Name,
    2655             :                         "Design Size Rated Sensible Cooling Capacity [W]",
    2656             :                         companionCoolingCoil.RatedCapCoolSens);
    2657         122 :                 } else if (companionCoolingCoil.WAHPPlantType ==
    2658             :                            DataPlant::PlantEquipmentType::CoilWAHPCoolingEquationFit) { // case 2: companion coil is of EquationFit type but is
    2659             :                                                                                         // not autosized
    2660           0 :                     RatedCapHeatDes = companionCoolingCoil.RatedCapCoolTotal * simpleWatertoAirHP.RatioRatedHeatRatedTotCoolCap;
    2661             :                 } else { // case 3: companion type is different than EquationFit
    2662           0 :                     RatedCapHeatDes = state.dataSize->DXCoolCap;
    2663             :                 }
    2664             :                 // heating capacity final determination
    2665         122 :                 simpleWatertoAirHP.RatedCapHeat = RatedCapHeatDes;
    2666         122 :                 simpleWatertoAirHP.RatedCapHeatAtRatedCdts = RatedCapHeatDes * RatedHeatCapTempModFac;
    2667             : 
    2668             :                 // heating power calculations
    2669         122 :                 RatedHeatPowerTempModFac =
    2670         122 :                     Curve::CurveValue(state, simpleWatertoAirHP.HeatPowCurveIndex, RatedHeatratioTDB, RatedHeatratioTS, 1.0, 1.0);
    2671         122 :                 simpleWatertoAirHP.RatedPowerHeat =
    2672         122 :                     simpleWatertoAirHP.RatedCapHeatAtRatedCdts / (simpleWatertoAirHP.RatedCOPHeatAtRatedCdts * RatedHeatPowerTempModFac);
    2673             : 
    2674             :                 // update reports
    2675         244 :                 OutputReportPredefined::PreDefTableEntry(state,
    2676         122 :                                                          state.dataOutRptPredefined->pdchWAHPRatedCapAtRatedCdts,
    2677             :                                                          simpleWatertoAirHP.Name,
    2678             :                                                          simpleWatertoAirHP.RatedCapHeatAtRatedCdts);
    2679         244 :                 OutputReportPredefined::PreDefTableEntry(
    2680         122 :                     state, state.dataOutRptPredefined->pdchWAHPRatedAirDBT, simpleWatertoAirHP.Name, RatedHeatMixDryBulb);
    2681         244 :                 OutputReportPredefined::PreDefTableEntry(
    2682         122 :                     state, state.dataOutRptPredefined->pdchWAHPRatedWtrT, simpleWatertoAirHP.Name, simpleWatertoAirHP.RatedEntWaterTemp);
    2683         366 :                 BaseSizer::reportSizerOutput(
    2684             :                     state,
    2685         244 :                     format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)]),
    2686             :                     simpleWatertoAirHP.Name,
    2687             :                     "Design Size Rated Heating Capacity [W]",
    2688             :                     simpleWatertoAirHP.RatedCapHeat);
    2689         244 :                 OutputReportPredefined::PreDefTableEntry(
    2690         122 :                     state, state.dataOutRptPredefined->pdchHeatCoilNomCap, simpleWatertoAirHP.Name, simpleWatertoAirHP.RatedCapHeat);
    2691         122 :                 if (simpleWatertoAirHP.RatedCapHeat != 0.0) {
    2692         244 :                     OutputReportPredefined::PreDefTableEntry(state,
    2693         122 :                                                              state.dataOutRptPredefined->pdchHeatCoilNomEff,
    2694             :                                                              simpleWatertoAirHP.Name,
    2695         122 :                                                              simpleWatertoAirHP.RatedPowerHeat / simpleWatertoAirHP.RatedCapHeat);
    2696             :                 } else {
    2697           0 :                     OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchHeatCoilNomEff, simpleWatertoAirHP.Name, 0.0);
    2698             :                 }
    2699             :             } else {
    2700          15 :                 if (simpleWatertoAirHP.RatedCapHeat > 0.0 && RatedCapHeatDes > 0.0 && !HardSizeNoDesRun) {
    2701           0 :                     RatedCapHeatUser = simpleWatertoAirHP.RatedCapHeat;
    2702           0 :                     BaseSizer::reportSizerOutput(
    2703             :                         state,
    2704           0 :                         format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)]),
    2705             :                         simpleWatertoAirHP.Name,
    2706             :                         "Design Size Rated Heating Capacity [W]",
    2707             :                         RatedCapHeatDes,
    2708             :                         "User-Specified Rated Heating Capacity [W]",
    2709             :                         RatedCapHeatUser);
    2710           0 :                     if (state.dataGlobal->DisplayExtraWarnings) {
    2711           0 :                         if ((std::abs(RatedCapHeatDes - RatedCapHeatUser) / RatedCapHeatUser) > state.dataSize->AutoVsHardSizingThreshold) {
    2712           0 :                             ShowMessage(
    2713             :                                 state,
    2714           0 :                                 format("SizeHVACWaterToAir: Potential issue with equipment sizing for coil {}:WATERTOAIRHEATPUMP:EQUATIONFIT {}",
    2715           0 :                                        WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)],
    2716           0 :                                        simpleWatertoAirHP.Name));
    2717           0 :                             ShowContinueError(state, format("User-Specified Rated Heating Capacity of {:.2R} [W]", RatedCapHeatUser));
    2718           0 :                             ShowContinueError(state, format("differs from Design Size Rated Heating Capacity of {:.2R} [W]", RatedCapHeatDes));
    2719           0 :                             ShowContinueError(state, "This may, or may not, indicate mismatched component sizes.");
    2720           0 :                             ShowContinueError(state, "Verify that the value entered is intended and is consistent with other components.");
    2721             :                         }
    2722             :                     }
    2723             :                 } else {
    2724          15 :                     if (simpleWatertoAirHP.RatedCapHeat > 0.0) {
    2725          15 :                         RatedCapHeatUser = simpleWatertoAirHP.RatedCapHeat;
    2726          45 :                         BaseSizer::reportSizerOutput(
    2727             :                             state,
    2728          30 :                             format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)]),
    2729             :                             simpleWatertoAirHP.Name,
    2730             :                             "User-Specified Rated Heating Capacity [W]",
    2731             :                             RatedCapHeatUser);
    2732             :                     }
    2733             :                 }
    2734             : 
    2735             :                 // user provided inputs are assumed to be at rated conditions
    2736          15 :                 simpleWatertoAirHP.RatedPowerHeat = simpleWatertoAirHP.RatedCapHeat / simpleWatertoAirHP.RatedCOPHeatAtRatedCdts;
    2737          15 :                 simpleWatertoAirHP.RatedCapHeatAtRatedCdts = 0;
    2738          15 :                 simpleWatertoAirHP.RatedPowerHeatAtRatedCdts = 0;
    2739             :             }
    2740             :             // Check that heat pump heating capacity is within 20% of cooling capacity. Check only for heating coil and report both.
    2741         137 :             if (simpleWatertoAirHP.WAHPType == WatertoAirHP::Heating && simpleWatertoAirHP.CompanionCoolingCoilNum > 0) {
    2742         137 :                 auto &companionCoolingCoil(state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(simpleWatertoAirHP.CompanionCoolingCoilNum));
    2743         137 :                 if (companionCoolingCoil.RatedCapCoolTotal > 0.0) {
    2744             : 
    2745         137 :                     if (std::abs(companionCoolingCoil.RatedCapCoolTotal - simpleWatertoAirHP.RatedCapHeat) / companionCoolingCoil.RatedCapCoolTotal >
    2746             :                         0.2) {
    2747             : 
    2748           0 :                         ShowWarningError(state,
    2749           0 :                                          format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT {}",
    2750           0 :                                                 WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)],
    2751           0 :                                                 simpleWatertoAirHP.Name));
    2752           0 :                         ShowContinueError(state,
    2753           0 :                                           format("...used with COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT {}",
    2754           0 :                                                  companionCoolingCoil.WAHPType,
    2755           0 :                                                  companionCoolingCoil.Name));
    2756           0 :                         ShowContinueError(state, "...heating capacity is disproportionate (> 20% different) to total cooling capacity");
    2757           0 :                         ShowContinueError(state, format("...heating capacity = {:.3T} W", simpleWatertoAirHP.RatedCapHeat));
    2758           0 :                         ShowContinueError(state, format("...cooling capacity = {:.3T} W", companionCoolingCoil.RatedCapCoolTotal));
    2759             :                     }
    2760             :                 }
    2761             :             }
    2762             : 
    2763         137 :             state.dataRptCoilSelection->coilSelectionReportObj->setCoilHeatingCapacity(
    2764             :                 state,
    2765         137 :                 simpleWatertoAirHP.Name,
    2766         274 :                 format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)]),
    2767             :                 RatedCapHeatDes,
    2768             :                 IsAutoSize,
    2769         137 :                 state.dataSize->CurSysNum,
    2770         137 :                 state.dataSize->CurZoneEqNum,
    2771         137 :                 state.dataSize->CurOASysNum,
    2772             :                 FanCoolLoad,
    2773             :                 1.0, // RatedHeatCapTempModFac,
    2774             :                 -999.0,
    2775             :                 -999.0);
    2776             : 
    2777             :         } // Heating
    2778             : 
    2779             :         // size/report rated efficiency and power
    2780         274 :         if (simpleWatertoAirHP.WAHPType == WatertoAirHP::Cooling) {
    2781         137 :             if (simpleWatertoAirHP.RatedPowerCool > 0) {
    2782         274 :                 OutputReportPredefined::PreDefTableEntry(state,
    2783         137 :                                                          state.dataOutRptPredefined->pdchCoolCoilNomEff,
    2784             :                                                          simpleWatertoAirHP.Name,
    2785         137 :                                                          simpleWatertoAirHP.RatedCapCoolTotal / simpleWatertoAirHP.RatedPowerCool);
    2786             :             }
    2787         137 :             if (IsAutoSize) {
    2788         244 :                 OutputReportPredefined::PreDefTableEntry(state,
    2789         122 :                                                          state.dataOutRptPredefined->pdchWAHPRatedPowerAtRatedCdts,
    2790             :                                                          simpleWatertoAirHP.Name,
    2791             :                                                          simpleWatertoAirHP.RatedPowerCoolAtRatedCdts);
    2792         122 :                 if (simpleWatertoAirHP.RatedPowerCoolAtRatedCdts > 0) {
    2793         244 :                     OutputReportPredefined::PreDefTableEntry(state,
    2794         122 :                                                              state.dataOutRptPredefined->pdchWAHPRatedCOPAtRatedCdts,
    2795             :                                                              simpleWatertoAirHP.Name,
    2796         122 :                                                              simpleWatertoAirHP.RatedCapCoolAtRatedCdts /
    2797         122 :                                                                  simpleWatertoAirHP.RatedPowerCoolAtRatedCdts);
    2798             :                 }
    2799             :             }
    2800         137 :         } else if (simpleWatertoAirHP.WAHPType == WatertoAirHP::Heating) {
    2801             :             // heating coil power
    2802         137 :             simpleWatertoAirHP.RatedPowerHeatAtRatedCdts = simpleWatertoAirHP.RatedCapHeatAtRatedCdts / simpleWatertoAirHP.RatedCOPHeatAtRatedCdts;
    2803         137 :             if (simpleWatertoAirHP.RatedPowerHeat > 0) {
    2804         274 :                 OutputReportPredefined::PreDefTableEntry(state,
    2805         137 :                                                          state.dataOutRptPredefined->pdchHeatCoilNomEff,
    2806             :                                                          simpleWatertoAirHP.Name,
    2807         137 :                                                          simpleWatertoAirHP.RatedCapHeat / simpleWatertoAirHP.RatedPowerHeat);
    2808             :             }
    2809         137 :             if (IsAutoSize) {
    2810         244 :                 OutputReportPredefined::PreDefTableEntry(state,
    2811         122 :                                                          state.dataOutRptPredefined->pdchWAHPRatedPowerAtRatedCdts,
    2812             :                                                          simpleWatertoAirHP.Name,
    2813             :                                                          simpleWatertoAirHP.RatedPowerHeatAtRatedCdts);
    2814         122 :                 if (simpleWatertoAirHP.RatedPowerHeatAtRatedCdts > 0) {
    2815         244 :                     OutputReportPredefined::PreDefTableEntry(state,
    2816         122 :                                                              state.dataOutRptPredefined->pdchWAHPRatedCOPAtRatedCdts,
    2817             :                                                              simpleWatertoAirHP.Name,
    2818         122 :                                                              simpleWatertoAirHP.RatedCapHeatAtRatedCdts /
    2819         122 :                                                                  simpleWatertoAirHP.RatedPowerHeatAtRatedCdts);
    2820             :                 }
    2821             :             }
    2822             :             // re-calculate companion coil power
    2823         137 :             if (simpleWatertoAirHP.CompanionCoolingCoilNum > 0) {
    2824         137 :                 auto &companionCoolingCoil(state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(simpleWatertoAirHP.CompanionCoolingCoilNum));
    2825         137 :                 companionCoolingCoil.RatedPowerCoolAtRatedCdts =
    2826         137 :                     companionCoolingCoil.RatedCapCoolAtRatedCdts / companionCoolingCoil.RatedCOPCoolAtRatedCdts;
    2827         137 :                 if (companionCoolingCoil.RatedCapCoolTotal > 0) {
    2828         274 :                     OutputReportPredefined::PreDefTableEntry(state,
    2829         137 :                                                              state.dataOutRptPredefined->pdchCoolCoilNomEff,
    2830             :                                                              companionCoolingCoil.Name,
    2831         137 :                                                              companionCoolingCoil.RatedCapCoolTotal / companionCoolingCoil.RatedPowerCool);
    2832         137 :                     if (IsAutoSize) {
    2833         244 :                         OutputReportPredefined::PreDefTableEntry(state,
    2834         122 :                                                                  state.dataOutRptPredefined->pdchWAHPRatedPowerAtRatedCdts,
    2835             :                                                                  companionCoolingCoil.Name,
    2836             :                                                                  companionCoolingCoil.RatedPowerCoolAtRatedCdts);
    2837         122 :                         if (companionCoolingCoil.RatedPowerCoolAtRatedCdts > 0) {
    2838         244 :                             OutputReportPredefined::PreDefTableEntry(state,
    2839         122 :                                                                      state.dataOutRptPredefined->pdchWAHPRatedCOPAtRatedCdts,
    2840             :                                                                      companionCoolingCoil.Name,
    2841         122 :                                                                      companionCoolingCoil.RatedCapCoolAtRatedCdts /
    2842         122 :                                                                          companionCoolingCoil.RatedPowerCoolAtRatedCdts);
    2843             :                         }
    2844             :                     }
    2845             :                 }
    2846             :             }
    2847             :         }
    2848             : 
    2849             :         // Size water volumetric flow rate
    2850         274 :         IsAutoSize = false;
    2851         274 :         if (simpleWatertoAirHP.RatedWaterVolFlowRate == DataSizing::AutoSize) {
    2852         244 :             IsAutoSize = true;
    2853             :         }
    2854             : 
    2855             :         //   WSHP condenser can be on either a plant loop or condenser loop. Test each to find plant sizing number.
    2856             :         //   first check to see if coil is connected to a plant loop, no warning on this CALL
    2857         274 :         if (IsAutoSize) {
    2858         488 :             PltSizNum = PlantUtilities::MyPlantSizingIndex(
    2859             :                 state,
    2860         488 :                 format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)]),
    2861             :                 simpleWatertoAirHP.Name,
    2862             :                 simpleWatertoAirHP.WaterInletNodeNum,
    2863             :                 simpleWatertoAirHP.WaterOutletNodeNum,
    2864             :                 ErrorsFound,
    2865             :                 false);
    2866             : 
    2867         244 :             if (PltSizNum > 0) {
    2868         244 :                 rho = FluidProperties::GetDensityGlycol(state,
    2869         244 :                                                         state.dataPlnt->PlantLoop(simpleWatertoAirHP.plantLoc.loopNum).FluidName,
    2870         244 :                                                         state.dataSize->PlantSizData(PltSizNum).ExitTemp,
    2871         244 :                                                         state.dataPlnt->PlantLoop(simpleWatertoAirHP.plantLoc.loopNum).FluidIndex,
    2872             :                                                         RoutineNameAlt);
    2873         244 :                 Cp = FluidProperties::GetSpecificHeatGlycol(state,
    2874         244 :                                                             state.dataPlnt->PlantLoop(simpleWatertoAirHP.plantLoc.loopNum).FluidName,
    2875         244 :                                                             state.dataSize->PlantSizData(PltSizNum).ExitTemp,
    2876         244 :                                                             state.dataPlnt->PlantLoop(simpleWatertoAirHP.plantLoc.loopNum).FluidIndex,
    2877             :                                                             RoutineNameAlt);
    2878             : 
    2879         244 :                 if (simpleWatertoAirHP.WAHPType == WatertoAirHP::Heating) {
    2880         122 :                     RatedWaterVolFlowRateDes =
    2881         122 :                         simpleWatertoAirHP.RatedCapHeatAtRatedCdts / (state.dataSize->PlantSizData(PltSizNum).DeltaT * Cp * rho);
    2882         122 :                 } else if (simpleWatertoAirHP.WAHPType == WatertoAirHP::Cooling) {
    2883             :                     //       use companion heating coil capacity to calculate volumetric flow rate
    2884         122 :                     if (simpleWatertoAirHP.CompanionHeatingCoilNum > 0) {
    2885             :                         auto &companionHeatingCoil(
    2886         122 :                             state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(simpleWatertoAirHP.CompanionHeatingCoilNum));
    2887         122 :                         if (companionHeatingCoil.RatedCapHeat == DataSizing::AutoSize) {
    2888         122 :                             SystemCapacity = simpleWatertoAirHP.RatedCapCoolTotal;
    2889             :                         } else {
    2890           0 :                             SystemCapacity = companionHeatingCoil.RatedCapHeat;
    2891             :                         }
    2892             :                     } else {
    2893           0 :                         SystemCapacity = simpleWatertoAirHP.RatedCapCoolAtRatedCdts;
    2894             :                     }
    2895             : 
    2896         122 :                     RatedWaterVolFlowRateDes = SystemCapacity / (state.dataSize->PlantSizData(PltSizNum).DeltaT * Cp * rho);
    2897             :                 }
    2898             :             } else {
    2899           0 :                 ShowSevereError(state, "Autosizing of water flow requires a loop Sizing:Plant object");
    2900           0 :                 ShowContinueError(state, "Autosizing also requires physical connection to a plant or condenser loop.");
    2901           0 :                 ShowContinueError(state,
    2902           0 :                                   format("Occurs in COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT Object={}",
    2903           0 :                                          WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)],
    2904           0 :                                          simpleWatertoAirHP.Name));
    2905           0 :                 ErrorsFound = true;
    2906             :             }
    2907             : 
    2908         244 :             if (SystemCapacity != DataSizing::AutoSize) {
    2909         122 :                 simpleWatertoAirHP.RatedWaterVolFlowRate = RatedWaterVolFlowRateDes;
    2910         366 :                 BaseSizer::reportSizerOutput(
    2911             :                     state,
    2912         244 :                     format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)]),
    2913             :                     simpleWatertoAirHP.Name,
    2914             :                     "Design Size Rated Water Flow Rate [m3/s]",
    2915             :                     RatedWaterVolFlowRateDes);
    2916         122 :                 if (simpleWatertoAirHP.WAHPType == WatertoAirHP::Heating && simpleWatertoAirHP.CompanionCoolingCoilNum > 0) {
    2917         122 :                     auto &companionCoolingCoil(state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(simpleWatertoAirHP.CompanionCoolingCoilNum));
    2918         122 :                     companionCoolingCoil.RatedWaterVolFlowRate = RatedWaterVolFlowRateDes;
    2919         366 :                     BaseSizer::reportSizerOutput(
    2920             :                         state,
    2921         244 :                         format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast<int>(companionCoolingCoil.WAHPType)]),
    2922             :                         companionCoolingCoil.Name,
    2923             :                         "Design Size Rated Water Flow Rate [m3/s]",
    2924             :                         RatedWaterVolFlowRateDes);
    2925         122 :                 } else if (simpleWatertoAirHP.WAHPType == WatertoAirHP::Cooling && simpleWatertoAirHP.CompanionHeatingCoilNum > 0) {
    2926           0 :                     auto &companionHeatingCoil(state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(simpleWatertoAirHP.CompanionHeatingCoilNum));
    2927           0 :                     companionHeatingCoil.RatedWaterVolFlowRate = RatedWaterVolFlowRateDes;
    2928           0 :                     BaseSizer::reportSizerOutput(
    2929             :                         state,
    2930           0 :                         format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast<int>(companionHeatingCoil.WAHPType)]),
    2931             :                         companionHeatingCoil.Name,
    2932             :                         "Design Size Rated Water Flow Rate [m3/s]",
    2933             :                         RatedWaterVolFlowRateDes);
    2934             :                 }
    2935             :             }
    2936             :         } else {
    2937          30 :             if (simpleWatertoAirHP.RatedWaterVolFlowRate > 0.0 && RatedWaterVolFlowRateDes > 0.0) {
    2938           0 :                 RatedWaterVolFlowRateUser = simpleWatertoAirHP.RatedWaterVolFlowRate;
    2939           0 :                 BaseSizer::reportSizerOutput(
    2940             :                     state,
    2941           0 :                     format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)]),
    2942             :                     simpleWatertoAirHP.Name,
    2943             :                     "Design Size Rated Water Flow Rate [m3/s]",
    2944             :                     RatedWaterVolFlowRateDes,
    2945             :                     "User-Specified Rated Water Flow Rate [m3/s]",
    2946             :                     RatedWaterVolFlowRateUser);
    2947           0 :                 if (state.dataGlobal->DisplayExtraWarnings) {
    2948           0 :                     if ((std::abs(RatedWaterVolFlowRateDes - RatedWaterVolFlowRateUser) / RatedWaterVolFlowRateUser) >
    2949           0 :                         state.dataSize->AutoVsHardSizingThreshold) {
    2950           0 :                         ShowMessage(state,
    2951           0 :                                     format("SizeHVACWaterToAir: Potential issue with equipment sizing for coil {}:WATERTOAIRHEATPUMP:EQUATIONFIT {}",
    2952           0 :                                            simpleWatertoAirHP.WAHPType,
    2953           0 :                                            simpleWatertoAirHP.Name));
    2954           0 :                         ShowContinueError(state, format("User-Specified Rated Water Flow Rate of {:.5R} [m3/s]", RatedWaterVolFlowRateUser));
    2955           0 :                         ShowContinueError(state, format("differs from Design Size Rated Water Flow Rate of {:.5R} [m3/s]", RatedWaterVolFlowRateDes));
    2956           0 :                         ShowContinueError(state, "This may, or may not, indicate mismatched component sizes.");
    2957           0 :                         ShowContinueError(state, "Verify that the value entered is intended and is consistent with other components.");
    2958             :                     }
    2959             :                 }
    2960             :             }
    2961             :         }
    2962             : 
    2963             :         // Save component design water volumetric flow rate.
    2964             :         // Use 1/2 flow since both cooling and heating coil will save flow yet only 1 will operate at a time
    2965         274 :         if (simpleWatertoAirHP.RatedWaterVolFlowRate > 0.0) {
    2966         152 :             if (simpleWatertoAirHP.WAHPType == WatertoAirHP::Heating) {
    2967         137 :                 PlantUtilities::RegisterPlantCompDesignFlow(
    2968         137 :                     state, simpleWatertoAirHP.WaterInletNodeNum, 0.5 * simpleWatertoAirHP.RatedWaterVolFlowRate);
    2969         137 :                 if (simpleWatertoAirHP.CompanionCoolingCoilNum > 0) {
    2970         137 :                     auto &companionCoolingCoil(state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(simpleWatertoAirHP.CompanionCoolingCoilNum));
    2971         137 :                     PlantUtilities::RegisterPlantCompDesignFlow(
    2972         137 :                         state, companionCoolingCoil.WaterInletNodeNum, 0.5 * simpleWatertoAirHP.RatedWaterVolFlowRate);
    2973             :                 }
    2974          15 :             } else if (simpleWatertoAirHP.WAHPType == WatertoAirHP::Cooling) {
    2975          15 :                 PlantUtilities::RegisterPlantCompDesignFlow(
    2976          15 :                     state, simpleWatertoAirHP.WaterInletNodeNum, 0.5 * simpleWatertoAirHP.RatedWaterVolFlowRate);
    2977             :             }
    2978             :         }
    2979         274 :     }
    2980             : 
    2981    21926434 :     void CalcHPCoolingSimple(EnergyPlusData &state,
    2982             :                              int const HPNum,                                // Heat Pump Number
    2983             :                              HVAC::FanOp const fanOp,                        // Fan/Compressor cycling scheme indicator
    2984             :                              [[maybe_unused]] Real64 const SensDemand,       // Cooling Sensible Demand [W] !unused1208
    2985             :                              [[maybe_unused]] Real64 const LatentDemand,     // Cooling Latent Demand [W]
    2986             :                              HVAC::CompressorOp const compressorOp,          // compressor operation flag
    2987             :                              Real64 const PartLoadRatio,                     // compressor part load ratio
    2988             :                              [[maybe_unused]] Real64 const OnOffAirFlowRatio // ratio of compressor on flow to average flow over time step
    2989             :     )
    2990             :     {
    2991             : 
    2992             :         //       AUTHOR         Arun Shenoy
    2993             :         //       DATE WRITTEN   Jan 2004
    2994             :         //       RE-ENGINEERED  Kenneth Tang (Jan 2005)
    2995             : 
    2996             :         // PURPOSE OF THIS SUBROUTINE:
    2997             :         // This subroutine is for simulating the cooling mode of the Water to Air HP Simple
    2998             : 
    2999             :         // METHODOLOGY EMPLOYED:
    3000             :         // Simulate the heat pump performance using the coefficients in quadlinear and quintlinear curves and rated conditions
    3001             :         // If the LatDegradModelSimFlag is enabled, the coil will be simulated twice:
    3002             :         // (1)first simulation at the rated conditions (2) second simulation at the
    3003             :         // actual operating conditions. Then call CalcEffectiveSHR and the effective SHR
    3004             :         // is adjusted.
    3005             :         // If the LatDegradModelSimFlag is disabled, the cooling coil is only simulated
    3006             :         // once at the actual operating conditions.
    3007             :         // Finally, adjust the heat pump outlet conditions based on the PartLoadRatio
    3008             :         // and RuntimeFrac.
    3009             : 
    3010             :         // REFERENCES:
    3011             :         // (1) Lash.T.A.,1992.Simulation and Analysis of a Water Loop Heat Pump System.
    3012             :         // M.S. Thesis, University of Illinois at Urbana Champaign.
    3013             :         // (2) Shenoy, Arun. 2004. Simulation, Modeling and Analysis of Water to Air Heat Pump.
    3014             :         // State Energy Simulation Program. M.S. Thesis, Department of Mechanical and Aerospace Engineering,
    3015             :         // Oklahoma State University. (downloadable from www.hvac.okstate.edu)
    3016             :         // (3) Tang,C.C.. 2005. Modeling Packaged Heat Pumps in a Quasi-Steady
    3017             :         // State Energy Simulation Program. M.S. Thesis, Department of Mechanical and Aerospace Engineering,
    3018             :         // Oklahoma State University. (downloadable from www.hvac.okstate.edu)
    3019             :         // (4) Henderson, H.I., K. Rengarajan.1996. A Model to Predict the Latent
    3020             :         // Capacity of Air Conditioners and Heat Pumps at Part-Load Conditions
    3021             :         // with Constant Fan Operation ASHRAE Transactions 102 (1), pp. 266-274.
    3022             : 
    3023    21926434 :         Real64 TimeStepSysSec = state.dataHVACGlobal->TimeStepSysSec;
    3024             : 
    3025             :         // SUBROUTINE PARAMETER DEFINITIONS:
    3026    21926434 :         constexpr Real64 Tref(283.15); // Reference Temperature for performance curves,10C [K]
    3027             :         static constexpr std::string_view RoutineName("CalcHPCoolingSimple");
    3028             :         static constexpr std::string_view RoutineNameSourceSideInletTemp("CalcHPCoolingSimple:SourceSideInletTemp");
    3029             : 
    3030             :         Real64 TotalCapRated;              // Rated Total Cooling Capacity [W]
    3031             :         Real64 SensCapRated;               // Rated Sensible Cooling Capacity [W]
    3032             :         Real64 CoolPowerRated;             // Rated Cooling Power Input[W]
    3033             :         Real64 AirVolFlowRateRated;        // Rated Air Volumetric Flow Rate [m3/s]
    3034             :         Real64 WaterVolFlowRateRated;      // Rated Water Volumetric Flow Rate [m3/s]
    3035             :         Real64 Twet_Rated;                 // Twet at rated conditions (coil air flow rate and air temperatures), sec
    3036             :         Real64 Gamma_Rated;                // Gamma at rated conditions (coil air flow rate and air temperatures)
    3037             :         Real64 SHRss;                      // Sensible heat ratio at steady state
    3038             :         Real64 SHReff;                     // Effective sensible heat ratio at part-load condition
    3039             :         Real64 ratioTDB;                   // Ratio of the inlet air dry bulb temperature to the rated conditions
    3040             :         Real64 ratioTWB;                   // Ratio of the inlet air wet bulb temperature to the rated conditions
    3041             :         Real64 ratioTS;                    // Ratio of the source side(water) inlet temperature to the rated conditions
    3042             :         Real64 ratioVL;                    // Ratio of the air flow rate to the rated conditions
    3043             :         Real64 ratioVS;                    // Ratio of the water flow rate to the rated conditions
    3044             :         Real64 CpWater;                    // Specific heat of water [J/kg_C]
    3045             :         Real64 CpAir;                      // Specific heat of air [J/kg_C]
    3046             :         Real64 LoadSideFullMassFlowRate;   // Load Side Full Load Mass Flow Rate [kg/s]
    3047             :         Real64 LoadSideFullOutletEnthalpy; // Load Side Full Load Outlet Air Enthalpy [J/kg]
    3048             : 
    3049             :         bool LatDegradModelSimFlag;      // Latent degradation model simulation flag
    3050             :         int NumIteration;                // Iteration Counter
    3051             :         Real64 LoadSideInletDBTemp_Unit; // calc conditions for unit
    3052             :         Real64 LoadSideInletWBTemp_Unit; // calc conditions for unit
    3053             :         Real64 LoadSideInletHumRat_Unit; // calc conditions for unit
    3054             :         Real64 LoadSideInletEnth_Unit;   // calc conditions for unit
    3055             :         Real64 CpAir_Unit;               // calc conditions for unit
    3056             : 
    3057    21926434 :         if (state.dataWaterToAirHeatPumpSimple->firstTime) {
    3058             :             // Set indoor air conditions to the rated condition
    3059          18 :             state.dataWaterToAirHeatPumpSimple->LoadSideInletDBTemp_Init = 26.7;
    3060          18 :             state.dataWaterToAirHeatPumpSimple->LoadSideInletHumRat_Init = 0.0111;
    3061          18 :             state.dataWaterToAirHeatPumpSimple->LoadSideInletEnth_Init = Psychrometrics::PsyHFnTdbW(
    3062          18 :                 state.dataWaterToAirHeatPumpSimple->LoadSideInletDBTemp_Init, state.dataWaterToAirHeatPumpSimple->LoadSideInletHumRat_Init);
    3063          18 :             state.dataWaterToAirHeatPumpSimple->CpAir_Init =
    3064          18 :                 Psychrometrics::PsyCpAirFnW(state.dataWaterToAirHeatPumpSimple->LoadSideInletHumRat_Init);
    3065          18 :             state.dataWaterToAirHeatPumpSimple->firstTime = false;
    3066             :         }
    3067    43852868 :         state.dataWaterToAirHeatPumpSimple->LoadSideInletWBTemp_Init =
    3068    21926434 :             Psychrometrics::PsyTwbFnTdbWPb(state,
    3069    21926434 :                                            state.dataWaterToAirHeatPumpSimple->LoadSideInletDBTemp_Init,
    3070    21926434 :                                            state.dataWaterToAirHeatPumpSimple->LoadSideInletHumRat_Init,
    3071    21926434 :                                            state.dataEnvrn->OutBaroPress,
    3072             :                                            RoutineName);
    3073             : 
    3074             :         //  LOAD LOCAL VARIABLES FROM DATA STRUCTURE (for code readability)
    3075             : 
    3076    21926434 :         auto &simpleWatertoAirHP(state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(HPNum));
    3077             : 
    3078    21926434 :         TotalCapRated = simpleWatertoAirHP.RatedCapCoolTotal;
    3079    21926434 :         SensCapRated = simpleWatertoAirHP.RatedCapCoolSens;
    3080    21926434 :         CoolPowerRated = simpleWatertoAirHP.RatedPowerCool;
    3081    21926434 :         AirVolFlowRateRated = simpleWatertoAirHP.RatedAirVolFlowRate;
    3082    21926434 :         WaterVolFlowRateRated = simpleWatertoAirHP.RatedWaterVolFlowRate;
    3083             : 
    3084    21926434 :         Twet_Rated = simpleWatertoAirHP.Twet_Rated;
    3085    21926434 :         Gamma_Rated = simpleWatertoAirHP.Gamma_Rated;
    3086             : 
    3087    21926434 :         if (fanOp == HVAC::FanOp::Continuous) {
    3088     4645802 :             LoadSideFullMassFlowRate = simpleWatertoAirHP.AirMassFlowRate;
    3089             :         } else {
    3090             :             // default to cycling fan, cycling compressor, full load air flow
    3091    17280632 :             if (PartLoadRatio > 0.0) {
    3092     5106321 :                 LoadSideFullMassFlowRate = simpleWatertoAirHP.AirMassFlowRate / PartLoadRatio;
    3093             :             } else {
    3094    12174311 :                 LoadSideFullMassFlowRate = 0.0;
    3095             :             }
    3096             :         }
    3097    21926434 :         state.dataWaterToAirHeatPumpSimple->SourceSideMassFlowRate = simpleWatertoAirHP.WaterMassFlowRate;
    3098    21926434 :         state.dataWaterToAirHeatPumpSimple->SourceSideInletTemp = simpleWatertoAirHP.InletWaterTemp;
    3099    21926434 :         state.dataWaterToAirHeatPumpSimple->SourceSideInletEnth = simpleWatertoAirHP.InletWaterEnthalpy;
    3100    21926434 :         CpWater = FluidProperties::GetSpecificHeatGlycol(state,
    3101    21926434 :                                                          state.dataPlnt->PlantLoop(simpleWatertoAirHP.plantLoc.loopNum).FluidName,
    3102    21926434 :                                                          state.dataWaterToAirHeatPumpSimple->SourceSideInletTemp,
    3103    21926434 :                                                          state.dataPlnt->PlantLoop(simpleWatertoAirHP.plantLoc.loopNum).FluidIndex,
    3104             :                                                          RoutineNameSourceSideInletTemp);
    3105             : 
    3106             :         // Check for flows, do not perform simulation if no flow in load side or source side.
    3107    21926434 :         if (state.dataWaterToAirHeatPumpSimple->SourceSideMassFlowRate <= 0.0 || LoadSideFullMassFlowRate <= 0.0) {
    3108    12774651 :             simpleWatertoAirHP.SimFlag = false;
    3109    12774651 :             return;
    3110             :         } else {
    3111     9151783 :             simpleWatertoAirHP.SimFlag = true;
    3112             :         }
    3113             : 
    3114     9151783 :         if (compressorOp == HVAC::CompressorOp::Off) {
    3115        8268 :             simpleWatertoAirHP.SimFlag = false;
    3116        8268 :             return;
    3117             :         }
    3118             : 
    3119             :         // Calculate Part Load Factor and Runtime Fraction
    3120     9143515 :         Real64 PLF = 1.0; // part load factor as a function of PLR, RTF = PLR / PLF
    3121     9143515 :         if (simpleWatertoAirHP.PLFCurveIndex > 0) {
    3122     9143515 :             PLF = Curve::CurveValue(state, simpleWatertoAirHP.PLFCurveIndex, PartLoadRatio); // Calculate part-load factor
    3123             :         }
    3124     9143515 :         if (fanOp == HVAC::FanOp::Cycling) {
    3125     5106143 :             state.dataHVACGlobal->OnOffFanPartLoadFraction = PLF;
    3126             :         }
    3127     9143515 :         simpleWatertoAirHP.RunFrac = PartLoadRatio / PLF;
    3128             : 
    3129             :         // Loop the calculation at least once depending whether the latent degradation model
    3130             :         // is enabled. 1st iteration to calculate the QLatent(rated) at (TDB,TWB)indoorair=(26.7C,19.4C)
    3131             :         // and 2nd iteration to calculate the  QLatent(actual)
    3132     9143515 :         if ((simpleWatertoAirHP.RunFrac >= 1.0) || (Twet_Rated <= 0.0) || (Gamma_Rated <= 0.0)) {
    3133     9143515 :             LatDegradModelSimFlag = false;
    3134             :             // Set NumIteration=1 so that latent model would quit after 1 simulation with the actual condition
    3135     9143515 :             NumIteration = 1;
    3136             :         } else {
    3137           0 :             LatDegradModelSimFlag = true;
    3138             :             // Set NumIteration=0 so that latent model would simulate twice with rated and actual condition
    3139           0 :             NumIteration = 0;
    3140             :         }
    3141             : 
    3142             :         // Set indoor air conditions to the actual condition
    3143     9143515 :         LoadSideInletDBTemp_Unit = simpleWatertoAirHP.InletAirDBTemp;
    3144     9143515 :         LoadSideInletHumRat_Unit = simpleWatertoAirHP.InletAirHumRat;
    3145             :         LoadSideInletWBTemp_Unit =
    3146     9143515 :             Psychrometrics::PsyTwbFnTdbWPb(state, LoadSideInletDBTemp_Unit, LoadSideInletHumRat_Unit, state.dataEnvrn->OutBaroPress, RoutineName);
    3147     9143515 :         LoadSideInletEnth_Unit = simpleWatertoAirHP.InletAirEnthalpy;
    3148     9143515 :         CpAir_Unit = Psychrometrics::PsyCpAirFnW(LoadSideInletHumRat_Unit);
    3149             : 
    3150             :         while (true) {
    3151     9143515 :             ++NumIteration;
    3152     9143515 :             if (NumIteration == 1) {
    3153             :                 // Set indoor air conditions to the rated conditions
    3154           0 :                 state.dataWaterToAirHeatPumpSimple->LoadSideInletDBTemp = state.dataWaterToAirHeatPumpSimple->LoadSideInletDBTemp_Init;
    3155           0 :                 state.dataWaterToAirHeatPumpSimple->LoadSideInletHumRat = state.dataWaterToAirHeatPumpSimple->LoadSideInletHumRat_Init;
    3156           0 :                 state.dataWaterToAirHeatPumpSimple->LoadSideInletWBTemp = state.dataWaterToAirHeatPumpSimple->LoadSideInletWBTemp_Init;
    3157           0 :                 state.dataWaterToAirHeatPumpSimple->LoadSideInletEnth = state.dataWaterToAirHeatPumpSimple->LoadSideInletEnth_Init;
    3158           0 :                 CpAir = state.dataWaterToAirHeatPumpSimple->CpAir_Init;
    3159             :             } else {
    3160             :                 // Set indoor air conditions to the actual condition
    3161     9143515 :                 state.dataWaterToAirHeatPumpSimple->LoadSideInletDBTemp = LoadSideInletDBTemp_Unit;
    3162     9143515 :                 state.dataWaterToAirHeatPumpSimple->LoadSideInletHumRat = LoadSideInletHumRat_Unit;
    3163     9143515 :                 state.dataWaterToAirHeatPumpSimple->LoadSideInletWBTemp = LoadSideInletWBTemp_Unit;
    3164     9143515 :                 state.dataWaterToAirHeatPumpSimple->LoadSideInletEnth = LoadSideInletEnth_Unit;
    3165     9143515 :                 CpAir = CpAir_Unit;
    3166             :             }
    3167             : 
    3168     9143515 :             ratioTDB = ((state.dataWaterToAirHeatPumpSimple->LoadSideInletDBTemp + state.dataWaterToAirHeatPumpSimple->CelsiustoKelvin) / Tref);
    3169     9143515 :             ratioTWB = ((state.dataWaterToAirHeatPumpSimple->LoadSideInletWBTemp + state.dataWaterToAirHeatPumpSimple->CelsiustoKelvin) / Tref);
    3170     9143515 :             ratioTS = ((state.dataWaterToAirHeatPumpSimple->SourceSideInletTemp + state.dataWaterToAirHeatPumpSimple->CelsiustoKelvin) / Tref);
    3171     9143515 :             ratioVL = (LoadSideFullMassFlowRate /
    3172     9143515 :                        (AirVolFlowRateRated * Psychrometrics::PsyRhoAirFnPbTdbW(state,
    3173     9143515 :                                                                                 state.dataEnvrn->StdBaroPress,
    3174     9143515 :                                                                                 state.dataWaterToAirHeatPumpSimple->LoadSideInletDBTemp,
    3175     9143515 :                                                                                 state.dataWaterToAirHeatPumpSimple->LoadSideInletHumRat,
    3176             :                                                                                 RoutineName)));
    3177             : 
    3178     9143515 :             if (simpleWatertoAirHP.DesignWaterMassFlowRate > 0.0) {
    3179     9143515 :                 ratioVS = (state.dataWaterToAirHeatPumpSimple->SourceSideMassFlowRate) / (simpleWatertoAirHP.DesignWaterMassFlowRate);
    3180             :             } else {
    3181           0 :                 ratioVS = 0.0;
    3182             :             }
    3183             : 
    3184     9143515 :             simpleWatertoAirHP.QLoadTotal =
    3185     9143515 :                 TotalCapRated * Curve::CurveValue(state, simpleWatertoAirHP.TotalCoolCapCurveIndex, ratioTWB, ratioTS, ratioVL, ratioVS);
    3186     9143515 :             simpleWatertoAirHP.QSensible =
    3187     9143515 :                 SensCapRated * Curve::CurveValue(state, simpleWatertoAirHP.SensCoolCapCurveIndex, ratioTDB, ratioTWB, ratioTS, ratioVL, ratioVS);
    3188    18287030 :             state.dataWaterToAirHeatPumpSimple->Winput =
    3189     9143515 :                 CoolPowerRated * Curve::CurveValue(state, simpleWatertoAirHP.CoolPowCurveIndex, ratioTWB, ratioTS, ratioVL, ratioVS);
    3190             : 
    3191             :             // Check if the Sensible Load is greater than the Total Cooling Load
    3192     9143515 :             if (simpleWatertoAirHP.QSensible > simpleWatertoAirHP.QLoadTotal) {
    3193     3279676 :                 simpleWatertoAirHP.QSensible = simpleWatertoAirHP.QLoadTotal;
    3194             :             }
    3195             : 
    3196     9143515 :             if (LatDegradModelSimFlag) {
    3197             :                 // Calculate for SHReff using the Latent Degradation Model
    3198           0 :                 if (NumIteration == 1) {
    3199           0 :                     state.dataWaterToAirHeatPumpSimple->QLatRated = simpleWatertoAirHP.QLoadTotal - simpleWatertoAirHP.QSensible;
    3200           0 :                 } else if (NumIteration == 2) {
    3201           0 :                     state.dataWaterToAirHeatPumpSimple->QLatActual = simpleWatertoAirHP.QLoadTotal - simpleWatertoAirHP.QSensible;
    3202           0 :                     SHRss = simpleWatertoAirHP.QSensible / simpleWatertoAirHP.QLoadTotal;
    3203           0 :                     SHReff = CalcEffectiveSHR(state,
    3204             :                                               HPNum,
    3205             :                                               SHRss,
    3206             :                                               fanOp,
    3207             :                                               simpleWatertoAirHP.RunFrac,
    3208           0 :                                               state.dataWaterToAirHeatPumpSimple->QLatRated,
    3209           0 :                                               state.dataWaterToAirHeatPumpSimple->QLatActual,
    3210           0 :                                               state.dataWaterToAirHeatPumpSimple->LoadSideInletDBTemp,
    3211           0 :                                               state.dataWaterToAirHeatPumpSimple->LoadSideInletWBTemp);
    3212             :                     //       Update sensible capacity based on effective SHR
    3213           0 :                     simpleWatertoAirHP.QSensible = simpleWatertoAirHP.QLoadTotal * SHReff;
    3214           0 :                     break;
    3215             :                 }
    3216             :             } else {
    3217             :                 // Assume SHReff=SHRss
    3218     9143515 :                 SHReff = simpleWatertoAirHP.QSensible / simpleWatertoAirHP.QLoadTotal;
    3219     9143515 :                 break;
    3220             :             }
    3221             :         }
    3222             : 
    3223             :         // calculate coil outlet state variables
    3224     9143515 :         LoadSideFullOutletEnthalpy = state.dataWaterToAirHeatPumpSimple->LoadSideInletEnth - simpleWatertoAirHP.QLoadTotal / LoadSideFullMassFlowRate;
    3225    18287030 :         state.dataWaterToAirHeatPumpSimple->LoadSideOutletDBTemp =
    3226     9143515 :             state.dataWaterToAirHeatPumpSimple->LoadSideInletDBTemp - simpleWatertoAirHP.QSensible / (LoadSideFullMassFlowRate * CpAir);
    3227    18287030 :         state.dataWaterToAirHeatPumpSimple->LoadSideOutletHumRat =
    3228     9143515 :             Psychrometrics::PsyWFnTdbH(state, state.dataWaterToAirHeatPumpSimple->LoadSideOutletDBTemp, LoadSideFullOutletEnthalpy, RoutineName);
    3229             :         // Actual outlet conditions are "average" for time step
    3230     9143515 :         if (fanOp == HVAC::FanOp::Continuous) {
    3231             :             // continuous fan, cycling compressor
    3232     4037372 :             simpleWatertoAirHP.OutletAirEnthalpy =
    3233     4037372 :                 PartLoadRatio * LoadSideFullOutletEnthalpy + (1.0 - PartLoadRatio) * state.dataWaterToAirHeatPumpSimple->LoadSideInletEnth;
    3234     4037372 :             simpleWatertoAirHP.OutletAirHumRat = PartLoadRatio * state.dataWaterToAirHeatPumpSimple->LoadSideOutletHumRat +
    3235     4037372 :                                                  (1.0 - PartLoadRatio) * state.dataWaterToAirHeatPumpSimple->LoadSideInletHumRat;
    3236     4037372 :             simpleWatertoAirHP.OutletAirDBTemp = Psychrometrics::PsyTdbFnHW(simpleWatertoAirHP.OutletAirEnthalpy, simpleWatertoAirHP.OutletAirHumRat);
    3237             :         } else {
    3238             :             // default to cycling fan, cycling compressor
    3239     5106143 :             simpleWatertoAirHP.OutletAirEnthalpy = LoadSideFullOutletEnthalpy;
    3240     5106143 :             simpleWatertoAirHP.OutletAirHumRat = state.dataWaterToAirHeatPumpSimple->LoadSideOutletHumRat;
    3241     5106143 :             simpleWatertoAirHP.OutletAirDBTemp = state.dataWaterToAirHeatPumpSimple->LoadSideOutletDBTemp;
    3242             :         }
    3243             : 
    3244             :         // scale heat transfer rates to PLR and power to RTF
    3245     9143515 :         simpleWatertoAirHP.QLoadTotal *= PartLoadRatio;
    3246    18287030 :         simpleWatertoAirHP.QLoadTotalReport = simpleWatertoAirHP.AirMassFlowRate *
    3247     9143515 :                                               (state.dataWaterToAirHeatPumpSimple->LoadSideInletEnth -
    3248     9143515 :                                                Psychrometrics::PsyHFnTdbW(simpleWatertoAirHP.OutletAirDBTemp,
    3249             :                                                                           simpleWatertoAirHP.OutletAirHumRat)); // Why doesn't this match QLoadTotal?
    3250     9143515 :         simpleWatertoAirHP.QSensible *= PartLoadRatio;
    3251     9143515 :         state.dataWaterToAirHeatPumpSimple->Winput *= simpleWatertoAirHP.RunFrac;
    3252     9143515 :         simpleWatertoAirHP.QSource = simpleWatertoAirHP.QLoadTotalReport + state.dataWaterToAirHeatPumpSimple->Winput;
    3253     9143515 :         state.dataHeatBal->HeatReclaimSimple_WAHPCoil(HPNum).AvailCapacity = simpleWatertoAirHP.QSource;
    3254             : 
    3255             :         //  Add power to global variable so power can be summed by parent object
    3256     9143515 :         state.dataHVACGlobal->DXElecCoolingPower = state.dataWaterToAirHeatPumpSimple->Winput;
    3257             : 
    3258     9143515 :         DataHeatBalance::HeatReclaimDataBase &HeatReclaim = state.dataHeatBal->HeatReclaimSimple_WAHPCoil(HPNum);
    3259     9143515 :         HeatReclaim.WaterHeatingDesuperheaterReclaimedHeatTotal = 0.0;
    3260     9143515 :         if (allocated(HeatReclaim.WaterHeatingDesuperheaterReclaimedHeat)) {
    3261       34404 :             for (auto &num : HeatReclaim.WaterHeatingDesuperheaterReclaimedHeat)
    3262       17202 :                 HeatReclaim.WaterHeatingDesuperheaterReclaimedHeatTotal += num;
    3263             :         }
    3264     9143515 :         simpleWatertoAirHP.QSource -= HeatReclaim.WaterHeatingDesuperheaterReclaimedHeatTotal;
    3265             : 
    3266             :         // Update heat pump data structure
    3267     9143515 :         simpleWatertoAirHP.Power = state.dataWaterToAirHeatPumpSimple->Winput;
    3268     9143515 :         simpleWatertoAirHP.QLoadTotal = simpleWatertoAirHP.QLoadTotalReport;
    3269     9143515 :         simpleWatertoAirHP.QLatent = simpleWatertoAirHP.QLoadTotalReport - simpleWatertoAirHP.QSensible;
    3270     9143515 :         simpleWatertoAirHP.Energy = state.dataWaterToAirHeatPumpSimple->Winput * TimeStepSysSec;
    3271     9143515 :         simpleWatertoAirHP.EnergyLoadTotal = simpleWatertoAirHP.QLoadTotalReport * TimeStepSysSec;
    3272     9143515 :         simpleWatertoAirHP.EnergySensible = simpleWatertoAirHP.QSensible * TimeStepSysSec;
    3273     9143515 :         simpleWatertoAirHP.EnergyLatent = (simpleWatertoAirHP.QLoadTotalReport - simpleWatertoAirHP.QSensible) * TimeStepSysSec;
    3274     9143515 :         simpleWatertoAirHP.EnergySource = simpleWatertoAirHP.QSource * TimeStepSysSec;
    3275     9143515 :         if (simpleWatertoAirHP.RunFrac == 0.0) {
    3276     1518654 :             simpleWatertoAirHP.COP = 0.0;
    3277             :         } else {
    3278     7624861 :             simpleWatertoAirHP.COP = simpleWatertoAirHP.QLoadTotalReport / state.dataWaterToAirHeatPumpSimple->Winput;
    3279             :         }
    3280     9143515 :         simpleWatertoAirHP.PartLoadRatio = PartLoadRatio;
    3281             : 
    3282     9143515 :         if ((simpleWatertoAirHP.WaterCyclingMode) == HVAC::WaterFlow::Cycling) {
    3283             :             // plant can lock flow at coil water inlet node, use design flow multiplied by PLR to calculate water mass flow rate
    3284     9143515 :             simpleWatertoAirHP.WaterMassFlowRate = simpleWatertoAirHP.DesignWaterMassFlowRate * PartLoadRatio;
    3285     9143515 :             PlantUtilities::SetComponentFlowRate(state,
    3286     9143515 :                                                  simpleWatertoAirHP.WaterMassFlowRate,
    3287             :                                                  simpleWatertoAirHP.WaterInletNodeNum,
    3288             :                                                  simpleWatertoAirHP.WaterOutletNodeNum,
    3289     9143515 :                                                  simpleWatertoAirHP.plantLoc);
    3290     9143515 :             if (simpleWatertoAirHP.WaterMassFlowRate > 0.0) {
    3291     7624861 :                 simpleWatertoAirHP.OutletWaterTemp = state.dataWaterToAirHeatPumpSimple->SourceSideInletTemp +
    3292     7624861 :                                                      simpleWatertoAirHP.QSource / (simpleWatertoAirHP.WaterMassFlowRate * CpWater);
    3293     7624861 :                 simpleWatertoAirHP.OutletWaterEnthalpy =
    3294     7624861 :                     state.dataWaterToAirHeatPumpSimple->SourceSideInletEnth + simpleWatertoAirHP.QSource / simpleWatertoAirHP.WaterMassFlowRate;
    3295             :             }
    3296             :         } else {
    3297           0 :             if ((simpleWatertoAirHP.WaterCyclingMode) == HVAC::WaterFlow::Constant) {
    3298           0 :                 if (simpleWatertoAirHP.WaterFlowMode) {
    3299           0 :                     simpleWatertoAirHP.WaterMassFlowRate = simpleWatertoAirHP.DesignWaterMassFlowRate;
    3300           0 :                     PlantUtilities::SetComponentFlowRate(state,
    3301           0 :                                                          simpleWatertoAirHP.WaterMassFlowRate,
    3302             :                                                          simpleWatertoAirHP.WaterInletNodeNum,
    3303             :                                                          simpleWatertoAirHP.WaterOutletNodeNum,
    3304           0 :                                                          simpleWatertoAirHP.plantLoc);
    3305             :                 } else {
    3306           0 :                     simpleWatertoAirHP.WaterMassFlowRate = state.dataWaterToAirHeatPumpSimple->SourceSideMassFlowRate;
    3307             :                 }
    3308             :             } else {
    3309           0 :                 simpleWatertoAirHP.WaterMassFlowRate = state.dataWaterToAirHeatPumpSimple->SourceSideMassFlowRate;
    3310             :             }
    3311           0 :             simpleWatertoAirHP.OutletWaterTemp = state.dataWaterToAirHeatPumpSimple->SourceSideInletTemp +
    3312           0 :                                                  simpleWatertoAirHP.QSource / (state.dataWaterToAirHeatPumpSimple->SourceSideMassFlowRate * CpWater);
    3313           0 :             simpleWatertoAirHP.OutletWaterEnthalpy = state.dataWaterToAirHeatPumpSimple->SourceSideInletEnth +
    3314           0 :                                                      simpleWatertoAirHP.QSource / state.dataWaterToAirHeatPumpSimple->SourceSideMassFlowRate;
    3315             :         }
    3316             :     }
    3317             : 
    3318    21926475 :     void CalcHPHeatingSimple(EnergyPlusData &state,
    3319             :                              int const HPNum,                                // Heat Pump Number
    3320             :                              HVAC::FanOp const fanOp,                        // Fan/Compressor cycling scheme indicator
    3321             :                              [[maybe_unused]] Real64 const SensDemand,       // Sensible Demand [W] !unused1208
    3322             :                              HVAC::CompressorOp const compressorOp,          // compressor operation flag
    3323             :                              Real64 const PartLoadRatio,                     // compressor part load ratio
    3324             :                              [[maybe_unused]] Real64 const OnOffAirFlowRatio // ratio of compressor on flow to average flow over time step
    3325             :     )
    3326             :     {
    3327             : 
    3328             :         //       AUTHOR         Arun Shenoy
    3329             :         //       DATE WRITTEN   Jan 2004
    3330             :         //       RE-ENGINEERED  Kenneth Tang (Jan 2005)
    3331             : 
    3332             :         // PURPOSE OF THIS SUBROUTINE:
    3333             :         // This subroutine is for simulating the heating mode of the Water to Air HP Simple
    3334             : 
    3335             :         // METHODOLOGY EMPLOYED:
    3336             :         // Simulate the heat pump performance using the coefficients in quadlinear and quintlinear curves and rated conditions
    3337             :         // Finally, adjust the heat pump outlet conditions based on the PartLoadRatio
    3338             :         // and RuntimeFrac.
    3339             : 
    3340             :         // REFERENCES:
    3341             :         // (1) Lash.T.A.,1992.Simulation and Analysis of a Water Loop Heat Pump System.
    3342             :         // M.S. Thesis, University of Illinois at Urbana Champaign.
    3343             :         // (2) Shenoy, Arun. 2004. Simulation, Modeling and Analysis of Water to Air Heat Pump.
    3344             :         // State Energy Simulation Program. M.S. Thesis, Department of Mechanical and Aerospace Engineering,
    3345             :         // Oklahoma State University. (downloadable from www.hvac.okstate.edu)
    3346             :         // (3) Tang,C.C.. 2005. Modeling Packaged Heat Pumps in a Quasi-Steady
    3347             :         // State Energy Simulation Program. M.S. Thesis, Department of Mechanical and Aerospace Engineering,
    3348             :         // Oklahoma State University. (downloadable from www.hvac.okstate.edu)
    3349             : 
    3350    21926475 :         Real64 TimeStepSysSec = state.dataHVACGlobal->TimeStepSysSec;
    3351             : 
    3352             :         // SUBROUTINE PARAMETER DEFINITIONS:
    3353    21926475 :         Real64 constexpr Tref(283.15); // Reference Temperature for performance curves,10C [K]
    3354             :         static constexpr std::string_view RoutineName("CalcHPHeatingSimple");
    3355             :         static constexpr std::string_view RoutineNameSourceSideInletTemp("CalcHPHeatingSimple:SourceSideInletTemp");
    3356             : 
    3357             :         Real64 HeatCapRated;               // Rated Heating Capacity [W]
    3358             :         Real64 HeatPowerRated;             // Rated Heating Power Input[W]
    3359             :         Real64 AirVolFlowRateRated;        // Rated Air Volumetric Flow Rate [m3/s]
    3360             :         Real64 WaterVolFlowRateRated;      // Rated Water Volumetric Flow Rate [m3/s]
    3361             :         Real64 ratioTDB;                   // Ratio of the inlet air dry bulb temperature to the rated conditions
    3362             :         Real64 ratioTS;                    // Ratio of the source side (water) inlet temperature to the rated conditions
    3363             :         Real64 ratioVL;                    // Ratio of the load side flow rate to the rated conditions
    3364             :         Real64 ratioVS;                    // Ratio of the source side flow rate to the rated conditions
    3365             :         Real64 CpWater;                    // Specific heat of water [J/kg_C]
    3366             :         Real64 CpAir;                      // Specific heat of air [J/kg_C]
    3367             :         Real64 LoadSideFullMassFlowRate;   // Load Side Full Load Mass Flow Rate [kg/s]
    3368             :         Real64 LoadSideFullOutletEnthalpy; // Load Side Full Load Outlet Air Enthalpy [J/kg]
    3369             : 
    3370             :         //  LOAD LOCAL VARIABLES FROM DATA STRUCTURE (for code readability)
    3371             : 
    3372    21926475 :         auto &simpleWatertoAirHP(state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(HPNum));
    3373             : 
    3374    21926475 :         HeatCapRated = simpleWatertoAirHP.RatedCapHeat;
    3375    21926475 :         HeatPowerRated = simpleWatertoAirHP.RatedPowerHeat;
    3376    21926475 :         AirVolFlowRateRated = simpleWatertoAirHP.RatedAirVolFlowRate;
    3377    21926475 :         WaterVolFlowRateRated = simpleWatertoAirHP.RatedWaterVolFlowRate;
    3378    21926475 :         if (fanOp == HVAC::FanOp::Continuous) {
    3379     4645802 :             LoadSideFullMassFlowRate = simpleWatertoAirHP.AirMassFlowRate;
    3380             :         } else {
    3381             :             // default to cycling fan, cycling compressor, full load air flow
    3382    17280673 :             if (PartLoadRatio > 0.0) {
    3383     6157573 :                 LoadSideFullMassFlowRate = simpleWatertoAirHP.AirMassFlowRate / PartLoadRatio;
    3384             :             } else {
    3385    11123100 :                 LoadSideFullMassFlowRate = 0.0;
    3386             :             }
    3387             :         }
    3388    21926475 :         state.dataWaterToAirHeatPumpSimple->LoadSideInletDBTemp = simpleWatertoAirHP.InletAirDBTemp;
    3389    21926475 :         state.dataWaterToAirHeatPumpSimple->LoadSideInletHumRat = simpleWatertoAirHP.InletAirHumRat;
    3390             : 
    3391    43852950 :         state.dataWaterToAirHeatPumpSimple->LoadSideInletWBTemp =
    3392    21926475 :             Psychrometrics::PsyTwbFnTdbWPb(state,
    3393    21926475 :                                            state.dataWaterToAirHeatPumpSimple->LoadSideInletDBTemp,
    3394    21926475 :                                            state.dataWaterToAirHeatPumpSimple->LoadSideInletHumRat,
    3395    21926475 :                                            state.dataEnvrn->OutBaroPress,
    3396             :                                            RoutineName);
    3397    21926475 :         state.dataWaterToAirHeatPumpSimple->LoadSideInletEnth = simpleWatertoAirHP.InletAirEnthalpy;
    3398    21926475 :         CpAir = Psychrometrics::PsyCpAirFnW(state.dataWaterToAirHeatPumpSimple->LoadSideInletHumRat);
    3399    21926475 :         state.dataWaterToAirHeatPumpSimple->SourceSideMassFlowRate = simpleWatertoAirHP.WaterMassFlowRate;
    3400    21926475 :         state.dataWaterToAirHeatPumpSimple->SourceSideInletTemp = simpleWatertoAirHP.InletWaterTemp;
    3401    21926475 :         state.dataWaterToAirHeatPumpSimple->SourceSideInletEnth = simpleWatertoAirHP.InletWaterEnthalpy;
    3402    21926475 :         CpWater = FluidProperties::GetSpecificHeatGlycol(state,
    3403    21926475 :                                                          state.dataPlnt->PlantLoop(simpleWatertoAirHP.plantLoc.loopNum).FluidName,
    3404    21926475 :                                                          state.dataWaterToAirHeatPumpSimple->SourceSideInletTemp,
    3405    21926475 :                                                          state.dataPlnt->PlantLoop(simpleWatertoAirHP.plantLoc.loopNum).FluidIndex,
    3406             :                                                          RoutineNameSourceSideInletTemp);
    3407             : 
    3408             :         // Check for flows, do not perform simulation if no flow in load side or source side.
    3409    21926475 :         if (state.dataWaterToAirHeatPumpSimple->SourceSideMassFlowRate <= 0.0 || LoadSideFullMassFlowRate <= 0.0) {
    3410    15614301 :             simpleWatertoAirHP.SimFlag = false;
    3411    15614301 :             return;
    3412             :         } else {
    3413     6312174 :             simpleWatertoAirHP.SimFlag = true;
    3414             :         }
    3415             : 
    3416     6312174 :         if (compressorOp == HVAC::CompressorOp::Off) {
    3417       11278 :             simpleWatertoAirHP.SimFlag = false;
    3418       11278 :             return;
    3419             :         }
    3420             : 
    3421             :         // Calculate Part Load Factor and Runtime Fraction
    3422     6300896 :         Real64 PLF = 1.0; // part load factor as a function of PLR, RTF = PLR / PLF
    3423     6300896 :         if (simpleWatertoAirHP.PLFCurveIndex > 0) {
    3424     6300896 :             PLF = Curve::CurveValue(state, simpleWatertoAirHP.PLFCurveIndex, PartLoadRatio); // Calculate part-load factor
    3425             :         }
    3426     6300896 :         if (fanOp == HVAC::FanOp::Cycling) {
    3427     6047350 :             state.dataHVACGlobal->OnOffFanPartLoadFraction = PLF;
    3428             :         }
    3429     6300896 :         simpleWatertoAirHP.RunFrac = PartLoadRatio / PLF;
    3430             : 
    3431     6300896 :         ratioTDB = ((state.dataWaterToAirHeatPumpSimple->LoadSideInletDBTemp + state.dataWaterToAirHeatPumpSimple->CelsiustoKelvin) / Tref);
    3432     6300896 :         ratioTS = ((state.dataWaterToAirHeatPumpSimple->SourceSideInletTemp + state.dataWaterToAirHeatPumpSimple->CelsiustoKelvin) / Tref);
    3433     6300896 :         ratioVL = (LoadSideFullMassFlowRate /
    3434     6300896 :                    (AirVolFlowRateRated * Psychrometrics::PsyRhoAirFnPbTdbW(state,
    3435     6300896 :                                                                             state.dataEnvrn->StdBaroPress,
    3436     6300896 :                                                                             state.dataWaterToAirHeatPumpSimple->LoadSideInletDBTemp,
    3437     6300896 :                                                                             state.dataWaterToAirHeatPumpSimple->LoadSideInletHumRat,
    3438             :                                                                             RoutineName)));
    3439     6300896 :         if (simpleWatertoAirHP.DesignWaterMassFlowRate > 0.0) {
    3440     6300896 :             ratioVS = (state.dataWaterToAirHeatPumpSimple->SourceSideMassFlowRate) / (simpleWatertoAirHP.DesignWaterMassFlowRate);
    3441             :         } else {
    3442           0 :             ratioVS = 0.0;
    3443             :         }
    3444             : 
    3445     6300896 :         simpleWatertoAirHP.QLoadTotal =
    3446     6300896 :             HeatCapRated * Curve::CurveValue(state, simpleWatertoAirHP.HeatCapCurveIndex, ratioTDB, ratioTS, ratioVL, ratioVS);
    3447     6300896 :         simpleWatertoAirHP.QSensible = simpleWatertoAirHP.QLoadTotal;
    3448    12601792 :         state.dataWaterToAirHeatPumpSimple->Winput =
    3449     6300896 :             HeatPowerRated * Curve::CurveValue(state, simpleWatertoAirHP.HeatPowCurveIndex, ratioTDB, ratioTS, ratioVL, ratioVS);
    3450             : 
    3451             :         // calculate coil outlet state variables
    3452     6300896 :         LoadSideFullOutletEnthalpy = state.dataWaterToAirHeatPumpSimple->LoadSideInletEnth + simpleWatertoAirHP.QLoadTotal / LoadSideFullMassFlowRate;
    3453    12601792 :         state.dataWaterToAirHeatPumpSimple->LoadSideOutletDBTemp =
    3454     6300896 :             state.dataWaterToAirHeatPumpSimple->LoadSideInletDBTemp + simpleWatertoAirHP.QSensible / (LoadSideFullMassFlowRate * CpAir);
    3455    12601792 :         state.dataWaterToAirHeatPumpSimple->LoadSideOutletHumRat =
    3456     6300896 :             Psychrometrics::PsyWFnTdbH(state, state.dataWaterToAirHeatPumpSimple->LoadSideOutletDBTemp, LoadSideFullOutletEnthalpy, RoutineName);
    3457             : 
    3458             :         // Actual outlet conditions are "average" for time step
    3459     6300896 :         if (fanOp == HVAC::FanOp::Continuous) {
    3460             :             // continuous fan, cycling compressor
    3461      253546 :             simpleWatertoAirHP.OutletAirEnthalpy =
    3462      253546 :                 PartLoadRatio * LoadSideFullOutletEnthalpy + (1.0 - PartLoadRatio) * state.dataWaterToAirHeatPumpSimple->LoadSideInletEnth;
    3463      253546 :             simpleWatertoAirHP.OutletAirHumRat = PartLoadRatio * state.dataWaterToAirHeatPumpSimple->LoadSideOutletHumRat +
    3464      253546 :                                                  (1.0 - PartLoadRatio) * state.dataWaterToAirHeatPumpSimple->LoadSideInletHumRat;
    3465      253546 :             simpleWatertoAirHP.OutletAirDBTemp = Psychrometrics::PsyTdbFnHW(simpleWatertoAirHP.OutletAirEnthalpy, simpleWatertoAirHP.OutletAirHumRat);
    3466             :         } else {
    3467             :             // default to cycling fan, cycling compressor
    3468     6047350 :             simpleWatertoAirHP.OutletAirEnthalpy = LoadSideFullOutletEnthalpy;
    3469     6047350 :             simpleWatertoAirHP.OutletAirHumRat = state.dataWaterToAirHeatPumpSimple->LoadSideOutletHumRat;
    3470     6047350 :             simpleWatertoAirHP.OutletAirDBTemp = state.dataWaterToAirHeatPumpSimple->LoadSideOutletDBTemp;
    3471             :         }
    3472             : 
    3473             :         // scale heat transfer rates to PLR and power to RTF
    3474     6300896 :         simpleWatertoAirHP.QLoadTotal *= PartLoadRatio;
    3475     6300896 :         simpleWatertoAirHP.QLoadTotalReport = simpleWatertoAirHP.QLoadTotal;
    3476     6300896 :         simpleWatertoAirHP.QSensible *= PartLoadRatio;
    3477     6300896 :         state.dataWaterToAirHeatPumpSimple->Winput *= simpleWatertoAirHP.RunFrac;
    3478     6300896 :         simpleWatertoAirHP.QSource = simpleWatertoAirHP.QLoadTotalReport - state.dataWaterToAirHeatPumpSimple->Winput;
    3479             : 
    3480             :         //  Add power to global variable so power can be summed by parent object
    3481     6300896 :         state.dataHVACGlobal->DXElecHeatingPower = state.dataWaterToAirHeatPumpSimple->Winput;
    3482             : 
    3483             :         // Update heat pump data structure
    3484     6300896 :         simpleWatertoAirHP.Power = state.dataWaterToAirHeatPumpSimple->Winput;
    3485     6300896 :         simpleWatertoAirHP.QLoadTotal = simpleWatertoAirHP.QLoadTotalReport;
    3486     6300896 :         simpleWatertoAirHP.QSensible = simpleWatertoAirHP.QSensible;
    3487     6300896 :         simpleWatertoAirHP.Energy = state.dataWaterToAirHeatPumpSimple->Winput * TimeStepSysSec;
    3488     6300896 :         simpleWatertoAirHP.EnergyLoadTotal = simpleWatertoAirHP.QLoadTotalReport * TimeStepSysSec;
    3489     6300896 :         simpleWatertoAirHP.EnergySensible = simpleWatertoAirHP.QSensible * TimeStepSysSec;
    3490     6300896 :         simpleWatertoAirHP.EnergyLatent = 0.0;
    3491     6300896 :         simpleWatertoAirHP.EnergySource = simpleWatertoAirHP.QSource * TimeStepSysSec;
    3492     6300896 :         if (simpleWatertoAirHP.RunFrac == 0.0) {
    3493       60632 :             simpleWatertoAirHP.COP = 0.0;
    3494             :         } else {
    3495     6240264 :             simpleWatertoAirHP.COP = simpleWatertoAirHP.QLoadTotalReport / state.dataWaterToAirHeatPumpSimple->Winput;
    3496             :         }
    3497     6300896 :         simpleWatertoAirHP.PartLoadRatio = PartLoadRatio;
    3498             : 
    3499     6300896 :         if ((simpleWatertoAirHP.WaterCyclingMode) == HVAC::WaterFlow::Cycling) {
    3500             :             // plant can lock flow at coil water inlet node, use design flow multiplied by PLR to calculate water mass flow rate
    3501     6300896 :             simpleWatertoAirHP.WaterMassFlowRate = simpleWatertoAirHP.DesignWaterMassFlowRate * PartLoadRatio;
    3502     6300896 :             PlantUtilities::SetComponentFlowRate(state,
    3503     6300896 :                                                  simpleWatertoAirHP.WaterMassFlowRate,
    3504             :                                                  simpleWatertoAirHP.WaterInletNodeNum,
    3505             :                                                  simpleWatertoAirHP.WaterOutletNodeNum,
    3506     6300896 :                                                  simpleWatertoAirHP.plantLoc);
    3507     6300896 :             if (simpleWatertoAirHP.WaterMassFlowRate > 0.0) {
    3508     6240280 :                 simpleWatertoAirHP.OutletWaterTemp = state.dataWaterToAirHeatPumpSimple->SourceSideInletTemp -
    3509     6240280 :                                                      simpleWatertoAirHP.QSource / (simpleWatertoAirHP.WaterMassFlowRate * CpWater);
    3510     6240280 :                 simpleWatertoAirHP.OutletWaterEnthalpy =
    3511     6240280 :                     state.dataWaterToAirHeatPumpSimple->SourceSideInletEnth - simpleWatertoAirHP.QSource / simpleWatertoAirHP.WaterMassFlowRate;
    3512             :             }
    3513             :         } else {
    3514           0 :             if ((simpleWatertoAirHP.WaterCyclingMode) == HVAC::WaterFlow::Constant) {
    3515           0 :                 if (simpleWatertoAirHP.WaterFlowMode) {
    3516           0 :                     simpleWatertoAirHP.WaterMassFlowRate = simpleWatertoAirHP.DesignWaterMassFlowRate;
    3517           0 :                     PlantUtilities::SetComponentFlowRate(state,
    3518           0 :                                                          simpleWatertoAirHP.WaterMassFlowRate,
    3519             :                                                          simpleWatertoAirHP.WaterInletNodeNum,
    3520             :                                                          simpleWatertoAirHP.WaterOutletNodeNum,
    3521           0 :                                                          simpleWatertoAirHP.plantLoc);
    3522             :                 } else {
    3523           0 :                     simpleWatertoAirHP.WaterMassFlowRate = state.dataWaterToAirHeatPumpSimple->SourceSideMassFlowRate;
    3524             :                 }
    3525             :             } else {
    3526           0 :                 simpleWatertoAirHP.WaterMassFlowRate = state.dataWaterToAirHeatPumpSimple->SourceSideMassFlowRate;
    3527             :             }
    3528           0 :             simpleWatertoAirHP.OutletWaterTemp = state.dataWaterToAirHeatPumpSimple->SourceSideInletTemp -
    3529           0 :                                                  simpleWatertoAirHP.QSource / (state.dataWaterToAirHeatPumpSimple->SourceSideMassFlowRate * CpWater);
    3530           0 :             simpleWatertoAirHP.OutletWaterEnthalpy = state.dataWaterToAirHeatPumpSimple->SourceSideInletEnth -
    3531           0 :                                                      simpleWatertoAirHP.QSource / state.dataWaterToAirHeatPumpSimple->SourceSideMassFlowRate;
    3532             :         }
    3533             :     }
    3534             : 
    3535    43852909 :     void UpdateSimpleWatertoAirHP(EnergyPlusData &state, int const HPNum)
    3536             :     {
    3537             :         // SUBROUTINE INFORMATION:
    3538             :         //       AUTHOR         Arun Shenoy
    3539             :         //       DATE WRITTEN   Jan 2004
    3540             :         //       RE-ENGINEERED  Kenneth Tang (Jan 2005)
    3541             : 
    3542             :         // PURPOSE OF THIS SUBROUTINE:
    3543             :         // This subroutine updates the Water to Air Heat Pump outlet nodes.
    3544             : 
    3545             :         // METHODOLOGY EMPLOYED:
    3546             :         // Data is moved from the HP data structure to the HP outlet nodes.
    3547             : 
    3548    43852909 :         Real64 TimeStepSysSec = state.dataHVACGlobal->TimeStepSysSec;
    3549             : 
    3550             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    3551             :         int AirInletNode;
    3552             :         int WaterInletNode;
    3553             :         int AirOutletNode;
    3554             :         int WaterOutletNode;
    3555             : 
    3556    43852909 :         auto &simpleWatertoAirHP(state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(HPNum));
    3557             : 
    3558    43852909 :         if (!simpleWatertoAirHP.SimFlag) {
    3559             :             // Heatpump is off; just pass through conditions
    3560    28408498 :             simpleWatertoAirHP.Power = 0.0;
    3561    28408498 :             simpleWatertoAirHP.QLoadTotal = 0.0;
    3562    28408498 :             simpleWatertoAirHP.QLoadTotalReport = 0.0;
    3563    28408498 :             simpleWatertoAirHP.QSensible = 0.0;
    3564    28408498 :             simpleWatertoAirHP.QLatent = 0.0;
    3565    28408498 :             simpleWatertoAirHP.QSource = 0.0;
    3566    28408498 :             simpleWatertoAirHP.Energy = 0.0;
    3567    28408498 :             simpleWatertoAirHP.EnergyLoadTotal = 0.0;
    3568    28408498 :             simpleWatertoAirHP.EnergySensible = 0.0;
    3569    28408498 :             simpleWatertoAirHP.EnergyLatent = 0.0;
    3570    28408498 :             simpleWatertoAirHP.EnergySource = 0.0;
    3571    28408498 :             simpleWatertoAirHP.COP = 0.0;
    3572    28408498 :             simpleWatertoAirHP.RunFrac = 0.0;
    3573    28408498 :             simpleWatertoAirHP.PartLoadRatio = 0.0;
    3574             : 
    3575    28408498 :             simpleWatertoAirHP.OutletAirDBTemp = simpleWatertoAirHP.InletAirDBTemp;
    3576    28408498 :             simpleWatertoAirHP.OutletAirHumRat = simpleWatertoAirHP.InletAirHumRat;
    3577    28408498 :             simpleWatertoAirHP.OutletAirEnthalpy = simpleWatertoAirHP.InletAirEnthalpy;
    3578    28408498 :             simpleWatertoAirHP.OutletWaterTemp = simpleWatertoAirHP.InletWaterTemp;
    3579    28408498 :             simpleWatertoAirHP.OutletWaterEnthalpy = simpleWatertoAirHP.InletWaterEnthalpy;
    3580             :         }
    3581             : 
    3582    43852909 :         AirInletNode = simpleWatertoAirHP.AirInletNodeNum;
    3583    43852909 :         WaterInletNode = simpleWatertoAirHP.WaterInletNodeNum;
    3584    43852909 :         AirOutletNode = simpleWatertoAirHP.AirOutletNodeNum;
    3585    43852909 :         WaterOutletNode = simpleWatertoAirHP.WaterOutletNodeNum;
    3586             : 
    3587             :         // Set the air outlet  nodes of the WatertoAirHPSimple
    3588    43852909 :         state.dataLoopNodes->Node(AirOutletNode).MassFlowRate = state.dataLoopNodes->Node(AirInletNode).MassFlowRate;
    3589    43852909 :         state.dataLoopNodes->Node(AirOutletNode).Temp = simpleWatertoAirHP.OutletAirDBTemp;
    3590    43852909 :         state.dataLoopNodes->Node(AirOutletNode).HumRat = simpleWatertoAirHP.OutletAirHumRat;
    3591    43852909 :         state.dataLoopNodes->Node(AirOutletNode).Enthalpy = simpleWatertoAirHP.OutletAirEnthalpy;
    3592             : 
    3593             :         // Set the air outlet nodes for properties that just pass through & not used
    3594    43852909 :         state.dataLoopNodes->Node(AirOutletNode).Quality = state.dataLoopNodes->Node(AirInletNode).Quality;
    3595    43852909 :         state.dataLoopNodes->Node(AirOutletNode).Press = state.dataLoopNodes->Node(AirInletNode).Press;
    3596    43852909 :         state.dataLoopNodes->Node(AirOutletNode).MassFlowRateMin = state.dataLoopNodes->Node(AirInletNode).MassFlowRateMin;
    3597    43852909 :         state.dataLoopNodes->Node(AirOutletNode).MassFlowRateMax = state.dataLoopNodes->Node(AirInletNode).MassFlowRateMax;
    3598    43852909 :         state.dataLoopNodes->Node(AirOutletNode).MassFlowRateMinAvail = state.dataLoopNodes->Node(AirInletNode).MassFlowRateMinAvail;
    3599    43852909 :         state.dataLoopNodes->Node(AirOutletNode).MassFlowRateMaxAvail = state.dataLoopNodes->Node(AirInletNode).MassFlowRateMaxAvail;
    3600             : 
    3601             :         // Set the water outlet node of the WatertoAirHPSimple
    3602             :         // Set the water outlet nodes for properties that just pass through & not used
    3603    43852909 :         PlantUtilities::SafeCopyPlantNode(state, WaterInletNode, WaterOutletNode);
    3604             : 
    3605    43852909 :         state.dataLoopNodes->Node(WaterOutletNode).Temp = simpleWatertoAirHP.OutletWaterTemp;
    3606    43852909 :         state.dataLoopNodes->Node(WaterOutletNode).Enthalpy = simpleWatertoAirHP.OutletWaterEnthalpy;
    3607             : 
    3608    43852909 :         simpleWatertoAirHP.Energy = simpleWatertoAirHP.Power * TimeStepSysSec;
    3609    43852909 :         simpleWatertoAirHP.EnergyLoadTotal = simpleWatertoAirHP.QLoadTotal * TimeStepSysSec;
    3610    43852909 :         simpleWatertoAirHP.EnergySensible = simpleWatertoAirHP.QSensible * TimeStepSysSec;
    3611    43852909 :         simpleWatertoAirHP.EnergyLatent = simpleWatertoAirHP.QLatent * TimeStepSysSec;
    3612    43852909 :         simpleWatertoAirHP.EnergySource = simpleWatertoAirHP.QSource * TimeStepSysSec;
    3613             : 
    3614    43852909 :         if (state.dataContaminantBalance->Contaminant.CO2Simulation) {
    3615           0 :             state.dataLoopNodes->Node(AirOutletNode).CO2 = state.dataLoopNodes->Node(AirInletNode).CO2;
    3616             :         }
    3617    43852909 :         if (state.dataContaminantBalance->Contaminant.GenericContamSimulation) {
    3618           0 :             state.dataLoopNodes->Node(AirOutletNode).GenContam = state.dataLoopNodes->Node(AirInletNode).GenContam;
    3619             :         }
    3620             : 
    3621    43852909 :         if (simpleWatertoAirHP.reportCoilFinalSizes) {
    3622    18042163 :             if (!state.dataGlobal->WarmupFlag && !state.dataGlobal->DoingHVACSizingSimulations && !state.dataGlobal->DoingSizing) {
    3623             : 
    3624         274 :                 if (simpleWatertoAirHP.WAHPType == WatertoAirHP::Cooling) {
    3625         137 :                     state.dataRptCoilSelection->coilSelectionReportObj->setCoilFinalSizes(
    3626             :                         state,
    3627         137 :                         simpleWatertoAirHP.Name,
    3628         274 :                         format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)]),
    3629             :                         simpleWatertoAirHP.RatedCapCoolTotal,
    3630             :                         simpleWatertoAirHP.RatedCapCoolSens,
    3631             :                         simpleWatertoAirHP.RatedAirVolFlowRate,
    3632             :                         simpleWatertoAirHP.RatedWaterVolFlowRate);
    3633         137 :                 } else if (simpleWatertoAirHP.WAHPType == WatertoAirHP::Heating) {
    3634         137 :                     state.dataRptCoilSelection->coilSelectionReportObj->setCoilFinalSizes(
    3635             :                         state,
    3636         137 :                         simpleWatertoAirHP.Name,
    3637         274 :                         format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast<int>(simpleWatertoAirHP.WAHPType)]),
    3638             :                         simpleWatertoAirHP.RatedCapHeat,
    3639             :                         simpleWatertoAirHP.RatedCapHeat,
    3640             :                         simpleWatertoAirHP.RatedAirVolFlowRate,
    3641             :                         simpleWatertoAirHP.RatedWaterVolFlowRate);
    3642             :                 }
    3643         274 :                 simpleWatertoAirHP.reportCoilFinalSizes = false;
    3644             :             }
    3645             :         }
    3646    43852909 :     }
    3647             : 
    3648             :     //        End of Update subroutines for the WatertoAirHP Module
    3649             :     // *****************************************************************************
    3650             : 
    3651           0 :     Real64 CalcEffectiveSHR(EnergyPlusData &state,
    3652             :                             int const HPNum,         // Index number for cooling coil
    3653             :                             Real64 const SHRss,      // Steady-state sensible heat ratio
    3654             :                             HVAC::FanOp const fanOp, // Fan/compressor cycling scheme indicator
    3655             :                             Real64 const RTF,        // Compressor run-time fraction
    3656             :                             Real64 const QLatRated,  // Rated latent capacity
    3657             :                             Real64 const QLatActual, // Actual latent capacity
    3658             :                             Real64 const EnteringDB, // Entering air dry-bulb temperature
    3659             :                             Real64 const EnteringWB  // Entering air wet-bulb temperature
    3660             :     )
    3661             :     {
    3662             : 
    3663             :         // FUNCTION INFORMATION:
    3664             :         //    AUTHOR         Richard Raustad, FSEC
    3665             :         //    DATE WRITTEN   September 2003
    3666             :         //    MODIFIED       Kenneth Tang (Aug 2004) Added capability for simulating FanOp::Cycling
    3667             : 
    3668             :         // PURPOSE OF THIS FUNCTION:
    3669             :         //    Adjust sensible heat ratio to account for degradation of DX coil latent
    3670             :         //    capacity at part-load (cycling) conditions.
    3671             : 
    3672             :         // METHODOLOGY EMPLOYED:
    3673             :         //    With model parameters entered by the user, the part-load latent performance
    3674             :         //    of a DX cooling coil is determined for a constant air flow system with
    3675             :         //    a cooling coil that cycles on/off. The model calculates the time
    3676             :         //    required for condensate to begin falling from the cooling coil.
    3677             :         //    Runtimes greater than this are integrated to a "part-load" latent
    3678             :         //    capacity which is used to determine the "part-load" sensible heat ratio.
    3679             :         //    See reference below for additional details (linear decay model, Eq. 8b).
    3680             : 
    3681             :         //    For cycling fan operation, a modified version of Henderson and Rengarajan (1996)
    3682             :         //    model is used by ultilizing the fan delay time as the time-off (or time duration
    3683             :         //    for the re-evaporation of moisture from time coil). Refer to Tang, C.C. (2005)
    3684             : 
    3685             :         // REFERENCES:
    3686             :         //    (1) Henderson, H.I., K. Rengarajan.1996. A Model to Predict the Latent
    3687             :         //    Capacity of Air Conditioners and Heat Pumps at Part-Load Conditions
    3688             :         //    with Constant Fan Operation ASHRAE Transactions 102 (1), pp. 266-274.
    3689             :         //    (2) Tang,C.C.. 2005. Modeling Packaged Heat Pumps in a Quasi-Steady
    3690             :         //    State Energy Simulation Program. M.S. Thesis, Department of Mechanical and Aerospace Engineering,
    3691             :         //    Oklahoma State University. (downloadable from www.hvac.okstate.edu)
    3692             : 
    3693             :         // Return value
    3694             :         Real64 SHReff; // Effective sensible heat ratio, includes degradation due to cycling effects
    3695             : 
    3696             :         // FUNCTION LOCAL VARIABLE DECLARATIONS:
    3697             :         Real64 Twet; // Nominal time for condensate to begin leaving the coil's condensate drain line
    3698             :         // at the current operating conditions (sec)
    3699             :         Real64 Gamma; // Initial moisture evaporation rate divided by steady-state AC latent capacity
    3700             :         // at the current operating conditions
    3701             :         Real64 Twet_Rated;                 // Twet at rated conditions (coil air flow rate and air temperatures), sec
    3702             :         Real64 Gamma_Rated;                // Gamma at rated conditions (coil air flow rate and air temperatures)
    3703             :         Real64 Twet_max;                   // Maximum allowed value for Twet
    3704             :         Real64 MaxONOFFCyclesperHour;      // Maximum cycling rate of heat pump [cycles/hr]
    3705             :         Real64 LatentCapacityTimeConstant; // Latent capacity time constant [s]
    3706             :         Real64 FanDelayTime;               // Fan delay time, time delay for the HP's fan to
    3707             :         // shut off after compressor cycle off  [s]
    3708             :         Real64 Ton;     // Coil on time (sec)
    3709             :         Real64 Toff;    // Coil off time (sec)
    3710             :         Real64 Toffa;   // Actual coil off time (sec). Equations valid for Toff <= (2.0 * Twet/Gamma)
    3711             :         Real64 aa;      // Intermediate variable
    3712             :         Real64 To1;     // Intermediate variable (first guess at To). To = time to the start of moisture removal
    3713             :         Real64 To2;     // Intermediate variable (second guess at To). To = time to the start of moisture removal
    3714             :         Real64 Error;   // Error for iteration (DO) loop
    3715             :         Real64 LHRmult; // Latent Heat Ratio (LHR) multiplier. The effective latent heat ratio LHR = (1-SHRss)*LHRmult
    3716             : 
    3717           0 :         auto &simpleWatertoAirHP(state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(HPNum));
    3718             : 
    3719           0 :         Twet_Rated = simpleWatertoAirHP.Twet_Rated;
    3720           0 :         Gamma_Rated = simpleWatertoAirHP.Gamma_Rated;
    3721           0 :         MaxONOFFCyclesperHour = simpleWatertoAirHP.MaxONOFFCyclesperHour;
    3722           0 :         LatentCapacityTimeConstant = simpleWatertoAirHP.LatentCapacityTimeConstant;
    3723           0 :         FanDelayTime = simpleWatertoAirHP.FanDelayTime;
    3724             : 
    3725             :         //  No moisture evaporation (latent degradation) occurs for runtime fraction of 1.0
    3726             :         //  All latent degradation model parameters cause divide by 0.0 if not greater than 0.0
    3727             :         //  Latent degradation model parameters initialize to 0.0 meaning no evaporation model used.
    3728           0 :         if ((RTF >= 1.0) || (QLatRated == 0.0) || (QLatActual == 0.0) || (Twet_Rated <= 0.0) || (Gamma_Rated <= 0.0) ||
    3729           0 :             (MaxONOFFCyclesperHour <= 0.0) || (LatentCapacityTimeConstant <= 0.0) || (RTF <= 0.0)) {
    3730           0 :             SHReff = SHRss;
    3731           0 :             return SHReff;
    3732             :         }
    3733             : 
    3734           0 :         Twet_max = 9999.0; // high limit for Twet
    3735             : 
    3736             :         //  Calculate the model parameters at the actual operating conditions
    3737           0 :         Twet = min(Twet_Rated * QLatRated / (QLatActual + 1.e-10), Twet_max);
    3738           0 :         Gamma = Gamma_Rated * QLatRated * (EnteringDB - EnteringWB) / ((26.7 - 19.4) * QLatActual + 1.e-10);
    3739             : 
    3740             :         //  Calculate the compressor on and off times using a converntional thermostat curve
    3741           0 :         Ton = 3600.0 / (4.0 * MaxONOFFCyclesperHour * (1.0 - RTF)); // duration of cooling coil on-cycle (sec)
    3742             : 
    3743           0 :         if ((fanOp == HVAC::FanOp::Cycling) && (FanDelayTime != 0.0)) {
    3744             :             // For FanOp::Cycling, moisture is evaporated from the cooling coil back to the air stream
    3745             :             // until the fan cycle off. Assume no evaporation from the coil after the fan shuts off.
    3746           0 :             Toff = FanDelayTime;
    3747             :         } else {
    3748             :             // For FanOp::Continuous, moisture is evaporated from the cooling coil back to the air stream
    3749             :             // for the entire heat pump off-cycle.
    3750           0 :             Toff = 3600.0 / (4.0 * MaxONOFFCyclesperHour * RTF); // duration of cooling coil off-cycle (sec)
    3751             :         }
    3752             : 
    3753             :         //  Cap Toff to meet the equation restriction
    3754           0 :         if (Gamma > 0.0) {
    3755           0 :             Toffa = min(Toff, 2.0 * Twet / Gamma);
    3756             :         } else {
    3757           0 :             Toffa = Toff;
    3758             :         }
    3759             : 
    3760             :         //  Use sucessive substitution to solve for To
    3761           0 :         aa = (Gamma * Toffa) - (0.25 / Twet) * pow_2(Gamma) * pow_2(Toffa);
    3762             : 
    3763           0 :         To1 = aa + LatentCapacityTimeConstant;
    3764           0 :         Error = 1.0;
    3765           0 :         while (Error > 0.001) {
    3766           0 :             To2 = aa - LatentCapacityTimeConstant * (std::exp(-To1 / LatentCapacityTimeConstant) - 1.0);
    3767           0 :             Error = std::abs((To2 - To1) / To1);
    3768           0 :             To1 = To2;
    3769             :         }
    3770             : 
    3771             :         //  Adjust Sensible Heat Ratio (SHR) using Latent Heat Ratio (LHR) multiplier
    3772             :         //  Floating underflow errors occur when -Ton/LatentCapacityTimeConstant is a large negative number.
    3773             :         //  Cap lower limit at -700 to avoid the underflow errors.
    3774           0 :         aa = std::exp(max(-700.0, -Ton / LatentCapacityTimeConstant));
    3775             :         //  Calculate latent heat ratio multiplier
    3776           0 :         LHRmult = max(((Ton - To2) / (Ton + LatentCapacityTimeConstant * (aa - 1.0))), 0.0);
    3777             : 
    3778             :         //  Calculate part-load or "effective" sensible heat ratio
    3779           0 :         SHReff = 1.0 - (1.0 - SHRss) * LHRmult;
    3780             : 
    3781           0 :         if (SHReff < SHRss) SHReff = SHRss; // Effective SHR can be less than the steady-state SHR
    3782           0 :         if (SHReff > 1.0) SHReff = 1.0;     // Effective sensible heat ratio can't be greater than 1.0
    3783             : 
    3784           0 :         return SHReff;
    3785             :     }
    3786             : 
    3787         275 :     int GetCoilIndex(EnergyPlusData &state,
    3788             :                      std::string const &CoilType, // must match coil types in this module
    3789             :                      std::string const &CoilName, // must match coil names for the coil type
    3790             :                      bool &ErrorsFound            // set to true if problem
    3791             :     )
    3792             :     {
    3793             : 
    3794             :         // FUNCTION INFORMATION:
    3795             :         //       AUTHOR         R. Raustad
    3796             :         //       DATE WRITTEN   August 2007
    3797             : 
    3798             :         // PURPOSE OF THIS FUNCTION:
    3799             :         // This function looks up the coil capacity for the given coil and returns it.  If
    3800             :         // incorrect coil type or name is given, ErrorsFound is returned as true and index is returned
    3801             :         // as zero.
    3802             : 
    3803             :         // Return value
    3804             :         int IndexNum; // returned index of matched coil
    3805             : 
    3806             :         // Obtains and Allocates WatertoAirHP related parameters from input file
    3807         275 :         if (state.dataWaterToAirHeatPumpSimple->GetCoilsInputFlag) { // First time subroutine has been entered
    3808          18 :             GetSimpleWatertoAirHPInput(state);
    3809          18 :             state.dataWaterToAirHeatPumpSimple->GetCoilsInputFlag = false;
    3810             :         }
    3811             : 
    3812         275 :         IndexNum = Util::FindItemInList(CoilName, state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP);
    3813             : 
    3814         275 :         if (IndexNum == 0) {
    3815           0 :             ShowSevereError(state, format(R"(Could not find CoilType="{}" with Name="{}")", CoilType, CoilName));
    3816           0 :             ErrorsFound = true;
    3817             :         }
    3818             : 
    3819         275 :         return IndexNum;
    3820             :     }
    3821             : 
    3822         300 :     Real64 GetCoilCapacity(EnergyPlusData &state,
    3823             :                            std::string const &CoilType, // must match coil types in this module
    3824             :                            std::string const &CoilName, // must match coil names for the coil type
    3825             :                            bool &ErrorsFound            // set to true if problem
    3826             :     )
    3827             :     {
    3828             : 
    3829             :         // FUNCTION INFORMATION:
    3830             :         //       AUTHOR         Linda Lawrie
    3831             :         //       DATE WRITTEN   February 2006
    3832             : 
    3833             :         // PURPOSE OF THIS FUNCTION:
    3834             :         // This function looks up the coil capacity for the given coil and returns it.  If
    3835             :         // incorrect coil type or name is given, ErrorsFound is returned as true and capacity is returned
    3836             :         // as negative.
    3837             : 
    3838             :         // Return value
    3839             :         Real64 CoilCapacity; // returned capacity of matched coil
    3840             : 
    3841             :         // FUNCTION LOCAL VARIABLE DECLARATIONS:
    3842             :         int WhichCoil;
    3843             : 
    3844             :         // Obtains and Allocates WatertoAirHP related parameters from input file
    3845         300 :         if (state.dataWaterToAirHeatPumpSimple->GetCoilsInputFlag) { // First time subroutine has been entered
    3846           0 :             GetSimpleWatertoAirHPInput(state);
    3847           0 :             state.dataWaterToAirHeatPumpSimple->GetCoilsInputFlag = false;
    3848             :         }
    3849             : 
    3850         437 :         if (Util::SameString(CoilType, "COIL:COOLING:WATERTOAIRHEATPUMP:EQUATIONFIT") ||
    3851         437 :             Util::SameString(CoilType, "COIL:HEATING:WATERTOAIRHEATPUMP:EQUATIONFIT")) {
    3852         300 :             WhichCoil = Util::FindItemInList(CoilName, state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP);
    3853         300 :             if (WhichCoil != 0) {
    3854         300 :                 if (Util::SameString(CoilType, "COIL:HEATING:WATERTOAIRHEATPUMP:EQUATIONFIT")) {
    3855         137 :                     CoilCapacity = state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(WhichCoil).RatedCapHeat;
    3856             :                 } else {
    3857         163 :                     CoilCapacity = state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(WhichCoil).RatedCapCoolTotal;
    3858             : 
    3859         163 :                     int companionHeatingCoil = state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(WhichCoil).CompanionHeatingCoilNum;
    3860         163 :                     if (companionHeatingCoil > 0) {
    3861         285 :                         if (CoilCapacity == DataSizing::AutoSize &&
    3862         122 :                             state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(companionHeatingCoil).WAHPPlantType ==
    3863         122 :                                 DataPlant::PlantEquipmentType::CoilWAHPHeatingEquationFit &&
    3864         407 :                             state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(companionHeatingCoil).RatedCapHeat == DataSizing::AutoSize &&
    3865         122 :                             state.dataSize->DXCoolCap > 0) {
    3866             :                             // Heating coil has not yet been sized, returning the temporary cooling capacity
    3867          26 :                             CoilCapacity = state.dataSize->DXCoolCap;
    3868             :                         }
    3869             :                     }
    3870             :                 }
    3871             :             }
    3872             :         } else {
    3873           0 :             WhichCoil = 0;
    3874             :         }
    3875             : 
    3876         300 :         if (WhichCoil == 0) {
    3877           0 :             ShowSevereError(state, format(R"(Could not find CoilType="{}" with Name="{}")", CoilType, CoilName));
    3878           0 :             ErrorsFound = true;
    3879           0 :             CoilCapacity = -1000.0;
    3880             :         }
    3881             : 
    3882         300 :         return CoilCapacity;
    3883             :     }
    3884             : 
    3885         274 :     Real64 GetCoilAirFlowRate(EnergyPlusData &state,
    3886             :                               std::string const &CoilType, // must match coil types in this module
    3887             :                               std::string const &CoilName, // must match coil names for the coil type
    3888             :                               bool &ErrorsFound            // set to true if problem
    3889             :     )
    3890             :     {
    3891             : 
    3892             :         // FUNCTION INFORMATION:
    3893             :         //       AUTHOR         Richard Raustad, FSEC
    3894             :         //       DATE WRITTEN   October 2011
    3895             : 
    3896             :         // PURPOSE OF THIS FUNCTION:
    3897             :         // This function looks up the coil air flow rate for the given coil and returns it.  If
    3898             :         // incorrect coil type or name is given, ErrorsFound is returned as true and capacity is returned
    3899             :         // as negative.
    3900             : 
    3901             :         // Return value
    3902             :         Real64 CoilAirFlowRate; // returned air volume flow rate of matched coil
    3903             : 
    3904             :         // FUNCTION LOCAL VARIABLE DECLARATIONS:
    3905             :         int WhichCoil;
    3906             : 
    3907             :         // Obtains and Allocates WatertoAirHP related parameters from input file
    3908         274 :         if (state.dataWaterToAirHeatPumpSimple->GetCoilsInputFlag) { // First time subroutine has been entered
    3909           0 :             GetSimpleWatertoAirHPInput(state);
    3910           0 :             state.dataWaterToAirHeatPumpSimple->GetCoilsInputFlag = false;
    3911             :         }
    3912             : 
    3913         411 :         if (Util::SameString(CoilType, "COIL:COOLING:WATERTOAIRHEATPUMP:EQUATIONFIT") ||
    3914         411 :             Util::SameString(CoilType, "COIL:HEATING:WATERTOAIRHEATPUMP:EQUATIONFIT")) {
    3915         274 :             WhichCoil = Util::FindItemInList(CoilName, state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP);
    3916         274 :             if (WhichCoil != 0) {
    3917         274 :                 CoilAirFlowRate = state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(WhichCoil).RatedAirVolFlowRate;
    3918             :             }
    3919             :         } else {
    3920           0 :             WhichCoil = 0;
    3921             :         }
    3922             : 
    3923         274 :         if (WhichCoil == 0) {
    3924           0 :             ShowSevereError(state, format(R"(Could not find CoilType="{}" with Name="{}")", CoilType, CoilName));
    3925           0 :             ErrorsFound = true;
    3926           0 :             CoilAirFlowRate = -1000.0;
    3927             :         }
    3928             : 
    3929         274 :         return CoilAirFlowRate;
    3930             :     }
    3931             : 
    3932         222 :     int GetCoilInletNode(EnergyPlusData &state,
    3933             :                          std::string const &CoilType, // must match coil types in this module
    3934             :                          std::string const &CoilName, // must match coil names for the coil type
    3935             :                          bool &ErrorsFound            // set to true if problem
    3936             :     )
    3937             :     {
    3938             : 
    3939             :         // FUNCTION INFORMATION:
    3940             :         //       AUTHOR         Linda Lawrie
    3941             :         //       DATE WRITTEN   February 2006
    3942             : 
    3943             :         // PURPOSE OF THIS FUNCTION:
    3944             :         // This function looks up the given coil and returns the inlet node.  If
    3945             :         // incorrect coil type or name is given, ErrorsFound is returned as true and value is returned
    3946             :         // as zero.
    3947             : 
    3948             :         // Return value
    3949             :         int NodeNumber; // returned outlet node of matched coil
    3950             : 
    3951             :         // FUNCTION LOCAL VARIABLE DECLARATIONS:
    3952             :         int WhichCoil;
    3953             : 
    3954             :         // Obtains and Allocates WatertoAirHP related parameters from input file
    3955         222 :         if (state.dataWaterToAirHeatPumpSimple->GetCoilsInputFlag) { // First time subroutine has been entered
    3956           0 :             GetSimpleWatertoAirHPInput(state);
    3957           0 :             state.dataWaterToAirHeatPumpSimple->GetCoilsInputFlag = false;
    3958             :         }
    3959             : 
    3960         222 :         WhichCoil = Util::FindItemInList(CoilName, state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP);
    3961         222 :         if (WhichCoil != 0) {
    3962         222 :             NodeNumber = state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(WhichCoil).AirInletNodeNum;
    3963             :         }
    3964             : 
    3965         222 :         if (WhichCoil == 0) {
    3966           0 :             ShowSevereError(state, format(R"(Could not find CoilType="{}" with Name="{}")", CoilType, CoilName));
    3967           0 :             ErrorsFound = true;
    3968           0 :             NodeNumber = 0;
    3969             :         }
    3970             : 
    3971         222 :         return NodeNumber;
    3972             :     }
    3973             : 
    3974         222 :     int GetCoilOutletNode(EnergyPlusData &state,
    3975             :                           std::string const &CoilType, // must match coil types in this module
    3976             :                           std::string const &CoilName, // must match coil names for the coil type
    3977             :                           bool &ErrorsFound            // set to true if problem
    3978             :     )
    3979             :     {
    3980             : 
    3981             :         // FUNCTION INFORMATION:
    3982             :         //       AUTHOR         R. Raustad
    3983             :         //       DATE WRITTEN   July 2007
    3984             : 
    3985             :         // PURPOSE OF THIS FUNCTION:
    3986             :         // This function looks up the given coil and returns the outlet node.  If
    3987             :         // incorrect coil type or name is given, ErrorsFound is returned as true and value is returned
    3988             :         // as zero.
    3989             : 
    3990             :         // Return value
    3991             :         int NodeNumber; // returned outlet node of matched coil
    3992             : 
    3993             :         // FUNCTION LOCAL VARIABLE DECLARATIONS:
    3994             :         int WhichCoil;
    3995             : 
    3996             :         // Obtains and Allocates WatertoAirHP related parameters from input file
    3997         222 :         if (state.dataWaterToAirHeatPumpSimple->GetCoilsInputFlag) { // First time subroutine has been entered
    3998           0 :             GetSimpleWatertoAirHPInput(state);
    3999           0 :             state.dataWaterToAirHeatPumpSimple->GetCoilsInputFlag = false;
    4000             :         }
    4001             : 
    4002         222 :         WhichCoil = Util::FindItemInList(CoilName, state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP);
    4003         222 :         if (WhichCoil != 0) {
    4004         222 :             NodeNumber = state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(WhichCoil).AirOutletNodeNum;
    4005             :         }
    4006             : 
    4007         222 :         if (WhichCoil == 0) {
    4008           0 :             ShowSevereError(state, format(R"(Could not find CoilType="{}" with Name="{}")", CoilType, CoilName));
    4009           0 :             ErrorsFound = true;
    4010           0 :             NodeNumber = 0;
    4011             :         }
    4012             : 
    4013         222 :         return NodeNumber;
    4014             :     }
    4015             : 
    4016         137 :     void SetSimpleWSHPData(EnergyPlusData &state,
    4017             :                            int const SimpleWSHPNum,                         // Number of OA Controller
    4018             :                            bool &ErrorsFound,                               // Set to true if certain errors found
    4019             :                            HVAC::WaterFlow const WaterCyclingMode,          // the coil water flow mode (cycling, constant or constantondemand)
    4020             :                            ObjexxFCL::Optional_int CompanionCoolingCoilNum, // Index to cooling coil for heating coil = SimpleWSHPNum
    4021             :                            ObjexxFCL::Optional_int CompanionHeatingCoilNum  // Index to heating coil for cooling coil = SimpleWSHPNum
    4022             :     )
    4023             :     {
    4024             : 
    4025             :         // SUBROUTINE INFORMATION:
    4026             :         //       AUTHOR         Richard Raustad
    4027             :         //       DATE WRITTEN   June 2009
    4028             : 
    4029             :         // PURPOSE OF THIS SUBROUTINE:
    4030             :         // This routine was designed to "push" information from a parent object to
    4031             :         // this WSHP coil object.
    4032             : 
    4033             :         // Obtains and Allocates WatertoAirHP related parameters from input file
    4034         137 :         if (state.dataWaterToAirHeatPumpSimple->GetCoilsInputFlag) { // First time subroutine has been entered
    4035           0 :             GetSimpleWatertoAirHPInput(state);
    4036           0 :             state.dataWaterToAirHeatPumpSimple->GetCoilsInputFlag = false;
    4037             :         }
    4038             : 
    4039         137 :         if (SimpleWSHPNum <= 0 || SimpleWSHPNum > state.dataWaterToAirHeatPumpSimple->NumWatertoAirHPs) {
    4040           0 :             ShowSevereError(state,
    4041           0 :                             format("SetSimpleWSHPData: called with WSHP Coil Number out of range={} should be >0 and <{}",
    4042             :                                    SimpleWSHPNum,
    4043           0 :                                    state.dataWaterToAirHeatPumpSimple->NumWatertoAirHPs));
    4044           0 :             ErrorsFound = true;
    4045           0 :             return;
    4046             :         }
    4047             : 
    4048         137 :         state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(SimpleWSHPNum).WaterCyclingMode = WaterCyclingMode;
    4049         137 :         if (present(CompanionCoolingCoilNum)) {
    4050           0 :             state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(SimpleWSHPNum).CompanionCoolingCoilNum = CompanionCoolingCoilNum;
    4051           0 :             state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(CompanionCoolingCoilNum).CompanionHeatingCoilNum = SimpleWSHPNum;
    4052           0 :             state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(CompanionCoolingCoilNum).WaterCyclingMode = WaterCyclingMode;
    4053             :         }
    4054             : 
    4055         137 :         if (present(CompanionHeatingCoilNum)) {
    4056         137 :             state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(SimpleWSHPNum).CompanionHeatingCoilNum = CompanionHeatingCoilNum;
    4057         137 :             state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(CompanionHeatingCoilNum).CompanionCoolingCoilNum = SimpleWSHPNum;
    4058         137 :             state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(CompanionHeatingCoilNum).WaterCyclingMode = WaterCyclingMode;
    4059             :         }
    4060             :     }
    4061             : 
    4062         274 :     void CheckSimpleWAHPRatedCurvesOutputs(EnergyPlusData &state, std::string const &CoilName)
    4063             :     {
    4064             :         int WhichCoil;
    4065         274 :         constexpr Real64 Tref(283.15); // Refrence Temperature for performance curves,10C [K]
    4066             :         static constexpr std::string_view RoutineName("CheckSimpleWAHPRatedCurvesOutputs");
    4067             : 
    4068         274 :         WhichCoil = Util::FindItemInList(CoilName, state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP);
    4069             : 
    4070         274 :         if (WhichCoil != 0) {
    4071         274 :             if (state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(WhichCoil).WAHPType == WatertoAirHP::Cooling) {
    4072         137 :                 int TotalCoolCapCurveIndex = state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(WhichCoil).TotalCoolCapCurveIndex;
    4073         137 :                 int CoolPowCurveIndex = state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(WhichCoil).CoolPowCurveIndex;
    4074         137 :                 int SensCoolCapCurveIndex = state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(WhichCoil).SensCoolCapCurveIndex;
    4075         137 :                 if (state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(WhichCoil).RatedEntAirWetbulbTemp != DataSizing::AutoSize) {
    4076         137 :                     Real64 RatedratioTWB = (state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(WhichCoil).RatedEntAirWetbulbTemp +
    4077         137 :                                             state.dataWaterToAirHeatPumpSimple->CelsiustoKelvin) /
    4078         137 :                                            Tref;
    4079         137 :                     Real64 RatedratioTS = (state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(WhichCoil).RatedEntWaterTemp +
    4080         137 :                                            state.dataWaterToAirHeatPumpSimple->CelsiustoKelvin) /
    4081         137 :                                           Tref;
    4082         137 :                     Real64 RatedTotCapTempModFac = Curve::CurveValue(state, TotalCoolCapCurveIndex, RatedratioTWB, RatedratioTS, 1.0, 1.0);
    4083         137 :                     Real64 RatedCoolPowerTempModFac = Curve::CurveValue(state, CoolPowCurveIndex, RatedratioTWB, RatedratioTS, 1.0, 1.0);
    4084         137 :                     if (RatedTotCapTempModFac > 1.02 || RatedTotCapTempModFac < 0.98) {
    4085           0 :                         ShowWarningError(state,
    4086           0 :                                          format("{}: Coil:Cooling:WaterToAirHeatPump:EquationFit=\"{}\"",
    4087           0 :                                                 std::string{RoutineName},
    4088           0 :                                                 state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(WhichCoil).Name));
    4089           0 :                         ShowContinueError(state,
    4090             :                                           "Total cooling capacity as a function of temperature curve output is not equal to 1.0 (+ or - 2%) "
    4091             :                                           "at rated conditions.");
    4092           0 :                         ShowContinueError(state, format("Curve output at rated conditions = {:.3T}", RatedTotCapTempModFac));
    4093             :                     }
    4094         137 :                     if (RatedCoolPowerTempModFac > 1.02 || RatedCoolPowerTempModFac < 0.98) {
    4095           0 :                         ShowWarningError(state,
    4096           0 :                                          format("{}: Coil:Cooling:WaterToAirHeatPump:EquationFit=\"{}\"",
    4097           0 :                                                 std::string{RoutineName},
    4098           0 :                                                 state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(WhichCoil).Name));
    4099           0 :                         ShowContinueError(state,
    4100             :                                           "Cooling power consumption as a function of temperature curve output is not equal to 1.0 (+ or - 2%) "
    4101             :                                           "at rated conditions.");
    4102           0 :                         ShowContinueError(state, format("Curve output at rated conditions = {:.3T}", RatedCoolPowerTempModFac));
    4103             :                     }
    4104         137 :                     if (state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(WhichCoil).RatedEntAirDrybulbTemp != DataSizing::AutoSize) {
    4105         137 :                         Real64 RatedratioTDB = (state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(WhichCoil).RatedEntAirDrybulbTemp +
    4106         137 :                                                 state.dataWaterToAirHeatPumpSimple->CelsiustoKelvin) /
    4107         137 :                                                Tref;
    4108             :                         Real64 RatedSensCapTempModFac =
    4109         137 :                             Curve::CurveValue(state, SensCoolCapCurveIndex, RatedratioTDB, RatedratioTWB, RatedratioTS, 1.0, 1.0);
    4110         137 :                         if (RatedSensCapTempModFac > 1.02 || RatedSensCapTempModFac < 0.98) {
    4111           0 :                             ShowWarningError(state,
    4112           0 :                                              format("{}: Coil:Cooling:WaterToAirHeatPump:EquationFit=\"{}\"",
    4113           0 :                                                     std::string{RoutineName},
    4114           0 :                                                     state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(WhichCoil).Name));
    4115           0 :                             ShowContinueError(state,
    4116             :                                               "Sensible cooling capacity as a function of temperature curve output is not equal to 1.0 (+ or - 2%) "
    4117             :                                               "at rated conditions.");
    4118           0 :                             ShowContinueError(state, format("Curve output at rated conditions = {:.3T}", RatedSensCapTempModFac));
    4119             :                         }
    4120             :                     }
    4121             :                 }
    4122         137 :             } else if (state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(WhichCoil).WAHPType == WatertoAirHP::Heating) {
    4123         137 :                 if (state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(WhichCoil).RatedEntAirDrybulbTemp != DataSizing::AutoSize) {
    4124         137 :                     int HeatCapCurveIndex = state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(WhichCoil).HeatCapCurveIndex;
    4125         137 :                     int HeatPowCurveIndex = state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(WhichCoil).HeatPowCurveIndex;
    4126         137 :                     Real64 RatedHeatratioTDB = (state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(WhichCoil).RatedEntAirDrybulbTemp +
    4127         137 :                                                 state.dataWaterToAirHeatPumpSimple->CelsiustoKelvin) /
    4128         137 :                                                Tref;
    4129         137 :                     Real64 RatedHeatratioTS = (state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(WhichCoil).RatedEntWaterTemp +
    4130         137 :                                                state.dataWaterToAirHeatPumpSimple->CelsiustoKelvin) /
    4131         137 :                                               Tref;
    4132         137 :                     Real64 RatedHeatCapTempModFac = Curve::CurveValue(state, HeatCapCurveIndex, RatedHeatratioTDB, RatedHeatratioTS, 1.0, 1.0);
    4133         137 :                     Real64 RatedHeatPowerTempModFac = Curve::CurveValue(state, HeatPowCurveIndex, RatedHeatratioTDB, RatedHeatratioTS, 1.0, 1.0);
    4134         137 :                     if (RatedHeatCapTempModFac > 1.02 || RatedHeatCapTempModFac < 0.98) {
    4135           0 :                         ShowWarningError(state,
    4136           0 :                                          format("{}: Coil:Heating:WaterToAirHeatPump:EquationFit=\"{}\"",
    4137           0 :                                                 std::string{RoutineName},
    4138           0 :                                                 state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(WhichCoil).Name));
    4139           0 :                         ShowContinueError(
    4140             :                             state, "Heating capacity as a function of temperature curve output is not equal to 1.0 (+ or - 2%) at rated conditions.");
    4141           0 :                         ShowContinueError(state, format("Curve output at rated conditions = {:.3T}", RatedHeatCapTempModFac));
    4142             :                     }
    4143         137 :                     if (RatedHeatPowerTempModFac > 1.02 || RatedHeatPowerTempModFac < 0.98) {
    4144           0 :                         ShowWarningError(state,
    4145           0 :                                          format("{}: Coil:Heating:WaterToAirHeatPump:EquationFit=\"{}\"",
    4146           0 :                                                 std::string{RoutineName},
    4147           0 :                                                 state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(WhichCoil).Name));
    4148           0 :                         ShowContinueError(state,
    4149             :                                           "Heating power consumption as a function of temperature curve output is not equal to 1.0 (+ or - 2%) at "
    4150             :                                           "rated conditions.");
    4151           0 :                         ShowContinueError(state, format("Curve output at rated conditions = {:.3T}", RatedHeatPowerTempModFac));
    4152             :                     }
    4153             :                 }
    4154             :             }
    4155             :         }
    4156         274 :     }
    4157             : } // namespace WaterToAirHeatPumpSimple
    4158             : 
    4159             : } // namespace EnergyPlus

Generated by: LCOV version 1.14