LCOV - code coverage report
Current view: top level - EnergyPlus - StandardRatings.cc (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 3316 3750 88.4 %
Date: 2024-08-23 23:50:59 Functions: 45 45 100.0 %

          Line data    Source code
       1             : // EnergyPlus, Copyright (c) 1996-2024, The Board of Trustees of the University of Illinois,
       2             : // The Regents of the University of California, through Lawrence Berkeley National Laboratory
       3             : // (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge
       4             : // National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other
       5             : // contributors. All rights reserved.
       6             : //
       7             : // NOTICE: This Software was developed under funding from the U.S. Department of Energy and the
       8             : // U.S. Government consequently retains certain rights. As such, the U.S. Government has been
       9             : // granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable,
      10             : // worldwide license in the Software to reproduce, distribute copies to the public, prepare
      11             : // derivative works, and perform publicly and display publicly, and to permit others to do so.
      12             : //
      13             : // Redistribution and use in source and binary forms, with or without modification, are permitted
      14             : // provided that the following conditions are met:
      15             : //
      16             : // (1) Redistributions of source code must retain the above copyright notice, this list of
      17             : //     conditions and the following disclaimer.
      18             : //
      19             : // (2) Redistributions in binary form must reproduce the above copyright notice, this list of
      20             : //     conditions and the following disclaimer in the documentation and/or other materials
      21             : //     provided with the distribution.
      22             : //
      23             : // (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory,
      24             : //     the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be
      25             : //     used to endorse or promote products derived from this software without specific prior
      26             : //     written permission.
      27             : //
      28             : // (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form
      29             : //     without changes from the version obtained under this License, or (ii) Licensee makes a
      30             : //     reference solely to the software portion of its product, Licensee must refer to the
      31             : //     software as "EnergyPlus version X" software, where "X" is the version number Licensee
      32             : //     obtained under this License and may not use a different name for the software. Except as
      33             : //     specifically required in this Section (4), Licensee shall not use in a company name, a
      34             : //     product name, in advertising, publicity, or other promotional activities any name, trade
      35             : //     name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly
      36             : //     similar designation, without the U.S. Department of Energy's prior written consent.
      37             : //
      38             : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
      39             : // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
      40             : // AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
      41             : // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
      42             : // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
      43             : // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
      44             : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
      45             : // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
      46             : // POSSIBILITY OF SUCH DAMAGE.
      47             : 
      48             : // C++ Headers
      49             : #include <string>
      50             : 
      51             : // ObjexxFCL Headers
      52             : #include <ObjexxFCL/Fmath.hh>
      53             : 
      54             : // EnergyPlus Headers
      55             : #include <EnergyPlus/CurveManager.hh>
      56             : #include <EnergyPlus/Data/EnergyPlusData.hh>
      57             : #include <EnergyPlus/DataBranchAirLoopPlant.hh>
      58             : #include <EnergyPlus/DataEnvironment.hh>
      59             : #include <EnergyPlus/DataHVACGlobals.hh>
      60             : #include <EnergyPlus/FluidProperties.hh>
      61             : #include <EnergyPlus/General.hh>
      62             : #include <EnergyPlus/OutputReportPredefined.hh>
      63             : #include <EnergyPlus/Plant/DataPlant.hh>
      64             : #include <EnergyPlus/Psychrometrics.hh>
      65             : #include <EnergyPlus/StandardRatings.hh>
      66             : #include <EnergyPlus/UtilityRoutines.hh>
      67             : #include <EnergyPlus/VariableSpeedCoils.hh>
      68             : 
      69             : namespace EnergyPlus {
      70             : 
      71             : namespace StandardRatings {
      72             : 
      73             :     // MODULE INFORMATION:
      74             :     //       AUTHOR         Chandan Sharma
      75             :     //       DATE WRITTEN   February 2012
      76             :     //       MODIFIED       February 2013, Bereket Nigusse
      77             :     //       RE-ENGINEERED  na
      78             : 
      79             :     // PURPOSE OF THIS MODULE:
      80             :     // This module contains the subroutines required to calculate the following standard ratings of HVAC equipment
      81             :     // 1) Integrated Part Load Value (IPLV) rating for EIR and Reformulated EIR chillers
      82             :     // 2) a) Standard Rated (net) Cooling Capacity
      83             :     //    b) Seasonal Energy Efficiency Ratio (SEER)
      84             :     //    c) Energy Efficiency Ratio (EER),
      85             :     //    d) Integrated Energy Efficiency Ratio (IEER)
      86             :     //       for Air-to-Air Direct Expansion Air Conditioner and Heat Pumps having a single-speed compressor,
      87             :     //       fixed speed indoor supply air fan, and air-cooled condensers.
      88             :     // 3) Heating Seasonal Performance Factor (HSPF) for Air-Source Direct Expansion Heat Pumps having a single-speed compressor,
      89             :     //       fixed speed indoor supply air fan
      90             :     // 4) Seasonal Energy Efficiency Ratio (SEER) for Air-Source Direct Expansion multi-speed compressor Heat Pumps
      91             :     // 5) Heating Seasonal Performance Factor (HSPF) for Air-Source Direct Expansion multi-speed compressor Heat Pumps
      92             :     // METHODOLOGY EMPLOYED:
      93             :     // Using the user specified reference capacity, reference COP and performance curves, the chiller or DX coil models are executed
      94             :     // for standard test conditions as specified in ANSI/AHRI 550/590, 210/240 and 340/360. Then results of the simulated test points
      95             :     // are processed into standard ratings according to standard's procedures.
      96             : 
      97             :     // REFERENCES:
      98             :     // (1) AHRI Standard 550/590-2011:  Standard for Performance Rating of Water-Chilling Packages using the Vapor
      99             :     //                                  Compression Cycle. Arlington, VA:  Air-Conditioning, Heating,
     100             :     //                                  and Refrigeration Institute.
     101             :     // (2) ANSI/AHRI Standard 210/240-2008:  Standard for Performance Rating of Unitary Air-Conditioning and
     102             :     //                                       Air-Source Heat Pumps. Arlington, VA:  Air-Conditioning, Heating
     103             :     //                                       , and Refrigeration Institute.
     104             :     // (3) ANSI/AHRI Standard 340/360-2007:  Standard for Performance Rating of Commercial and Industrial
     105             :     //                                       Unitary Air-Conditioning and Heat Pump Equipment.  Arlington,
     106             :     //                                       VA:  Air-Conditioning, Heating, and Refrigeration Institute.
     107             : 
     108             :     // OTHER NOTES: none
     109             : 
     110             :     // Data
     111             :     Real64 constexpr IndoorCoilInletAirWetBulbTempRated(19.44);     // 19.44C (67F)  Tests A2, B2, B1, and F1
     112             :     Real64 constexpr OutdoorCoilInletAirDryBulbTempRated(35.0);     // 35.00C (95F)  Tests A2, B2, B1, and F1
     113             :     Real64 constexpr OutdoorCoilInletAirDryBulbTempTestA2(35.0);    // 35.00C (95F)  Test A2 (high speed)
     114             :     Real64 constexpr OutdoorCoilInletAirDryBulbTempTestB2(27.78);   // 27.78C (82F)  Test B2 (high speed)
     115             :     Real64 constexpr OutdoorCoilInletAirDryBulbTempTestB1(27.78);   // 27.78C (82F)  Test B1 (Low speed)
     116             :     Real64 constexpr OutdoorCoilInletAirDryBulbTempTestF1(19.44);   // 19.44C (67F)  Test B1 (Low speed)
     117             :     Real64 constexpr OutdoorCoilInletAirDryBulbTempTestEint(30.55); // 30.55 (87F) Test Eint
     118             : 
     119             :     // AHRI Standard 210/240-2008 Performance Test Conditions for Unitary Air-to-Air Air-Conditioning and Heat Pump Equipment
     120             :     // AHRI STANDARD 210/240 - 2023
     121             :     Real64 constexpr CoolingCoilInletAirWetBulbTempRated(19.44); // 19.44C (67F)  Tests A and B
     122             :     // AHRI STANDARD 210/240 - 2023
     123             :     Real64 constexpr OutdoorUnitInletAirDryBulbTempRated(35.0); // 35.00C (95F)  Test A (rated capacity)
     124             : 
     125             :     Real64 constexpr OutdoorUnitInletAirDryBulbTemp(27.78); // 27.78C (82F)  Test B (for SEER)
     126             :     Real64 constexpr AirMassFlowRatioRated(1.0);            // AHRI test is at the design flow rate and hence AirMassFlowRatio is 1.0
     127             :     // AHRI STANDARD 210/240 - 2017
     128             :     Real64 constexpr DefaultFanPowerPerEvapAirFlowRate(773.3); // 365 W/1000 scfm or 773.3 W/(m3/s). The AHRI standard
     129             :     // AHRI STANDARD 210/240 - 2023
     130             :     Real64 constexpr DefaultFanPowerPerEvapAirFlowRateSEER2(934.4); // 441 W/1000 scfm or 934.4 W/(m3/s). The AHRI standard
     131             :     // specifies a nominal/default fan electric power consumption per rated air
     132             :     // volume flow rate to account for indoor fan electric power consumption
     133             :     // when the standard tests are conducted on units that do not have an
     134             :     // indoor air circulating fan. Used if user doesn't enter a specific value.
     135             : 
     136             :     // AHRI STANDARD 210/240 - 2023
     137             :     Real64 constexpr PLRforSEER(0.5); // Part-load ratio for SEER calculation (single speed DX cooling coils)
     138             : 
     139             :     static constexpr std::array<Real64, 4> ReducedPLR = {1.0, 0.75, 0.50, 0.25};               // Reduced Capacity part-load conditions
     140             :     static constexpr std::array<Real64, 4> IEERWeightingFactor = {0.020, 0.617, 0.238, 0.125}; // EER Weighting factors (IEER)
     141             :     Real64 constexpr OADBTempLowReducedCapacityTest(18.3);                                     // Outdoor air dry-bulb temp in degrees C (65F)
     142             :     // Std. AHRI AHRI 340/360 Dry-bulb Temp at reduced capacity, <= 0.444
     143             : 
     144             :     // HSPF AHRI STANDARD 210/240 - 2017
     145             :     int constexpr TotalNumOfStandardDHRs(16);                                                  // Total number of standard design heating requirements
     146             :     static constexpr std::array<Real64, 6> TotalNumOfTemperatureBins = {9, 10, 13, 15, 18, 9}; // Total number of temperature bins for a region
     147             :     static constexpr std::array<Real64, 16> StandardDesignHeatingRequirement = {1465.36,
     148             :                                                                                 2930.71,
     149             :                                                                                 4396.07,
     150             :                                                                                 5861.42,
     151             :                                                                                 7326.78,
     152             :                                                                                 8792.14,
     153             :                                                                                 10257.49,
     154             :                                                                                 11722.85,
     155             :                                                                                 14653.56,
     156             :                                                                                 17584.27,
     157             :                                                                                 20514.98,
     158             :                                                                                 23445.70,
     159             :                                                                                 26376.41,
     160             :                                                                                 29307.12,
     161             :                                                                                 32237.83,
     162             :                                                                                 38099.26};
     163             : 
     164             :     // HSPF2 AHRI STANDARD 210/240 - 2023
     165             :     // BPS: As Fractional Bin hours are not summing up to 1 we using an adjusted array of total number of Temperature Bins per region.
     166             :     // static constexpr std::array<Real64, 6> TotalNumOfTemperatureBinsHSPF2 = {8, 8, 11, 13, 16, 7}; // Total number of temperature bins for each
     167             :     // region
     168             :     static constexpr std::array<Real64, 6> TotalNumOfTemperatureBinsHSPF2 = {9, 10, 13, 15, 18, 9};
     169             : 
     170             :     // Standardized DHRs from ANSI/AHRI 210/240 - 2017
     171             :     Real64 constexpr CorrectionFactor(0.77); // A correction factor which tends to improve the agreement
     172             :     // Slope Adjustment Factor (Cx)  from ANSI/AHRI 210/240 - 2023 (Section 11.2.2 - Table 14)
     173             :     // 1. Variable Speed Load Factor (Cvs) | Variable Speed  Equipment
     174             :     static constexpr std::array<Real64, 6> VariableSpeedLoadFactor = {1.03, 0.99, 1.21, 1.07, 1.08, 1.03};
     175             :     // 2. Heating Load Line Equation Slope Factor (C) | other Equipment types
     176             :     static constexpr std::array<Real64, 6> SpeedLoadFactor = {1.10, 1.06, 1.30, 1.15, 1.16, 1.11};
     177             : 
     178             :     // between calculated and measured building loads, dimensionless.
     179             :     Real64 constexpr CyclicDegradationCoeff(0.25);
     180             :     // For Single Stage Systems, if the optional CFull and DFull tests are not performed, a
     181             :     // default value of 0.20 shall be used for the cooling Degradation Coefficient
     182             :     Real64 constexpr CyclicDegradationCoeffSEER2(0.20); // ANSI/AHRI 210/240 2023 Section 6.1.3.1
     183             : 
     184             :     // Default Heating Degradation Coefficient | HSPF2
     185             :     // ANSI/AHRI Standard 2023 Section 6.1.3.2.1 -> For Single Stage Systems, if the optional H1CFull test or H1CLow is not performed, a default value
     186             :     // of 0.25 shall be used for the heating Degradation Coefficient
     187             :     Real64 constexpr CyclicHeatingDegradationCoeffHSPF2(0.25);
     188             : 
     189             :     // AHRI STANDARD 210/240 - 2017 & 2023
     190             :     static constexpr std::array<Real64, 6> OutdoorDesignTemperature = {2.78, -2.78, -8.33, -15.0, -23.33, -1.11};
     191             : 
     192             :     // (Tzl)the zero-load temperature variation by climate region ANSI/AHRI 210/240 - 2023 (Section 11.2.2 - Table 14)
     193             :     // [ 58 57 56 55 55 57 ] in Fahrenheit
     194             :     static constexpr std::array<Real64, 6> ZoneLoadTemperature = {14.44, 13.89, 13.33, 12.78, 12.78, 13.89};
     195             : 
     196             :     // Outdoor design temperature for a region from ANSI/AHRI 210/240 - 2017 & 2023
     197             :     static constexpr std::array<Real64, 18> OutdoorBinTemperature = {
     198             :         16.67, 13.89, 11.11, 8.33, 5.56, 2.78, 0.00, -2.78, -5.56, -8.33, -11.11, -13.89, -16.67, -19.44, -22.22, -25.00, -27.78, -30.56};
     199             :     int constexpr NumberOfRegions{6};
     200             :     int constexpr NumberOfBins{18};
     201             :     // Fractional bin hours for different bin temperatures from ANSI/AHRI 210/240 - 2017
     202             :     static constexpr std::array<std::array<Real64, NumberOfBins>, NumberOfRegions> FracBinHoursAtOutdoorBinTemp = {
     203             :         {{0.291, 0.239, 0.194, 0.129, 0.081, 0.041, 0.019, 0.005, 0.001, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
     204             :          {0.215, 0.189, 0.163, 0.143, 0.112, 0.088, 0.056, 0.024, 0.008, 0.002, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
     205             :          {0.153, 0.142, 0.138, 0.137, 0.135, 0.118, 0.092, 0.047, 0.021, 0.009, 0.005, 0.002, 0.001, 0.0, 0.0, 0.0, 0.0, 0.0},
     206             :          {0.132, 0.111, 0.103, 0.093, 0.1, 0.109, 0.126, 0.087, 0.055, 0.036, 0.026, 0.013, 0.006, 0.002, 0.001, 0.0, 0.0, 0.0},
     207             :          {0.106, 0.092, 0.086, 0.076, 0.078, 0.087, 0.102, 0.094, 0.074, 0.055, 0.047, 0.038, 0.029, 0.018, 0.01, 0.005, 0.002, 0.001},
     208             :          {0.113, 0.206, 0.215, 0.204, 0.141, 0.076, 0.034, 0.008, 0.003, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}}};
     209             : 
     210             :     // Fractional bin hours for different bin temperatures from ANSI/AHRI 210/240 - 2023 (Section 11.2.2 - Table 14)
     211             :     // As the Fractional Bin Hours for each region is not summing up to 1 we're using the adjusted one down below
     212             :     // static constexpr std::array<std::array<Real64, NumberOfBins>, NumberOfRegions> FracBinHoursAtOutdoorBinTempHSPF2 = {
     213             :     //{{0.0, 0.239, 0.194, 0.129, 0.081, 0.041, 0.019, 0.005, 0.001, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
     214             :     // {0.0, 0.0, 0.163, 0.143, 0.112, 0.088, 0.056, 0.024, 0.008, 0.002, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
     215             :     // {0.0, 0.0, 0.138, 0.137, 0.135, 0.118, 0.092, 0.047, 0.021, 0.009, 0.005, 0.002, 0.001, 0.0, 0.0, 0.0, 0.0, 0.0},
     216             :     // {0.0, 0.0, 0.103, 0.093, 0.1, 0.109, 0.126, 0.087, 0.055, 0.036, 0.026, 0.013, 0.006, 0.002, 0.001, 0.0, 0.0, 0.0},
     217             :     // {0.0, 0.0, 0.086, 0.076, 0.078, 0.087, 0.102, 0.094, 0.074, 0.055, 0.047, 0.038, 0.029, 0.018, 0.01, 0.005, 0.002, 0.001},
     218             :     // {0.0, 0.0, 0.215, 0.204, 0.141, 0.076, 0.034, 0.008, 0.003, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}}};
     219             :     // Adjusted to sum up to 1
     220             :     static constexpr std::array<std::array<Real64, NumberOfBins>, NumberOfRegions> FracBinHoursAtOutdoorBinTempHSPF2 = {{{0.0,
     221             :                                                                                                                           0.337094499,
     222             :                                                                                                                           0.273624824,
     223             :                                                                                                                           0.181946403,
     224             :                                                                                                                           0.114245416,
     225             :                                                                                                                           0.057827927,
     226             :                                                                                                                           0.026798307,
     227             :                                                                                                                           0.007052186,
     228             :                                                                                                                           0.001410437,
     229             :                                                                                                                           0.0,
     230             :                                                                                                                           0.0,
     231             :                                                                                                                           0.0,
     232             :                                                                                                                           0.0,
     233             :                                                                                                                           0.0,
     234             :                                                                                                                           0.0,
     235             :                                                                                                                           0.0,
     236             :                                                                                                                           0.0,
     237             :                                                                                                                           0.0},
     238             :                                                                                                                          {0.0,
     239             :                                                                                                                           0.0,
     240             :                                                                                                                           0.273489933,
     241             :                                                                                                                           0.239932886,
     242             :                                                                                                                           0.187919463,
     243             :                                                                                                                           0.147651007,
     244             :                                                                                                                           0.093959732,
     245             :                                                                                                                           0.040268456,
     246             :                                                                                                                           0.013422819,
     247             :                                                                                                                           0.003355705,
     248             :                                                                                                                           0.0,
     249             :                                                                                                                           0.0,
     250             :                                                                                                                           0.0,
     251             :                                                                                                                           0.0,
     252             :                                                                                                                           0.0,
     253             :                                                                                                                           0.0,
     254             :                                                                                                                           0.0,
     255             :                                                                                                                           0.0},
     256             :                                                                                                                          {0.0,
     257             :                                                                                                                           0.0,
     258             :                                                                                                                           0.195744681,
     259             :                                                                                                                           0.194326241,
     260             :                                                                                                                           0.191489362,
     261             :                                                                                                                           0.167375887,
     262             :                                                                                                                           0.130496454,
     263             :                                                                                                                           0.066666667,
     264             :                                                                                                                           0.029787234,
     265             :                                                                                                                           0.012765957,
     266             :                                                                                                                           0.007092199,
     267             :                                                                                                                           0.002836879,
     268             :                                                                                                                           0.00141844,
     269             :                                                                                                                           0.0,
     270             :                                                                                                                           0.0,
     271             :                                                                                                                           0.0,
     272             :                                                                                                                           0.0,
     273             :                                                                                                                           0.0},
     274             :                                                                                                                          {0.0,
     275             :                                                                                                                           0.0,
     276             :                                                                                                                           0.136063408,
     277             :                                                                                                                           0.122853369,
     278             :                                                                                                                           0.132100396,
     279             :                                                                                                                           0.143989432,
     280             :                                                                                                                           0.166446499,
     281             :                                                                                                                           0.114927345,
     282             :                                                                                                                           0.072655218,
     283             :                                                                                                                           0.047556143,
     284             :                                                                                                                           0.034346103,
     285             :                                                                                                                           0.017173052,
     286             :                                                                                                                           0.007926024,
     287             :                                                                                                                           0.002642008,
     288             :                                                                                                                           0.001321004,
     289             :                                                                                                                           0.0,
     290             :                                                                                                                           0.0,
     291             :                                                                                                                           0.0},
     292             :                                                                                                                          {0.0,
     293             :                                                                                                                           0.0,
     294             :                                                                                                                           0.10723192,
     295             :                                                                                                                           0.094763092,
     296             :                                                                                                                           0.097256858,
     297             :                                                                                                                           0.108478803,
     298             :                                                                                                                           0.127182045,
     299             :                                                                                                                           0.117206983,
     300             :                                                                                                                           0.092269327,
     301             :                                                                                                                           0.068578554,
     302             :                                                                                                                           0.058603491,
     303             :                                                                                                                           0.047381546,
     304             :                                                                                                                           0.036159601,
     305             :                                                                                                                           0.02244389,
     306             :                                                                                                                           0.012468828,
     307             :                                                                                                                           0.006234414,
     308             :                                                                                                                           0.002493766,
     309             :                                                                                                                           0.001246883},
     310             :                                                                                                                          {0.0,
     311             :                                                                                                                           0.0,
     312             :                                                                                                                           0.315712188,
     313             :                                                                                                                           0.299559471,
     314             :                                                                                                                           0.207048458,
     315             :                                                                                                                           0.111600587,
     316             :                                                                                                                           0.049926579,
     317             :                                                                                                                           0.01174743,
     318             :                                                                                                                           0.004405286,
     319             :                                                                                                                           0.0,
     320             :                                                                                                                           0.0,
     321             :                                                                                                                           0.0,
     322             :                                                                                                                           0.0,
     323             :                                                                                                                           0.0,
     324             :                                                                                                                           0.0,
     325             :                                                                                                                           0.0,
     326             :                                                                                                                           0.0,
     327             :                                                                                                                           0.0}}};
     328             : 
     329             :     // Representative cooling season Outdoor air temperature bin from ANSI/AHRI 210/240-2008
     330             :     int constexpr NumOfOATempBins(8); // number of outdoor temperature bins for cooling season
     331             :     static constexpr std::array<Real64, NumOfOATempBins> OutdoorBinTemperatureSEER = {19.44, 22.22, 25.00, 27.78, 30.56, 33.33, 36.11, 38.89};
     332             :     // Fractional bin hours for different bin temperatures for cooling, from ANSI/AHRI 210/240 - 2008
     333             :     // AHRI STANDARD 210/240 - 2023 | This does sum up to 1
     334             :     static constexpr std::array<Real64, NumOfOATempBins> CoolFracBinHoursAtOutdoorBinTemp = {0.214, 0.231, 0.216, 0.161, 0.104, 0.052, 0.018, 0.004};
     335             : 
     336             :     Real64 constexpr HeatingIndoorCoilInletAirDBTempRated(21.11); // Heating coil entering air dry-bulb temperature in
     337             :     // degrees C (70F) Test H1, H2 and H3
     338             :     // (low and High Speed) Std. AHRI 210/240
     339             :     Real64 constexpr HeatingOutdoorCoilInletAirDBTempH0Test(16.67); // Outdoor air dry-bulb temp in degrees C (47F)
     340             :     // Test H0 (low and High Speed) Std. AHRI 210/240
     341             : 
     342             :     // ANSI/ASHRAE Standard 127-2012 -- Method of Testing for Rating Computer and Data Processing Room Unitary Air Conditioners
     343             :     //  Class 1 23.9C( 75.0F ) 23.9C( 75.0F ) 23.9C( 75.0F ) 23.9C( 75.0F )
     344             :     //  Class 2 29.4C( 85.0F ) 29.4C( 85.0F ) 29.4C( 85.0F ) 29.4C( 85.0F )
     345             :     //  Class 3 35.0C( 95.0F ) 35.0C( 95.0F ) 35.0C( 95.0F ) 35.0C( 95.0F )
     346             :     //  Class 4 40.5C( 105F ) 40.5C( 105F ) 40.5C( 105F ) 40.5C( 105F )
     347             :     static constexpr std::array<Real64, 4> IndoorDBTempClassI2IV = {23.9, 29.4, 35.0, 40.5};
     348             :     Real64 constexpr IndoorTDPA2D(11.1);
     349             :     // 35.0C( 95.0F ) 26.7C( 80.0F ) 18.3C( 65.0F ) 4.4C( 40.0F )
     350             :     static constexpr std::array<Real64, 4> OutdoorDBTempAllClassA2D = {35.0, 26.7, 18.3, 4.4};
     351             : 
     352             :     // AHRI Std. 340/360-2022 (IP)
     353             :     // Reduced Capacity part-load conditions
     354             :     static constexpr std::array<Real64, 4> ReducedPLRIEER = {0.25, 0.50, 0.75, 1.0};
     355             :     // Table 6
     356             :     // Cooling
     357             :     // Real64 CoilInletAirWetBulbTemp = 23.89;  // 75F
     358             :     Real64 constexpr CoilInletAirCoolDryBulbIEER(35);     // 95F
     359             :     Real64 constexpr CoilWaterOutletTempIEER(35);         // 95F
     360             :     Real64 constexpr CoilWaterInletTempIEER(29.44);       // 85F
     361             :     Real64 constexpr CoilInletEvapWetBulbTempIEER(23.89); // 75F
     362             :     Real64 constexpr CoilInletEvapDryBulbTempIEER(35);    // 95F
     363             :     // Heating
     364             :     Real64 constexpr CoilHeatingInletAirWetBulbTempIEER(6.11); // 43F
     365             :     Real64 constexpr CoilHeatingInletAirCoolDryBulbIEER(8.33); // 47F
     366             : 
     367             :     // Functions
     368             : 
     369          93 :     void CalcChillerIPLV(EnergyPlusData &state,
     370             :                          std::string const &ChillerName,               // Name of Chiller for which IPLV is calculated
     371             :                          DataPlant::PlantEquipmentType ChillerType,    // Type of Chiller - EIR or Reformulated EIR
     372             :                          Real64 const RefCap,                          // Reference capacity of chiller [W]
     373             :                          Real64 const RefCOP,                          // Reference coefficient of performance [W/W]
     374             :                          DataPlant::CondenserType const CondenserType, // Type of Condenser - Air Cooled, Water Cooled or Evap Cooled
     375             :                          int const CapFTempCurveIndex,                 // Index for the total cooling capacity modifier curve
     376             :                          int const EIRFTempCurveIndex,                 // Index for the energy input ratio modifier curve
     377             :                          int const EIRFPLRCurveIndex,                  // Index for the EIR vs part-load ratio curve
     378             :                          Real64 const MinUnloadRat,                    // Minimum unloading ratio
     379             :                          Real64 &IPLVSI,                               // IPLV.SI determined using AHRI Std 551/591 (SI)
     380             :                          Real64 &IPLVIP,                               // IPLV.IP determined using AHRI Std 550/590 (IP)
     381             :                          ObjexxFCL::Optional<Real64 const> CondVolFlowRate,
     382             :                          ObjexxFCL::Optional_int_const CondLoopNum,
     383             :                          ObjexxFCL::Optional<Real64 const> OpenMotorEff)
     384             :     {
     385             : 
     386             :         // SUBROUTINE INFORMATION:
     387             :         //       AUTHOR         Chandan Sharma, FSEC
     388             :         //       DATE WRITTEN   January 2012
     389             :         //       Modified       na
     390             :         //       RE-ENGINEERED  na
     391             : 
     392             :         // PURPOSE OF THIS SUBROUTINE:
     393             :         //     Calculates Integrated Part Load Value (IPLV) for EIR and reformulated EIR chillers.
     394             :         //     Writes the result to EIO file.
     395             :         // METHODOLOGY EMPLOYED:
     396             :         // (1) Obtains the reference cooling capacity, reference COP and performance curves of the chiller
     397             :         // (2) Evaluates the cooling capacity at AHRI test conditions (Per AHRI 551/591,2011 Table 3)
     398             :         // (3) Evaluates the EIR at AHRI test conditions (Per AHRI 551/591,2011 Table 3)
     399             :         // (4) The EER is evaluated from the total cooling capacity and total electric power
     400             :         //     evaluated at the standard rated test conditions.  The IPLV is a weighted value of the COP evaluated
     401             :         //     at four different capacities of 100%, 75%, 50% and 25%.  The reduced capacity COPs are evaluated
     402             :         //     at different outdoor coil entering temperatures.
     403             :         // REFERENCES:
     404             :         // (1) AHRI Standard 551/591-2011:  Standard for Performance Rating of Water-Chilling Packages using the Vapor
     405             :         //                                  Compression Cycle. Arlington, VA:  Air-Conditioning, Heating,
     406             :         //                                  and Refrigeration Institute.
     407             : 
     408             :         // Using/Aliasing
     409             :         using namespace OutputReportPredefined;
     410             :         using Curve::CurveValue;
     411             :         using Curve::GetCurveName;
     412             :         using FluidProperties::GetDensityGlycol;
     413             :         using FluidProperties::GetSpecificHeatGlycol;
     414             :         using General::SolveRoot;
     415             : 
     416          93 :         Real64 constexpr Acc(0.0001);     // Accuracy of result
     417          93 :         int constexpr NumOfReducedCap(4); // Number of reduced capacity test conditions (100%,75%,50%,and 25%)
     418          93 :         int constexpr IterMax(500);       // Maximum number of iterations
     419             :         static constexpr std::array<Real64, 4> IPLVWeightingFactor = {0.010, 0.42, 0.45, 0.12}; // EER Weighting factors (IPLV)
     420             :         static constexpr std::string_view RoutineName("CalcChillerIPLV");
     421             : 
     422             :         // INTERFACE BLOCK SPECIFICATIONS
     423             :         // na
     424             : 
     425             :         // DERIVED TYPE DEFINITIONS
     426             :         // na
     427             : 
     428             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     429          93 :         Real64 AvailChillerCap(0.0);               // Chiller available capacity at current operating conditions [W]
     430          93 :         Real64 EnteringWaterTempReduced(0.0);      // Entering Condenser Water Temperature at reduced conditions [C]
     431          93 :         Real64 EnteringAirDryBulbTempReduced(0.0); // Outdoor unit entering air dry-bulb temperature
     432             :         // at reduced capacity [C]
     433          93 :         Real64 EnteringAirWetBulbTempReduced(0.0); // Outdoor unit entering air wet-bulb temperature
     434             :         // at reduced capacity [C]
     435          93 :         Real64 CondenserInletTemp(0.0);   // Entering Condenser Temperature at reduced conditions [C]
     436          93 :         Real64 CondenserOutletTemp0(0.0); // Lower bound for condenser outlet temperature [C]
     437          93 :         Real64 CondenserOutletTemp1(0.0); // Upper bound for condenser outlet temperature [C]
     438          93 :         Real64 CondenserOutletTemp(0.0);  // Calculated condenser outlet temperature which corresponds
     439             :         // to EnteringWaterTempReduced above [C]
     440          93 :         Real64 Cp(0.0);         // Water specific heat [J/(kg*C)]
     441          93 :         Real64 Rho(0.0);        // Water density [kg/m3]
     442          93 :         Real64 EIR(0.0);        // Inverse of COP at reduced capacity test conditions (100%, 75%, 50%, and 25%)
     443          93 :         Real64 Power(0.0);      // Power at reduced capacity test conditions (100%, 75%, 50%, and 25%)
     444          93 :         Real64 COPReduced(0.0); // COP at reduced capacity test conditions (100%, 75%, 50%, and 25%)
     445          93 :         Real64 LoadFactor(0.0); // Fractional "on" time for last stage at the desired reduced capacity,
     446             :         // (dimensionless)
     447          93 :         Real64 DegradationCoeff(0.0);   // Degradation coeficient, (dimenssionless)
     448          93 :         Real64 ChillerCapFT_rated(0.0); // Chiller capacity fraction at AHRI rated conditions (evaluated as a function of temperature)
     449          93 :         Real64 ChillerCapFT(0.0);       // Chiller capacity fraction (evaluated as a function of temperature)
     450          93 :         Real64 ChillerEIRFT_rated(0.0); // Chiller electric input ratio (EIR = 1 / COP) at AHRI rated conditions as a function of temperature
     451          93 :         Real64 ChillerEIRFT(0.0);       // Chiller electric input ratio (EIR = 1 / COP) as a function of temperature
     452          93 :         Real64 ChillerEIRFPLR(0.0);     // Chiller EIR as a function of part-load ratio (PLR)
     453          93 :         Real64 PartLoadRatio(0.0);      // Part load ratio (PLR) at which chiller is operatign at reduced capacity
     454             :         int RedCapNum;                  // Integer counter for reduced capacity
     455             :         int SolFla;                     // Flag of solver
     456             : 
     457             :         // Initialize local variables
     458          93 :         AvailChillerCap = 0.0;
     459          93 :         EnteringWaterTempReduced = 0.0;
     460          93 :         EnteringAirDryBulbTempReduced = 0.0;
     461          93 :         EnteringAirWetBulbTempReduced = 0.0;
     462          93 :         CondenserInletTemp = 0.0;
     463          93 :         CondenserOutletTemp0 = 0.0;
     464          93 :         CondenserOutletTemp1 = 0.0;
     465          93 :         CondenserOutletTemp = 0.0;
     466          93 :         Cp = 0.0;
     467          93 :         Rho = 0.0;
     468          93 :         IPLVSI = 0.0;
     469          93 :         IPLVIP = 0.0;
     470          93 :         EIR = 0.0;
     471          93 :         Power = 0.0;
     472          93 :         COPReduced = 0.0;
     473          93 :         LoadFactor = 0.0;
     474          93 :         DegradationCoeff = 0.0;
     475          93 :         ChillerCapFT_rated = 0.0;
     476          93 :         ChillerCapFT = 0.0;
     477          93 :         ChillerEIRFT_rated = 0.0;
     478          93 :         ChillerEIRFT = 0.0;
     479          93 :         ChillerEIRFPLR = 0.0;
     480          93 :         PartLoadRatio = 0.0;
     481             : 
     482          93 :         CheckCurveLimitsForIPLV(state, ChillerName, ChillerType, CondenserType, CapFTempCurveIndex, EIRFTempCurveIndex);
     483             : 
     484          93 :         Real64 IPLV = 0.0;                        // current IPLV
     485          93 :         Real64 EvapOutletTemp = 0.0;              // evaporator leaving water temperature, deg C
     486          93 :         Real64 constexpr EvapOutletTempSI = 7.0;  // evaporator LWT, 2011 AHRI Std 551 / 591(SI)
     487          93 :         Real64 constexpr EvapOutletTempIP = 6.67; // evaporator LWT, 2011 AHRI Std 550 / 590(IP), (44F)
     488          93 :         bool ReportStdRatingsOnce = true;
     489             : 
     490         279 :         for (const auto &AhriStd : {AhriChillerStd::AHRI550_590, AhriChillerStd::AHRI551_591}) {
     491         186 :             if (AhriStd == AhriChillerStd::AHRI550_590) {
     492          93 :                 EvapOutletTemp = EvapOutletTempIP;
     493          93 :                 ReportStdRatingsOnce = true;
     494          93 :             } else if (AhriStd == AhriChillerStd::AHRI551_591) {
     495          93 :                 EvapOutletTemp = EvapOutletTempSI;
     496          93 :                 ReportStdRatingsOnce = false;
     497             :             }
     498         186 :             IPLV = 0.0;
     499             : 
     500             :             // IPLV calculations:
     501         930 :             for (RedCapNum = 0; RedCapNum < NumOfReducedCap; ++RedCapNum) {
     502             : 
     503         744 :                 CondenserInletTemp = CondenserEnteringFluidTemperature(CondenserType, AhriStd, ReducedPLR[RedCapNum]);
     504             : 
     505         744 :                 if (ChillerType == DataPlant::PlantEquipmentType::Chiller_ElectricEIR) {
     506         416 :                     if (RedCapNum == 0) {
     507             :                         // Get curve modifier values at rated conditions (load = 100%)
     508         104 :                         ChillerCapFT_rated = CurveValue(state, CapFTempCurveIndex, EvapOutletTemp, CondenserInletTemp);
     509         104 :                         ChillerEIRFT_rated = CurveValue(state, EIRFTempCurveIndex, EvapOutletTemp, CondenserInletTemp);
     510             : 
     511             :                         // Report rated capacity and chiller COP
     512         104 :                         if (ReportStdRatingsOnce) {
     513          52 :                             PreDefTableEntry(state, state.dataOutRptPredefined->pdchMechRatCap, ChillerName, RefCap * ChillerCapFT_rated);
     514          52 :                             PreDefTableEntry(state, state.dataOutRptPredefined->pdchMechRatEff, ChillerName, RefCOP / ChillerEIRFT_rated);
     515             :                         }
     516             :                     }
     517             : 
     518             :                     // Get capacity curve info with respect to CW setpoint and entering condenser temps
     519         416 :                     ChillerCapFT = CurveValue(state, CapFTempCurveIndex, EvapOutletTemp, CondenserInletTemp);
     520             : 
     521         416 :                     ChillerEIRFT = CurveValue(state, EIRFTempCurveIndex, EvapOutletTemp, CondenserInletTemp);
     522             : 
     523         416 :                     PartLoadRatio = ReducedPLR[RedCapNum] * ChillerCapFT_rated / ChillerCapFT;
     524             : 
     525         416 :                     if (PartLoadRatio >= MinUnloadRat) {
     526         334 :                         ChillerEIRFPLR = CurveValue(state, EIRFPLRCurveIndex, PartLoadRatio);
     527             :                     } else {
     528          82 :                         ChillerEIRFPLR = CurveValue(state, EIRFPLRCurveIndex, MinUnloadRat);
     529          82 :                         PartLoadRatio = MinUnloadRat;
     530             :                     }
     531             : 
     532         328 :                 } else if (ChillerType == DataPlant::PlantEquipmentType::Chiller_ElectricReformEIR) {
     533         328 :                     EnteringWaterTempReduced = CondenserInletTemp;
     534         328 :                     Cp = GetSpecificHeatGlycol(state,
     535         328 :                                                state.dataPlnt->PlantLoop(CondLoopNum).FluidName,
     536             :                                                EnteringWaterTempReduced,
     537         328 :                                                state.dataPlnt->PlantLoop(CondLoopNum).FluidIndex,
     538             :                                                RoutineName);
     539             : 
     540         328 :                     Rho = GetDensityGlycol(state,
     541         328 :                                            state.dataPlnt->PlantLoop(CondLoopNum).FluidName,
     542             :                                            EnteringWaterTempReduced,
     543         328 :                                            state.dataPlnt->PlantLoop(CondLoopNum).FluidIndex,
     544             :                                            RoutineName);
     545             : 
     546         328 :                     Real64 reducedPLR = ReducedPLR[RedCapNum];
     547         328 :                     CondenserOutletTemp0 = EnteringWaterTempReduced + 0.1;
     548         328 :                     CondenserOutletTemp1 = EnteringWaterTempReduced + 10.0;
     549             : 
     550             :                     // CONST_LAMBDA_CAPTURE Issue, see PR 9670
     551         328 :                     Real64 tmpEvapOutletTemp = EvapOutletTemp;
     552        1290 :                     auto f = [&state,
     553             :                               EnteringWaterTempReduced,
     554             :                               Cp,
     555             :                               reducedPLR,
     556             :                               CondVolFlowRate,
     557             :                               Rho,
     558             :                               CapFTempCurveIndex,
     559             :                               EIRFTempCurveIndex,
     560             :                               EIRFPLRCurveIndex,
     561             :                               RefCap,
     562             :                               RefCOP,
     563             :                               OpenMotorEff,
     564             :                               tmpEvapOutletTemp,
     565       11284 :                               ChillerCapFT_rated](Real64 const CondenserOutletTemp) {
     566        1290 :                         Real64 AvailChillerCap(0.0);         // Chiller available capacity at current operating conditions [W]
     567        1290 :                         Real64 CondenserInletTemp(0.0);      // Calculated condenser inlet temperature [C]
     568        1290 :                         Real64 QEvap(0.0);                   // Rate of heat transfer to the evaporator coil [W]
     569        1290 :                         Real64 QCond(0.0);                   // Rate of heat transfer to the condenser coil [W]
     570        1290 :                         Real64 Power(0.0);                   // Power at reduced capacity test conditions (100%, 75%, 50%, and 25%)
     571        1290 :                         Real64 ReformEIRChillerCapFT(0.0);   // Chiller capacity fraction (evaluated as a function of temperature)
     572        1290 :                         Real64 ReformEIRChillerEIRFT(0.0);   // Chiller electric input ratio (EIR = 1 / COP) as a function of temperature
     573        1290 :                         Real64 ReformEIRChillerEIRFPLR(0.0); // Chiller EIR as a function of part-load ratio (PLR)
     574        1290 :                         Real64 PartLoadRatio(0.0);           // Chiller part load ratio
     575             : 
     576        1290 :                         ReformEIRChillerCapFT = CurveValue(state, CapFTempCurveIndex, tmpEvapOutletTemp, CondenserOutletTemp);
     577             : 
     578        1290 :                         ReformEIRChillerEIRFT = CurveValue(state, EIRFTempCurveIndex, tmpEvapOutletTemp, CondenserOutletTemp);
     579             : 
     580             :                         // Available chiller capacity as a function of temperature
     581        1290 :                         AvailChillerCap = RefCap * ReformEIRChillerCapFT;
     582             : 
     583        1290 :                         switch (state.dataCurveManager->PerfCurve(EIRFPLRCurveIndex)->numDims) {
     584           0 :                         case 1:
     585           0 :                             ReformEIRChillerEIRFPLR = CurveValue(state, EIRFPLRCurveIndex, CondenserOutletTemp);
     586           0 :                             break;
     587        1260 :                         case 2:
     588        1260 :                             ReformEIRChillerEIRFPLR = CurveValue(state, EIRFPLRCurveIndex, CondenserOutletTemp, reducedPLR);
     589        1260 :                             break;
     590          30 :                         case 3:
     591             :                         default: // this default allows the simulation to continue, but will issue a warning, should be removed eventually
     592          30 :                             ReformEIRChillerEIRFPLR = CurveValue(state, EIRFPLRCurveIndex, CondenserOutletTemp, reducedPLR, 0.0);
     593          30 :                             break;
     594             :                         }
     595             : 
     596        1290 :                         Power = (AvailChillerCap / RefCOP) * ReformEIRChillerEIRFPLR * ReformEIRChillerEIRFT;
     597             : 
     598        1290 :                         if (reducedPLR >= 1.0) {
     599         326 :                             PartLoadRatio = reducedPLR;
     600             :                         } else {
     601         964 :                             PartLoadRatio = reducedPLR * ChillerCapFT_rated / ReformEIRChillerCapFT;
     602             :                         }
     603             : 
     604        1290 :                         QEvap = AvailChillerCap * PartLoadRatio;
     605             : 
     606        1290 :                         QCond = Power * OpenMotorEff + QEvap;
     607             : 
     608        1290 :                         if (CondVolFlowRate > DataBranchAirLoopPlant::MassFlowTolerance) {
     609        1290 :                             CondenserInletTemp = CondenserOutletTemp - QCond / (CondVolFlowRate * Rho) / Cp;
     610             :                         }
     611        1290 :                         return (EnteringWaterTempReduced - CondenserInletTemp) / EnteringWaterTempReduced;
     612         328 :                     };
     613             : 
     614         328 :                     General::SolveRoot(state, Acc, IterMax, SolFla, CondenserOutletTemp, f, CondenserOutletTemp0, CondenserOutletTemp1);
     615         328 :                     if (SolFla == -1) {
     616           0 :                         ShowWarningError(state, "Iteration limit exceeded in calculating Reform Chiller IPLV");
     617           0 :                         ShowContinueError(state, format("Reformulated Chiller IPLV calculation failed for {}", ChillerName));
     618         328 :                     } else if (SolFla == -2) {
     619           0 :                         ShowWarningError(state, "Bad starting values for calculating Reform Chiller IPLV");
     620           0 :                         ShowContinueError(state, format("Reformulated Chiller IPLV calculation failed for {}", ChillerName));
     621             :                     }
     622             : 
     623         328 :                     if (RedCapNum == 0) {
     624             :                         // Get curve modifier values at rated conditions (load = 100%)
     625          82 :                         ChillerCapFT_rated = CurveValue(state, CapFTempCurveIndex, EvapOutletTemp, CondenserOutletTemp);
     626          82 :                         ChillerEIRFT_rated = CurveValue(state, EIRFTempCurveIndex, EvapOutletTemp, CondenserOutletTemp);
     627             : 
     628             :                         // Report rated capacity and chiller COP
     629          82 :                         if (ReportStdRatingsOnce) {
     630          41 :                             PreDefTableEntry(state, state.dataOutRptPredefined->pdchMechRatCap, ChillerName, RefCap * ChillerCapFT_rated);
     631          41 :                             PreDefTableEntry(state, state.dataOutRptPredefined->pdchMechRatEff, ChillerName, RefCOP / ChillerEIRFT_rated);
     632             :                         }
     633             :                     }
     634             : 
     635         328 :                     ChillerCapFT = CurveValue(state, CapFTempCurveIndex, EvapOutletTemp, CondenserOutletTemp);
     636             : 
     637         328 :                     ChillerEIRFT = CurveValue(state, EIRFTempCurveIndex, EvapOutletTemp, CondenserOutletTemp);
     638             : 
     639         328 :                     PartLoadRatio = ReducedPLR[RedCapNum] * ChillerCapFT_rated / ChillerCapFT;
     640             : 
     641         328 :                     if (PartLoadRatio >= MinUnloadRat) {
     642         322 :                         switch (state.dataCurveManager->PerfCurve(EIRFPLRCurveIndex)->numDims) {
     643           0 :                         case 1:
     644           0 :                             ChillerEIRFPLR = CurveValue(state, EIRFPLRCurveIndex, CondenserOutletTemp);
     645           0 :                             break;
     646         314 :                         case 2:
     647         314 :                             ChillerEIRFPLR = CurveValue(state, EIRFPLRCurveIndex, CondenserOutletTemp, PartLoadRatio);
     648         314 :                             break;
     649           8 :                         case 3:
     650             :                         default: // this default allows the simulation to continue, but will issue a warning, should be removed eventually
     651           8 :                             ChillerEIRFPLR = CurveValue(state, EIRFPLRCurveIndex, CondenserOutletTemp, PartLoadRatio, 0.0);
     652           8 :                             break;
     653             :                         }
     654             :                     } else {
     655           6 :                         switch (state.dataCurveManager->PerfCurve(EIRFPLRCurveIndex)->numDims) {
     656           0 :                         case 1:
     657           0 :                             ChillerEIRFPLR = CurveValue(state, EIRFPLRCurveIndex, CondenserOutletTemp);
     658           0 :                             break;
     659           6 :                         case 2:
     660           6 :                             ChillerEIRFPLR = CurveValue(state, EIRFPLRCurveIndex, CondenserOutletTemp, MinUnloadRat);
     661           6 :                             break;
     662           0 :                         case 3:
     663             :                         default: // this default allows the simulation to continue, but will issue a warning, should be removed eventually
     664           0 :                             ChillerEIRFPLR = CurveValue(state, EIRFPLRCurveIndex, CondenserOutletTemp, MinUnloadRat, 0.0);
     665           0 :                             break;
     666             :                         }
     667           6 :                         PartLoadRatio = MinUnloadRat;
     668             :                     }
     669         328 :                 } else {
     670           0 :                     assert(false);
     671             :                 }
     672             : 
     673             :                 // Available chiller capacity as a function of temperature
     674         744 :                 if (RefCap > 0.0 && RefCOP > 0.0 && ChillerCapFT > 0.0 && ChillerEIRFT > 0.0) {
     675         744 :                     AvailChillerCap = RefCap * ChillerCapFT;
     676         744 :                     Power = (AvailChillerCap / RefCOP) * ChillerEIRFPLR * ChillerEIRFT;
     677         744 :                     EIR = Power / (PartLoadRatio * AvailChillerCap);
     678             : 
     679         744 :                     if (ReducedPLR[RedCapNum] >= MinUnloadRat) {
     680         744 :                         COPReduced = 1.0 / EIR;
     681             :                     } else {
     682           0 :                         LoadFactor = (ReducedPLR[RedCapNum] * RefCap) / (MinUnloadRat * AvailChillerCap);
     683           0 :                         DegradationCoeff = 1.130 - 0.130 * LoadFactor;
     684           0 :                         COPReduced = 1.0 / (DegradationCoeff * EIR);
     685             :                     }
     686         744 :                     IPLV += IPLVWeightingFactor[RedCapNum] * COPReduced;
     687             :                 } else {
     688             :                     {
     689           0 :                         if (ChillerType == DataPlant::PlantEquipmentType::Chiller_ElectricEIR) {
     690           0 :                             ShowWarningError(
     691           0 :                                 state, format("Chiller:Electric:EIR = {}:  Integrated Part Load Value (IPLV) cannot be calculated.", ChillerName));
     692           0 :                         } else if (ChillerType == DataPlant::PlantEquipmentType::Chiller_ElectricReformEIR) {
     693             : 
     694           0 :                             ShowWarningError(state,
     695           0 :                                              format("Chiller:Electric:ReformulatedEIR = {}:  Integrated Part Load Value (IPLV) cannot be calculated.",
     696             :                                                     ChillerName));
     697             :                         }
     698             :                     }
     699           0 :                     if (RefCap <= 0.0) {
     700           0 :                         ShowContinueError(
     701             :                             state,
     702           0 :                             format(" Check the chiller autosized or user specified capacity. Autosized or specified chiller capacity = {:.2R}",
     703             :                                    RefCap));
     704             :                     }
     705           0 :                     if (RefCOP <= 0.0) {
     706           0 :                         ShowContinueError(state, format(" Check the chiller reference or rated COP specified. Specified COP = {:.2R}", RefCOP));
     707             :                     }
     708           0 :                     if (ChillerCapFT <= 0.0) {
     709           0 :                         ShowContinueError(
     710             :                             state,
     711           0 :                             format(" Check limits in Cooling Capacity Function of Temperature Curve, Curve Type = {}, Curve Name = {}.",
     712           0 :                                    Curve::objectNames[static_cast<int>(state.dataCurveManager->PerfCurve(CapFTempCurveIndex)->curveType)],
     713           0 :                                    GetCurveName(state, CapFTempCurveIndex)));
     714           0 :                         ShowContinueError(state, format(" ..ChillerCapFT value at standard test condition = {:.2R}", ChillerCapFT));
     715             :                     }
     716           0 :                     if (ChillerEIRFT <= 0.0) {
     717           0 :                         ShowContinueError(
     718             :                             state,
     719           0 :                             format(" Check limits in EIR Function of Temperature Curve, Curve Type = {}, Curve Name = {}.",
     720           0 :                                    Curve::objectNames[static_cast<int>(state.dataCurveManager->PerfCurve(EIRFTempCurveIndex)->curveType)],
     721           0 :                                    GetCurveName(state, EIRFTempCurveIndex)));
     722           0 :                         ShowContinueError(state, format(" ..ChillerEIRFT value at standard test condition = {:.2R}", ChillerEIRFT));
     723             :                     }
     724           0 :                     IPLV = 0.0;
     725           0 :                     break;
     726             :                 }
     727             :             }
     728             : 
     729         186 :             if (AhriStd == AhriChillerStd::AHRI550_590) {
     730          93 :                 IPLVIP = IPLV;
     731             :             } else {
     732          93 :                 IPLVSI = IPLV;
     733             :             }
     734             :         }
     735             :         // Writes the IPLV value to the EIO file and standard tabular output tables
     736          93 :         ReportChillerIPLV(state, ChillerName, ChillerType, IPLVSI, IPLVIP * ConvFromSIToIP);
     737          93 :     }
     738             : 
     739          93 :     void ReportChillerIPLV(EnergyPlusData &state,
     740             :                            std::string const &ChillerName,            // Name of Chiller for which IPLV is calculated
     741             :                            DataPlant::PlantEquipmentType ChillerType, // Type of Chiller - EIR or Reformulated EIR
     742             :                            Real64 const IPLVValueSI,                  // IPLV value in SI units {W/W}
     743             :                            Real64 const IPLVValueIP                   // IPLV value in IP units {Btu/W-h}
     744             :     )
     745             :     {
     746             : 
     747             :         // SUBROUTINE INFORMATION:
     748             :         //       AUTHOR         Chandan Sharma
     749             :         //       DATE WRITTEN   January 2012
     750             :         //       MODIFIED       na
     751             :         //       RE-ENGINEERED  na
     752             : 
     753             :         // PURPOSE OF THIS SUBROUTINE:
     754             :         // This subroutine writes the IPLV values in SI and IP units to
     755             :         // the "eio" and tabular output files for EIR Chillers.
     756             : 
     757             :         // Using/Aliasing
     758             :         using namespace OutputReportPredefined;
     759             : 
     760             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     761             : 
     762          93 :         if (state.dataHVACGlobal->StandardRatingsMyOneTimeFlag) {
     763          68 :             print(state.files.eio,
     764             :                   "{}\n",
     765             :                   "! <Chiller Standard Rating Information>, Component Type, Component Name, IPLV in SI Units {W/W}, IPLV in IP Units {Btu/W-h}");
     766          68 :             state.dataHVACGlobal->StandardRatingsMyOneTimeFlag = false;
     767             :         }
     768             : 
     769             :         {
     770             :             static constexpr std::string_view Format_991(" Chiller Standard Rating Information, {}, {}, {:.2R}, {:.2R}\n");
     771          93 :             if (ChillerType == DataPlant::PlantEquipmentType::Chiller_ElectricEIR) {
     772             : 
     773          52 :                 print(state.files.eio, Format_991, "Chiller:Electric:EIR", ChillerName, IPLVValueSI, IPLVValueIP);
     774          52 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchMechType, ChillerName, "Chiller:Electric:EIR");
     775             : 
     776          41 :             } else if (ChillerType == DataPlant::PlantEquipmentType::Chiller_ElectricReformEIR) {
     777             : 
     778          41 :                 print(state.files.eio, Format_991, "Chiller:Electric:ReformulatedEIR", ChillerName, IPLVValueSI, IPLVValueIP);
     779          41 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchMechType, ChillerName, "Chiller:Electric:ReformulatedEIR");
     780             :             }
     781             :         }
     782             : 
     783             :         // Note: We don't want unit conversio, here, but it's ok since W/W will convert to itself since the column heading has "SI" as a hint
     784          93 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchMechIPLVSI, ChillerName, IPLVValueSI, 2);
     785          93 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchMechIPLVIP, ChillerName, IPLVValueIP, 2);
     786          93 :     }
     787             : 
     788          93 :     void CheckCurveLimitsForIPLV(EnergyPlusData &state,
     789             :                                  std::string const &ChillerName,               // Name of Chiller
     790             :                                  DataPlant::PlantEquipmentType ChillerType,    // Type of Chiller - EIR or ReformulatedEIR
     791             :                                  DataPlant::CondenserType const CondenserType, // Type of Condenser - Air Cooled, Water Cooled or Evap Cooled
     792             :                                  int const CapFTempCurveIndex,                 // Index for the total cooling capacity modifier curve
     793             :                                  int const EIRFTempCurveIndex                  // Index for the energy input ratio modifier curve
     794             :     )
     795             :     {
     796             : 
     797             :         // SUBROUTINE INFORMATION:
     798             :         //       AUTHOR            Chandan Sharma, FSEC
     799             :         //       DATE WRITTEN      January 2012
     800             :         //       MODIFIED          na
     801             :         //       RE-ENGINEERED     na
     802             : 
     803             :         // PURPOSE OF THIS SUBROUTINE:
     804             :         // Checks the limits of the various curves used in EIR chiller and returns .FALSE. if the limits do not include
     805             :         // the standard test condition(s).
     806             : 
     807             :         // Using/Aliasing
     808             :         using Curve::GetCurveMinMaxValues;
     809             :         using Curve::GetCurveName;
     810             : 
     811             :         // Following parameters are taken from AHRI 551/591,2011 Table 3
     812          93 :         Real64 constexpr HighEWTemp(30.0);       // Entering water temp in degrees C at full load capacity (85F)
     813          93 :         Real64 constexpr LowEWTemp(19.0);        // Entering water temp in degrees C at minimum reduced capacity (65F)
     814          93 :         Real64 constexpr OAHighEDBTemp(35.0);    // Outdoor air dry-bulb temp in degrees C at full load capacity (95F)
     815          93 :         Real64 constexpr OALowEDBTemp(12.78);    // Outdoor air dry-bulb temp in degrees C at part load capacity for AirCooled Chillers (55F)
     816          93 :         Real64 constexpr OAHighEWBTemp(24.0);    // Outdoor air wet-bulb temp in degrees C at full load capacity (75F)
     817          93 :         Real64 constexpr OALowEWBTemp(13.47);    // Outdoor air wet-bulb temp in degrees C at full load capacity for EvapCooled Chillers (56.25F)
     818          93 :         Real64 constexpr LeavingWaterTemp(6.67); // Evaporator leaving water temperature in degrees C [44 F]
     819             : 
     820             :         //  Minimum and Maximum independent variable limits from Total Cooling Capacity Function of Temperature Curve
     821          93 :         Real64 CapacityLWTempMin(0.0);           // Capacity modifier Min value (leaving water temp), from the Curve:BiQuadratic object
     822          93 :         Real64 CapacityLWTempMax(0.0);           // Capacity modifier Max value (leaving water temp), from the Curve:BiQuadratic object
     823          93 :         Real64 CapacityEnteringCondTempMin(0.0); // Capacity modifier Min value (entering cond temp), from the Curve:BiQuadratic object
     824          93 :         Real64 CapacityEnteringCondTempMax(0.0); // Capacity modifier Max value (entering cond temp), from the Curve:BiQuadratic object
     825             : 
     826             :         //  Minimum and Maximum independent variable limits from Energy Input Ratio (EIR) Function of Temperature Curve
     827          93 :         Real64 EIRLWTempMin(0.0);           // EIR modifier Min value (leaving water temp), from the Curve:BiQuadratic object
     828          93 :         Real64 EIRLWTempMax(0.0);           // EIR modifier Max value (leaving water temp), from the Curve:BiQuadratic object
     829          93 :         Real64 EIREnteringCondTempMin(0.0); // EIR modifier Min value (entering cond temp), from the Curve:BiQuadratic object
     830          93 :         Real64 EIREnteringCondTempMax(0.0); // EIR modifier Max value (entering cond temp), from the Curve:BiQuadratic object
     831             : 
     832          93 :         Real64 HighCondenserEnteringTempLimit(0.0); // High limit of entering condenser temperature
     833          93 :         Real64 LowCondenserEnteringTempLimit(0.0);  // Low limit of entering condenser temperature
     834             : 
     835          93 :         bool CapCurveIPLVLimitsExceeded(false); // Logical for capacity curve temperature limits being exceeded (IPLV calcs)
     836          93 :         bool EIRCurveIPLVLimitsExceeded(false); // Logical for EIR temperature limits being exceeded (IPLV calcs)
     837             : 
     838          93 :         GetCurveMinMaxValues(
     839             :             state, CapFTempCurveIndex, CapacityLWTempMin, CapacityLWTempMax, CapacityEnteringCondTempMin, CapacityEnteringCondTempMax);
     840          93 :         GetCurveMinMaxValues(state, EIRFTempCurveIndex, EIRLWTempMin, EIRLWTempMax, EIREnteringCondTempMin, EIREnteringCondTempMax);
     841             : 
     842          93 :         if (CondenserType == DataPlant::CondenserType::WaterCooled) {
     843          84 :             HighCondenserEnteringTempLimit = HighEWTemp;
     844          84 :             LowCondenserEnteringTempLimit = LowEWTemp;
     845           9 :         } else if (CondenserType == DataPlant::CondenserType::AirCooled) {
     846           8 :             HighCondenserEnteringTempLimit = OAHighEDBTemp;
     847           8 :             LowCondenserEnteringTempLimit = OALowEDBTemp;
     848             :         } else { // Evaporatively Cooled Condenser
     849           1 :             HighCondenserEnteringTempLimit = OAHighEWBTemp;
     850           1 :             LowCondenserEnteringTempLimit = OALowEWBTemp;
     851             :         }
     852             : 
     853             :         // Checking the limits of capacity modifying curve for temperatures (IPLV high and low test conditions)
     854          93 :         if (CapacityEnteringCondTempMax < HighCondenserEnteringTempLimit || CapacityEnteringCondTempMin > LowCondenserEnteringTempLimit ||
     855          54 :             CapacityLWTempMax < LeavingWaterTemp || CapacityLWTempMin > LeavingWaterTemp) {
     856          39 :             CapCurveIPLVLimitsExceeded = true;
     857             :         }
     858             :         // Checking the limits of EIR modifying curve for temperatures (IPLV high and low test conditions)
     859          93 :         if (EIREnteringCondTempMax < HighCondenserEnteringTempLimit || EIREnteringCondTempMin > LowCondenserEnteringTempLimit ||
     860          54 :             EIRLWTempMax < LeavingWaterTemp || EIRLWTempMin > LeavingWaterTemp) {
     861          39 :             EIRCurveIPLVLimitsExceeded = true;
     862             :         }
     863             : 
     864             :         // For IPLV:
     865          93 :         if (CapCurveIPLVLimitsExceeded || EIRCurveIPLVLimitsExceeded) {
     866          39 :             if (state.dataGlobal->DisplayExtraWarnings) {
     867             : 
     868           4 :                 if (ChillerType == DataPlant::PlantEquipmentType::Chiller_ElectricEIR) {
     869             : 
     870           8 :                     ShowWarningError(
     871             :                         state,
     872           8 :                         format("Chiller:Electric:EIR = {}:  Integrated Part Load Value (IPLV) calculated is not at the AHRI test condition.",
     873             :                                ChillerName));
     874           0 :                 } else if (ChillerType == DataPlant::PlantEquipmentType::Chiller_ElectricReformEIR) {
     875             : 
     876           0 :                     ShowWarningError(
     877             :                         state,
     878           0 :                         format(
     879             :                             "Chiller:Electric:ReformulatedEIR = {}:  Integrated Part Load Value (IPLV) calculated is not at the AHRI test condition.",
     880             :                             ChillerName));
     881             :                 }
     882           4 :                 if (CapCurveIPLVLimitsExceeded) {
     883           8 :                     ShowContinueError(state,
     884           8 :                                       format(" Check limits in Cooling Capacity Function of Temperature Curve, Curve Type = {}, Curve Name = {}",
     885           4 :                                              Curve::objectNames[static_cast<int>(state.dataCurveManager->PerfCurve(CapFTempCurveIndex)->curveType)],
     886           8 :                                              GetCurveName(state, CapFTempCurveIndex)));
     887             :                 }
     888           4 :                 if (EIRCurveIPLVLimitsExceeded) {
     889           8 :                     ShowContinueError(state,
     890           8 :                                       format(" Check limits in EIR Function of Temperature Curve, Curve Type = {}, Curve Name = {}",
     891           4 :                                              Curve::objectNames[static_cast<int>(state.dataCurveManager->PerfCurve(EIRFTempCurveIndex)->curveType)],
     892           8 :                                              GetCurveName(state, EIRFTempCurveIndex)));
     893             :                 }
     894             :             }
     895             :         }
     896          93 :     }
     897             : 
     898         782 :     void CalcDXCoilStandardRating(
     899             :         EnergyPlusData &state,
     900             :         std::string const &DXCoilName,                             // Name of DX coil for which HSPF is calculated
     901             :         std::string const &DXCoilType,                             // Type of DX coil for which HSPF is calculated
     902             :         int const DXCoilType_Num,                                  // Integer Type of DX coil - heating or cooling
     903             :         int const ns,                                              // Number of compressor speeds
     904             :         Array1A<Real64> const RatedTotalCapacity,                  // Reference capacity of DX coil [W]
     905             :         Array1A<Real64> const RatedCOP,                            // Reference coefficient of performance [W/W]
     906             :         Array1A_int const CapFFlowCurveIndex,                      // Index for the capacity as a function of flow fraction modifier curve
     907             :         Array1A_int const CapFTempCurveIndex,                      // Index for the capacity as a function of temperature modifier curve
     908             :         Array1A_int const EIRFFlowCurveIndex,                      // Index for the EIR as a function of flow fraction modifier curve
     909             :         Array1A_int const EIRFTempCurveIndex,                      // Index for the EIR as a function of temperature modifier curve
     910             :         Array1A_int const PLFFPLRCurveIndex,                       // Index for the PLF vs part-load ratio curve
     911             :         Array1A<Real64> const RatedAirVolFlowRate,                 // Reference air flow rate of DX coil [m3/s]
     912             :         Array1A<Real64> const FanPowerPerEvapAirFlowRateFromInput, // Reference fan power per evap air flow rate [W/(m3/s)]
     913             :         Array1A<Real64> const FanPowerPerEvapAirFlowRateFromInput_2023,
     914             :         Array1D<DataHeatBalance::RefrigCondenserType> CondenserType,
     915             :         ObjexxFCL::Optional_int_const
     916             :             RegionNum, // Region number for calculating HSPF of single speed DX heating coil //Autodesk:OPTIONAL Used without PRESENT check
     917             :         ObjexxFCL::Optional<Real64 const>
     918             :             MinOATCompressor, // Minimum OAT for heat pump compressor operation [C] //Autodesk:OPTIONAL Used without PRESENT check
     919             :         ObjexxFCL::Optional<Real64 const>
     920             :             OATempCompressorOn, // The outdoor temperature when the compressor is automatically turned //Autodesk:OPTIONAL Used without PRESENT check
     921             :         ObjexxFCL::Optional_bool_const
     922             :             OATempCompressorOnOffBlank, // Flag used to determine low temperature cut out factor //Autodesk:OPTIONAL Used without PRESENT check
     923             :         ObjexxFCL::Optional<HPdefrostControl const>
     924             :             DefrostControl,                              // defrost control; 1=timed, 2=on-demand //Autodesk:OPTIONAL Used without PRESENT check
     925             :         ObjexxFCL::Optional_bool_const ASHRAE127StdRprt, // true if user wishes to report ASHRAE 127 standard ratings
     926             :         ObjexxFCL::Optional<Real64 const> GrossRatedTotalCoolingCapacityVS, // Gross Rated Total Cooling Capacity At Selected Nominal Speed Level {W}
     927             :         ObjexxFCL::Optional<Real64 const> RatedVolumetricAirFlowRateVS      //  Rated Air Flow Rate At Selected Nominal Speed Level {m3/s}
     928             :     )
     929             :     {
     930             : 
     931             :         // SUBROUTINE INFORMATION:
     932             :         //       AUTHOR         Bereket Nigusse, Chandan Sharma FSEC
     933             :         //       DATE WRITTEN   February 2010,
     934             :         //                      B. Nigusse, May 2010  Added EER and IEER Calculation
     935             :         //                      C. Sharma, March 2012  Added HSPF Calculation for single speed HP
     936             :         //                      B. Nigusse, August 2012 Added SEER Calculation for Multi-speed HP
     937             :         //                      B. Nigusse, November 2012 Added HSPF Calculation for Multi-speed HP
     938             : 
     939             :         //       RE-ENGINEERED  na
     940             : 
     941             :         // PURPOSE OF THIS SUBROUTINE:
     942             :         //     Calculates:
     943             :         //                 (1) Standard Rated (net) Cooling Capacity
     944             :         //                 (2) Seasonal Energy Efficiency Ratio (SEER)
     945             :         //                 (3) Energy Efficiency Ratio (EER),
     946             :         //                 (4) Integrated Energy Efficiency Ratio (IEER)
     947             :         //                 for Air-to-Air Direct Expansion Air Conditioner and Heat Pumps having a single-speed compressor,
     948             :         //                 fixed speed indoor supply air fan, and air-cooled condensers. Writes the result to EIO file.
     949             :         //                 (5) Heating Seasonal Performance Factor (HSPF) for Air-Source Direct Expansion Heat Pumps having
     950             :         //                  a single-speed compressor, fixed speed indoor supply air fan
     951             :         //                 (6) Standard Rated (net) Cooling Capacity; and
     952             :         //                 (7) Seasonal Energy Efficiency Ratio (SEER) for Air-to-Air Heat Pumps having multi-speed
     953             :         //                     compressor.
     954             :         //                 (8) Heating Seasonal Performance Factor (HSPF) for Air-to-Air Heat Pumps having multi-speed
     955             :         //                     compressor.
     956             :         // METHODOLOGY EMPLOYED:
     957             :         // (A) Methodology for calculating standard ratings for DX air conditioners
     958             :         //     (1) Obtains the rated condition parameters:
     959             :         //         Cooling capacity (User specified or Autosized Value)
     960             :         //         Rated Air volume flow rate through the DX Cooling Coil (User specified or autosized value)
     961             :         //     (2) Evaluates the total cooling coil capacity at AHRI test conditions 26.7C/19.4C/27.8C. Then net
     962             :         //         cooling capacity is determined from the total cooling capacity of the DX coil at the AHRI test
     963             :         //         conditions and accounting for the INDOOR supply air fan heat.
     964             :         //     (3) Calculates the electric power consumed by the DX Coil Unit (compressor + outdoor condenser fan).
     965             :         //         Evaluates the EIR capacity and flow fraction modifiers at 26.7C/19.4C/27.8C. The net electric
     966             :         //         power consumption is determined by adding the indoor fan electric power to the electric power
     967             :         //         consumption by the DX Coil Condenser Fan and Compressor at the AHRI test conditions.
     968             :         //     (4) The EER is evaluated from the total net cooling capacity and total electric power
     969             :         //         evaluated at the standard rated test conditions.  The IEER is a weighted value of the EER evaluated
     970             :         //         at four different capacities of 100%, 75%, 50% and 25%.  The reduced capacity EERs are evaluated
     971             :         //         at different outdoor coil entering air dry-bulb temperatures.
     972             :         // (B) Methodology for calculating standard ratings for DX air air source heat pumps
     973             :         //     (1) Obtains the rated condition parameters:
     974             :         //         heating capacity (User specified or Autosized Value), COP,  Rated Air volume flow rate through the
     975             :         //         DX Cooling Coil (User specified or autosized value) and Fan power per rated air flow rate
     976             :         //     (2) Evaluates the heating coil capacities for AHRI tests H1, H2 and H3 using the performance cuves and
     977             :         //         input values specified at (1) above. Then net heating capacity is determined from the total heating capacity
     978             :         //         of the DX coil at the AHRI test conditions and accounting for the INDOOR supply air fan heat.
     979             :         //     (3) Calculates the electric power consumed by the DX Coil Unit (compressor + outdoor condenser fan).
     980             :         //         The net electric power consumption is determined by adding the indoor fan electric power to the
     981             :         //         electric power consumption by the DX Coil Condenser Fan and Compressor at the AHRI test conditions.
     982             :         //     (4) High Temperature Heating Standard (Net) Rating Capacity and Low Temperature Heating Standard (Net)
     983             :         //         Rating Capacity capacity are determined using tests H1 adn H3 per ANSI/AHRI 210/240 2008.
     984             :         //     (5) The HSPF is evaluated from the total net heating capacity and total electric power
     985             :         //         evaluated at the standard rated test conditions. For user specified region number, the outdoor temperatures
     986             :         //         are Binned (grouped) and fractioanl bin hours for each bin over the entire heating season are taken
     987             :         //         from AHRI 210/240. Then for each bin, building load, heat pump energy adn resistance space heating enegry are
     988             :         //         calculated. The sum of building load divided by sum of heat pump and resistance space heating over the
     989             :         //         entire heating season gives the HSPF. The detailed calculation algorithms of calculating HSPF
     990             :         //         are described in Engineering Reference.
     991             :         // (C) Methodology for calculating standard ratings for Multi-Speed Heat Pumps
     992             :         //     Net Total Cooling Capacity and SEER
     993             :         //     (1) Obtains the rated condition parameters:
     994             :         //         Cooling capacity (User specified or Autosized Value)
     995             :         //         Rated Air volume flow rate through the DX Cooling Coil (User specified or autosized value)
     996             :         //     (2) Evaluates the total cooling coil capacity at AHRI A2 test conditions 26.7C/19.4C/35.0C. Then net
     997             :         //         cooling capacity is determined from the total cooling capacity of the DX coil at the AHRI A2 test
     998             :         //         conditions and accounting for the INDOOR supply air fan effect.  The net total cooling capacity
     999             :         //         is reported at the high (maximum) speed only.
    1000             :         //     (3) Calculates the electric power consumed by the DX Coil Unit (compressor + outdoor condenser fan).
    1001             :         //         Evaluates the EIR capacity and flow fraction modifiers at A2, B2, B1, and F1 test coditions per
    1002             :         //         AHRI/ANSI Std. 210/240 test procedure for multi-speed compressor.  For any inter-
    1003             :         //         mediate operating conditions (speed), the successive lower and the higher speed performnace are
    1004             :         //         weighed per the standard.  Electric Power consumption is determined by adding the indoor fan
    1005             :         //         electric power to the electric power consumption by the outdoor DX Coil Fan and Compressor Power
    1006             :         //         at the AHRI test conditions.  The net total cooling capacity is also corrected for the fan heat
    1007             :         //         effect for SEER calculation.
    1008             :         //     Net Heatingg Capacity and HSPF
    1009             :         //     (4) Obtains the rated condition parameters:
    1010             :         //         Heating capacity (User specified or Autosized Value)
    1011             :         //         Rated Air volume flow rate through the DX Heating Coil (User specified or autosized value)
    1012             :         //     (5) Evaluates the heating coil capacity at AHRI H12 test conditions 21.1C/15.6C/8.33C. Then net
    1013             :         //         heating capacity is determined from the total heating capacity of the DX coil at the AHRI H12
    1014             :         //         test conditions and accounting for the supply supply air fan effect.  The net heating capacity
    1015             :         //         is reported at the high (maximum) speed only.
    1016             :         //     (6) Calculates the electric power consumed by the DX Coil Unit (compressor + outdoor condenser fan).
    1017             :         //         Evaluates the EIR capacity and flow fraction modifiers per AHRI/ANSI Std. 210/240 test procedures
    1018             :         //         for two speed compressor (H01, H11, H21, H31, H12, H22, and H32 ). This procedure was modified
    1019             :         //         for multispeed heat pumps. For any inter-mediate operating conditions (speed), the successive
    1020             :         //         lower and the higher speed performnace are weighed per the standard.
    1021             :         //         Electric Power consumption is determined by adding the supply fan electric power to the electric
    1022             :         //         power consumption by the outdoor DX Coil Fan and Compressor Power at the AHRI test conditions.
    1023             :         //         The net heating capacity is also corrected for the fan heat effect for SEER calculation.
    1024             :         // REFERENCES:
    1025             :         // (1) ANSI/AHRI Standard 210/240-2008:  Standard for Performance Rating of Unitary Air-Conditioning and
    1026             :         //                                       Air-Source Heat Pumps. Arlington, VA:  Air-Conditioning, Heating
    1027             :         //                                       , and Refrigeration Institute.
    1028             :         // (2) ANSI/AHRI Standard 340/360-2007:  Standard for Performance Rating of Commercial and Industrial
    1029             :         //                                       Unitary Air-Conditioning and Heat Pump Equipment.  Arlington,
    1030             :         //                                       VA:  Air-Conditioning, Heating, and Refrigeration Institute.
    1031             : 
    1032             :         // USE STATEMENTS:
    1033             : 
    1034             :         // Using/Aliasing
    1035             :         using Curve::CurveValue;
    1036             :         using Curve::GetCurveMinMaxValues;
    1037             :         using HVAC::Coil_CoolingAirToAirVariableSpeed;
    1038             :         using HVAC::CoilDX_CoolingSingleSpeed;
    1039             :         using HVAC::CoilDX_HeatingEmpirical;
    1040             :         using HVAC::CoilDX_MultiSpeedCooling;
    1041             :         using HVAC::CoilDX_MultiSpeedHeating;
    1042             : 
    1043             :         // Argument array dimensioning
    1044         782 :         RatedTotalCapacity.dim(ns);
    1045         782 :         RatedCOP.dim(ns);
    1046         782 :         CapFFlowCurveIndex.dim(ns);
    1047         782 :         CapFTempCurveIndex.dim(ns);
    1048         782 :         EIRFFlowCurveIndex.dim(ns);
    1049         782 :         EIRFTempCurveIndex.dim(ns);
    1050         782 :         PLFFPLRCurveIndex.dim(ns);
    1051         782 :         RatedAirVolFlowRate.dim(ns);
    1052         782 :         FanPowerPerEvapAirFlowRateFromInput.dim(ns);
    1053             : 
    1054             :         ////TODO: this will be passed as argument in this method later on
    1055             :         // Array1A<Real64> const FanPowerPerEvapAirFlowRateFromInputSEER2;
    1056         782 :         FanPowerPerEvapAirFlowRateFromInput_2023.dim(ns);
    1057             :         // Locals
    1058             :         // SUBROUTINE ARGUMENT DEFINITIONS:
    1059             : 
    1060             :         // back on, if applicable, following automatic shut off. This field is
    1061             :         // used only for HSPF calculation. [C]
    1062             : 
    1063             :         // SUBROUTINE PARAMETER DEFINITIONS:
    1064             : 
    1065             :         // INTERFACE BLOCK SPECIFICATIONS
    1066             :         // na
    1067             : 
    1068             :         // DERIVED TYPE DEFINITIONS
    1069             :         // na
    1070             : 
    1071             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    1072         782 :         Array1D<Real64> FanPowerPerEvapAirFlowRate(ns); // Fan power per air volume flow rate through the evaporator coil [W/(m3/s)]
    1073             : 
    1074             :         // Intermediate values calculated from the inputs in the idf file
    1075             :         int spnum; // compressor speed number
    1076             : 
    1077             :         // Calculated and reported to the EIO file
    1078         782 :         Real64 SEER_User(0.0);     // Seasonal Energy Efficiency Ratio using user PLF curve in SI [W/W]
    1079         782 :         Real64 SEER_Standard(0.0); // Seasonal Energy Efficiency Ratio using AHRI 210/240 PLF default curve & C_D in SI [W/W]
    1080         782 :         Real64 EER(0.0);           // Energy Efficiency Ratio using AHRI 210-240 2017 in SI [W/W]
    1081         782 :         Real64 IEER(0.0);          // Integerated Energy Efficiency Ratio in SI [W/W]
    1082             : 
    1083             :         // SEER2 ANSI/AHRI 210/240 Standard 2023 Ratings
    1084         782 :         Real64 SEER2_User(0.0);     // Seasonal Energy Efficiency Ratio using user PLF curve in SI [W/W]
    1085         782 :         Real64 SEER2_Standard(0.0); // Seasonal Energy Efficiency Ratio using AHRI 210/240 PLF default curve & C_D in SI [W/W]
    1086         782 :         Real64 EER2(0.0);           // Energy Efficiency Ratio using AHRI 210/140 - 2023
    1087         782 :         Real64 EER_2022(0.0);       // Energy Efficiency Ratio in SI [W/W]
    1088         782 :         Real64 IEER_2022(0.0);      // Integerated Energy Efficiency Ratio in SI [W/W]
    1089         782 :         Real64 NetCoolingCapRated2022(0.0);
    1090         782 :         Real64 NetCoolingCapRatedMaxSpeed2023(0.0);
    1091             : 
    1092         782 :         Real64 HSPF(0.0);                       // Heating Seasonal Performance Factor in SI [W/W]
    1093         782 :         Real64 NetHeatingCapRatedHighTemp(0.0); // Net Rated heating capacity at high temp [W]
    1094         782 :         Real64 NetHeatingCapRatedLowTemp(0.0);  // Net Rated heating capacity at low temp [W]
    1095             : 
    1096             :         // HSPF2 ANSI/AHRI 210/240 Standard 2023 Ratings
    1097         782 :         Real64 HSPF2_2023(0.0);                      // Heating Seasonal Performance Factor in SI [W/W]
    1098         782 :         Real64 NetHeatingCapRatedHighTemp_2023(0.0); // Net Rated heating capacity at high temp [W]
    1099         782 :         Real64 NetHeatingCapRatedLowTemp_2023(0.0);  // Net Rated heating capacity at low temp [W]
    1100             : 
    1101         782 :         Array1D<Real64> NetCoolingCapRated(ns);    // Net Cooling Coil capacity at Rated conditions, accounting for supply fan heat [W]
    1102         782 :         Array1D<Real64> NetTotCoolingCapRated(16); // net total cooling capacity of DX Coils for the sixteen ASHRAE Std 127 Test conditions
    1103         782 :         Array1D<Real64> TotElectricPowerRated(16); // total electric power of DX Coils for the sixteen ASHRAE Std 127 Test conditions
    1104             : 
    1105         782 :         Array1D<Real64> NetCoolingCapRated_2023(ns);    // Net Cooling Coil capacity at Rated conditions, accounting for supply fan heat [W]
    1106         782 :         Array1D<Real64> NetTotCoolingCapRated_2023(16); // net total cooling capacity of DX Coils for the sixteen ASHRAE Std 127 Test conditions
    1107         782 :         Array1D<Real64> TotElectricPowerRated_2023(16); // total electric power of DX Coils for the sixteen ASHRAE Std 127 Test conditions
    1108             : 
    1109         782 :         NetCoolingCapRated = 0.0;
    1110             : 
    1111         782 :         switch (DXCoilType_Num) {
    1112             : 
    1113         612 :         case CoilDX_CoolingSingleSpeed: { // Coil:Cooling:DX:SingleSpeed
    1114             : 
    1115        3060 :             CheckCurveLimitsForStandardRatings(state,
    1116             :                                                DXCoilName,
    1117             :                                                DXCoilType,
    1118             :                                                DXCoilType_Num,
    1119         612 :                                                CapFTempCurveIndex(1),
    1120         612 :                                                CapFFlowCurveIndex(1),
    1121         612 :                                                EIRFTempCurveIndex(1),
    1122         612 :                                                EIRFFlowCurveIndex(1),
    1123         612 :                                                PLFFPLRCurveIndex(1));
    1124             : 
    1125             :             // Calculated Net Cooling Capacity, SEER, SEER Default, EER, and IEER of single speed DX cooling coils
    1126             :             std::map<std::string, Real64> StandarRatingResults = SingleSpeedDXCoolingCoilStandardRatings(state,
    1127             :                                                                                                          DXCoilName,
    1128             :                                                                                                          DXCoilType,
    1129        1224 :                                                                                                          CapFTempCurveIndex(1),
    1130        1224 :                                                                                                          CapFFlowCurveIndex(1),
    1131        1224 :                                                                                                          EIRFTempCurveIndex(1),
    1132        1224 :                                                                                                          EIRFFlowCurveIndex(1),
    1133        1224 :                                                                                                          PLFFPLRCurveIndex(1),
    1134        1224 :                                                                                                          RatedTotalCapacity(1),
    1135        1224 :                                                                                                          RatedCOP(1),
    1136        1224 :                                                                                                          RatedAirVolFlowRate(1),
    1137        1224 :                                                                                                          FanPowerPerEvapAirFlowRateFromInput(1),
    1138        1224 :                                                                                                          FanPowerPerEvapAirFlowRateFromInput_2023(1),
    1139         612 :                                                                                                          CondenserType(1));
    1140         612 :             NetCoolingCapRated(1) = StandarRatingResults["NetCoolingCapRated"];
    1141         612 :             SEER_User = StandarRatingResults["SEER_User"];
    1142         612 :             SEER_Standard = StandarRatingResults["SEER_Standard"];
    1143         612 :             EER = StandarRatingResults["EER"];
    1144         612 :             IEER = StandarRatingResults["IEER"];
    1145             : 
    1146         612 :             NetCoolingCapRated_2023(1) = StandarRatingResults["NetCoolingCapRated2023"];
    1147         612 :             SEER2_User = StandarRatingResults["SEER2_User"];
    1148         612 :             SEER2_Standard = StandarRatingResults["SEER2_Standard"];
    1149         612 :             EER_2022 = StandarRatingResults["EER_2022"];
    1150         612 :             IEER_2022 = StandarRatingResults["IEER_2022"];
    1151             : 
    1152             :             // Writes the net rated cooling capacity, SEER, SEER Default, EER and IEER values to the EIO file and standard tabular output tables
    1153        1224 :             ReportDXCoilRating(state,
    1154             :                                DXCoilType,
    1155             :                                DXCoilName,
    1156             :                                DXCoilType_Num,
    1157         612 :                                NetCoolingCapRated(1),
    1158             :                                SEER_User * ConvFromSIToIP,
    1159             :                                SEER_Standard * ConvFromSIToIP,
    1160             :                                EER,
    1161             :                                EER * ConvFromSIToIP,
    1162             :                                IEER * ConvFromSIToIP,
    1163             :                                NetHeatingCapRatedHighTemp,
    1164             :                                NetHeatingCapRatedLowTemp,
    1165             :                                HSPF * ConvFromSIToIP,
    1166             :                                RegionNum,
    1167             :                                false);
    1168             : 
    1169             :             // ANSI/AHRI 210/240 Std. 2023 Ratings
    1170             :             // Writes the net rated cooling capacity, SEER2_USER, SEER2_Standard, EER and IEER values to the EIO file and standard tabular output
    1171             :             // tables
    1172        1224 :             ReportDXCoilRating(state,
    1173             :                                DXCoilType,
    1174             :                                DXCoilName,
    1175             :                                DXCoilType_Num,
    1176         612 :                                NetCoolingCapRated_2023(1),
    1177             :                                SEER2_User * ConvFromSIToIP,
    1178             :                                SEER2_Standard * ConvFromSIToIP,
    1179             :                                EER_2022,
    1180             :                                EER_2022 * ConvFromSIToIP,
    1181             :                                IEER_2022 * ConvFromSIToIP,
    1182             :                                NetHeatingCapRatedHighTemp_2023,
    1183             :                                NetHeatingCapRatedLowTemp_2023,
    1184             :                                HSPF2_2023 * ConvFromSIToIP,
    1185             :                                RegionNum,
    1186             :                                true);
    1187             : 
    1188         612 :             if (ASHRAE127StdRprt) {
    1189          72 :                 DXCoolingCoilDataCenterStandardRatings(state,
    1190             :                                                        DXCoilName,
    1191             :                                                        DXCoilType,
    1192           8 :                                                        CapFTempCurveIndex(1),
    1193           8 :                                                        CapFFlowCurveIndex(1),
    1194           8 :                                                        EIRFTempCurveIndex(1),
    1195           8 :                                                        EIRFFlowCurveIndex(1),
    1196           8 :                                                        PLFFPLRCurveIndex(1),
    1197           8 :                                                        RatedTotalCapacity(1),
    1198           8 :                                                        RatedCOP(1),
    1199           8 :                                                        RatedAirVolFlowRate(1),
    1200           8 :                                                        FanPowerPerEvapAirFlowRateFromInput(1),
    1201             :                                                        NetTotCoolingCapRated,
    1202             :                                                        TotElectricPowerRated);
    1203           8 :                 ReportDXCoolCoilDataCenterApplication(state, DXCoilType, DXCoilName, DXCoilType_Num, NetTotCoolingCapRated, TotElectricPowerRated);
    1204             :             }
    1205         612 :             break;
    1206         612 :         }
    1207          75 :         case CoilDX_HeatingEmpirical: { // Coil:Heating:DX:SingleSpeed
    1208             : 
    1209         375 :             CheckCurveLimitsForStandardRatings(state,
    1210             :                                                DXCoilName,
    1211             :                                                DXCoilType,
    1212             :                                                DXCoilType_Num,
    1213          75 :                                                CapFTempCurveIndex(1),
    1214          75 :                                                CapFFlowCurveIndex(1),
    1215          75 :                                                EIRFTempCurveIndex(1),
    1216          75 :                                                EIRFFlowCurveIndex(1),
    1217          75 :                                                PLFFPLRCurveIndex(1));
    1218             :             // Calculate the standard ratings for single speed DX heating coil
    1219             :             std::map<std::string, Real64> StandardRatingsResults =
    1220             :                 SingleSpeedDXHeatingCoilStandardRatings(state,
    1221             :                                                         DXCoilType,
    1222         150 :                                                         RatedTotalCapacity(1),
    1223         150 :                                                         RatedCOP(1),
    1224         150 :                                                         CapFFlowCurveIndex(1),
    1225         150 :                                                         CapFTempCurveIndex(1),
    1226         150 :                                                         EIRFFlowCurveIndex(1),
    1227         150 :                                                         EIRFTempCurveIndex(1),
    1228         150 :                                                         RatedAirVolFlowRate(1),
    1229         150 :                                                         FanPowerPerEvapAirFlowRateFromInput(1),
    1230          75 :                                                         FanPowerPerEvapAirFlowRateFromInput_2023(1),
    1231             :                                                         RegionNum,
    1232             :                                                         MinOATCompressor,
    1233             :                                                         OATempCompressorOn,
    1234             :                                                         OATempCompressorOnOffBlank,
    1235         225 :                                                         DefrostControl);
    1236          75 :             NetHeatingCapRatedHighTemp = StandardRatingsResults["NetHeatingCapRated"];
    1237          75 :             NetHeatingCapRatedLowTemp = StandardRatingsResults["NetHeatingCapH3Test"];
    1238          75 :             HSPF = StandardRatingsResults["HSPF"];
    1239             : 
    1240          75 :             NetHeatingCapRatedHighTemp_2023 = StandardRatingsResults["NetHeatingCapRated_2023"];
    1241          75 :             NetHeatingCapRatedLowTemp_2023 = StandardRatingsResults["NetHeatingCapH3Test_2023"];
    1242          75 :             HSPF2_2023 = StandardRatingsResults["HSPF2_2023"];
    1243          75 :             IEER_2022 = StandardRatingsResults["IEER_2022"];
    1244             :             // Writes the HSPF value to the EIO file and standard tabular output tables
    1245         150 :             ReportDXCoilRating(state,
    1246             :                                DXCoilType,
    1247             :                                DXCoilName,
    1248             :                                DXCoilType_Num,
    1249          75 :                                NetCoolingCapRated(1),
    1250             :                                SEER_User * ConvFromSIToIP,
    1251             :                                SEER_Standard * ConvFromSIToIP,
    1252             :                                EER,
    1253             :                                EER * ConvFromSIToIP,
    1254             :                                IEER * ConvFromSIToIP,
    1255             :                                NetHeatingCapRatedHighTemp,
    1256             :                                NetHeatingCapRatedLowTemp,
    1257             :                                HSPF * ConvFromSIToIP,
    1258             :                                RegionNum,
    1259             :                                false);
    1260             : 
    1261             :             // ANSI/AHRI 210/240 Std. 2023 Ratings
    1262             :             // Writes the HSPF2 value to the EIO file and standard tabular output tables
    1263         150 :             ReportDXCoilRating(state,
    1264             :                                DXCoilType,
    1265             :                                DXCoilName,
    1266             :                                DXCoilType_Num,
    1267          75 :                                NetCoolingCapRated_2023(1),
    1268             :                                SEER2_User * ConvFromSIToIP,
    1269             :                                SEER2_Standard * ConvFromSIToIP,
    1270             :                                EER_2022,
    1271             :                                EER_2022 * ConvFromSIToIP,
    1272             :                                IEER_2022 * ConvFromSIToIP,
    1273             :                                NetHeatingCapRatedHighTemp_2023,
    1274             :                                NetHeatingCapRatedLowTemp_2023,
    1275             :                                HSPF2_2023 * ConvFromSIToIP,
    1276             :                                RegionNum,
    1277             :                                true);
    1278          75 :             break;
    1279          75 :         }
    1280          49 :         case CoilDX_MultiSpeedCooling: { // Coil:Cooling:DX:MultiSpeed,
    1281             : 
    1282         162 :             for (spnum = 1; spnum <= ns; ++spnum) {
    1283         565 :                 CheckCurveLimitsForStandardRatings(state,
    1284             :                                                    DXCoilName,
    1285             :                                                    DXCoilType,
    1286             :                                                    DXCoilType_Num,
    1287         113 :                                                    CapFTempCurveIndex(spnum),
    1288         113 :                                                    CapFFlowCurveIndex(spnum),
    1289         113 :                                                    EIRFTempCurveIndex(spnum),
    1290         113 :                                                    EIRFFlowCurveIndex(spnum),
    1291         113 :                                                    PLFFPLRCurveIndex(spnum));
    1292             :             }
    1293             :             // Calculate the standard ratings for multispeed DX cooling coil
    1294             :             std::map<std::string, Real64> StandardRatingsResult = MultiSpeedDXCoolingCoilStandardRatings(state,
    1295             :                                                                                                          DXCoilName,
    1296             :                                                                                                          DXCoilType,
    1297             :                                                                                                          CapFTempCurveIndex,
    1298             :                                                                                                          CapFFlowCurveIndex,
    1299             :                                                                                                          EIRFTempCurveIndex,
    1300             :                                                                                                          EIRFFlowCurveIndex,
    1301             :                                                                                                          PLFFPLRCurveIndex,
    1302             :                                                                                                          RatedTotalCapacity,
    1303             :                                                                                                          RatedCOP,
    1304             :                                                                                                          RatedAirVolFlowRate,
    1305             :                                                                                                          FanPowerPerEvapAirFlowRateFromInput,
    1306             :                                                                                                          FanPowerPerEvapAirFlowRateFromInput_2023,
    1307             :                                                                                                          ns,
    1308          98 :                                                                                                          CondenserType);
    1309          49 :             NetCoolingCapRated(ns) = StandardRatingsResult["NetCoolingCapRatedMaxSpeed"];
    1310          49 :             SEER_User = StandardRatingsResult["SEER_User"];
    1311          49 :             SEER_Standard = StandardRatingsResult["SEER_Standard"];
    1312          49 :             EER = StandardRatingsResult["EER"];
    1313             : 
    1314          49 :             NetCoolingCapRated_2023(ns) = StandardRatingsResult["NetCoolingCapRatedMaxSpeed2023"];
    1315          49 :             SEER2_User = StandardRatingsResult["SEER2_User"];
    1316          49 :             SEER2_Standard = StandardRatingsResult["SEER2_Standard"];
    1317          49 :             EER2 = StandardRatingsResult["EER2"];
    1318             : 
    1319          49 :             IEER_2022 = StandardRatingsResult["IEER_2022"];
    1320          49 :             EER_2022 = StandardRatingsResult["EER_2022"];
    1321             : 
    1322             :             // Writes the SEER value to the EIO file and standard tabular output tables
    1323          49 :             ReportDXCoilRating(state,
    1324             :                                DXCoilType,
    1325             :                                DXCoilName,
    1326             :                                DXCoilType_Num,
    1327          49 :                                NetCoolingCapRated(ns),
    1328             :                                SEER_User * ConvFromSIToIP,
    1329             :                                SEER_Standard * ConvFromSIToIP,
    1330             :                                EER,
    1331             :                                EER * ConvFromSIToIP,
    1332             :                                0.0,
    1333             :                                0.0,
    1334             :                                0.0,
    1335             :                                0.0,
    1336             :                                0,
    1337             :                                false);
    1338             : 
    1339             :             // Writes the SEER value to the EIO file and standard tabular output tables
    1340          49 :             ReportDXCoilRating(state,
    1341             :                                DXCoilType,
    1342             :                                DXCoilName,
    1343             :                                DXCoilType_Num,
    1344          49 :                                NetCoolingCapRated_2023(ns),
    1345             :                                SEER2_User * ConvFromSIToIP,
    1346             :                                SEER2_Standard * ConvFromSIToIP,
    1347             :                                EER_2022,
    1348             :                                EER_2022 * ConvFromSIToIP,
    1349             :                                IEER_2022 * ConvFromSIToIP,
    1350             :                                0.0,
    1351             :                                0.0,
    1352             :                                0.0,
    1353             :                                0,
    1354             :                                true);
    1355             : 
    1356          49 :             break;
    1357          49 :         }
    1358          22 :         case CoilDX_MultiSpeedHeating: { // Coil:Heating:DX:MultiSpeed
    1359             : 
    1360          92 :             for (spnum = 1; spnum <= ns; ++spnum) {
    1361         350 :                 CheckCurveLimitsForStandardRatings(state,
    1362             :                                                    DXCoilName,
    1363             :                                                    DXCoilType,
    1364             :                                                    DXCoilType_Num,
    1365          70 :                                                    CapFTempCurveIndex(spnum),
    1366          70 :                                                    CapFFlowCurveIndex(spnum),
    1367          70 :                                                    EIRFTempCurveIndex(spnum),
    1368          70 :                                                    EIRFFlowCurveIndex(spnum),
    1369          70 :                                                    PLFFPLRCurveIndex(spnum));
    1370             :             }
    1371             :             // Calculate Net heatig capacity and HSPF & HSPF2 of multispeed DX heating coils
    1372             :             std::map<std::string, Real64> StandardRatingsResult = MultiSpeedDXHeatingCoilStandardRatings(state,
    1373             :                                                                                                          DXCoilName,
    1374             :                                                                                                          DXCoilType,
    1375             :                                                                                                          CapFTempCurveIndex,
    1376             :                                                                                                          CapFFlowCurveIndex,
    1377             :                                                                                                          EIRFTempCurveIndex,
    1378             :                                                                                                          EIRFFlowCurveIndex,
    1379             :                                                                                                          PLFFPLRCurveIndex,
    1380             :                                                                                                          RatedTotalCapacity,
    1381             :                                                                                                          RatedCOP,
    1382             :                                                                                                          RatedAirVolFlowRate,
    1383             :                                                                                                          FanPowerPerEvapAirFlowRateFromInput,
    1384             :                                                                                                          FanPowerPerEvapAirFlowRateFromInput_2023,
    1385             :                                                                                                          ns,
    1386             :                                                                                                          RegionNum,
    1387             :                                                                                                          MinOATCompressor,
    1388             :                                                                                                          OATempCompressorOn,
    1389             :                                                                                                          OATempCompressorOnOffBlank,
    1390          44 :                                                                                                          DefrostControl);
    1391             : 
    1392          22 :             NetHeatingCapRatedHighTemp = StandardRatingsResult["NetHeatingCapRatedHighTemp"];
    1393          22 :             NetHeatingCapRatedLowTemp = StandardRatingsResult["NetHeatingCapRatedLowTemp"];
    1394          22 :             HSPF = StandardRatingsResult["HSPF"];
    1395             : 
    1396          22 :             NetHeatingCapRatedHighTemp_2023 = StandardRatingsResult["NetHeatingCapRatedHighTemp_2023"];
    1397          22 :             NetHeatingCapRatedLowTemp_2023 = StandardRatingsResult["NetHeatingCapRatedLowTemp_2023"];
    1398          22 :             HSPF2_2023 = StandardRatingsResult["HSPF2_2023"];
    1399             : 
    1400          22 :             IEER_2022 = StandardRatingsResult["IEER_2022"];
    1401             :             // ANSI/AHRI Std. 2017 Ratings
    1402             :             // Writes the HSPF value to the EIO file and standard tabular output tables
    1403          44 :             ReportDXCoilRating(state,
    1404             :                                DXCoilType,
    1405             :                                DXCoilName,
    1406             :                                DXCoilType_Num,
    1407          22 :                                NetCoolingCapRated(ns),
    1408             :                                SEER_User * ConvFromSIToIP,
    1409             :                                SEER_Standard * ConvFromSIToIP,
    1410             :                                EER,
    1411             :                                EER * ConvFromSIToIP,
    1412             :                                IEER * ConvFromSIToIP,
    1413             :                                NetHeatingCapRatedHighTemp,
    1414             :                                NetHeatingCapRatedLowTemp,
    1415             :                                HSPF * ConvFromSIToIP,
    1416             :                                RegionNum,
    1417             :                                false);
    1418             : 
    1419             :             // ANSI/AHRI 210/240 Std. 2023 Ratings
    1420             :             // Writes the HSPF2 value to the EIO file and standard tabular output tables
    1421          44 :             ReportDXCoilRating(state,
    1422             :                                DXCoilType,
    1423             :                                DXCoilName,
    1424             :                                DXCoilType_Num,
    1425          22 :                                NetCoolingCapRated(ns),
    1426             :                                SEER_User * ConvFromSIToIP,
    1427             :                                SEER_Standard * ConvFromSIToIP,
    1428             :                                EER,
    1429             :                                EER * ConvFromSIToIP,
    1430             :                                IEER_2022 * ConvFromSIToIP,
    1431             :                                NetHeatingCapRatedHighTemp_2023,
    1432             :                                NetHeatingCapRatedLowTemp_2023,
    1433             :                                HSPF2_2023 * ConvFromSIToIP,
    1434             :                                RegionNum,
    1435             :                                true);
    1436             : 
    1437          22 :             break;
    1438          22 :         }
    1439          24 :         case Coil_CoolingAirToAirVariableSpeed: {
    1440         204 :             for (spnum = 1; spnum <= ns; ++spnum) {
    1441         900 :                 CheckCurveLimitsForStandardRatings(state,
    1442             :                                                    DXCoilName,
    1443             :                                                    DXCoilType,
    1444             :                                                    DXCoilType_Num,
    1445         180 :                                                    CapFTempCurveIndex(spnum),
    1446         180 :                                                    CapFFlowCurveIndex(spnum),
    1447         180 :                                                    EIRFTempCurveIndex(spnum),
    1448         180 :                                                    EIRFFlowCurveIndex(spnum),
    1449         180 :                                                    PLFFPLRCurveIndex(spnum));
    1450             :             }
    1451             : 
    1452             :             // Calculate the standard ratings for multispeed DX cooling coil
    1453          24 :             std::map<std::string, Real64> StandardRatingsResult = VariableSpeedDXCoolingCoilStandardRatings(state,
    1454             :                                                                                                             DXCoilType,
    1455             :                                                                                                             DXCoilName,
    1456             :                                                                                                             CapFTempCurveIndex,
    1457             :                                                                                                             CapFFlowCurveIndex,
    1458             :                                                                                                             EIRFTempCurveIndex,
    1459             :                                                                                                             EIRFFlowCurveIndex,
    1460          24 :                                                                                                             PLFFPLRCurveIndex(1),
    1461             :                                                                                                             RatedTotalCapacity,
    1462             :                                                                                                             RatedCOP,
    1463             :                                                                                                             RatedAirVolFlowRate,
    1464             :                                                                                                             FanPowerPerEvapAirFlowRateFromInput,
    1465             :                                                                                                             FanPowerPerEvapAirFlowRateFromInput_2023,
    1466             :                                                                                                             ns,
    1467          48 :                                                                                                             CondenserType(1),
    1468             :                                                                                                             GrossRatedTotalCoolingCapacityVS,
    1469          72 :                                                                                                             RatedVolumetricAirFlowRateVS);
    1470             : 
    1471          24 :             NetCoolingCapRated_2023(ns) = StandardRatingsResult["NetCoolingCapRatedMaxSpeed2023"];
    1472          24 :             SEER2_User = StandardRatingsResult["SEER2_User"];
    1473          24 :             SEER2_Standard = StandardRatingsResult["SEER2_Standard"];
    1474          24 :             EER2 = StandardRatingsResult["EER2"];
    1475             : 
    1476          24 :             IEER_2022 = StandardRatingsResult["IEER_2022"];
    1477          24 :             EER_2022 = StandardRatingsResult["EER_2022"];
    1478             : 
    1479          24 :             NetCoolingCapRated(ns) = StandardRatingsResult["NetCoolingCapRatedMaxSpeed"];
    1480             : 
    1481             :             // Writes the SEER2 & IEER 2022 value to the EIO file and standard tabular output tables | 2023
    1482          24 :             ReportDXCoilRating(state,
    1483             :                                DXCoilType,
    1484             :                                DXCoilName,
    1485             :                                DXCoilType_Num,
    1486          24 :                                NetCoolingCapRated_2023(ns),
    1487             :                                SEER2_User * ConvFromSIToIP,
    1488             :                                SEER2_Standard * ConvFromSIToIP,
    1489             :                                EER_2022,
    1490             :                                EER_2022 * ConvFromSIToIP,
    1491             :                                IEER_2022 * ConvFromSIToIP,
    1492             :                                0.0,
    1493             :                                0.0,
    1494             :                                0.0,
    1495             :                                0,
    1496             :                                true);
    1497          24 :             break;
    1498          24 :         }
    1499           0 :         default:
    1500           0 :             break; //... other DX Coil types will follow here
    1501             :         }
    1502         782 :     }
    1503             : 
    1504          67 :     void CalcTwoSpeedDXCoilRating(EnergyPlusData &state,
    1505             :                                   std::string const &DXCoilName,
    1506             :                                   std::string const &DXCoilType,
    1507             :                                   int const DXCoilType_Num,
    1508             :                                   Array1A<Real64> const &RatedTotalCapacity,
    1509             :                                   Real64 const RatedTotCap2,
    1510             :                                   Array1A<Real64> const &RatedCOP,
    1511             :                                   Real64 const RatedCOP2,
    1512             :                                   Array1A_int const &CapFFlowCurveIndex, // only hs
    1513             :                                   Array1A_int const &CapFTempCurveIndex,
    1514             :                                   int const CCapFTemp2,
    1515             :                                   Array1A_int const &EIRFFlowCurveIndex, // only hs
    1516             :                                   Array1A_int const &EIRFTempCurveIndex,
    1517             :                                   int const EIRFTemp2,
    1518             :                                   Array1A<Real64> const &RatedAirVolFlowRate,
    1519             :                                   Real64 const RatedAirVolFlowRate2,
    1520             :                                   Array1A<Real64> const &FanPowerPerEvapAirFlowRate_2023,
    1521             :                                   Array1A<Real64> const &FanPowerPerEvapAirFlowRate_2023_LowSpeed,
    1522             :                                   Array1D<DataHeatBalance::RefrigCondenserType> const &CondenserType,
    1523             :                                   int const PLFFPLRCurveIndex)
    1524             :     {
    1525          67 :         std::map<std::string, Real64> StandardRatingsResult;
    1526             : 
    1527             :         // Intermediate values calculated from the inputs in the idf file
    1528             :         // SEER2 ANSI/AHRI 210/240 Standard 2023 Ratings
    1529          67 :         Real64 SEER2_User(0.0);                     // Seasonal Energy Efficiency Ratio using user PLF curve in SI [W/W]
    1530          67 :         Real64 SEER2_Standard(0.0);                 // Seasonal Energy Efficiency Ratio using AHRI 210/240 PLF default curve & C_D in SI [W/W]
    1531          67 :         Real64 EER2(0.0);                           // Energy Efficiency Ratio using AHRI 210/240 - 2023
    1532          67 :         Real64 NetCoolingCapRatedMaxSpeed2023(0.0); // net cooling capacity at maximum speed
    1533             : 
    1534          67 :         Real64 EER_2022(0.0);  // Energy Efficiency Ratio in SI [W/W]
    1535          67 :         Real64 IEER_2022(0.0); // Integerated Energy Efficiency Ratio in SI [W/W]
    1536          67 :         Real64 NetCoolingCapRated2022(0.0);
    1537             : 
    1538          67 :         Real64 EER(0.0);
    1539          67 :         Real64 NetCoolingCapRated(0.0);
    1540             : 
    1541          67 :         int ns = 2;
    1542             : 
    1543         134 :         StandardRatingsResult = TwoSpeedDXCoilStandardRatings(state,
    1544             :                                                               DXCoilName,
    1545             :                                                               DXCoilType,
    1546             :                                                               DXCoilType_Num,
    1547             :                                                               RatedTotalCapacity,
    1548             :                                                               RatedTotCap2,
    1549             :                                                               RatedCOP,
    1550             :                                                               RatedCOP2,
    1551             :                                                               CapFFlowCurveIndex, // only hs
    1552             :                                                               CapFTempCurveIndex,
    1553             :                                                               CCapFTemp2,
    1554             :                                                               EIRFFlowCurveIndex, // only hs
    1555             :                                                               EIRFTempCurveIndex,
    1556             :                                                               EIRFTemp2,
    1557             :                                                               RatedAirVolFlowRate,
    1558             :                                                               RatedAirVolFlowRate2,
    1559             :                                                               FanPowerPerEvapAirFlowRate_2023,
    1560             :                                                               FanPowerPerEvapAirFlowRate_2023_LowSpeed,
    1561             :                                                               CondenserType,
    1562          67 :                                                               PLFFPLRCurveIndex);
    1563             : 
    1564             :         // From SEER2 implementation
    1565          67 :         NetCoolingCapRatedMaxSpeed2023 = StandardRatingsResult["NetCoolingCapRatedMaxSpeed2023"];
    1566          67 :         SEER2_User = StandardRatingsResult["SEER2_User"];
    1567          67 :         SEER2_Standard = StandardRatingsResult["SEER2_Standard"];
    1568          67 :         EER2 = StandardRatingsResult["EER2"];
    1569             : 
    1570             :         // From IEER 2022 implementation
    1571          67 :         NetCoolingCapRated2022 = StandardRatingsResult["NetCoolingCapRatedMaxSpeed"];
    1572          67 :         IEER_2022 = StandardRatingsResult["IEER_2022"];
    1573          67 :         EER_2022 = StandardRatingsResult["EER_2022"];
    1574             : 
    1575          67 :         NetCoolingCapRated = NetCoolingCapRatedMaxSpeed2023;
    1576             :         // for the Report routine to correctly initialize with EER value.
    1577          67 :         if (StandardRatingsResult["SEER2_Standard"] > 0.0) {
    1578          66 :             EER = EER2;
    1579           1 :         } else if (StandardRatingsResult["IEER_2022"] > 0.0) {
    1580           1 :             EER = EER_2022;
    1581           1 :             NetCoolingCapRated = NetCoolingCapRated2022;
    1582             :         }
    1583             : 
    1584             :         // Writes the SEER & IEER value to the EIO file and standard tabular output tables
    1585          67 :         ReportDXCoilRating(state,
    1586             :                            DXCoilType,
    1587             :                            DXCoilName,
    1588             :                            DXCoilType_Num,
    1589             :                            NetCoolingCapRated,
    1590             :                            SEER2_User * ConvFromSIToIP,
    1591             :                            SEER2_Standard * ConvFromSIToIP,
    1592             :                            EER,
    1593             :                            EER * ConvFromSIToIP,
    1594             :                            IEER_2022 * ConvFromSIToIP,
    1595             :                            0.0,
    1596             :                            0.0,
    1597             :                            0.0,
    1598             :                            0,
    1599             :                            true);
    1600          67 :     }
    1601             : 
    1602          67 :     std::map<std::string, Real64> TwoSpeedDXCoilStandardRatings(EnergyPlusData &state,
    1603             :                                                                 std::string const &DXCoilName,
    1604             :                                                                 std::string const &DXCoilType,
    1605             :                                                                 int const &DXCoilType_Num,
    1606             :                                                                 Array1A<Real64> const &RatedTotalCapacity,
    1607             :                                                                 Real64 const &RatedTotCap2,
    1608             :                                                                 Array1A<Real64> const &RatedCOP,
    1609             :                                                                 Real64 const &RatedCOP2,
    1610             :                                                                 Array1A_int const &CapFFlowCurveIndex, // only hs
    1611             :                                                                 Array1A_int const &CapFTempCurveIndex,
    1612             :                                                                 int const &CCapFTemp2,
    1613             :                                                                 Array1A_int const &EIRFFlowCurveIndex, // only hs
    1614             :                                                                 Array1A_int const &EIRFTempCurveIndex,
    1615             :                                                                 int const &EIRFTemp2,
    1616             :                                                                 Array1A<Real64> const &RatedAirVolFlowRate,
    1617             :                                                                 Real64 const &RatedAirVolFlowRate2,
    1618             :                                                                 Array1A<Real64> const &FanPowerPerEvapAirFlowRate_2023,
    1619             :                                                                 Array1A<Real64> const &FanPowerPerEvapAirFlowRate_2023_LowSpeed,
    1620             :                                                                 Array1D<DataHeatBalance::RefrigCondenserType> const &CondenserType,
    1621             :                                                                 int const &PLFFPLRCurveIndex)
    1622             :     {
    1623          67 :         std::map<std::string, Real64> StandardRatingsResult;
    1624             : 
    1625             :         // Intermediate values calculated from the inputs in the idf file
    1626             :         // SEER2 ANSI/AHRI 210/240 Standard 2023 Ratings
    1627          67 :         Real64 SEER2_User(0.0);                     // Seasonal Energy Efficiency Ratio using user PLF curve in SI [W/W]
    1628          67 :         Real64 SEER2_Standard(0.0);                 // Seasonal Energy Efficiency Ratio using AHRI 210/240 PLF default curve & C_D in SI [W/W]
    1629          67 :         Real64 EER2(0.0);                           // Energy Efficiency Ratio using AHRI 210/240 - 2023
    1630          67 :         Real64 NetCoolingCapRatedMaxSpeed2023(0.0); // net cooling capacity at maximum speed
    1631             : 
    1632          67 :         Real64 EER_2022(0.0);  // Energy Efficiency Ratio in SI [W/W]
    1633          67 :         Real64 IEER_2022(0.0); // Integerated Energy Efficiency Ratio in SI [W/W]
    1634          67 :         Real64 NetCoolingCapRated2022(0.0);
    1635             : 
    1636          67 :         int ns = 2;
    1637          67 :         Array1D<Real64> NetCoolingCapRated_2023(ns);    // Net Cooling Coil capacity at Rated conditions, accounting for supply fan heat [W]
    1638          67 :         Array1D<Real64> NetTotCoolingCapRated_2023(16); // net total cooling capacity of DX Coils for the sixteen ASHRAE Std 127 Test conditions
    1639          67 :         Array1D<Real64> TotElectricPowerRated_2023(16); // total electric power of DX Coils for the sixteen ASHRAE Std 127 Test conditions
    1640             : 
    1641          67 :         Array1D_int TSCCapFTemp;
    1642          67 :         TSCCapFTemp.push_back(CapFTempCurveIndex(1));
    1643          67 :         TSCCapFTemp.push_back(CCapFTemp2);
    1644             : 
    1645          67 :         Array1D<Real64> TSFanPowerPerEvapAirFlowRate2023;
    1646          67 :         TSFanPowerPerEvapAirFlowRate2023.push_back(FanPowerPerEvapAirFlowRate_2023(1));
    1647          67 :         TSFanPowerPerEvapAirFlowRate2023.push_back(FanPowerPerEvapAirFlowRate_2023_LowSpeed(1));
    1648             : 
    1649          67 :         Array1D<Real64> TSRatedTotCap;
    1650          67 :         TSRatedTotCap.push_back(RatedTotalCapacity(1));
    1651          67 :         TSRatedTotCap.push_back(RatedTotCap2);
    1652             : 
    1653          67 :         Array1D<Real64> TSRatedAirVolFlowRate;
    1654          67 :         TSRatedAirVolFlowRate.push_back(RatedAirVolFlowRate(1));
    1655          67 :         TSRatedAirVolFlowRate.push_back(RatedAirVolFlowRate2);
    1656             : 
    1657          67 :         Array1D_int TSEIRFTemp;
    1658          67 :         TSEIRFTemp.push_back(EIRFTempCurveIndex(1));
    1659          67 :         TSEIRFTemp.push_back(EIRFTemp2);
    1660             : 
    1661          67 :         Array1D<Real64> TSRatedCOP;
    1662          67 :         TSRatedCOP.push_back(RatedCOP(1));
    1663          67 :         TSRatedCOP.push_back(RatedCOP2);
    1664             : 
    1665         201 :         for (int spnum = 1; spnum <= ns; ++spnum) {
    1666             :             // TODO:BPS Implement Two Speed Case :
    1667         670 :             CheckCurveLimitsForStandardRatings(state,
    1668             :                                                DXCoilName,
    1669             :                                                DXCoilType,
    1670             :                                                DXCoilType_Num,
    1671         134 :                                                TSCCapFTemp(spnum),
    1672         134 :                                                CapFFlowCurveIndex(1), // only HS
    1673         134 :                                                TSEIRFTemp(spnum),
    1674         134 :                                                EIRFFlowCurveIndex(1), // Only HS
    1675             :                                                PLFFPLRCurveIndex);    // Only Coil Level
    1676             :         }
    1677             : 
    1678          67 :         if (RatedTotalCapacity(1) > 0.0 && RatedAirVolFlowRate(1) > 0.0) {
    1679             : 
    1680             :             Real64 TotCapTempModFac =
    1681          67 :                 Curve::CurveValue(state, CapFTempCurveIndex(1), CoolingCoilInletAirWetBulbTempRated, CoilInletAirCoolDryBulbIEER);
    1682          67 :             Real64 TotCapFlowModFac = Curve::CurveValue(state, CapFFlowCurveIndex(1), AirMassFlowRatioRated);
    1683          67 :             NetCoolingCapRatedMaxSpeed2023 =
    1684          67 :                 RatedTotalCapacity(1) * TotCapTempModFac * TotCapFlowModFac - FanPowerPerEvapAirFlowRate_2023(1) * RatedAirVolFlowRate(1);
    1685             :             // TODO: Commercial and industrial unitary air-conditioning condensing units with a capacity greater than 135,000 Btu/h (39564.59445
    1686             :             // Watts) as defined in ANSI/AHRI Standard 365(I-P). | Scope 2.2.6 (ANSI/AHRI 340-360 2022)
    1687             : 
    1688          67 :             if (CondenserType(1) == DataHeatBalance::RefrigCondenserType::Air) {
    1689             :                 // ANSI/AHRI 210/240 Standard 2023 only applies for solely to Air Cooled Cooling Coils
    1690             :                 // Also, this standard applies to factory-made Unitary Air-conditioners and Unitary Air-source Heat Pumps with
    1691             :                 // capacities less than 65,000 Btu/h (19049.61955 Watts) | Section 2.1
    1692             :                 // Removal of water-cooled and evaporatively-cooled products from the scope | Foreword (ANSI/AHRI 210-240 2023)
    1693             : 
    1694             :                 // SEER2 Calculations ANSI/AHRI 210/240 Standard 2023
    1695          66 :                 std::tie(NetCoolingCapRatedMaxSpeed2023, SEER2_User, SEER2_Standard, EER2) =
    1696         132 :                     TwoSpeedDXCoolingCoilSEER2(state,
    1697             :                                                // 2, // nsp will always be 2 in case of Two Speed Coil
    1698             :                                                CapFFlowCurveIndex, // only HS
    1699             :                                                TSRatedTotCap,
    1700             :                                                TSCCapFTemp,
    1701             :                                                TSFanPowerPerEvapAirFlowRate2023,
    1702             :                                                TSRatedAirVolFlowRate,
    1703             :                                                EIRFFlowCurveIndex, // only HS
    1704             :                                                TSRatedCOP,
    1705             :                                                TSEIRFTemp,
    1706          66 :                                                PLFFPLRCurveIndex); // only coil level
    1707             :             }
    1708             : 
    1709             :             // Calculate the IEER 2022 Standard ratings for Two Speed DX cooling coil | AHRI 340/360
    1710         134 :             std::tie(IEER_2022, NetCoolingCapRated2022, EER_2022) = IEERCalculationTwoSpeed(state,
    1711             :                                                                                             DXCoilType,
    1712             :                                                                                             CondenserType,
    1713             :                                                                                             TSCCapFTemp,
    1714             :                                                                                             TSRatedTotCap,
    1715             :                                                                                             CapFFlowCurveIndex,
    1716             :                                                                                             TSFanPowerPerEvapAirFlowRate2023,
    1717             :                                                                                             TSRatedAirVolFlowRate,
    1718             :                                                                                             TSEIRFTemp,
    1719             :                                                                                             TSRatedCOP,
    1720          67 :                                                                                             EIRFFlowCurveIndex);
    1721          67 :             NetCoolingCapRated_2023(ns) = NetCoolingCapRated2022;
    1722             : 
    1723             :         } else {
    1724           0 :             ShowSevereError(state,
    1725             :                             "Standard Ratings: Coil:Cooling:DX:TwoSpeed either has a zero rated total cooling capacity or zero air flow rate. "
    1726             :                             "Standard ratings cannot be calculated.");
    1727             :         }
    1728             : 
    1729             :         // From SEER2 implementation
    1730          67 :         StandardRatingsResult["NetCoolingCapRatedMaxSpeed2023"] = NetCoolingCapRatedMaxSpeed2023;
    1731          67 :         StandardRatingsResult["SEER2_User"] = SEER2_User;
    1732          67 :         StandardRatingsResult["SEER2_Standard"] = SEER2_Standard;
    1733          67 :         StandardRatingsResult["EER2"] = EER2;
    1734             : 
    1735             :         // From IEER2 implementation
    1736          67 :         StandardRatingsResult["NetCoolingCapRatedMaxSpeed"] = NetCoolingCapRated2022;
    1737          67 :         StandardRatingsResult["IEER_2022"] = IEER_2022;
    1738          67 :         StandardRatingsResult["EER_2022"] = EER_2022;
    1739             : 
    1740         134 :         return StandardRatingsResult;
    1741          67 :     }
    1742             : 
    1743          75 :     Real64 SingleSpeedHeatingHSPF(const Real64 NetHeatingCapRated,
    1744             :                                   ObjexxFCL::Optional_int_const RegionNum,
    1745             :                                   const Real64 NetHeatingCapH3Test,
    1746             :                                   const Real64 ElecPowerH3Test,
    1747             :                                   const Real64 ElecPowerRated,
    1748             :                                   const Real64 NetHeatingCapH2Test,
    1749             :                                   const Real64 ElecPowerH2Test,
    1750             :                                   ObjexxFCL::Optional<Real64 const> MinOATCompressor,
    1751             :                                   ObjexxFCL::Optional_bool_const OATempCompressorOnOffBlank,
    1752             :                                   ObjexxFCL::Optional<Real64 const> OATempCompressorOn,
    1753             :                                   ObjexxFCL::Optional<const HPdefrostControl> DefrostControl)
    1754             :     {
    1755             :         int BinNum;                           // bin number counter
    1756             :         Int64 StandardDHRNum;                 // Integer counter for standardized DHRs
    1757          75 :         Real64 CheckCOP(0.0);                 // Checking COP at an outdoor bin temperature against unity [-]
    1758          75 :         Real64 DesignHeatingRequirement(0.0); // The amount of heating required to maintain a given indoor temperature
    1759             :         // at a particular outdoor design temperature.  [W]
    1760          75 :         Real64 DesignHeatingRequirementMin(0.0); // minimum design heating requirement [W]
    1761          75 :         Real64 FractionalBinHours(0.0);          // Fractional bin hours for the heating season  [-]
    1762          75 :         Real64 BuildingLoad(0.0);                // Building space conditioning load corresponding to an outdoor bin temperature [W]
    1763             : 
    1764          75 :         Real64 HeatingModeLoadFactor(0.0); // Heating mode load factor corresponding to an outdoor bin temperature  [-]
    1765          75 :         Real64 NetHeatingCapReduced(0.0);  // Net Heating Coil capacity corresponding to an outdoor bin temperature [W]
    1766          75 :         Real64 TotalBuildingLoad(0.0);     // Sum of building load over the entire heating season [W]
    1767             : 
    1768          75 :         Real64 TotalElectricalEnergy(0.0); // Sum of electrical energy consumed by the heatpump over the heating season [W]
    1769          75 :         Real64 DemandDeforstCredit(1.0);   // A factor to adjust HSPF if coil has demand defrost control  [-]
    1770             : 
    1771          75 :         Real64 ElectricalPowerConsumption(0.0);            // Electrical power corresponding to an outdoor bin temperature [W]
    1772          75 :         Real64 HeatPumpElectricalEnergy(0.0);              // Heatpump electrical energy corresponding to an outdoor bin temperature [W]
    1773          75 :         Real64 TotalHeatPumpElectricalEnergy(0.0);         // Sum of Heatpump electrical energy over the entire heating season [W]
    1774          75 :         Real64 ResistiveSpaceHeatingElectricalEnergy(0.0); // resistance heating electrical energy corresponding to an
    1775             :         // outdoor bin temperature [W]
    1776          75 :         Real64 TotalResistiveSpaceHeatingElectricalEnergy(0.0); // Sum of resistance heating electrical energy over the
    1777             :         // entire heating season [W]
    1778             :         Real64 PartLoadFactor;
    1779          75 :         Real64 LowTempCutOutFactor(0.0); // Factor which corresponds to compressor operation depending on outdoor temperature
    1780          75 :         Real64 OATempCompressorOff(0.0); // Minimum outdoor air temperature to turn the commpressor off, [C]
    1781          75 :         Real64 HSPF(0.0);
    1782             : 
    1783          75 :         if (RegionNum == 5) {
    1784           0 :             DesignHeatingRequirementMin = NetHeatingCapRated;
    1785             :         } else {
    1786          75 :             DesignHeatingRequirementMin = NetHeatingCapRated * 1.8 * (18.33 - OutdoorDesignTemperature[static_cast<int64_t>(RegionNum) - 1]) / 60.0;
    1787             :         }
    1788             : 
    1789        1200 :         for (StandardDHRNum = 0; StandardDHRNum < TotalNumOfStandardDHRs - 1; ++StandardDHRNum) {
    1790        1680 :             if (StandardDesignHeatingRequirement[StandardDHRNum] <= DesignHeatingRequirementMin &&
    1791         555 :                 StandardDesignHeatingRequirement[StandardDHRNum + 1] >= DesignHeatingRequirementMin) {
    1792         101 :                 if ((DesignHeatingRequirementMin - StandardDesignHeatingRequirement[StandardDHRNum]) >
    1793         101 :                     (StandardDesignHeatingRequirement[StandardDHRNum + 1] - DesignHeatingRequirementMin)) {
    1794          39 :                     DesignHeatingRequirementMin = StandardDesignHeatingRequirement[StandardDHRNum + 1];
    1795             :                 } else {
    1796          62 :                     DesignHeatingRequirementMin = StandardDesignHeatingRequirement[StandardDHRNum];
    1797             :                 }
    1798             :             }
    1799             :         }
    1800          75 :         if (StandardDesignHeatingRequirement[0] >= DesignHeatingRequirementMin) {
    1801           0 :             DesignHeatingRequirement = StandardDesignHeatingRequirement[0];
    1802          75 :         } else if (StandardDesignHeatingRequirement[TotalNumOfStandardDHRs - 1] <= DesignHeatingRequirementMin) {
    1803          13 :             DesignHeatingRequirement = StandardDesignHeatingRequirement[TotalNumOfStandardDHRs - 1];
    1804             :         } else {
    1805          62 :             DesignHeatingRequirement = DesignHeatingRequirementMin;
    1806             :         }
    1807             : 
    1808        1200 :         for (BinNum = 0; BinNum < TotalNumOfTemperatureBins[static_cast<int64_t>(RegionNum) - 1]; ++BinNum) {
    1809             : 
    1810        1125 :             FractionalBinHours = FracBinHoursAtOutdoorBinTemp[static_cast<int64_t>(RegionNum) - 1][BinNum];
    1811             : 
    1812        1125 :             BuildingLoad = (18.33 - OutdoorBinTemperature[BinNum]) / (18.33 - OutdoorDesignTemperature[static_cast<int64_t>(RegionNum) - 1]) *
    1813             :                            CorrectionFactor * DesignHeatingRequirement;
    1814             : 
    1815        1125 :             if ((OutdoorBinTemperature[BinNum] <= -8.33) || (OutdoorBinTemperature[BinNum] >= 7.22)) {
    1816         750 :                 NetHeatingCapReduced =
    1817         750 :                     NetHeatingCapH3Test + (NetHeatingCapRated - NetHeatingCapH3Test) * (OutdoorBinTemperature[BinNum] + 8.33) / (16.67);
    1818         750 :                 ElectricalPowerConsumption = ElecPowerH3Test + (ElecPowerRated - ElecPowerH3Test) * (OutdoorBinTemperature[BinNum] + 8.33) / (16.67);
    1819             :             } else {
    1820         375 :                 NetHeatingCapReduced =
    1821         375 :                     NetHeatingCapH3Test + (NetHeatingCapH2Test - NetHeatingCapH3Test) * (OutdoorBinTemperature[BinNum] + 8.33) / (10.0);
    1822         375 :                 ElectricalPowerConsumption = ElecPowerH3Test + (ElecPowerH2Test - ElecPowerH3Test) * (OutdoorBinTemperature[BinNum] + 8.33) / (10.0);
    1823             :             }
    1824             : 
    1825        1125 :             if (NetHeatingCapReduced != 0.0) {
    1826        1125 :                 HeatingModeLoadFactor = BuildingLoad / NetHeatingCapReduced;
    1827             :             }
    1828             : 
    1829        1125 :             if (HeatingModeLoadFactor > 1.0) {
    1830         445 :                 HeatingModeLoadFactor = 1.0;
    1831             :             }
    1832             : 
    1833        1125 :             PartLoadFactor = 1 - CyclicDegradationCoeff * (1 - HeatingModeLoadFactor);
    1834             : 
    1835        1125 :             if (ElectricalPowerConsumption != 0.0) {
    1836        1125 :                 CheckCOP = NetHeatingCapReduced / ElectricalPowerConsumption;
    1837             :             }
    1838             : 
    1839        1125 :             OATempCompressorOff = MinOATCompressor;
    1840             : 
    1841        1125 :             if (CheckCOP < 1.0) {
    1842         136 :                 LowTempCutOutFactor = 0.0;
    1843             :             } else {
    1844         989 :                 if (!OATempCompressorOnOffBlank) {
    1845          15 :                     if (OutdoorBinTemperature[BinNum] <= OATempCompressorOff) {
    1846           5 :                         LowTempCutOutFactor = 0.0;
    1847          10 :                     } else if (OutdoorBinTemperature[BinNum] > OATempCompressorOff && OutdoorBinTemperature[BinNum] <= OATempCompressorOn) {
    1848           5 :                         LowTempCutOutFactor = 0.5;
    1849             :                     } else {
    1850           5 :                         LowTempCutOutFactor = 1.0;
    1851             :                     }
    1852             :                 } else {
    1853         974 :                     LowTempCutOutFactor = 1.0;
    1854             :                 }
    1855             :             }
    1856             : 
    1857        1125 :             if (PartLoadFactor != 0.0) {
    1858        1125 :                 HeatPumpElectricalEnergy =
    1859        1125 :                     (HeatingModeLoadFactor * ElectricalPowerConsumption * LowTempCutOutFactor) * FractionalBinHours / PartLoadFactor;
    1860             :             }
    1861             : 
    1862        1125 :             ResistiveSpaceHeatingElectricalEnergy =
    1863        1125 :                 (BuildingLoad - HeatingModeLoadFactor * NetHeatingCapReduced * LowTempCutOutFactor) * FractionalBinHours;
    1864             : 
    1865        1125 :             TotalBuildingLoad += (BuildingLoad * FractionalBinHours);
    1866             : 
    1867        1125 :             TotalHeatPumpElectricalEnergy += HeatPumpElectricalEnergy;
    1868             : 
    1869        1125 :             TotalResistiveSpaceHeatingElectricalEnergy += ResistiveSpaceHeatingElectricalEnergy;
    1870             :         }
    1871             : 
    1872          75 :         TotalElectricalEnergy = TotalHeatPumpElectricalEnergy + TotalResistiveSpaceHeatingElectricalEnergy;
    1873             : 
    1874          75 :         if (DefrostControl == HPdefrostControl::Timed) {
    1875          66 :             DemandDeforstCredit = 1.0; // Timed defrost control
    1876             :         } else {
    1877           9 :             DemandDeforstCredit = 1.03; // Demand defrost control
    1878             :         }
    1879             : 
    1880          75 :         if (TotalElectricalEnergy != 0.0) {
    1881          75 :             HSPF = TotalBuildingLoad * DemandDeforstCredit / TotalElectricalEnergy;
    1882             :         }
    1883          75 :         return HSPF;
    1884             :     }
    1885             : 
    1886          75 :     Real64 SingleSpeedHeatingHSPF2(const Real64 NetHeatingCapRated_2023,
    1887             :                                    ObjexxFCL::Optional_int_const RegionNum,
    1888             :                                    const Real64 NetHeatingCapH3Test_2023,
    1889             :                                    const Real64 ElecPowerH3Test2023,
    1890             :                                    const Real64 ElecPowerRated2023,
    1891             :                                    const Real64 NetHeatingCapH2Test2023,
    1892             :                                    const Real64 ElecPowerH2Test2023,
    1893             :                                    ObjexxFCL::Optional<Real64 const> MinOATCompressor,
    1894             :                                    ObjexxFCL::Optional_bool_const OATempCompressorOnOffBlank,
    1895             :                                    ObjexxFCL::Optional<Real64 const> OATempCompressorOn,
    1896             :                                    ObjexxFCL::Optional<const HPdefrostControl> DefrostControl)
    1897             :     {
    1898          75 :         Real64 DesignHeatingRequirement2023(0.0);   // HSPF2 minimum design heating requirement [W]
    1899             :         int BinNum2023;                             // HSPF2 bin number counter
    1900          75 :         Real64 FractionalBinHours2023(0.0);         // HSPF2 Fractional bin hours for the heating season  [-]
    1901          75 :         Real64 BuildingLoad2023(0.0);               // HSPF2 Building space conditioning load corresponding to an outdoor bin temperature [W]
    1902          75 :         Real64 NetHeatingCapReduced2023(0.0);       // HSPF2 Net Heating Coil capacity corresponding to an outdoor bin temperature [W]
    1903          75 :         Real64 ElectricalPowerConsumption2023(0.0); // HSPF2 Electrical power corresponding to an outdoor bin temperature [W]
    1904          75 :         Real64 HeatingModeLoadFactor2023(0.0);      // HSPF2 Heating mode load factor corresponding to an outdoor bin temperature  [-]
    1905             :         Real64 PartLoadFactor2023;
    1906          75 :         Real64 CheckCOP2023(0.0);                              // HSPF2 Checking COP at an outdoor bin temperature against unity [-]
    1907          75 :         Real64 OATempCompressorOff2023(0.0);                   // HSPF2 Minimum outdoor air temperature to turn the commpressor off, [C]
    1908          75 :         Real64 LowTempCutOutFactor2023(0.0);                   // Factor which corresponds to compressor operation depending on outdoor temperature
    1909          75 :         Real64 HeatPumpElectricalEnergy2023(0.0);              // HSPF2 Heatpump electrical energy corresponding to an outdoor bin temperature [W]
    1910          75 :         Real64 ResistiveSpaceHeatingElectricalEnergy2023(0.0); // HSPF2 resistance heating electrical energy corresponding to an
    1911             :         // outdoor bin temperature [W]
    1912          75 :         Real64 TotalBuildingLoad2023(0.0);                          // Sum of building load over the entire heating season [W]
    1913          75 :         Real64 TotalHeatPumpElectricalEnergy2023(0.0);              // HSPF2 Sum of Heatpump electrical energy over the entire heating season [W]
    1914          75 :         Real64 TotalResistiveSpaceHeatingElectricalEnergy2023(0.0); // Sum of resistance heating electrical energy over the
    1915             :         // entire heating season [W]
    1916          75 :         Real64 TotalElectricalEnergy2023(0.0); // HSPF2 Sum of electrical energy consumed by the heatpump over the heating season [W]
    1917          75 :         Real64 DemandDeforstCredit2023(1.0);   // A factor to adjust HSPF2 if coil has demand defrost control  [-]
    1918          75 :         Real64 HSPF2_2023(0.0);
    1919             : 
    1920             :         // For ANSI/AHRI 210/240 Standard 2023 | Concept of DHRI min and max is removed
    1921             :         // Section 11.2.2.1 Equation 11.104  which suggests QAFull is used instead of DHRI min
    1922          75 :         DesignHeatingRequirement2023 = NetHeatingCapRated_2023;
    1923          75 :         Int64 RN = static_cast<int64_t>(RegionNum);
    1924             : 
    1925        1200 :         for (BinNum2023 = 0; BinNum2023 < TotalNumOfTemperatureBinsHSPF2[RN - 1]; ++BinNum2023) {
    1926             : 
    1927        1125 :             FractionalBinHours2023 = FracBinHoursAtOutdoorBinTempHSPF2[RN - 1][BinNum2023];
    1928             : 
    1929        1125 :             BuildingLoad2023 = (ZoneLoadTemperature[RN - 1] - OutdoorBinTemperature[BinNum2023]) /
    1930        1125 :                                (ZoneLoadTemperature[RN - 1] - OutdoorDesignTemperature[RN - 1]) * SpeedLoadFactor[RN - 1] *
    1931             :                                DesignHeatingRequirement2023;
    1932        1125 :             if ((OutdoorBinTemperature[BinNum2023] <= -8.33) || (OutdoorBinTemperature[BinNum2023] >= 7.22)) {
    1933        1500 :                 NetHeatingCapReduced2023 = NetHeatingCapH3Test_2023 + (NetHeatingCapRated_2023 - NetHeatingCapH3Test_2023) *
    1934         750 :                                                                           (OutdoorBinTemperature[BinNum2023] + 8.33) / (16.67);
    1935         750 :                 ElectricalPowerConsumption2023 =
    1936         750 :                     ElecPowerH3Test2023 + (ElecPowerRated2023 - ElecPowerH3Test2023) * (OutdoorBinTemperature[BinNum2023] + 8.33) / (16.67);
    1937             :             } else {
    1938         375 :                 NetHeatingCapReduced2023 = NetHeatingCapH3Test_2023 +
    1939         375 :                                            (NetHeatingCapH2Test2023 - NetHeatingCapH3Test_2023) * (OutdoorBinTemperature[BinNum2023] + 8.33) / (10.0);
    1940         375 :                 ElectricalPowerConsumption2023 =
    1941         375 :                     ElecPowerH3Test2023 + (ElecPowerH2Test2023 - ElecPowerH3Test2023) * (OutdoorBinTemperature[BinNum2023] + 8.33) / (10.0);
    1942             :             }
    1943        1125 :             if (NetHeatingCapReduced2023 != 0.0) {
    1944        1125 :                 HeatingModeLoadFactor2023 = BuildingLoad2023 / NetHeatingCapReduced2023;
    1945             :             }
    1946             : 
    1947        1125 :             if (HeatingModeLoadFactor2023 > 1.0) {
    1948         525 :                 HeatingModeLoadFactor2023 = 1.0;
    1949             :             }
    1950        1125 :             PartLoadFactor2023 = 1 - CyclicHeatingDegradationCoeffHSPF2 * (1 - HeatingModeLoadFactor2023);
    1951        1125 :             if (ElectricalPowerConsumption2023 != 0.0) {
    1952        1125 :                 CheckCOP2023 = NetHeatingCapReduced2023 / ElectricalPowerConsumption2023;
    1953             :             }
    1954        1125 :             OATempCompressorOff2023 = MinOATCompressor;
    1955        1125 :             if (CheckCOP2023 < 1.0) {
    1956         136 :                 LowTempCutOutFactor2023 = 0.0;
    1957             :             } else {
    1958         989 :                 if (!OATempCompressorOnOffBlank) {
    1959          15 :                     if (OutdoorBinTemperature[BinNum2023] <= OATempCompressorOff2023) {
    1960           5 :                         LowTempCutOutFactor2023 = 0.0;
    1961          20 :                     } else if (OutdoorBinTemperature[BinNum2023] > OATempCompressorOff2023 &&
    1962          10 :                                OutdoorBinTemperature[BinNum2023] <= OATempCompressorOn) {
    1963           5 :                         LowTempCutOutFactor2023 = 0.5;
    1964             :                     } else {
    1965           5 :                         LowTempCutOutFactor2023 = 1.0;
    1966             :                     }
    1967             :                 } else {
    1968         974 :                     LowTempCutOutFactor2023 = 1.0;
    1969             :                 }
    1970             :             }
    1971             : 
    1972        1125 :             if (PartLoadFactor2023 != 0.0) {
    1973        1125 :                 HeatPumpElectricalEnergy2023 = (HeatingModeLoadFactor2023 * ElectricalPowerConsumption2023 * LowTempCutOutFactor2023) *
    1974             :                                                FractionalBinHours2023 / PartLoadFactor2023;
    1975             :             }
    1976             : 
    1977        1125 :             ResistiveSpaceHeatingElectricalEnergy2023 =
    1978        1125 :                 (BuildingLoad2023 - HeatingModeLoadFactor2023 * NetHeatingCapReduced2023 * LowTempCutOutFactor2023) * FractionalBinHours2023;
    1979             : 
    1980        1125 :             TotalBuildingLoad2023 += (BuildingLoad2023 * FractionalBinHours2023);
    1981             : 
    1982        1125 :             TotalHeatPumpElectricalEnergy2023 += HeatPumpElectricalEnergy2023;
    1983             : 
    1984        1125 :             TotalResistiveSpaceHeatingElectricalEnergy2023 += ResistiveSpaceHeatingElectricalEnergy2023;
    1985             :         }
    1986          75 :         TotalElectricalEnergy2023 = TotalHeatPumpElectricalEnergy2023 + TotalResistiveSpaceHeatingElectricalEnergy2023;
    1987             : 
    1988          75 :         if (DefrostControl == HPdefrostControl::Timed) {
    1989          66 :             DemandDeforstCredit2023 = 1.0; // Timed defrost control
    1990             :         } else {
    1991           9 :             DemandDeforstCredit2023 = 1.03; // Demand defrost control
    1992             :         }
    1993             : 
    1994          75 :         if (TotalElectricalEnergy2023 != 0.0) {
    1995          75 :             HSPF2_2023 = TotalBuildingLoad2023 * DemandDeforstCredit2023 / TotalElectricalEnergy2023;
    1996             :         }
    1997          75 :         return HSPF2_2023;
    1998             :     }
    1999             : 
    2000          75 :     std::map<std::string, Real64> SingleSpeedDXHeatingCoilStandardRatings(
    2001             :         EnergyPlusData &state,
    2002             :         [[maybe_unused]] std::string const &DXCoilType,            // Type of DX coil for which HSPF is calculated
    2003             :         Real64 const RatedTotalCapacity,                           // Reference capacity of DX coil [W]
    2004             :         Real64 const RatedCOP,                                     // Reference coefficient of performance [W/W]
    2005             :         int const CapFFlowCurveIndex,                              // Index for the capacity as a function of flow fraction modifier curve
    2006             :         int const CapFTempCurveIndex,                              // Index for the capacity as a function of temperature modifier curve
    2007             :         int const EIRFFlowCurveIndex,                              // Index for the EIR as a function of flow fraction modifier curve
    2008             :         int const EIRFTempCurveIndex,                              // Index for the EIR as a function of temperature modifier curve
    2009             :         Real64 const RatedAirVolFlowRate,                          // Rated air volume flow rate [m3/s]
    2010             :         Real64 const FanPowerPerEvapAirFlowRateFromInput,          // 2017 Fan power per air volume flow rate [W/(m3/s)]
    2011             :         Real64 const FanPowerPerEvapAirFlowRateFromInput_2023,     // 2023 Fan power per air volume flow rate [W/(m3/s)]
    2012             :         ObjexxFCL::Optional_int_const RegionNum,                   // Region number for calculating HSPF of single speed DX heating coil
    2013             :         ObjexxFCL::Optional<Real64 const> MinOATCompressor,        // Minimum OAT for heat pump compressor operation [C]
    2014             :         ObjexxFCL::Optional<Real64 const> OATempCompressorOn,      // The outdoor temperature when the compressor is automatically turned
    2015             :         ObjexxFCL::Optional_bool_const OATempCompressorOnOffBlank, // Flag used to determine low temperature cut out factor
    2016             :         ObjexxFCL::Optional<HPdefrostControl const> DefrostControl // defrost control; 1=timed, 2=on-demand
    2017             :     )
    2018             :     {
    2019          75 :         Real64 NetHeatingCapRated(0.0);  // Net Heating Coil capacity at Rated conditions,
    2020          75 :         Real64 NetHeatingCapH3Test(0.0); // Net Heating Coil capacity at H3 test conditions
    2021          75 :         Real64 HSPF(0.0);                // seasonale energy efficiency ratio of multi speed DX cooling coil
    2022             : 
    2023             :         // ANSI/AHRI 210/240 Standard 2023
    2024          75 :         Real64 NetHeatingCapRated_2023(0.0);  // Net Heating Coil capacity at Rated conditions,
    2025          75 :         Real64 NetHeatingCapH3Test_2023(0.0); // Net Heating Coil capacity at H3 test conditions
    2026          75 :         Real64 HSPF2_2023(0.0);               // seasonale energy efficiency ratio of multi speed DX cooling coil
    2027          75 :         Real64 IEER_2022(0.0);
    2028          75 :         std::map<std::string, Real64> StandardRatingsResults;
    2029             :         // SUBROUTINE INFORMATION:
    2030             :         //       AUTHOR         Chandan Sharma
    2031             :         //       DATE WRITTEN   February 2012
    2032             :         //       MODIFIED       B Nigusse, December 2012
    2033             :         //       RE-ENGINEERED  na
    2034             : 
    2035             :         // PURPOSE OF THIS SUBROUTINE:
    2036             :         // na
    2037             : 
    2038             :         // METHODOLOGY EMPLOYED:
    2039             :         // na
    2040             : 
    2041             :         // REFERENCES:
    2042             :         // na
    2043             : 
    2044             :         // Using/Aliasing
    2045             :         using Curve::CurveValue;
    2046             :         using Curve::GetCurveMinMaxValues;
    2047             :         using Curve::GetCurveName;
    2048             : 
    2049             :         // Locals
    2050             :         // SUBROUTINE ARGUMENT DEFINITIONS:
    2051             : 
    2052             :         // back on, if applicable, following automatic shut off. This field is
    2053             :         // used only for HSPF calculation. [C]
    2054             :         // accounting for supply fan heat [W]
    2055             :         // accounting for supply fan heat [W]
    2056             : 
    2057             :         // SUBROUTINE PARAMETER DEFINITIONS:
    2058             :         // na
    2059             :         // INTERFACE BLOCK SPECIFICATIONS
    2060             :         // na
    2061             : 
    2062             :         // DERIVED TYPE DEFINITIONS
    2063             :         // na
    2064             : 
    2065             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    2066          75 :         Real64 TotalHeatingCapRated(0.0);            // Heating Coil capacity at Rated conditions, without accounting supply fan heat [W]
    2067          75 :         Real64 EIRRated(0.0);                        // EIR at Rated conditions [-]
    2068          75 :         Real64 TotCapTempModFacRated(0.0);           // Total capacity as a function of temerature modifier at rated conditions [-]
    2069          75 :         Real64 EIRTempModFacRated(0.0);              // EIR as a function of temerature modifier at rated conditions [-]
    2070          75 :         Real64 TotalHeatingCapH2Test(0.0);           // Heating Coil capacity at H2 test conditions, without accounting supply fan heat [W]
    2071          75 :         Real64 TotalHeatingCapH3Test(0.0);           // Heating Coil capacity at H3 test conditions, without accounting supply fan heat [W]
    2072          75 :         Real64 CapTempModFacH2Test(0.0);             // Total capacity as a function of temerature modifier at H2 test conditions [-]
    2073          75 :         Real64 EIRTempModFacH2Test(0.0);             // EIR as a function of temerature modifier at H2 test conditions [-]
    2074          75 :         Real64 EIRH2Test(0.0);                       // EIR at H2 test conditions [-]
    2075          75 :         Real64 CapTempModFacH3Test(0.0);             // Total capacity as a function of temerature modifier at H3 test conditions [-]
    2076          75 :         Real64 EIRTempModFacH3Test(0.0);             // EIR as a function of temerature modifier at H3 test conditions [-]
    2077          75 :         Real64 EIRH3Test(0.0);                       // EIR at H3 test conditions [-]
    2078          75 :         Real64 TotCapFlowModFac(0.0);                // Total capacity modifier (function of actual supply air flow vs rated flow)
    2079          75 :         Real64 EIRFlowModFac(0.0);                   // EIR modifier (function of actual supply air flow vs rated flow)
    2080          75 :         Real64 FanPowerPerEvapAirFlowRate(0.0);      // 2017 Fan power per air volume flow rate [W/(m3/s)]
    2081          75 :         Real64 FanPowerPerEvapAirFlowRate_2023(0.0); // 2023 Fan power per air volume flow rate [W/(m3/s)]
    2082             : 
    2083             :         Real64 ElecPowerRated;  // Total system power at Rated conditions accounting for supply fan heat [W]
    2084             :         Real64 ElecPowerH2Test; // Total system power at H2 test conditions accounting for supply fan heat [W]
    2085             :         Real64 ElecPowerH3Test; // Total system power at H3 test conditions accounting for supply fan heat [W]
    2086             : 
    2087             :         // For ANSI/AHRI 210/240 Standard 2023
    2088             :         Real64 ElecPowerRated2023;  // Total system power at Rated conditions accounting for supply fan heat [W]
    2089             :         Real64 ElecPowerH2Test2023; // Total system power at H2 test conditions accounting for supply fan heat [W]
    2090             :         Real64 ElecPowerH3Test2023; // Total system power at H3 test conditions accounting for supply fan heat [W]
    2091             : 
    2092             :         Real64 NetHeatingCapH2Test;     // Net Heating Coil capacity at H2 test conditions accounting for supply fan heat [W]
    2093             :         Real64 NetHeatingCapH2Test2023; // (for 2023 Standard) Net Heating Coil capacity at H2 test conditions accounting for supply fan heat [W]
    2094             : 
    2095             :         // Calculate the supply air fan electric power consumption.  The electric power consumption is estimated
    2096             :         // using either user supplied or AHRI default value for fan power per air volume flow rate
    2097          75 :         if (FanPowerPerEvapAirFlowRateFromInput <= 0.0) {
    2098           0 :             FanPowerPerEvapAirFlowRate = DefaultFanPowerPerEvapAirFlowRate;
    2099             :         } else {
    2100          75 :             FanPowerPerEvapAirFlowRate = FanPowerPerEvapAirFlowRateFromInput;
    2101             :         }
    2102          75 :         if (FanPowerPerEvapAirFlowRateFromInput_2023 <= 0.0) {
    2103           0 :             FanPowerPerEvapAirFlowRate_2023 = DefaultFanPowerPerEvapAirFlowRateSEER2;
    2104             :         } else {
    2105          75 :             FanPowerPerEvapAirFlowRate_2023 = FanPowerPerEvapAirFlowRateFromInput_2023;
    2106             :         }
    2107             : 
    2108          75 :         TotCapFlowModFac = CurveValue(state, CapFFlowCurveIndex, AirMassFlowRatioRated);
    2109          75 :         EIRFlowModFac = CurveValue(state, EIRFFlowCurveIndex, AirMassFlowRatioRated);
    2110             : 
    2111             :         {
    2112          75 :             if (state.dataCurveManager->PerfCurve(CapFTempCurveIndex)->numDims == 1) {
    2113          74 :                 TotCapTempModFacRated = CurveValue(state, CapFTempCurveIndex, HeatingOutdoorCoilInletAirDBTempRated);
    2114             : 
    2115          74 :                 CapTempModFacH2Test = CurveValue(state, CapFTempCurveIndex, HeatingOutdoorCoilInletAirDBTempH2Test);
    2116             : 
    2117          74 :                 CapTempModFacH3Test = CurveValue(state, CapFTempCurveIndex, HeatingOutdoorCoilInletAirDBTempH3Test);
    2118             :             } else {
    2119           1 :                 TotCapTempModFacRated =
    2120           1 :                     CurveValue(state, CapFTempCurveIndex, HeatingIndoorCoilInletAirDBTempRated, HeatingOutdoorCoilInletAirDBTempRated);
    2121             : 
    2122           1 :                 CapTempModFacH2Test =
    2123           1 :                     CurveValue(state, CapFTempCurveIndex, HeatingIndoorCoilInletAirDBTempRated, HeatingOutdoorCoilInletAirDBTempH2Test);
    2124             : 
    2125           1 :                 CapTempModFacH3Test =
    2126           1 :                     CurveValue(state, CapFTempCurveIndex, HeatingIndoorCoilInletAirDBTempRated, HeatingOutdoorCoilInletAirDBTempH3Test);
    2127             :             }
    2128             :         }
    2129             : 
    2130             :         {
    2131          75 :             if (state.dataCurveManager->PerfCurve(EIRFTempCurveIndex)->numDims == 1) {
    2132          74 :                 EIRTempModFacRated = CurveValue(state, EIRFTempCurveIndex, HeatingOutdoorCoilInletAirDBTempRated);
    2133             : 
    2134          74 :                 EIRTempModFacH2Test = CurveValue(state, EIRFTempCurveIndex, HeatingOutdoorCoilInletAirDBTempH2Test);
    2135             : 
    2136          74 :                 EIRTempModFacH3Test = CurveValue(state, EIRFTempCurveIndex, HeatingOutdoorCoilInletAirDBTempH3Test);
    2137             :             } else {
    2138           1 :                 EIRTempModFacRated =
    2139           1 :                     CurveValue(state, EIRFTempCurveIndex, HeatingIndoorCoilInletAirDBTempRated, HeatingOutdoorCoilInletAirDBTempRated);
    2140             : 
    2141           1 :                 EIRTempModFacH2Test =
    2142           1 :                     CurveValue(state, EIRFTempCurveIndex, HeatingIndoorCoilInletAirDBTempRated, HeatingOutdoorCoilInletAirDBTempH2Test);
    2143             : 
    2144           1 :                 EIRTempModFacH3Test =
    2145           1 :                     CurveValue(state, EIRFTempCurveIndex, HeatingIndoorCoilInletAirDBTempRated, HeatingOutdoorCoilInletAirDBTempH3Test);
    2146             :             }
    2147             :         }
    2148             : 
    2149          75 :         TotalHeatingCapRated = RatedTotalCapacity * TotCapTempModFacRated * TotCapFlowModFac;
    2150          75 :         NetHeatingCapRated = TotalHeatingCapRated + FanPowerPerEvapAirFlowRate * RatedAirVolFlowRate;
    2151          75 :         NetHeatingCapRated_2023 = TotalHeatingCapRated + FanPowerPerEvapAirFlowRate_2023 * RatedAirVolFlowRate;
    2152             : 
    2153          75 :         TotalHeatingCapH2Test = RatedTotalCapacity * CapTempModFacH2Test * TotCapFlowModFac;
    2154          75 :         NetHeatingCapH2Test = TotalHeatingCapH2Test + FanPowerPerEvapAirFlowRate * RatedAirVolFlowRate;
    2155          75 :         NetHeatingCapH2Test2023 = TotalHeatingCapH2Test + FanPowerPerEvapAirFlowRate_2023 * RatedAirVolFlowRate;
    2156             : 
    2157          75 :         TotalHeatingCapH3Test = RatedTotalCapacity * CapTempModFacH3Test * TotCapFlowModFac;
    2158          75 :         NetHeatingCapH3Test = TotalHeatingCapH3Test + FanPowerPerEvapAirFlowRate * RatedAirVolFlowRate;
    2159          75 :         NetHeatingCapH3Test_2023 = TotalHeatingCapH3Test + FanPowerPerEvapAirFlowRate_2023 * RatedAirVolFlowRate;
    2160             : 
    2161             :         // check curves value
    2162          75 :         if (TotCapTempModFacRated < 0.0 || CapTempModFacH2Test < 0.0 || CapTempModFacH3Test < 0.0 || EIRTempModFacRated < 0.0 ||
    2163          75 :             EIRTempModFacH2Test < 0.0 || EIRTempModFacH3Test < 0.0) {
    2164           0 :             if (TotCapTempModFacRated < 0.0) {
    2165           0 :                 ShowSevereError(
    2166             :                     state,
    2167           0 :                     format(" Invalid Total Heating Capacity Function of Temperature Curve value = {:.2R}, Curve Type = {}, Curve Name = {}",
    2168             :                            TotCapTempModFacRated,
    2169           0 :                            Curve::objectNames[static_cast<int>(state.dataCurveManager->PerfCurve(CapFTempCurveIndex)->curveType)],
    2170           0 :                            GetCurveName(state, CapFTempCurveIndex)));
    2171           0 :                 ShowContinueError(state,
    2172             :                                   " ...Net heating capacity at high temperature is set to zero. The curve value must be > 0. Check the curve.");
    2173           0 :                 NetHeatingCapRated = 0.0;
    2174           0 :                 NetHeatingCapRated_2023 = 0.0;
    2175             :             }
    2176           0 :             if (CapTempModFacH3Test < 0.0) {
    2177           0 :                 ShowSevereError(
    2178             :                     state,
    2179           0 :                     format(" Invalid Total Heating Capacity Function of Temperature Curve value = {:.2R}, Curve Type = {}, Curve Name = {}",
    2180             :                            CapTempModFacH3Test,
    2181           0 :                            Curve::objectNames[static_cast<int>(state.dataCurveManager->PerfCurve(CapFTempCurveIndex)->curveType)],
    2182           0 :                            GetCurveName(state, CapFTempCurveIndex)));
    2183           0 :                 ShowContinueError(state, " ...Net heating capacity at low temperature is set to zero. The curve value must be > 0. Check the curve.");
    2184           0 :                 NetHeatingCapH3Test = 0.0;
    2185           0 :                 NetHeatingCapH3Test_2023 = 0.0;
    2186             :             }
    2187           0 :             if (CapTempModFacH2Test < 0.0) {
    2188           0 :                 ShowSevereError(
    2189             :                     state,
    2190           0 :                     format(" Invalid Total Heating Capacity Function of Temperature Curve value = {:.2R}, Curve Type = {}, Curve Name = {}",
    2191             :                            CapTempModFacH2Test,
    2192           0 :                            Curve::objectNames[static_cast<int>(state.dataCurveManager->PerfCurve(CapFTempCurveIndex)->curveType)],
    2193           0 :                            GetCurveName(state, CapFTempCurveIndex)));
    2194           0 :                 ShowContinueError(state, " ...HSPF calculation is incorrect. The curve value must be > 0. Check the curve.");
    2195           0 :                 NetHeatingCapH3Test = 0.0;
    2196           0 :                 NetHeatingCapH3Test_2023 = 0.0;
    2197             :             }
    2198             :             // check EIR curve values
    2199           0 :             if (EIRTempModFacRated < 0.0) {
    2200           0 :                 ShowSevereError(state,
    2201           0 :                                 format(" Invalid EIR Function of Temperature Curve value = {:.2R}, Curve Type = {}, Curve Name = {}",
    2202             :                                        EIRTempModFacRated,
    2203           0 :                                        Curve::objectNames[static_cast<int>(state.dataCurveManager->PerfCurve(EIRFTempCurveIndex)->curveType)],
    2204           0 :                                        GetCurveName(state, EIRFTempCurveIndex)));
    2205           0 :                 ShowContinueError(state, " ...HSPF calculation is incorrect. The curve value must be > 0. Check the curve.");
    2206             :             }
    2207           0 :             if (EIRTempModFacH2Test < 0.0) {
    2208           0 :                 ShowSevereError(state,
    2209           0 :                                 format(" Invalid EIR Function of Temperature Curve value = {:.2R}, Curve Type = {}, Curve Name = {}",
    2210             :                                        EIRTempModFacH2Test,
    2211           0 :                                        Curve::objectNames[static_cast<int>(state.dataCurveManager->PerfCurve(EIRFTempCurveIndex)->curveType)],
    2212           0 :                                        GetCurveName(state, EIRFTempCurveIndex)));
    2213           0 :                 ShowContinueError(state, " ...HSPF calculation is incorrect. The curve value must be > 0. Check the curve.");
    2214             :             }
    2215           0 :             if (EIRTempModFacH3Test < 0.0) {
    2216           0 :                 ShowSevereError(state,
    2217           0 :                                 format(" Invalid EIR Function of Temperature Curve value = {:.2R}, Curve Type = {}, Curve Name = {}",
    2218             :                                        EIRTempModFacH3Test,
    2219           0 :                                        Curve::objectNames[static_cast<int>(state.dataCurveManager->PerfCurve(EIRFTempCurveIndex)->curveType)],
    2220           0 :                                        GetCurveName(state, EIRFTempCurveIndex)));
    2221           0 :                 ShowContinueError(state, " ...HSPF calculation is incorrect. The curve value must be > 0. Check the curve.");
    2222             :             }
    2223           0 :             ShowContinueError(state, " ...HSPF value has been reset to 0.0 and simulation is continuing.");
    2224           0 :             HSPF = 0.0;
    2225           0 :             HSPF2_2023 = 0.0;
    2226           0 :             IEER_2022 = 0.0;
    2227             : 
    2228           0 :             StandardRatingsResults["NetHeatingCapRated"] = NetHeatingCapRated;
    2229           0 :             StandardRatingsResults["NetHeatingCapH3Test"] = NetHeatingCapH3Test;
    2230           0 :             StandardRatingsResults["HSPF"] = HSPF;
    2231           0 :             StandardRatingsResults["NetHeatingCapRated_2023"] = NetHeatingCapRated_2023;
    2232           0 :             StandardRatingsResults["NetHeatingCapH3Test_2023"] = NetHeatingCapH3Test_2023;
    2233           0 :             StandardRatingsResults["HSPF2_2023"] = HSPF2_2023;
    2234           0 :             return StandardRatingsResults;
    2235             :         }
    2236             : 
    2237          75 :         if (RatedCOP > 0.0) { // RatedCOP <= 0.0 is trapped in GetInput, but keep this as "safety"
    2238             : 
    2239          75 :             EIRRated = EIRTempModFacRated * EIRFlowModFac / RatedCOP;
    2240          75 :             EIRH2Test = EIRTempModFacH2Test * EIRFlowModFac / RatedCOP;
    2241          75 :             EIRH3Test = EIRTempModFacH3Test * EIRFlowModFac / RatedCOP;
    2242             :         }
    2243             : 
    2244          75 :         ElecPowerRated = EIRRated * TotalHeatingCapRated + FanPowerPerEvapAirFlowRate * RatedAirVolFlowRate;
    2245          75 :         ElecPowerH2Test = EIRH2Test * TotalHeatingCapH2Test + FanPowerPerEvapAirFlowRate * RatedAirVolFlowRate;
    2246          75 :         ElecPowerH3Test = EIRH3Test * TotalHeatingCapH3Test + FanPowerPerEvapAirFlowRate * RatedAirVolFlowRate;
    2247             : 
    2248          75 :         ElecPowerRated2023 = EIRRated * TotalHeatingCapRated + FanPowerPerEvapAirFlowRate_2023 * RatedAirVolFlowRate;
    2249          75 :         ElecPowerH2Test2023 = EIRH2Test * TotalHeatingCapH2Test + FanPowerPerEvapAirFlowRate_2023 * RatedAirVolFlowRate;
    2250          75 :         ElecPowerH3Test2023 = EIRH3Test * TotalHeatingCapH3Test + FanPowerPerEvapAirFlowRate_2023 * RatedAirVolFlowRate;
    2251             : 
    2252          75 :         HSPF2_2023 = SingleSpeedHeatingHSPF2(NetHeatingCapRated_2023,
    2253             :                                              RegionNum,
    2254             :                                              NetHeatingCapH3Test_2023,
    2255             :                                              ElecPowerH3Test2023,
    2256             :                                              ElecPowerRated2023,
    2257             :                                              NetHeatingCapH2Test2023,
    2258             :                                              ElecPowerH2Test2023,
    2259             :                                              MinOATCompressor,
    2260             :                                              OATempCompressorOnOffBlank,
    2261             :                                              OATempCompressorOn,
    2262             :                                              DefrostControl);
    2263             : 
    2264          75 :         HSPF = SingleSpeedHeatingHSPF(NetHeatingCapRated,
    2265             :                                       RegionNum,
    2266             :                                       NetHeatingCapH3Test,
    2267             :                                       ElecPowerH3Test,
    2268             :                                       ElecPowerRated,
    2269             :                                       NetHeatingCapH2Test,
    2270             :                                       ElecPowerH2Test,
    2271             :                                       MinOATCompressor,
    2272             :                                       OATempCompressorOnOffBlank,
    2273             :                                       OATempCompressorOn,
    2274             :                                       DefrostControl);
    2275             : 
    2276          75 :         StandardRatingsResults["NetHeatingCapRated"] = NetHeatingCapRated;
    2277          75 :         StandardRatingsResults["NetHeatingCapH3Test"] = NetHeatingCapH3Test;
    2278          75 :         StandardRatingsResults["HSPF"] = HSPF;
    2279          75 :         StandardRatingsResults["NetHeatingCapRated_2023"] = NetHeatingCapRated_2023;
    2280          75 :         StandardRatingsResults["NetHeatingCapH3Test_2023"] = NetHeatingCapH3Test_2023;
    2281          75 :         StandardRatingsResults["HSPF2_2023"] = HSPF2_2023;
    2282          75 :         return StandardRatingsResults;
    2283           0 :     }
    2284             : 
    2285         612 :     std::tuple<Real64, Real64> IEERSingleSpeedCooling(EnergyPlus::EnergyPlusData &state,
    2286             :                                                       const int CapFTempCurveIndex,
    2287             :                                                       const Real64 RatedTotalCapacity,
    2288             :                                                       const Real64 TotCapFlowModFac,
    2289             :                                                       const Real64 FanPowerPerEvapAirFlowRate,
    2290             :                                                       const Real64 RatedAirVolFlowRate,
    2291             :                                                       const int EIRFTempCurveIndex,
    2292             :                                                       const Real64 RatedCOP,
    2293             :                                                       const Real64 EIRFlowModFac)
    2294             :     {
    2295             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    2296         612 :         int constexpr NumOfReducedCap(4);                  // Number of reduced capacity test conditions (100%,75%,50%,and 25%)
    2297         612 :         Real64 TotCapTempModFac(0.0);                      // Total capacity modifier (function of entering wetbulb, outside drybulb) [-]
    2298         612 :         Real64 OutdoorUnitInletAirDryBulbTempReduced(0.0); // Outdoor unit entering air dry-bulb temperature at reduced capacity [C]
    2299         612 :         Real64 NetCoolingCapReduced(0.0);                  // Net Cooling Coil capacity at reduced conditions, accounting for supply fan heat [W]
    2300         612 :         Real64 EIRTempModFac(0.0);                         // EIR modifier (function of entering wetbulb, outside drybulb) [-]
    2301         612 :         Real64 EIR(0.0);                                   // Energy Efficiency Ratio at AHRI test conditions for SEER [-]
    2302         612 :         Real64 LoadFactor(0.0);                            // Fractional "on" time for last stage at the desired reduced capacity, (dimensionless)
    2303         612 :         Real64 DegradationCoeff(0.0);                      // Degradation coeficient, (dimenssionless)
    2304         612 :         Real64 ElecPowerReducedCap(0.0);                   // Net power consumption (Cond Fan+Compressor) at reduced test condition [W]
    2305         612 :         Real64 EERReduced(0.0);                            // EER at reduced capacity test conditions (100%, 75%, 50%, and 25%)
    2306         612 :         Real64 IEER = 0.0;                                 // Integareted energy efficiency ratio of single speed DX cooling coil
    2307         612 :         Real64 NetCoolingCapRated = 0.0;                   // net cooling capacity of single speed DX cooling coil
    2308             : 
    2309             :         // Calculate the net cooling capacity at the rated conditions (19.44C WB and 35.0C DB )
    2310         612 :         TotCapTempModFac = Curve::CurveValue(state, CapFTempCurveIndex, CoolingCoilInletAirWetBulbTempRated, OutdoorUnitInletAirDryBulbTempRated);
    2311         612 :         NetCoolingCapRated = RatedTotalCapacity * TotCapTempModFac * TotCapFlowModFac - FanPowerPerEvapAirFlowRate * RatedAirVolFlowRate;
    2312             :         // RedCapNum : Integer counter for reduced capacity
    2313        3060 :         for (int RedCapNum = 0; RedCapNum < NumOfReducedCap; ++RedCapNum) {
    2314             :             // get the outdoor air dry bulb temperature for the reduced capacity test conditions
    2315        2448 :             if (ReducedPLR[RedCapNum] > 0.444) {
    2316        1836 :                 OutdoorUnitInletAirDryBulbTempReduced = 5.0 + 30.0 * ReducedPLR[RedCapNum];
    2317             :             } else {
    2318         612 :                 OutdoorUnitInletAirDryBulbTempReduced = OADBTempLowReducedCapacityTest;
    2319             :             }
    2320             :             TotCapTempModFac =
    2321        2448 :                 Curve::CurveValue(state, CapFTempCurveIndex, CoolingCoilInletAirWetBulbTempRated, OutdoorUnitInletAirDryBulbTempReduced);
    2322        2448 :             NetCoolingCapReduced = RatedTotalCapacity * TotCapTempModFac * TotCapFlowModFac - FanPowerPerEvapAirFlowRate * RatedAirVolFlowRate;
    2323        2448 :             EIRTempModFac = Curve::CurveValue(state, EIRFTempCurveIndex, CoolingCoilInletAirWetBulbTempRated, OutdoorUnitInletAirDryBulbTempReduced);
    2324        2448 :             if (RatedCOP > 0.0) {
    2325        2448 :                 EIR = EIRTempModFac * EIRFlowModFac / RatedCOP;
    2326             :             } else {
    2327           0 :                 EIR = 0.0;
    2328             :             }
    2329        2448 :             if (NetCoolingCapReduced > 0.0) {
    2330        2448 :                 LoadFactor = ReducedPLR[RedCapNum] * NetCoolingCapRated / NetCoolingCapReduced;
    2331             :             } else {
    2332           0 :                 LoadFactor = 1.0;
    2333             :             }
    2334        2448 :             DegradationCoeff = 1.130 - 0.130 * LoadFactor;
    2335        2448 :             ElecPowerReducedCap = DegradationCoeff * EIR * (RatedTotalCapacity * TotCapTempModFac * TotCapFlowModFac);
    2336        2448 :             EERReduced = (LoadFactor * NetCoolingCapReduced) / (LoadFactor * ElecPowerReducedCap + FanPowerPerEvapAirFlowRate * RatedAirVolFlowRate);
    2337        2448 :             IEER += IEERWeightingFactor[RedCapNum] * EERReduced;
    2338             :         }
    2339        1224 :         return std::make_tuple(IEER, NetCoolingCapRated);
    2340             :     }
    2341             : 
    2342         806 :     Real64 GetIEEREquationResult(const Real64 A, const Real64 B, const Real64 C, const Real64 D)
    2343             :     {
    2344         806 :         return (0.020 * A) + (0.617 * B) + (0.238 * C) + (0.125 * D);
    2345             :     }
    2346             : 
    2347        3282 :     Real64 GetOutdoorUnitInletAirDryBulbTempReduced(Real64 const ReducedPLR, DataHeatBalance::RefrigCondenserType const CondenserType)
    2348             :     {
    2349        3282 :         Real64 OutdoorUnitInletAirDryBulbTempReduced(0.0);
    2350             :         // As per Table 9. IEER Part-Load Rating Conditions | AHRI Std.340/360-2022(IP)
    2351        3282 :         if (ReducedPLR == 0.25) {
    2352         822 :             if (CondenserType == DataHeatBalance::RefrigCondenserType::Air) {
    2353             :                 // Entering Dry Bulb Temperature (OAT)
    2354         819 :                 OutdoorUnitInletAirDryBulbTempReduced = 18.33; // 65F
    2355           3 :             } else if (CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
    2356             :                 // Entering Condenser Water Temperature (EWT)
    2357           0 :                 OutdoorUnitInletAirDryBulbTempReduced = 12.77; // 55F
    2358           3 :             } else if (CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
    2359             :                 // Entering Air Wet-bulb/Air Dry-bulb/Makeup Water Temperature EWB/DB/MW
    2360             :                 // OutdoorUnitInletAirDryBulbTempReduced = 52.8F/65.0F/77.0F
    2361           3 :                 OutdoorUnitInletAirDryBulbTempReduced = 18.33;
    2362             :             }
    2363        2460 :         } else if (ReducedPLR == 0.50) {
    2364         827 :             if (CondenserType == DataHeatBalance::RefrigCondenserType::Air) {
    2365         824 :                 OutdoorUnitInletAirDryBulbTempReduced = 20; // 68F
    2366           3 :             } else if (CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
    2367           0 :                 OutdoorUnitInletAirDryBulbTempReduced = 16.66; // 62F
    2368           3 :             } else if (CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
    2369             :                 // OutdoorUnitInletAirDryBulbTempReduced = 57.5F / 68.0F / 77.0F EWB / DB / MW
    2370           3 :                 OutdoorUnitInletAirDryBulbTempReduced = 20;
    2371             :             }
    2372        1633 :         } else if (ReducedPLR == 0.75) {
    2373         827 :             if (CondenserType == DataHeatBalance::RefrigCondenserType::Air) {
    2374         825 :                 OutdoorUnitInletAirDryBulbTempReduced = 27.5; // 81.5F
    2375           2 :             } else if (CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
    2376           0 :                 OutdoorUnitInletAirDryBulbTempReduced = 23.05; // 73.5F
    2377           2 :             } else if (CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
    2378             :                 // OutdoorUnitInletAirDryBulbTempReduced = 66.2F / 81.5F / 77.0F EWB / DB / MW
    2379           2 :                 OutdoorUnitInletAirDryBulbTempReduced = 27.5; // 81.5F
    2380             :             }
    2381         806 :         } else if (ReducedPLR == 1.0) {
    2382         806 :             if (CondenserType == DataHeatBalance::RefrigCondenserType::Air) {
    2383         804 :                 OutdoorUnitInletAirDryBulbTempReduced = 35; // 95.0F
    2384           2 :             } else if (CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
    2385           0 :                 OutdoorUnitInletAirDryBulbTempReduced = 29.44; // 85.0F
    2386           2 :             } else if (CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
    2387             :                 // OutdoorUnitInletAirDryBulbTempReduced = 75.0F / 95.0F / 85.0F EWB / DB / MW
    2388           2 :                 OutdoorUnitInletAirDryBulbTempReduced = 35;
    2389             :             }
    2390             :         }
    2391        3282 :         return OutdoorUnitInletAirDryBulbTempReduced;
    2392             :     }
    2393             : 
    2394        3282 :     Real64 CalculateInterMediateEER(EnergyPlus::EnergyPlusData &state,
    2395             :                                     Real64 QAFull,
    2396             :                                     Real64 OutdoorUnitInletAirDryBulbTempReduced,
    2397             :                                     int CapFTempCurveIndex,
    2398             :                                     Real64 CoolingCoilInletAirWetBulbTempRated,
    2399             :                                     Real64 RatedTotalCapacity,
    2400             :                                     Real64 TotCapFlowModFac,
    2401             :                                     Real64 FanPowerPerEvapAirFlowRate_2023,
    2402             :                                     Real64 RatedAirVolFlowRate,
    2403             :                                     Real64 EIRFTempCurveIndex,
    2404             :                                     Real64 RatedCOP,
    2405             :                                     Real64 EIRFlowModFac,
    2406             :                                     Real64 ReducedPLR)
    2407             :     {
    2408             :         Real64 TotCapTempModFac =
    2409        3282 :             Curve::CurveValue(state, CapFTempCurveIndex, CoolingCoilInletAirWetBulbTempRated, OutdoorUnitInletAirDryBulbTempReduced);
    2410             :         // TBD: Discuss TotCapTempModFac Calculation for both Evap and Water Cooled.
    2411             :         // This will be our Qlx
    2412        3282 :         Real64 NetCoolingCapReduced =
    2413        3282 :             RatedTotalCapacity * TotCapTempModFac * TotCapFlowModFac - FanPowerPerEvapAirFlowRate_2023 * RatedAirVolFlowRate;
    2414             :         Real64 EIRTempModFac =
    2415        3282 :             Curve::CurveValue(state, EIRFTempCurveIndex, CoolingCoilInletAirWetBulbTempRated, OutdoorUnitInletAirDryBulbTempReduced);
    2416             : 
    2417        3282 :         Real64 EIR(0.0);
    2418        3282 :         if (RatedCOP > 0.0) {
    2419        3282 :             EIR = EIRTempModFac * EIRFlowModFac / RatedCOP;
    2420             :         } else {
    2421           0 :             EIR = 0.0;
    2422             :         }
    2423        3282 :         Real64 EER(0.0); // Energy Efficiency Rating
    2424             : 
    2425        3282 :         Real64 CD(0.0);               // Degradation Cofficient, (Btu/h)/(Btu/h)
    2426        3282 :         Real64 LF(0.0);               // Fraction "on" time for the last stage at the tested load Point | Load Factor
    2427        3282 :         Real64 PL = ReducedPLR * 100; // Percent Load
    2428             : 
    2429        3282 :         Real64 Qlx = NetCoolingCapReduced; // Part Load Net Capacity (Btu/h) | Previously NetCoolingCapReduced
    2430        3282 :         if (Qlx > 0.0) {
    2431        3282 :             LF = ((PL / 100) * QAFull) / Qlx;
    2432             :         } else {
    2433           0 :             LF = 1.0;
    2434             :         }
    2435             :         // PC - Compressor power at the lowest machine unloading point operating at the applicable part-load Rating condition, W
    2436             :         // PCD - Condenser Section Power, at the applicable part-load Rating condition, W
    2437        3282 :         Real64 PIF(0.0); // Indoor Fan Power, W
    2438        3282 :         Real64 PCT(0.0); // Control Circuit Power and any auxilary Power, W
    2439        3282 :         Real64 q(0.0);   // Cooling Capacity at the lowest machine unloading point operating at the applicable part-load Rating condition, Btu/h
    2440             : 
    2441        3282 :         q = Qlx;
    2442        3282 :         PIF = FanPowerPerEvapAirFlowRate_2023 * RatedAirVolFlowRate; // Calculated for each Speed
    2443        3282 :         PCT = 0;                                                     // Control Circuit Power  and any auxilary Power not in Energy Plus Object.
    2444        3282 :         Real64 PC_plus_PCD = EIR * (RatedTotalCapacity * TotCapTempModFac * TotCapFlowModFac);
    2445        3282 :         CD = (-0.13 * LF) + 1.13; // DegradationCoeff
    2446        3282 :         EER = (LF * q) / (LF * (CD * (PC_plus_PCD)) + PIF + PCT);
    2447        3282 :         return EER;
    2448             :     }
    2449             : 
    2450             :     std::tuple<Real64, Real64, Real64, Real64>
    2451          54 :     SEER2CalulcationCurveFit(EnergyPlusData &state, std::string const &CoilType, EnergyPlus::CoilCoolingDXCurveFitOperatingMode operatingMode)
    2452             :     {
    2453          54 :         Real64 EEER2(0.0);
    2454          54 :         Real64 SEER2_User(0.0);
    2455          54 :         Real64 SEER2_Standard(0.0);
    2456          54 :         Real64 NetCoolingCapRated2023(0.0); // QAFull
    2457             : 
    2458          54 :         Array1D<int> MSCCapFTemp;
    2459          54 :         Array1D<Real64> MSRatedTotCap;
    2460          54 :         Array1D<int> MSCCapAirFFlow;
    2461          54 :         Array1D<Real64> MSRatedEvaporatorFanPowerPerVolumeFlowRate2023;
    2462          54 :         Array1D<Real64> MSRatedAirVolFlowRate;
    2463          54 :         Array1D<int> MSEIRFTemp;
    2464          54 :         Array1D<Real64> MSRatedCOP;
    2465          54 :         Array1D<int> MSEIRAirFFlow;
    2466          54 :         Array1D<int> MSPLRFPLF;
    2467             : 
    2468          54 :         int nsp = operatingMode.speeds.size();
    2469             : 
    2470         170 :         for (int i = 0; i < nsp; ++i) {
    2471         116 :             CoilCoolingDXCurveFitSpeed speed = operatingMode.speeds[i];
    2472         116 :             MSCCapFTemp.push_back(speed.indexCapFT);
    2473             : 
    2474             :             // Calculate the rated cooling capacity for the speed using Gross Total Cooling Capacity
    2475             :             // and Gross Total Cooling Capacity Fraction of the speed.
    2476         116 :             MSRatedTotCap.push_back(speed.rated_total_capacity); // get the capcity at each speed bymultiplying this fraCTION WITH the gross.
    2477         116 :             MSCCapAirFFlow.push_back(speed.indexCapFFF);
    2478         116 :             MSRatedEvaporatorFanPowerPerVolumeFlowRate2023.push_back(speed.rated_evap_fan_power_per_volume_flow_rate_2023);
    2479             :             // Calculate the rated evap air flow rate for the speed using Rated Evaporator Air flow Rate
    2480             :             // and Rated Evaporator Air flow fraction of the speed
    2481         116 :             MSRatedAirVolFlowRate.push_back(speed.evap_air_flow_rate);
    2482             : 
    2483         116 :             MSEIRFTemp.push_back(speed.indexEIRFT);
    2484         116 :             MSRatedCOP.push_back(speed.ratedCOP);
    2485         116 :             MSEIRAirFFlow.push_back(speed.indexEIRFFF);
    2486         116 :             MSPLRFPLF.push_back(speed.indexPLRFPLF);
    2487         116 :         }
    2488             : 
    2489          54 :         std::tie(NetCoolingCapRated2023, SEER2_User, SEER2_Standard, EEER2) =
    2490         108 :             VariableSpeedDXCoolingCoilSEER2(state,
    2491             :                                             nsp,
    2492             :                                             MSCCapAirFFlow,
    2493             :                                             MSRatedTotCap,
    2494             :                                             MSCCapFTemp,
    2495             :                                             MSRatedEvaporatorFanPowerPerVolumeFlowRate2023,
    2496             :                                             MSRatedAirVolFlowRate,
    2497             :                                             MSEIRAirFFlow,
    2498             :                                             MSRatedCOP,
    2499             :                                             MSEIRFTemp,
    2500          54 :                                             MSPLRFPLF);
    2501             : 
    2502         108 :         return std::make_tuple(NetCoolingCapRated2023, SEER2_User, SEER2_Standard, EEER2);
    2503          54 :     }
    2504             : 
    2505             :     std::tuple<Real64, Real64, Real64>
    2506          54 :     IEERCalulcationCurveFit(EnergyPlusData &state, std::string const &CoilType, EnergyPlus::CoilCoolingDXCurveFitOperatingMode operatingMode)
    2507             :     {
    2508          54 :         Real64 IEER_2022(0.0);
    2509          54 :         Real64 EER_2022(0.0);
    2510          54 :         Real64 NetCoolingCapRated2022(0.0); // QAFull
    2511             : 
    2512          54 :         Array1D<int> MSCCapFTemp;
    2513          54 :         Array1D<Real64> MSRatedTotCap;
    2514          54 :         Array1D<int> MSCCapAirFFlow;
    2515          54 :         Array1D<Real64> MSRatedEvaporatorFanPowerPerVolumeFlowRate2023;
    2516          54 :         Array1D<Real64> MSRatedAirVolFlowRate;
    2517          54 :         Array1D<int> MSEIRFTemp;
    2518          54 :         Array1D<Real64> MSRatedCOP;
    2519          54 :         Array1D<int> MSEIRAirFFlow;
    2520             : 
    2521          54 :         int nsp = operatingMode.speeds.size();
    2522             : 
    2523         170 :         for (int i = 0; i < nsp; ++i) {
    2524         116 :             CoilCoolingDXCurveFitSpeed speed = operatingMode.speeds[i];
    2525         116 :             MSCCapFTemp.push_back(speed.indexCapFT);
    2526             :             // Calculate the rated cooling capacity for the speed using Gross Total Cooling Capacity
    2527             :             // and Gross Total Cooling Capacity Fraction of the speed.
    2528         116 :             MSRatedTotCap.push_back(speed.rated_total_capacity); // get the capcity at each speed bymultiplying this fraCTION WITH the gross.
    2529         116 :             MSCCapAirFFlow.push_back(speed.indexCapFFF);
    2530         116 :             MSRatedEvaporatorFanPowerPerVolumeFlowRate2023.push_back(speed.rated_evap_fan_power_per_volume_flow_rate_2023);
    2531             :             // Calculate the rated evap air flow rate for the speed using Rated Evaporator Air flow Rate
    2532             :             // and Rated Evaporator Air flow fraction of the speed
    2533         116 :             MSRatedAirVolFlowRate.push_back(speed.evap_air_flow_rate);
    2534         116 :             MSEIRFTemp.push_back(speed.indexEIRFT);
    2535         116 :             MSRatedCOP.push_back(speed.ratedCOP);
    2536         116 :             MSEIRAirFFlow.push_back(speed.indexEIRFFF);
    2537         116 :         }
    2538             : 
    2539             :         // For Condenser Type
    2540             :         DataHeatBalance::RefrigCondenserType _CondenserType;
    2541          54 :         switch (operatingMode.condenserType) {
    2542           0 :         case CoilCoolingDXCurveFitOperatingMode::CondenserType::EVAPCOOLED:
    2543           0 :             _CondenserType = DataHeatBalance::RefrigCondenserType::Evap;
    2544           0 :             break;
    2545          54 :         case CoilCoolingDXCurveFitOperatingMode::CondenserType::AIRCOOLED:
    2546             :         default:
    2547          54 :             _CondenserType = DataHeatBalance::RefrigCondenserType::Air;
    2548          54 :             break;
    2549             :         }
    2550             : 
    2551         108 :         std::tie(IEER_2022, NetCoolingCapRated2022, EER_2022) = IEERCalculationVariableSpeed(state,
    2552             :                                                                                              CoilType,
    2553             :                                                                                              nsp,
    2554             :                                                                                              MSCCapFTemp,
    2555             :                                                                                              MSRatedTotCap,
    2556             :                                                                                              MSCCapAirFFlow,
    2557             :                                                                                              MSRatedEvaporatorFanPowerPerVolumeFlowRate2023,
    2558             :                                                                                              MSRatedAirVolFlowRate,
    2559             :                                                                                              MSEIRFTemp,
    2560             :                                                                                              MSRatedCOP,
    2561             :                                                                                              MSEIRAirFFlow,
    2562          54 :                                                                                              _CondenserType);
    2563             : 
    2564         108 :         return std::make_tuple(IEER_2022, NetCoolingCapRated2022, EER_2022);
    2565          54 :     }
    2566             : 
    2567          78 :     std::tuple<Real64, Real64, Real64> IEERCalculationVariableSpeed(
    2568             :         EnergyPlusData &state,
    2569             :         std::string const &VSCoilType, // Type of DX coil
    2570             :         int const nsp,
    2571             :         Array1A_int const &CapFTempCurveIndex,
    2572             :         Array1A<Real64> const &RatedTotalCapacity,
    2573             :         Array1A_int const &CapFFlowCurveIndex,
    2574             :         Array1A<Real64> const &FanPowerPerEvapAirFlowRateFromInput_2023, // 2023 Rated Fan Power per air volume flow rate through the evaporator coil
    2575             :         Array1A<Real64> const &RatedAirVolFlowRate,
    2576             :         Array1A_int const &EIRFTempCurveIndex,
    2577             :         Array1A<Real64> const &RatedCOP, // Reference coefficient of performance [W/W]
    2578             :         Array1A_int const &EIRFFlowCurveIndex,
    2579             :         DataHeatBalance::RefrigCondenserType const _CondenserType) // Type of condenser user by the DX Cooling Coil
    2580             :     {
    2581          78 :         Real64 IEER_2022(0.0);
    2582          78 :         Real64 EER_2022(0.0);
    2583          78 :         Real64 QAFull(0.0);
    2584          78 :         Array1D<Real64> Q_A_Full(nsp);                        // Total cooling capacity at A2 test condition (High speed) | q_A_Full
    2585          78 :         Array1D<Real64> FanPowerPerEvapAirFlowRate_2023(nsp); // 2023 Fan power per air volume flow rate through the evaporator coil [W/(m3/s)]
    2586             :         // Calculate these for each speed
    2587             :         // hint : curve index will change, AirFlow rate will remain same
    2588          78 :         Array1D<Real64> TotCapFlowModFac(nsp); // Total capacity modifier f(actual flow vs rated flow) for each speed [-]
    2589          78 :         Array1D<Real64> EIRFlowModFac(nsp);    // EIR modifier f(actual supply air flow vs rated flow) for each speed [-]
    2590          78 :         Array1D<Real64> TotCapTempModFac(nsp);
    2591          78 :         Array1D<Real64> NetCoolingCapRated(nsp);
    2592          78 :         Real64 OutdoorUnitInletAirDryBulbTempReduced(0.0); // Outdoor unit entering air dry-bulb temperature at reduced capacity [C]
    2593             :         // EER Reduced
    2594          78 :         Real64 A(0.0); // EER, (Btu/h)/W, at 100% Capacity at AHRI Standard Rating Conditions (see Table 6)| AHRI Std.340/360-2022(IP)
    2595          78 :         Real64 B(0.0); // EER, (Btu/h)/W, at 75% Capacity at AHRI Standard Rating Conditions (see Table 6)| AHRI Std.340/360-2022(IP)
    2596          78 :         Real64 C(0.0); // EER, (Btu/h)/W, at 50% Capacity at AHRI Standard Rating Conditions (see Table 6)| AHRI Std.340/360-2022(IP)
    2597          78 :         Real64 D(0.0); // EER, (Btu/h)/W, at 25% Capacity at AHRI Standard Rating Conditions (see Table 6)| AHRI Std.340/360-2022(IP)
    2598             : 
    2599          78 :         Array1D<DataHeatBalance::RefrigCondenserType> CondenserType(nsp);
    2600             : 
    2601         374 :         for (int spnum = 1; spnum <= nsp; ++spnum) {
    2602         296 :             FanPowerPerEvapAirFlowRate_2023(spnum) = 0.0;
    2603         296 :             if (FanPowerPerEvapAirFlowRateFromInput_2023(spnum) <= 0.0) {
    2604           0 :                 FanPowerPerEvapAirFlowRate_2023(spnum) = DefaultFanPowerPerEvapAirFlowRateSEER2;
    2605             :             } else {
    2606         296 :                 FanPowerPerEvapAirFlowRate_2023(spnum) = FanPowerPerEvapAirFlowRateFromInput_2023(spnum);
    2607             :             }
    2608         296 :             CondenserType(spnum) = _CondenserType;
    2609             :         }
    2610             : 
    2611         374 :         for (int spnum = nsp; spnum > 0; --spnum) {
    2612             :             // TotCapFlowModFac(spnum) = Curve::CurveValue(state, CapFFlowCurveIndex(spnum), AirMassFlowRatioRated);
    2613         296 :             TotCapFlowModFac(spnum) = Curve::CurveValue(state, CapFFlowCurveIndex(spnum), AirMassFlowRatioRated);
    2614             :             // EIRFlowModFac(spnum) = Curve::CurveValue(state, EIRFFlowCurveIndex(spnum), AirMassFlowRatioRated);
    2615         296 :             EIRFlowModFac(spnum) = Curve::CurveValue(state, EIRFFlowCurveIndex(spnum), AirMassFlowRatioRated);
    2616             : 
    2617             :             // if CondenserType is AirCooled
    2618         296 :             if (CondenserType(spnum) == DataHeatBalance::RefrigCondenserType::Air) {
    2619             :                 // Cooling Coil | Calculate the net cooling capacity at the rated conditions (23.89C(75F) Wet Bulb and 35.0C(95F) Dry Bulb )
    2620         296 :                 if (VSCoilType.find("Cooling") != std::string::npos)
    2621         296 :                     TotCapTempModFac(spnum) =
    2622         296 :                         Curve::CurveValue(state, CapFTempCurveIndex(spnum), CoolingCoilInletAirWetBulbTempRated, CoilInletAirCoolDryBulbIEER);
    2623             :                 else // Heating Coil | Calculate the net cooling capacity at the rated conditions (6.11C(43F) Wet Bulb and 8.33C(47F) Dry Bulb )
    2624           0 :                     TotCapTempModFac(spnum) =
    2625           0 :                         Curve::CurveValue(state, CapFTempCurveIndex(spnum), CoilHeatingInletAirWetBulbTempIEER, CoilHeatingInletAirCoolDryBulbIEER);
    2626             :             }
    2627             :             // if CondenserType is WaterCooled
    2628         296 :             if (CondenserType(spnum) == DataHeatBalance::RefrigCondenserType::Water) {
    2629             :                 // Calculate the net cooling capacity at the rated conditions (35.0C(95F) Outlet and 29.44C(85F) Inlet )
    2630             : 
    2631           0 :                 TotCapTempModFac(spnum) = Curve::CurveValue(state, CapFTempCurveIndex(spnum), CoilWaterOutletTempIEER, CoilWaterInletTempIEER);
    2632             :             }
    2633             :             // if CondesnerType is EvaporativelyCooled
    2634         296 :             if (CondenserType(spnum) == DataHeatBalance::RefrigCondenserType::Evap) {
    2635             :                 // Calculate the net cooling capacity at the rated conditions (23.89C(75F) Wet Bulb and 35.0C(95F) Dry Bulb )
    2636           0 :                 TotCapTempModFac(spnum) =
    2637           0 :                     Curve::CurveValue(state, CapFTempCurveIndex(spnum), CoilInletEvapWetBulbTempIEER, CoilInletEvapDryBulbTempIEER);
    2638             :             }
    2639             : 
    2640             :             // This Will be our QAFull
    2641         296 :             NetCoolingCapRated(spnum) = RatedTotalCapacity(spnum) * TotCapTempModFac(spnum) * TotCapFlowModFac(spnum) -
    2642         296 :                                         FanPowerPerEvapAirFlowRate_2023(spnum) * RatedAirVolFlowRate(spnum);
    2643         296 :             Q_A_Full(spnum) = NetCoolingCapRated(spnum);
    2644             :         }
    2645             : 
    2646          78 :         QAFull = Q_A_Full(nsp);
    2647             : 
    2648          78 :         Real64 _100PercentCoolCap = RatedTotalCapacity(nsp);
    2649          78 :         Real64 _75PercentCoolCap = RatedTotalCapacity(nsp) * 0.75;
    2650          78 :         Real64 _50PercentCoolCap = RatedTotalCapacity(nsp) * 0.50;
    2651          78 :         Real64 _25PercentCoolCap = RatedTotalCapacity(nsp) * 0.25;
    2652             : 
    2653          78 :         Array1D<int> speedsForA;
    2654          78 :         Array1D<int> speedsForB;
    2655          78 :         int smallerThanSpeedB(0);
    2656          78 :         int largerThanSpeedB(0);
    2657          78 :         Array1D<int> speedsForC;
    2658          78 :         int smallerThanSpeedC(0);
    2659          78 :         int largerThanSpeedC(0);
    2660          78 :         Array1D<int> speedsForD;
    2661          78 :         int smallerThanSpeedD(0);
    2662          78 :         int largerThanSpeedD(0);
    2663          78 :         bool bFound = false;
    2664          78 :         bool cFound = false;
    2665          78 :         bool dFound = false;
    2666          78 :         Array1D<Real64> ratioArray;
    2667             : 
    2668          78 :         if (nsp > 4) {
    2669         176 :             for (int i = 1; i <= nsp; ++i) {
    2670         160 :                 Real64 ratioAtithSpeed = (RatedTotalCapacity(i) / _100PercentCoolCap) * 100;
    2671         160 :                 ratioArray.push_back(ratioAtithSpeed);
    2672             :             }
    2673         176 :             for (int i = 1; i <= nsp; ++i) {
    2674         160 :                 if ((int)(ratioArray(i)) == 100.0) {
    2675          16 :                     speedsForA.push_back(i);
    2676          16 :                     continue;
    2677         144 :                 } else if ((int)(ratioArray(i)) == 75.0) {
    2678           0 :                     speedsForB.push_back(i);
    2679           0 :                     bFound = true;
    2680           0 :                     smallerThanSpeedB = 0;
    2681           0 :                     largerThanSpeedB = 0;
    2682           0 :                     continue;
    2683         144 :                 } else if ((int)(ratioArray(i)) == 50.0) {
    2684           0 :                     speedsForC.push_back(i);
    2685           0 :                     cFound = true;
    2686           0 :                     smallerThanSpeedC = 0;
    2687           0 :                     largerThanSpeedC = 0;
    2688           0 :                     continue;
    2689         144 :                 } else if ((int)(ratioArray(i)) == 25.0) {
    2690           0 :                     speedsForD.push_back(i);
    2691           0 :                     dFound = true;
    2692           0 :                     smallerThanSpeedD = 0;
    2693           0 :                     largerThanSpeedD = 0;
    2694           0 :                     continue;
    2695             :                 } else {
    2696         144 :                     if (((int)(ratioArray(i)) > 0.0 && (int)(ratioArray(i)) < 25.0) && !dFound) {
    2697          16 :                         if (smallerThanSpeedD == 0) {
    2698          16 :                             smallerThanSpeedD = i;
    2699             :                         } else {
    2700           0 :                             if (std::abs(RatedTotalCapacity(smallerThanSpeedD) - _25PercentCoolCap) >
    2701           0 :                                 std::abs(RatedTotalCapacity(i) - _25PercentCoolCap)) {
    2702           0 :                                 smallerThanSpeedD = i;
    2703             :                             }
    2704             :                         }
    2705             :                     }
    2706         144 :                     if (((int)(ratioArray(i)) > 25.0 && (int)(ratioArray(i)) < 50.0) && !dFound) {
    2707          48 :                         if (largerThanSpeedD == 0) {
    2708          16 :                             largerThanSpeedD = i;
    2709             :                         } else {
    2710          64 :                             if (std::abs(RatedTotalCapacity(largerThanSpeedD) - _25PercentCoolCap) >
    2711          32 :                                 std::abs(RatedTotalCapacity(i) - _25PercentCoolCap)) {
    2712           0 :                                 largerThanSpeedD = i;
    2713             :                             }
    2714             :                         }
    2715             :                     }
    2716         144 :                     if (((int)(ratioArray(i)) > 25.0 && (int)(ratioArray(i)) < 50.0) && !cFound) {
    2717          48 :                         if (smallerThanSpeedC == 0) {
    2718          16 :                             smallerThanSpeedC = i;
    2719             :                         } else {
    2720          64 :                             if (std::abs(RatedTotalCapacity(smallerThanSpeedC) - _50PercentCoolCap) >
    2721          32 :                                 std::abs(RatedTotalCapacity(i) - _50PercentCoolCap)) {
    2722          32 :                                 smallerThanSpeedC = i;
    2723             :                             }
    2724             :                         }
    2725             :                     }
    2726         144 :                     if (((int)(ratioArray(i)) > 50.0 && (int)(ratioArray(i)) < 75.0) && !cFound) {
    2727          48 :                         if (largerThanSpeedC == 0) {
    2728          16 :                             largerThanSpeedC = i;
    2729             :                         } else {
    2730          64 :                             if (std::abs(RatedTotalCapacity(largerThanSpeedC) - _50PercentCoolCap) >
    2731          32 :                                 std::abs(RatedTotalCapacity(i) - _50PercentCoolCap)) {
    2732           0 :                                 largerThanSpeedC = i;
    2733             :                             }
    2734             :                         }
    2735             :                     }
    2736         144 :                     if (((int)(ratioArray(i)) > 50.0 && (int)(ratioArray(i)) < 75.0) && !bFound) {
    2737          48 :                         if (smallerThanSpeedB == 0) {
    2738          16 :                             smallerThanSpeedB = i;
    2739             :                         } else {
    2740          64 :                             if (std::abs(RatedTotalCapacity(smallerThanSpeedB) - _75PercentCoolCap) >
    2741          32 :                                 std::abs(RatedTotalCapacity(i) - _75PercentCoolCap)) {
    2742          32 :                                 smallerThanSpeedB = i;
    2743             :                             }
    2744             :                         }
    2745             :                     }
    2746         144 :                     if (((int)(ratioArray(i)) > 75.0 && (int)(ratioArray(i)) < 100.0) && !bFound) {
    2747          32 :                         if (largerThanSpeedB == 0) {
    2748          16 :                             largerThanSpeedB = i;
    2749             :                         } else {
    2750          32 :                             if (std::abs(RatedTotalCapacity(largerThanSpeedB) - _75PercentCoolCap) >
    2751          16 :                                 std::abs(RatedTotalCapacity(i) - _75PercentCoolCap)) {
    2752           0 :                                 largerThanSpeedB = i;
    2753             :                             }
    2754             :                         }
    2755             :                     }
    2756             :                 }
    2757             :             }
    2758             : 
    2759          16 :             if (smallerThanSpeedB != 0) speedsForB.push_back(smallerThanSpeedB);
    2760          16 :             if (largerThanSpeedB != 0) speedsForB.push_back(largerThanSpeedB);
    2761             : 
    2762          16 :             if (smallerThanSpeedC != 0) speedsForC.push_back(smallerThanSpeedC);
    2763          16 :             if (largerThanSpeedC != 0) speedsForC.push_back(largerThanSpeedC);
    2764             : 
    2765          16 :             if (smallerThanSpeedD != 0) speedsForD.push_back(smallerThanSpeedD);
    2766          16 :             if (largerThanSpeedD != 0) speedsForD.push_back(largerThanSpeedD);
    2767             : 
    2768             :             // int totalEERCount = speedsForA.size() + speedsForB.size() + speedsForC.size() + speedsForD.size();
    2769             :             // For A | 100% - ReducedPLRIEER[3]
    2770          16 :             int RedCapNum = speedsForA(1);
    2771          16 :             OutdoorUnitInletAirDryBulbTempReduced = GetOutdoorUnitInletAirDryBulbTempReduced(1.00, CondenserType(RedCapNum));
    2772             : 
    2773         160 :             A = CalculateInterMediateEER(state,
    2774             :                                          QAFull,
    2775             :                                          OutdoorUnitInletAirDryBulbTempReduced,
    2776          16 :                                          CapFTempCurveIndex(RedCapNum),
    2777             :                                          CoolingCoilInletAirWetBulbTempRated,
    2778          16 :                                          RatedTotalCapacity(RedCapNum),
    2779          16 :                                          TotCapFlowModFac(RedCapNum),
    2780          16 :                                          FanPowerPerEvapAirFlowRate_2023(RedCapNum),
    2781          16 :                                          RatedAirVolFlowRate(RedCapNum),
    2782          16 :                                          EIRFTempCurveIndex(RedCapNum),
    2783          16 :                                          RatedCOP(RedCapNum),
    2784          16 :                                          EIRFlowModFac(RedCapNum),
    2785          16 :                                          ReducedPLRIEER[3]);
    2786             : 
    2787             :             // For B | 75% - ReducedPLRIEER[2]
    2788          16 :             Real64 EER_BLow(0.0);
    2789          16 :             Real64 EER_BHigh(0.0);
    2790          48 :             for (int i = 1; i <= 2; ++i) {
    2791          32 :                 if ((unsigned long)i > speedsForB.size()) continue;
    2792             : 
    2793          32 :                 RedCapNum = speedsForB(i);
    2794          32 :                 OutdoorUnitInletAirDryBulbTempReduced = GetOutdoorUnitInletAirDryBulbTempReduced(0.75, CondenserType(RedCapNum));
    2795             : 
    2796         320 :                 Real64 EER = CalculateInterMediateEER(state,
    2797             :                                                       QAFull,
    2798             :                                                       OutdoorUnitInletAirDryBulbTempReduced,
    2799          32 :                                                       CapFTempCurveIndex(RedCapNum),
    2800             :                                                       CoolingCoilInletAirWetBulbTempRated,
    2801          32 :                                                       RatedTotalCapacity(RedCapNum),
    2802          32 :                                                       TotCapFlowModFac(RedCapNum),
    2803          32 :                                                       FanPowerPerEvapAirFlowRate_2023(RedCapNum),
    2804          32 :                                                       RatedAirVolFlowRate(RedCapNum),
    2805          32 :                                                       EIRFTempCurveIndex(RedCapNum),
    2806          32 :                                                       RatedCOP(RedCapNum),
    2807          32 :                                                       EIRFlowModFac(RedCapNum),
    2808          32 :                                                       ReducedPLRIEER[2]);
    2809          32 :                 if (speedsForB.size() == 1) {
    2810           0 :                     B = EER;
    2811             :                 } else {
    2812          32 :                     if (i == 1)
    2813          16 :                         EER_BLow = EER; // ?? Check first is low or high
    2814          16 :                     else if (i == 2)
    2815          16 :                         EER_BHigh = EER;
    2816             :                 }
    2817             :             }
    2818             :             // Do the interpolation for B if required
    2819          16 :             if (speedsForB.size() == 2) {
    2820          16 :                 B = ((EER_BHigh - EER_BLow) / (ratioArray(speedsForB(2)) - ratioArray(speedsForB(1)))) * (75 - ratioArray(speedsForB(1))) + EER_BLow;
    2821             :             }
    2822             : 
    2823             :             // For C | 50% - ReducedPLRIEER[1]
    2824          16 :             Real64 EER_CLow(0.0);
    2825          16 :             Real64 EER_CHigh(0.0);
    2826          48 :             for (int i = 1; i <= 2; ++i) {
    2827          32 :                 if ((unsigned long)i > speedsForC.size()) continue;
    2828             : 
    2829          32 :                 RedCapNum = speedsForC(i);
    2830          32 :                 OutdoorUnitInletAirDryBulbTempReduced = GetOutdoorUnitInletAirDryBulbTempReduced(0.50, CondenserType(RedCapNum));
    2831             : 
    2832         320 :                 Real64 EER = CalculateInterMediateEER(state,
    2833             :                                                       QAFull,
    2834             :                                                       OutdoorUnitInletAirDryBulbTempReduced,
    2835          32 :                                                       CapFTempCurveIndex(RedCapNum),
    2836             :                                                       CoolingCoilInletAirWetBulbTempRated,
    2837          32 :                                                       RatedTotalCapacity(RedCapNum),
    2838          32 :                                                       TotCapFlowModFac(RedCapNum),
    2839          32 :                                                       FanPowerPerEvapAirFlowRate_2023(RedCapNum),
    2840          32 :                                                       RatedAirVolFlowRate(RedCapNum),
    2841          32 :                                                       EIRFTempCurveIndex(RedCapNum),
    2842          32 :                                                       RatedCOP(RedCapNum),
    2843          32 :                                                       EIRFlowModFac(RedCapNum),
    2844          32 :                                                       ReducedPLRIEER[1]);
    2845          32 :                 if (speedsForC.size() == 1) {
    2846           0 :                     C = EER;
    2847             :                 } else {
    2848          32 :                     if (i == 1)
    2849          16 :                         EER_CLow = EER; // ?? Check first is low or high
    2850          16 :                     else if (i == 2)
    2851          16 :                         EER_CHigh = EER;
    2852             :                 }
    2853             :             }
    2854             :             // Do the interpolation for C if required
    2855          16 :             if (speedsForC.size() == 2) {
    2856          16 :                 C = ((EER_CHigh - EER_CLow) / (ratioArray(speedsForC(2)) - ratioArray(speedsForC(1)))) * (50 - ratioArray(speedsForC(1))) + EER_CLow;
    2857             :             }
    2858             : 
    2859             :             // For D | 25% - ReducedPLRIEER[0]
    2860          16 :             Real64 EER_DLow(0.0);
    2861          16 :             Real64 EER_DHigh(0.0);
    2862          48 :             for (int i = 1; i <= 2; ++i) {
    2863          32 :                 if ((unsigned long)i > speedsForD.size()) continue;
    2864             : 
    2865          32 :                 RedCapNum = speedsForD(i);
    2866          32 :                 OutdoorUnitInletAirDryBulbTempReduced = GetOutdoorUnitInletAirDryBulbTempReduced(0.25, CondenserType(RedCapNum));
    2867             : 
    2868         320 :                 Real64 EER = CalculateInterMediateEER(state,
    2869             :                                                       QAFull,
    2870             :                                                       OutdoorUnitInletAirDryBulbTempReduced,
    2871          32 :                                                       CapFTempCurveIndex(RedCapNum),
    2872             :                                                       CoolingCoilInletAirWetBulbTempRated,
    2873          32 :                                                       RatedTotalCapacity(RedCapNum),
    2874          32 :                                                       TotCapFlowModFac(RedCapNum),
    2875          32 :                                                       FanPowerPerEvapAirFlowRate_2023(RedCapNum),
    2876          32 :                                                       RatedAirVolFlowRate(RedCapNum),
    2877          32 :                                                       EIRFTempCurveIndex(RedCapNum),
    2878          32 :                                                       RatedCOP(RedCapNum),
    2879          32 :                                                       EIRFlowModFac(RedCapNum),
    2880          32 :                                                       ReducedPLRIEER[0]);
    2881          32 :                 if (speedsForD.size() == 1) {
    2882           0 :                     D = EER;
    2883             :                 } else {
    2884          32 :                     if (i == 1)
    2885          16 :                         EER_DLow = EER; // ?? Check first is low or high
    2886          16 :                     else if (i == 2)
    2887          16 :                         EER_DHigh = EER;
    2888             :                 }
    2889             :             }
    2890             :             // Do the interpolation for D if required
    2891          16 :             if (speedsForD.size() == 2) {
    2892          16 :                 D = ((EER_DHigh - EER_DLow) / (ratioArray(speedsForD(2)) - ratioArray(speedsForD(1)))) * (25 - ratioArray(speedsForD(1))) + EER_DLow;
    2893             :             }
    2894             : 
    2895          16 :             IEER_2022 = GetIEEREquationResult(A, B, C, D);
    2896          16 :             EER_2022 = A;
    2897          62 :         } else if (nsp == 2 || nsp == 3 || nsp == 4) {
    2898             :             // 2, 3 & 4 Speeds
    2899          40 :             Real64 QAFull_(0.0);
    2900          80 :             std::tie(IEER_2022, QAFull_, EER_2022) = IEERCalculationMultiSpeed(state,
    2901             :                                                                                VSCoilType,
    2902             :                                                                                nsp,
    2903             :                                                                                CapFTempCurveIndex,
    2904             :                                                                                RatedTotalCapacity,
    2905             :                                                                                CapFFlowCurveIndex,
    2906             :                                                                                FanPowerPerEvapAirFlowRate_2023,
    2907             :                                                                                RatedAirVolFlowRate,
    2908             :                                                                                EIRFTempCurveIndex,
    2909             :                                                                                RatedCOP,
    2910             :                                                                                EIRFFlowCurveIndex,
    2911          40 :                                                                                CondenserType);
    2912          62 :         } else if (nsp == 1) {
    2913             :             // 1 Speed
    2914          22 :             Real64 QAFull_(0.0);
    2915          44 :             std::tie(IEER_2022, QAFull_, EER_2022) = IEERCalculationSingleSpeed(state,
    2916             :                                                                                 VSCoilType,
    2917          22 :                                                                                 CapFTempCurveIndex(1),
    2918          22 :                                                                                 RatedTotalCapacity(1),
    2919          22 :                                                                                 TotCapFlowModFac(1),
    2920          22 :                                                                                 FanPowerPerEvapAirFlowRate_2023(1),
    2921          22 :                                                                                 RatedAirVolFlowRate(1),
    2922          22 :                                                                                 EIRFTempCurveIndex(1),
    2923          22 :                                                                                 RatedCOP(1),
    2924          22 :                                                                                 EIRFlowModFac(1),
    2925          44 :                                                                                 CondenserType(1));
    2926             :         }
    2927             : 
    2928         156 :         return std::make_tuple(IEER_2022, QAFull, EER_2022);
    2929          78 :     }
    2930             : 
    2931          89 :     std::tuple<Real64, Real64, Real64> IEERCalculationMultiSpeed(
    2932             :         EnergyPlus::EnergyPlusData &state,
    2933             :         std::string const &DXCoilType, // Type of DX coil
    2934             :         int const nsp,
    2935             :         Array1A_int const &CapFTempCurveIndex,
    2936             :         Array1A<Real64> const &RatedTotalCapacity,
    2937             :         Array1A_int const &CapFFlowCurveIndex,
    2938             :         Array1A<Real64> const &FanPowerPerEvapAirFlowRateFromInput_2023, // 2023 Rated Fan Power per air volume flow rate through the evaporator coil
    2939             :         Array1A<Real64> const &RatedAirVolFlowRate,
    2940             :         Array1A_int const &EIRFTempCurveIndex,
    2941             :         Array1A<Real64> const &RatedCOP, // Reference coefficient of performance [W/W]
    2942             :         Array1A_int const &EIRFFlowCurveIndex,
    2943             :         Array1D<DataHeatBalance::RefrigCondenserType> const &CondenserType) // Type of condenser user by the DX Cooling Coil
    2944             :     {
    2945          89 :         Real64 IEER_2022(0.0);
    2946          89 :         Real64 EER_2022(0.0);
    2947          89 :         Real64 QAFull(0.0);
    2948          89 :         Array1D<Real64> Q_A_Full(nsp);                        // Total cooling capacity at A2 test condition (High speed) | q_A_Full
    2949          89 :         Array1D<Real64> FanPowerPerEvapAirFlowRate_2023(nsp); // 2023 Fan power per air volume flow rate through the evaporator coil [W/(m3/s)]
    2950             :         // Calculate these for each speed
    2951             :         // hint : curve index will change, AirFlow rate will remain same
    2952          89 :         Array1D<Real64> TotCapFlowModFac(nsp); // Total capacity modifier f(actual flow vs rated flow) for each speed [-]
    2953          89 :         Array1D<Real64> EIRFlowModFac(nsp);    // EIR modifier f(actual supply air flow vs rated flow) for each speed [-]
    2954          89 :         Array1D<Real64> TotCapTempModFac(nsp);
    2955          89 :         Array1D<Real64> NetCoolingCapRated(nsp);
    2956          89 :         Real64 OutdoorUnitInletAirDryBulbTempReduced(0.0); // Outdoor unit entering air dry-bulb temperature at reduced capacity [C]
    2957          89 :         Real64 EER(0.0);                                   // Energy Efficiency Rating
    2958          89 :         Real64 PartLoad(0.0);
    2959             :         // EER Reduced
    2960          89 :         Real64 A(0.0); // EER, (Btu/h)/W, at 100% Capacity at AHRI Standard Rating Conditions (see Table 6)| AHRI Std.340/360-2022(IP)
    2961          89 :         Real64 B(0.0); // EER, (Btu/h)/W, at 75% Capacity at AHRI Standard Rating Conditions (see Table 6)| AHRI Std.340/360-2022(IP)
    2962          89 :         Real64 C(0.0); // EER, (Btu/h)/W, at 50% Capacity at AHRI Standard Rating Conditions (see Table 6)| AHRI Std.340/360-2022(IP)
    2963          89 :         Real64 D(0.0); // EER, (Btu/h)/W, at 25% Capacity at AHRI Standard Rating Conditions (see Table 6)| AHRI Std.340/360-2022(IP)
    2964             : 
    2965         316 :         for (int spnum = 1; spnum <= nsp; ++spnum) {
    2966         227 :             FanPowerPerEvapAirFlowRate_2023(spnum) = 0.0;
    2967         227 :             if (FanPowerPerEvapAirFlowRateFromInput_2023(spnum) <= 0.0) {
    2968           0 :                 FanPowerPerEvapAirFlowRate_2023(spnum) = DefaultFanPowerPerEvapAirFlowRateSEER2;
    2969             :             } else {
    2970         227 :                 FanPowerPerEvapAirFlowRate_2023(spnum) = FanPowerPerEvapAirFlowRateFromInput_2023(spnum);
    2971             :             }
    2972             :         }
    2973             : 
    2974             :         // int maxSpeed = nsp;
    2975         316 :         for (int spnum = nsp; spnum > 0; --spnum) {
    2976             :             // TotCapFlowModFac(spnum) = Curve::CurveValue(state, CapFFlowCurveIndex(spnum), AirMassFlowRatioRated);
    2977         227 :             TotCapFlowModFac(spnum) = Curve::CurveValue(state, CapFFlowCurveIndex(spnum), AirMassFlowRatioRated);
    2978             :             // EIRFlowModFac(spnum) = Curve::CurveValue(state, EIRFFlowCurveIndex(spnum), AirMassFlowRatioRated);
    2979         227 :             EIRFlowModFac(spnum) = Curve::CurveValue(state, EIRFFlowCurveIndex(spnum), AirMassFlowRatioRated);
    2980             : 
    2981             :             // if CondenserType is AirCooled
    2982         227 :             if (CondenserType(spnum) == DataHeatBalance::RefrigCondenserType::Air) {
    2983             :                 // Cooling Coil | Calculate the net cooling capacity at the rated conditions (23.89C(75F) Wet Bulb and 35.0C(95F) Dry Bulb )
    2984         227 :                 if (DXCoilType.find("Cooling") != std::string::npos)
    2985         114 :                     TotCapTempModFac(spnum) =
    2986         114 :                         Curve::CurveValue(state, CapFTempCurveIndex(spnum), CoolingCoilInletAirWetBulbTempRated, CoilInletAirCoolDryBulbIEER);
    2987             :                 else // Heating Coil | Calculate the net cooling capacity at the rated conditions (6.11C(43F) Wet Bulb and 8.33C(47F) Dry Bulb )
    2988         113 :                     TotCapTempModFac(spnum) =
    2989         113 :                         Curve::CurveValue(state, CapFTempCurveIndex(spnum), CoilHeatingInletAirWetBulbTempIEER, CoilHeatingInletAirCoolDryBulbIEER);
    2990             :             }
    2991             :             // if CondenserType is WaterCooled
    2992         227 :             if (CondenserType(spnum) == DataHeatBalance::RefrigCondenserType::Water) {
    2993             :                 // Calculate the net cooling capacity at the rated conditions (35.0C(95F) Outlet and 29.44C(85F) Inlet )
    2994             : 
    2995           0 :                 TotCapTempModFac(spnum) = Curve::CurveValue(state, CapFTempCurveIndex(spnum), CoilWaterOutletTempIEER, CoilWaterInletTempIEER);
    2996             :             }
    2997             :             // if CondesnerType is EvaporativelyCooled
    2998         227 :             if (CondenserType(spnum) == DataHeatBalance::RefrigCondenserType::Evap) {
    2999             :                 // Calculate the net cooling capacity at the rated conditions (23.89C(75F) Wet Bulb and 35.0C(95F) Dry Bulb )
    3000           0 :                 TotCapTempModFac(spnum) =
    3001           0 :                     Curve::CurveValue(state, CapFTempCurveIndex(spnum), CoilInletEvapWetBulbTempIEER, CoilInletEvapDryBulbTempIEER);
    3002             :             }
    3003             : 
    3004             :             // This Will be our QAFull
    3005         227 :             NetCoolingCapRated(spnum) = RatedTotalCapacity(spnum) * TotCapTempModFac(spnum) * TotCapFlowModFac(spnum) -
    3006         227 :                                         FanPowerPerEvapAirFlowRate_2023(spnum) * RatedAirVolFlowRate(spnum);
    3007         227 :             Q_A_Full(spnum) = NetCoolingCapRated(spnum);
    3008             :         }
    3009          89 :         QAFull = Q_A_Full(nsp);
    3010             : 
    3011          89 :         Real64 _100PercentCoolCap = RatedTotalCapacity(nsp);
    3012             : 
    3013          89 :         Array1D<int> speedsForA;
    3014          89 :         Array1D<int> speedsForB;
    3015          89 :         Array1D<int> speedsForC;
    3016          89 :         Array1D<int> speedsForD;
    3017          89 :         Array1D<Real64> ratioArray;
    3018             : 
    3019          89 :         if (nsp == 4) {
    3020             : 
    3021             :             // RedCapNum : Integer counter for reduced capacity
    3022         110 :             for (int RedCapNum = nsp; RedCapNum > 0; --RedCapNum) {
    3023             : 
    3024          88 :                 PartLoad = ReducedPLRIEER[RedCapNum - 1.0];
    3025          88 :                 OutdoorUnitInletAirDryBulbTempReduced = GetOutdoorUnitInletAirDryBulbTempReduced(PartLoad, CondenserType(RedCapNum));
    3026             : 
    3027         792 :                 EER = CalculateInterMediateEER(state,
    3028             :                                                QAFull,
    3029             :                                                OutdoorUnitInletAirDryBulbTempReduced,
    3030          88 :                                                CapFTempCurveIndex(RedCapNum),
    3031             :                                                CoolingCoilInletAirWetBulbTempRated,
    3032          88 :                                                RatedTotalCapacity(RedCapNum),
    3033          88 :                                                TotCapFlowModFac(RedCapNum),
    3034          88 :                                                FanPowerPerEvapAirFlowRate_2023(RedCapNum),
    3035          88 :                                                RatedAirVolFlowRate(RedCapNum),
    3036          88 :                                                EIRFTempCurveIndex(RedCapNum),
    3037          88 :                                                RatedCOP(RedCapNum),
    3038          88 :                                                EIRFlowModFac(RedCapNum),
    3039             :                                                PartLoad);
    3040             : 
    3041          88 :                 if (PartLoad == 1.00) {
    3042          22 :                     A = EER;
    3043          66 :                 } else if (PartLoad == 0.75) {
    3044          22 :                     B = EER;
    3045          44 :                 } else if (PartLoad == 0.50) {
    3046          22 :                     C = EER;
    3047          22 :                 } else if (PartLoad == 0.25) {
    3048          22 :                     D = EER;
    3049             :                 }
    3050             :             }
    3051          22 :             IEER_2022 = GetIEEREquationResult(A, B, C, D);
    3052          22 :             EER_2022 = A;
    3053          67 :         } else if (nsp == 3) {
    3054           5 :             speedsForA.push_back(3);
    3055             : 
    3056           5 :             speedsForB.push_back(2);
    3057           5 :             speedsForB.push_back(3);
    3058             : 
    3059           5 :             speedsForC.push_back(1);
    3060           5 :             speedsForC.push_back(2);
    3061             : 
    3062           5 :             speedsForD.push_back(1);
    3063             : 
    3064          20 :             for (int i = 1; i <= nsp; ++i) {
    3065          15 :                 Real64 ratioAtithSpeed = (RatedTotalCapacity(i) / _100PercentCoolCap) * 100;
    3066          15 :                 ratioArray.push_back(ratioAtithSpeed);
    3067             :             }
    3068             : 
    3069             :             // For A | 100% - ReducedPLRIEER[3]
    3070           5 :             int RedCapNum = speedsForA(1);
    3071             : 
    3072           5 :             OutdoorUnitInletAirDryBulbTempReduced = GetOutdoorUnitInletAirDryBulbTempReduced(1.00, CondenserType(RedCapNum));
    3073             : 
    3074          50 :             A = CalculateInterMediateEER(state,
    3075             :                                          QAFull,
    3076             :                                          OutdoorUnitInletAirDryBulbTempReduced,
    3077           5 :                                          CapFTempCurveIndex(RedCapNum),
    3078             :                                          CoolingCoilInletAirWetBulbTempRated,
    3079           5 :                                          RatedTotalCapacity(RedCapNum),
    3080           5 :                                          TotCapFlowModFac(RedCapNum),
    3081           5 :                                          FanPowerPerEvapAirFlowRate_2023(RedCapNum),
    3082           5 :                                          RatedAirVolFlowRate(RedCapNum),
    3083           5 :                                          EIRFTempCurveIndex(RedCapNum),
    3084           5 :                                          RatedCOP(RedCapNum),
    3085           5 :                                          EIRFlowModFac(RedCapNum),
    3086           5 :                                          ReducedPLRIEER[3]);
    3087             : 
    3088             :             // For B | 75% - ReducedPLRIEER[2]
    3089           5 :             Real64 EER_BLow(0.0);
    3090           5 :             Real64 EER_BHigh(0.0);
    3091          15 :             for (int i = 1; i <= 2; ++i) {
    3092          10 :                 if ((unsigned long)i > speedsForB.size()) continue;
    3093             : 
    3094          10 :                 RedCapNum = speedsForB(i);
    3095          10 :                 OutdoorUnitInletAirDryBulbTempReduced = GetOutdoorUnitInletAirDryBulbTempReduced(0.75, CondenserType(RedCapNum));
    3096             : 
    3097         100 :                 Real64 EER = CalculateInterMediateEER(state,
    3098             :                                                       QAFull,
    3099             :                                                       OutdoorUnitInletAirDryBulbTempReduced,
    3100          10 :                                                       CapFTempCurveIndex(RedCapNum),
    3101             :                                                       CoolingCoilInletAirWetBulbTempRated,
    3102          10 :                                                       RatedTotalCapacity(RedCapNum),
    3103          10 :                                                       TotCapFlowModFac(RedCapNum),
    3104          10 :                                                       FanPowerPerEvapAirFlowRate_2023(RedCapNum),
    3105          10 :                                                       RatedAirVolFlowRate(RedCapNum),
    3106          10 :                                                       EIRFTempCurveIndex(RedCapNum),
    3107          10 :                                                       RatedCOP(RedCapNum),
    3108          10 :                                                       EIRFlowModFac(RedCapNum),
    3109          10 :                                                       ReducedPLRIEER[2]);
    3110             : 
    3111          10 :                 if (i == 1)
    3112           5 :                     EER_BLow = EER; // ?? Check first is low or high
    3113           5 :                 else if (i == 2)
    3114           5 :                     EER_BHigh = EER;
    3115             :             }
    3116             :             // Do the interpolation for B if required
    3117           5 :             if (speedsForB.size() == 2) {
    3118           5 :                 B = ((EER_BHigh - EER_BLow) / (ratioArray(speedsForB(2)) - ratioArray(speedsForB(1)))) * (75 - ratioArray(speedsForB(1))) + EER_BLow;
    3119             :             }
    3120             : 
    3121             :             // For C | 50% - ReducedPLRIEER[1]
    3122           5 :             Real64 EER_CLow(0.0);
    3123           5 :             Real64 EER_CHigh(0.0);
    3124          15 :             for (int i = 1; i <= 2; ++i) {
    3125          10 :                 if ((unsigned long)i > speedsForC.size()) continue;
    3126             : 
    3127          10 :                 RedCapNum = speedsForC(i);
    3128          10 :                 OutdoorUnitInletAirDryBulbTempReduced = GetOutdoorUnitInletAirDryBulbTempReduced(0.50, CondenserType(RedCapNum));
    3129             : 
    3130         100 :                 Real64 EER = CalculateInterMediateEER(state,
    3131             :                                                       QAFull,
    3132             :                                                       OutdoorUnitInletAirDryBulbTempReduced,
    3133          10 :                                                       CapFTempCurveIndex(RedCapNum),
    3134             :                                                       CoolingCoilInletAirWetBulbTempRated,
    3135          10 :                                                       RatedTotalCapacity(RedCapNum),
    3136          10 :                                                       TotCapFlowModFac(RedCapNum),
    3137          10 :                                                       FanPowerPerEvapAirFlowRate_2023(RedCapNum),
    3138          10 :                                                       RatedAirVolFlowRate(RedCapNum),
    3139          10 :                                                       EIRFTempCurveIndex(RedCapNum),
    3140          10 :                                                       RatedCOP(RedCapNum),
    3141          10 :                                                       EIRFlowModFac(RedCapNum),
    3142          10 :                                                       ReducedPLRIEER[1]);
    3143             : 
    3144          10 :                 if (i == 1)
    3145           5 :                     EER_CLow = EER; // ?? Check first is low or high
    3146           5 :                 else if (i == 2)
    3147           5 :                     EER_CHigh = EER;
    3148             :             }
    3149             :             // Do the interpolation for C if required
    3150           5 :             if (speedsForC.size() == 2) {
    3151           5 :                 C = ((EER_CHigh - EER_CLow) / (ratioArray(speedsForC(2)) - ratioArray(speedsForC(1)))) * (50 - ratioArray(speedsForC(1))) + EER_CLow;
    3152             :             }
    3153             : 
    3154             :             // For D | 25% - ReducedPLRIEER[0]
    3155             : 
    3156           5 :             RedCapNum = speedsForD(1);
    3157           5 :             OutdoorUnitInletAirDryBulbTempReduced = GetOutdoorUnitInletAirDryBulbTempReduced(0.25, CondenserType(RedCapNum));
    3158             : 
    3159          50 :             D = CalculateInterMediateEER(state,
    3160             :                                          QAFull,
    3161             :                                          OutdoorUnitInletAirDryBulbTempReduced,
    3162           5 :                                          CapFTempCurveIndex(RedCapNum),
    3163             :                                          CoolingCoilInletAirWetBulbTempRated,
    3164           5 :                                          RatedTotalCapacity(RedCapNum),
    3165           5 :                                          TotCapFlowModFac(RedCapNum),
    3166           5 :                                          FanPowerPerEvapAirFlowRate_2023(RedCapNum),
    3167           5 :                                          RatedAirVolFlowRate(RedCapNum),
    3168           5 :                                          EIRFTempCurveIndex(RedCapNum),
    3169           5 :                                          RatedCOP(RedCapNum),
    3170           5 :                                          EIRFlowModFac(RedCapNum),
    3171           5 :                                          ReducedPLRIEER[0]);
    3172             : 
    3173           5 :             IEER_2022 = GetIEEREquationResult(A, B, C, D);
    3174           5 :             EER_2022 = A;
    3175          62 :         } else if (nsp == 2) {
    3176             :             // Having 2 Speeds
    3177          62 :             Real64 QAFull_(0.0);
    3178             :             // Reversing the input arrays because IEERCalculationTwoSpeed is expecting High Speed Data before the Low Speed.
    3179          62 :             Array1D<Real64> FanPowerPerEvapAirFlowRateHighAndLow(FanPowerPerEvapAirFlowRate_2023.size()); // Ensure ReversedArray has the same size
    3180          62 :             std::reverse_copy(
    3181             :                 FanPowerPerEvapAirFlowRate_2023.begin(), FanPowerPerEvapAirFlowRate_2023.end(), FanPowerPerEvapAirFlowRateHighAndLow.begin());
    3182             : 
    3183          62 :             Array1D<Real64> RatedAirVolFlowRateHighAndLow(RatedAirVolFlowRate.size());
    3184          62 :             std::reverse_copy(RatedAirVolFlowRate.begin(), RatedAirVolFlowRate.end(), RatedAirVolFlowRateHighAndLow.begin());
    3185             : 
    3186          62 :             Array1D<Real64> RatedCOPHighAndLow(RatedCOP.size());
    3187          62 :             std::reverse_copy(RatedCOP.begin(), RatedCOP.end(), RatedCOPHighAndLow.begin());
    3188             : 
    3189          62 :             Array1D<Real64> RatedTotalCapacityHighAndLow(RatedTotalCapacity.size());
    3190          62 :             std::reverse_copy(RatedTotalCapacity.begin(), RatedTotalCapacity.end(), RatedTotalCapacityHighAndLow.begin());
    3191             : 
    3192         124 :             std::tie(IEER_2022, QAFull_, EER_2022) = IEERCalculationTwoSpeed(state,
    3193             :                                                                              DXCoilType,
    3194             :                                                                              CondenserType,
    3195             :                                                                              CapFTempCurveIndex,
    3196             :                                                                              RatedTotalCapacityHighAndLow,
    3197             :                                                                              CapFFlowCurveIndex, // Only for HIGH SPEED
    3198             :                                                                              FanPowerPerEvapAirFlowRateHighAndLow,
    3199             :                                                                              RatedAirVolFlowRateHighAndLow,
    3200             :                                                                              EIRFTempCurveIndex,
    3201             :                                                                              RatedCOPHighAndLow,
    3202             :                                                                              EIRFFlowCurveIndex // Only for HIGH SPEED
    3203          62 :             );
    3204          62 :         } else if (nsp == 1) {
    3205             :             // NA : The minimum number of speeds for cooling is 2 and the maximum number is 4 for Coil:Cooling:DX:MultiSpeed
    3206             :         }
    3207         178 :         return std::make_tuple(IEER_2022, QAFull, EER_2022);
    3208          89 :     }
    3209             : 
    3210         129 :     std::tuple<Real64, Real64, Real64> IEERCalculationTwoSpeed(
    3211             :         EnergyPlusData &state,
    3212             :         std::string const &DXCoilType, // Type of DX coil
    3213             :         Array1D<DataHeatBalance::RefrigCondenserType> const &CondenserType,
    3214             :         Array1A_int const &CapFTempCurveIndex,
    3215             :         Array1A<Real64> const &RatedTotalCapacity,
    3216             :         Array1A_int const &CCapFFlowCurveIndex,                          //  | Only for HIGH SPEED
    3217             :         Array1A<Real64> const &FanPowerPerEvapAirFlowRateFromInput_2023, // 2023 Rated Fan Power per air volume flow rate through the evaporator coil
    3218             :         Array1A<Real64> const &RatedAirVolFlowRate,
    3219             :         Array1A_int const &EIRFTempCurveIndex,
    3220             :         Array1A<Real64> const &RatedCOP,      // Reference coefficient of performance [W/W]
    3221             :         Array1A_int const &EIRFFlowCurveIndex //  | Only for HIGH SPEED
    3222             :     )
    3223             :     {
    3224         129 :         int constexpr nsp = 4; // As IEER Requires EER for at least 4 different Speeds,
    3225             :         // we'll be carrying out the calculations with low and high speed in such a way that we have
    3226             :         // A,B,C,D for the required IEER equation. So nsp is initialized as 4 here.
    3227         129 :         Real64 IEER_2022(0.0);
    3228         129 :         Real64 EER_2022(0.0);
    3229         129 :         Real64 QAFull(0.0);
    3230         129 :         Array1D<Real64> Q_A_Full(nsp);                        // Total cooling capacity at A2 test condition (High speed) | q_A_Full
    3231         129 :         Array1D<Real64> FanPowerPerEvapAirFlowRate_2023(nsp); // 2023 Fan power per air volume flow rate through the evaporator coil [W/(m3/s)]
    3232             :         // Calculate these for each speed
    3233             :         // hint : curve index will change, AirFlow rate will remain same
    3234         129 :         Array1D<Real64> TotCapFlowModFac(nsp); // Total capacity modifier f(actual flow vs rated flow) for each speed [-]
    3235         129 :         Array1D<Real64> EIRFlowModFac(nsp);    // EIR modifier f(actual supply air flow vs rated flow) for each speed [-]
    3236         129 :         Array1D<Real64> TotCapTempModFac(nsp);
    3237         129 :         Array1D<Real64> NetCoolingCapRated(nsp);
    3238         129 :         Real64 OutdoorUnitInletAirDryBulbTempReduced(0.0); // Outdoor unit entering air dry-bulb temperature at reduced capacity [C]
    3239         129 :         Real64 EER(0.0);                                   // Energy Efficiency Rating
    3240         129 :         Real64 PartLoad(0.0);
    3241             :         // EER Reduced
    3242         129 :         Real64 A(0.0); // EER, (Btu/h)/W, at 100% Capacity at AHRI Standard Rating Conditions (see Table 6)| AHRI Std.340/360-2022(IP)
    3243         129 :         Real64 B(0.0); // EER, (Btu/h)/W, at 75% Capacity at AHRI Standard Rating Conditions (see Table 6)| AHRI Std.340/360-2022(IP)
    3244         129 :         Real64 C(0.0); // EER, (Btu/h)/W, at 50% Capacity at AHRI Standard Rating Conditions (see Table 6)| AHRI Std.340/360-2022(IP)
    3245         129 :         Real64 D(0.0); // EER, (Btu/h)/W, at 25% Capacity at AHRI Standard Rating Conditions (see Table 6)| AHRI Std.340/360-2022(IP)
    3246         129 :         Array1D<DataHeatBalance::RefrigCondenserType> _condenserType(nsp);
    3247             : 
    3248         645 :         for (int spnum = 1; spnum <= nsp; ++spnum) {
    3249         516 :             FanPowerPerEvapAirFlowRate_2023(spnum) = 0.0;
    3250         516 :             if (spnum == 1 || spnum == 2) { // First two speeds will have Low Speed Props
    3251         258 :                 if (FanPowerPerEvapAirFlowRateFromInput_2023(2) <= 0.0) {
    3252           0 :                     FanPowerPerEvapAirFlowRate_2023(spnum) = DefaultFanPowerPerEvapAirFlowRateSEER2;
    3253             :                 } else {
    3254         258 :                     FanPowerPerEvapAirFlowRate_2023(spnum) = FanPowerPerEvapAirFlowRateFromInput_2023(2);
    3255             :                 }
    3256         258 :                 _condenserType(spnum) = CondenserType(1);
    3257         258 :             } else if (spnum == 3 || spnum == 4) {
    3258         258 :                 if (FanPowerPerEvapAirFlowRateFromInput_2023(1) <= 0.0) { // Last two speeds will have High Speed Props
    3259           0 :                     FanPowerPerEvapAirFlowRate_2023(spnum) = DefaultFanPowerPerEvapAirFlowRateSEER2;
    3260             :                 } else {
    3261         258 :                     FanPowerPerEvapAirFlowRate_2023(spnum) = FanPowerPerEvapAirFlowRateFromInput_2023(1);
    3262             :                 }
    3263         258 :                 _condenserType(spnum) = CondenserType(2);
    3264             :             }
    3265             :         }
    3266             : 
    3267             :         // Calculate QAFull, EIRFlowModeFac & TotCapFlowModFac
    3268         645 :         for (int spnum = nsp; spnum > 0; --spnum) {
    3269             : 
    3270         516 :             if (spnum == 3 || spnum == 4) {
    3271         258 :                 if (DXCoilType == "Coil:Cooling:DX:TwoSpeed") {
    3272         134 :                     TotCapFlowModFac(spnum) = Curve::CurveValue(state, CCapFFlowCurveIndex(1), AirMassFlowRatioRated);
    3273         134 :                     EIRFlowModFac(spnum) = Curve::CurveValue(state, EIRFFlowCurveIndex(1), AirMassFlowRatioRated);
    3274             :                 } else {
    3275             :                     // Coil:Cooling:DX:MultiSpeed || Coil:Cooling:DX:VariableSpeed
    3276         124 :                     TotCapFlowModFac(spnum) = Curve::CurveValue(state, CCapFFlowCurveIndex(2), AirMassFlowRatioRated);
    3277         124 :                     EIRFlowModFac(spnum) = Curve::CurveValue(state, EIRFFlowCurveIndex(2), AirMassFlowRatioRated);
    3278             :                 }
    3279         258 :             } else if (spnum == 1 || spnum == 2) {
    3280         258 :                 if (DXCoilType == "Coil:Cooling:DX:TwoSpeed") {
    3281         134 :                     TotCapFlowModFac(spnum) = 1; // As per IO Reference there are no CCapFFlowCurve for Low Speed | Section ??
    3282         134 :                     EIRFlowModFac(spnum) = 1;    // As per IO Reference there are no EIRFFlowCurve for Low Speed | Section ??
    3283             :                 } else {
    3284             :                     // Coil:Cooling:DX:MultiSpeed || Coil:Cooling:DX:VariableSpeed
    3285         124 :                     TotCapFlowModFac(spnum) = Curve::CurveValue(state, CCapFFlowCurveIndex(1), AirMassFlowRatioRated);
    3286         124 :                     EIRFlowModFac(spnum) = Curve::CurveValue(state, EIRFFlowCurveIndex(1), AirMassFlowRatioRated);
    3287             :                 }
    3288             :             }
    3289             : 
    3290         516 :             if (_condenserType(spnum) == DataHeatBalance::RefrigCondenserType::Air) { // Case: CondenserType is AirCooled
    3291         514 :                 if (spnum == 3 || spnum == 4) {
    3292             :                     // Cooling Coil | Calculate the net cooling capacity at the rated conditions (23.89C(75F) Wet Bulb and 35.0C(95F) Dry Bulb )
    3293         258 :                     if (DXCoilType.find("Cooling") != std::string::npos)
    3294         176 :                         TotCapTempModFac(spnum) =
    3295         176 :                             Curve::CurveValue(state, CapFTempCurveIndex(1), CoolingCoilInletAirWetBulbTempRated, CoilInletAirCoolDryBulbIEER);
    3296             :                     else // Heating Coil | Calculate the net cooling capacity at the rated conditions (6.11C(43F) Wet Bulb and 8.33C(47F) Dry Bulb )
    3297          82 :                         TotCapTempModFac(spnum) =
    3298          82 :                             Curve::CurveValue(state, CapFTempCurveIndex(1), CoilHeatingInletAirWetBulbTempIEER, CoilHeatingInletAirCoolDryBulbIEER);
    3299         256 :                 } else if (spnum == 1 || spnum == 2) {
    3300             :                     // Cooling Coil | Calculate the net cooling capacity at the rated conditions (23.89C(75F) Wet Bulb and 35.0C(95F) Dry Bulb )
    3301         256 :                     if (DXCoilType.find("Cooling") != std::string::npos)
    3302         174 :                         TotCapTempModFac(spnum) =
    3303         174 :                             Curve::CurveValue(state, CapFTempCurveIndex(2), CoolingCoilInletAirWetBulbTempRated, CoilInletAirCoolDryBulbIEER);
    3304             :                     else // Heating Coil | Calculate the net cooling capacity at the rated conditions (6.11C(43F) Wet Bulb and 8.33C(47F) Dry Bulb )
    3305          82 :                         TotCapTempModFac(spnum) =
    3306          82 :                             Curve::CurveValue(state, CapFTempCurveIndex(2), CoilHeatingInletAirWetBulbTempIEER, CoilHeatingInletAirCoolDryBulbIEER);
    3307             :                 }
    3308           2 :             } else if (_condenserType(spnum) == DataHeatBalance::RefrigCondenserType::Water) { // Case: CondenserType is WaterCooled
    3309             :                 // Calculate the net cooling capacity at the rated conditions (35.0C(95F) Outlet and 29.44C(85F) Inlet )
    3310           0 :                 if (spnum == 3 || spnum == 4) {
    3311           0 :                     TotCapTempModFac(spnum) = Curve::CurveValue(state, CapFTempCurveIndex(1), CoilWaterOutletTempIEER, CoilWaterInletTempIEER);
    3312           0 :                 } else if (spnum == 1 || spnum == 2) {
    3313           0 :                     TotCapTempModFac(spnum) = Curve::CurveValue(state, CapFTempCurveIndex(2), CoilWaterOutletTempIEER, CoilWaterInletTempIEER);
    3314             :                 }
    3315           2 :             } else if (_condenserType(spnum) == DataHeatBalance::RefrigCondenserType::Evap) { // Case: CondesnerType is EvaporativelyCooled
    3316             :                 // Calculate the net cooling capacity at the rated conditions (23.89C(75F) Wet Bulb and 35.0C(95F) Dry Bulb )
    3317           2 :                 if (spnum == 3 || spnum == 4) {
    3318           0 :                     TotCapTempModFac(spnum) =
    3319           0 :                         Curve::CurveValue(state, CapFTempCurveIndex(1), CoilInletEvapWetBulbTempIEER, CoilInletEvapDryBulbTempIEER);
    3320           2 :                 } else if (spnum == 1 || spnum == 2) {
    3321           2 :                     TotCapTempModFac(spnum) =
    3322           2 :                         Curve::CurveValue(state, CapFTempCurveIndex(2), CoilInletEvapWetBulbTempIEER, CoilInletEvapDryBulbTempIEER);
    3323             :                 }
    3324             :             }
    3325             :             // This Will be our QAFull
    3326         516 :             if (spnum == 3 || spnum == 4) {
    3327         516 :                 NetCoolingCapRated(spnum) = RatedTotalCapacity(1) * TotCapTempModFac(spnum) * TotCapFlowModFac(spnum) -
    3328         258 :                                             FanPowerPerEvapAirFlowRate_2023(spnum) * RatedAirVolFlowRate(1);
    3329         258 :             } else if (spnum == 1 || spnum == 2) {
    3330         516 :                 NetCoolingCapRated(spnum) = RatedTotalCapacity(2) * TotCapTempModFac(spnum) * TotCapFlowModFac(spnum) -
    3331         258 :                                             FanPowerPerEvapAirFlowRate_2023(spnum) * RatedAirVolFlowRate(2);
    3332             :             }
    3333         516 :             Q_A_Full(spnum) = NetCoolingCapRated(spnum);
    3334             :         }
    3335         129 :         QAFull = Q_A_Full(nsp);
    3336             : 
    3337             :         // RedCapNum : Integer counter for reduced capacity
    3338         645 :         for (int RedCapNum = nsp; RedCapNum > 0; --RedCapNum) {
    3339             : 
    3340         516 :             PartLoad = ReducedPLRIEER[(int)RedCapNum - 1.0];
    3341         516 :             OutdoorUnitInletAirDryBulbTempReduced = GetOutdoorUnitInletAirDryBulbTempReduced(PartLoad, _condenserType(RedCapNum));
    3342             : 
    3343         516 :             if (RedCapNum == 3 || RedCapNum == 4) {
    3344             : 
    3345         258 :                 EER = CalculateInterMediateEER(state,
    3346             :                                                QAFull,
    3347             :                                                OutdoorUnitInletAirDryBulbTempReduced,
    3348         258 :                                                CapFTempCurveIndex(1),
    3349             :                                                CoolingCoilInletAirWetBulbTempRated,
    3350         258 :                                                RatedTotalCapacity(1),
    3351         258 :                                                TotCapFlowModFac(RedCapNum),
    3352         258 :                                                FanPowerPerEvapAirFlowRate_2023(RedCapNum),
    3353         258 :                                                RatedAirVolFlowRate(1),
    3354         258 :                                                EIRFTempCurveIndex(1),
    3355         258 :                                                RatedCOP(1),
    3356         258 :                                                EIRFlowModFac(RedCapNum),
    3357             :                                                PartLoad);
    3358             : 
    3359         258 :             } else if (RedCapNum == 1 || RedCapNum == 2) {
    3360             : 
    3361         258 :                 EER = CalculateInterMediateEER(state,
    3362             :                                                QAFull,
    3363             :                                                OutdoorUnitInletAirDryBulbTempReduced,
    3364         258 :                                                CapFTempCurveIndex(2),
    3365             :                                                CoolingCoilInletAirWetBulbTempRated,
    3366         258 :                                                RatedTotalCapacity(2),
    3367         258 :                                                TotCapFlowModFac(RedCapNum),
    3368         258 :                                                FanPowerPerEvapAirFlowRate_2023(RedCapNum),
    3369         258 :                                                RatedAirVolFlowRate(2),
    3370         258 :                                                EIRFTempCurveIndex(2),
    3371         258 :                                                RatedCOP(2),
    3372         258 :                                                EIRFlowModFac(RedCapNum),
    3373             :                                                PartLoad);
    3374             :             }
    3375             : 
    3376         516 :             if (PartLoad == 1.00) {
    3377         129 :                 A = EER;
    3378         387 :             } else if (PartLoad == 0.75) {
    3379         129 :                 B = EER;
    3380         258 :             } else if (PartLoad == 0.50) {
    3381         129 :                 C = EER;
    3382         129 :             } else if (PartLoad == 0.25) {
    3383         129 :                 D = EER;
    3384             :             }
    3385             :         }
    3386             : 
    3387         129 :         IEER_2022 = GetIEEREquationResult(A, B, C, D);
    3388         129 :         EER_2022 = A;
    3389         258 :         return std::make_tuple(IEER_2022, QAFull, EER_2022);
    3390         129 :     }
    3391             : 
    3392         634 :     std::tuple<Real64, Real64, Real64> IEERCalculationSingleSpeed(EnergyPlus::EnergyPlusData &state,
    3393             :                                                                   std::string const &DXCoilType, // Type of DX coil for which HSPF is calculated
    3394             :                                                                   const int CapFTempCurveIndex,
    3395             :                                                                   const Real64 RatedTotalCapacity,
    3396             :                                                                   const Real64 TotCapFlowModFac,
    3397             :                                                                   const Real64 FanPowerPerEvapAirFlowRate,
    3398             :                                                                   const Real64 RatedAirVolFlowRate,
    3399             :                                                                   const int EIRFTempCurveIndex,
    3400             :                                                                   const Real64 RatedCOP,
    3401             :                                                                   const Real64 EIRFlowModFac,
    3402             :                                                                   DataHeatBalance::RefrigCondenserType const CondenserType)
    3403             :     {
    3404             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    3405         634 :         int constexpr NumOfReducedCap(4);                  // Number of reduced capacity test conditions (100%,75%,50%,and 25%)
    3406         634 :         Real64 TotCapTempModFac(0.0);                      // Total capacity modifier (function of entering wetbulb, outside drybulb) [-]
    3407         634 :         Real64 OutdoorUnitInletAirDryBulbTempReduced(0.0); // Outdoor unit entering air dry-bulb temperature at reduced capacity [C]
    3408         634 :         Real64 EERReduced(0.0);                            // EER at reduced capacity test conditions (100%, 75%, 50%, and 25%)
    3409         634 :         Real64 IEER = 0.0;                                 // Integareted energy efficiency ratio of single speed DX cooling coil
    3410         634 :         Real64 NetCoolingCapRated = 0.0;                   // net cooling capacity of single speed DX cooling coil
    3411         634 :         Real64 EER2 = 0.0;                                 // EER at high speed
    3412         634 :         Real64 CoilInletAirWetBulbTemp = 19.44;            // 67F
    3413             :         // EER Reduced
    3414         634 :         Real64 A(0.0);      // EER, (Btu/h)/W, at 100% Capacity at AHRI Standard Rating Conditions (see Table 6)| AHRI Std.340/360-2022(IP)
    3415         634 :         Real64 B(0.0);      // EER, (Btu/h)/W, at 75% Capacity at AHRI Standard Rating Conditions (see Table 6)| AHRI Std.340/360-2022(IP)
    3416         634 :         Real64 C(0.0);      // EER, (Btu/h)/W, at 50% Capacity at AHRI Standard Rating Conditions (see Table 6)| AHRI Std.340/360-2022(IP)
    3417         634 :         Real64 D(0.0);      // EER, (Btu/h)/W, at 25% Capacity at AHRI Standard Rating Conditions (see Table 6)| AHRI Std.340/360-2022(IP)
    3418         634 :         Real64 QAFull(0.0); // Full Load Net Capacity (Btu/h) | Previously NetCoolingCapRated
    3419             : 
    3420             :         // if CondenserType is AirCooled
    3421         634 :         if (CondenserType == DataHeatBalance::RefrigCondenserType::Air) {
    3422             :             // Calculate the net cooling capacity at the rated conditions (19.44C(67F) Wet Bulb and 35.0C(95F) Dry Bulb )
    3423         632 :             if (DXCoilType.find("Cooling") != std::string::npos)
    3424         632 :                 TotCapTempModFac = Curve::CurveValue(state, CapFTempCurveIndex, CoilInletAirWetBulbTemp, CoilInletAirCoolDryBulbIEER);
    3425             :             else
    3426             :                 TotCapTempModFac =
    3427           0 :                     Curve::CurveValue(state, CapFTempCurveIndex, CoilHeatingInletAirWetBulbTempIEER, CoilHeatingInletAirCoolDryBulbIEER);
    3428             :         }
    3429             :         // if CondenserType is WaterCooled
    3430         634 :         if (CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
    3431             :             // Calculate the net cooling capacity at the rated conditions (19.44C(67F) Wet Bulb and 29.44C(85F) Dry Bulb )
    3432           0 :             TotCapTempModFac = Curve::CurveValue(state, CapFTempCurveIndex, CoilInletAirWetBulbTemp, CoilWaterInletTempIEER);
    3433             :         }
    3434             :         // if CondesnerType is EvaporativelyCooled
    3435         634 :         if (CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
    3436             :             // Calculate the net cooling capacity at the rated conditions (19.44C(67F) Wet Bulb and 35.0C(95F) Dry Bulb )
    3437           2 :             TotCapTempModFac = Curve::CurveValue(state, CapFTempCurveIndex, CoilInletAirWetBulbTemp, CoilInletEvapDryBulbTempIEER);
    3438             :         }
    3439             :         // This Will be our QAFull
    3440         634 :         NetCoolingCapRated = RatedTotalCapacity * TotCapTempModFac * TotCapFlowModFac - FanPowerPerEvapAirFlowRate * RatedAirVolFlowRate;
    3441         634 :         QAFull = NetCoolingCapRated;
    3442             : 
    3443             :         // RedCapNum : Integer counter for reduced capacity
    3444        3170 :         for (int RedCapNum = 0; RedCapNum < NumOfReducedCap; ++RedCapNum) {
    3445             :             // Get the outdoor air dry bulb temperature for the reduced capacity test conditions
    3446        2536 :             OutdoorUnitInletAirDryBulbTempReduced = GetOutdoorUnitInletAirDryBulbTempReduced(ReducedPLRIEER[RedCapNum], CondenserType);
    3447             : 
    3448        2536 :             EERReduced = CalculateInterMediateEER(state,
    3449             :                                                   QAFull,
    3450             :                                                   OutdoorUnitInletAirDryBulbTempReduced,
    3451             :                                                   CapFTempCurveIndex,
    3452             :                                                   CoolingCoilInletAirWetBulbTempRated,
    3453             :                                                   RatedTotalCapacity,
    3454             :                                                   TotCapFlowModFac,
    3455             :                                                   FanPowerPerEvapAirFlowRate,
    3456             :                                                   RatedAirVolFlowRate,
    3457             :                                                   EIRFTempCurveIndex,
    3458             :                                                   RatedCOP,
    3459             :                                                   EIRFlowModFac,
    3460        2536 :                                                   ReducedPLRIEER[RedCapNum]);
    3461             : 
    3462        2536 :             if (ReducedPLRIEER[RedCapNum] == 1.00) {
    3463         634 :                 A = EERReduced;
    3464        1902 :             } else if (ReducedPLRIEER[RedCapNum] == 0.75) {
    3465         634 :                 B = EERReduced;
    3466        1268 :             } else if (ReducedPLRIEER[RedCapNum] == 0.50) {
    3467         634 :                 C = EERReduced;
    3468         634 :             } else if (ReducedPLRIEER[RedCapNum] == 0.25) {
    3469         634 :                 D = EERReduced;
    3470             :             }
    3471             :         }
    3472         634 :         IEER = GetIEEREquationResult(A, B, C, D);
    3473         634 :         EER2 = A;
    3474        1268 :         return std::make_tuple(IEER, QAFull, EER2);
    3475             :     }
    3476             : 
    3477        1224 :     Real64 EERSingleSpeedCooling(EnergyPlus::EnergyPlusData &state,
    3478             :                                  const int CapFTempCurveIndex,
    3479             :                                  const Real64 RatedTotalCapacity,
    3480             :                                  const Real64 TotCapFlowModFac,
    3481             :                                  const Real64 FanPowerPerEvapAirFlowRate,
    3482             :                                  const Real64 RatedAirVolFlowRate,
    3483             :                                  const int EIRFTempCurveIndex,
    3484             :                                  const Real64 RatedCOP,
    3485             :                                  const Real64 EIRFlowModFac)
    3486             :     {
    3487             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    3488        1224 :         Real64 EER = 0.0;                // energy efficiency ratio of single speed DX cooling coil
    3489        1224 :         Real64 TotCapTempModFac(0.0);    // Total capacity modifier (function of entering wetbulb, outside drybulb) [-]
    3490        1224 :         Real64 NetCoolingCapRated(0.0);  // net cooling capacity of single speed DX cooling coil
    3491        1224 :         Real64 EIRTempModFac(0.0);       // EIR modifier (function of entering wetbulb, outside drybulb) [-]
    3492        1224 :         Real64 EIR(0.0);                 // Energy Efficiency Ratio at AHRI test conditions for SEER [-]
    3493        1224 :         Real64 TotalElecPowerRated(0.0); // Net power consumption (Cond Fan+Compressor+Indoor Fan) at Rated test conditions [W]
    3494             :         // Calculate the net cooling capacity at the rated conditions (19.44C WB and 35.0C DB )
    3495        1224 :         TotCapTempModFac = Curve::CurveValue(state, CapFTempCurveIndex, CoolingCoilInletAirWetBulbTempRated, OutdoorUnitInletAirDryBulbTempRated);
    3496        1224 :         NetCoolingCapRated = RatedTotalCapacity * TotCapTempModFac * TotCapFlowModFac - FanPowerPerEvapAirFlowRate * RatedAirVolFlowRate;
    3497             :         // Calculate Energy Efficiency Ratio (EER) at (19.44C WB and 35.0C DB ), ANSI/AHRI Std. 340/360
    3498        1224 :         EIRTempModFac = Curve::CurveValue(state, EIRFTempCurveIndex, CoolingCoilInletAirWetBulbTempRated, OutdoorUnitInletAirDryBulbTempRated);
    3499        1224 :         if (RatedCOP > 0.0) {
    3500             :             // RatedCOP <= 0.0 is trapped in GetInput, but keep this as "safety"
    3501        1224 :             EIR = EIRTempModFac * EIRFlowModFac / RatedCOP;
    3502             :         } else {
    3503           0 :             EIR = 0.0;
    3504             :         }
    3505        1224 :         TotalElecPowerRated = EIR * (RatedTotalCapacity * TotCapTempModFac * TotCapFlowModFac) + FanPowerPerEvapAirFlowRate * RatedAirVolFlowRate;
    3506        1224 :         if (TotalElecPowerRated > 0.0) {
    3507        1224 :             EER = NetCoolingCapRated / TotalElecPowerRated;
    3508             :         } else {
    3509           0 :             EER = 0.0;
    3510             :         }
    3511        1224 :         return EER;
    3512             :     }
    3513             : 
    3514        1222 :     std::tuple<Real64, Real64> SEERSingleStageCalculation(EnergyPlusData &state,
    3515             :                                                           int CapFTempCurveIndex,
    3516             :                                                           Real64 RatedTotalCapacity,
    3517             :                                                           Real64 TotCapFlowModFac,
    3518             :                                                           int EIRFTempCurveIndex,
    3519             :                                                           Real64 EIRFlowModFac,
    3520             :                                                           [[maybe_unused]] int EIRFFlowCurveIndex,
    3521             :                                                           Real64 RatedCOP,
    3522             :                                                           Real64 FanPowerPerEvapAirFlowRate,
    3523             :                                                           Real64 RatedAirVolFlowRate,
    3524             :                                                           int PLFFPLRCurveIndex,
    3525             :                                                           Real64 const CyclicDegradationCoefficient)
    3526             :     {
    3527             :         // SUBROUTINE INFORMATION:
    3528             :         //       AUTHOR         B. Nigusse, FSEC
    3529             :         //       DATE WRITTEN   December 2012
    3530             :         //       MODIFIED
    3531             :         //       RE-ENGINEERED  Brijendra Singh, D-Alchemy
    3532             : 
    3533             :         // PURPOSE OF THIS SUBROUTINE:
    3534             :         // Calculates the SEER values for single speed based on AHRI 210/230 2017 & 2023
    3535             : 
    3536             :         // METHODOLOGY EMPLOYED:
    3537             :         // na
    3538             : 
    3539             :         // REFERENCES:
    3540             :         // AHRI Standard 340/360 (2022)
    3541             : 
    3542             :         // Locals
    3543             :         // SUBROUTINE ARGUMENT DEFINITIONS:
    3544             : 
    3545             :         // SUBROUTINE PARAMETER DEFINITIONS:
    3546             : 
    3547             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    3548             :         // SEER calculations:
    3549        1222 :         Real64 TotCapTempModFac(0.0);  // Total capacity modifier (function of entering wetbulb, outside drybulb) [-]
    3550        1222 :         Real64 TotCoolingCapAHRI(0.0); // Total Cooling Coil capacity (gross) at AHRI test conditions [W]
    3551        1222 :         Real64 EIRTempModFac(0.0);     // EIR modifier (function of entering wetbulb, outside drybulb) [-]
    3552        1222 :         Real64 NetCoolingCapAHRI(0.0); // Net Cooling Coil capacity at AHRI TestB conditions, accounting for fan heat [W]
    3553        1222 :         Real64 EIR(0.0);               // Energy Efficiency Ratio at AHRI test conditions for SEER [-]
    3554        1222 :         Real64 TotalElecPower(0.0);    // Net power consumption (Cond Fan+Compressor+Indoor Fan) at AHRI test conditions [W]
    3555        1222 :         Real64 PartLoadFactorUser(
    3556             :             0.0); // Part load factor based on user-input PLF curve and C_D value that accounts for thermal lag at compressor startup [-]
    3557        1222 :         Real64 PartLoadFactorStandard(
    3558             :             0.0); // part-load factor that accounts for the cyclic degradation from AHRI Standard 210/240-2008 default PLF curve and C_D value, [-]
    3559        1222 :         Real64 SEER_User = 0.0;     // seasonal energy efficiency ratio of single speed DX cooling coil, from user-input PLF curve and C_D value
    3560        1222 :         Real64 SEER_Standard = 0.0; // seasonal energy efficiency ratio of single speed DX cooling coil, from user-input PLF curve and C_D value
    3561             : 
    3562        1222 :         TotCapTempModFac = Curve::CurveValue(state, CapFTempCurveIndex, CoolingCoilInletAirWetBulbTempRated, OutdoorUnitInletAirDryBulbTemp);
    3563        1222 :         TotCoolingCapAHRI = RatedTotalCapacity * TotCapTempModFac * TotCapFlowModFac;
    3564        1222 :         EIRTempModFac = Curve::CurveValue(state, EIRFTempCurveIndex, CoolingCoilInletAirWetBulbTempRated, OutdoorUnitInletAirDryBulbTemp);
    3565        1222 :         EIR = (RatedCOP > 0.0) ? EIRTempModFac * EIRFlowModFac / RatedCOP : 0.0;
    3566             : 
    3567             :         // Calculate net cooling capacity
    3568        1222 :         NetCoolingCapAHRI = TotCoolingCapAHRI - FanPowerPerEvapAirFlowRate * RatedAirVolFlowRate;
    3569        1222 :         TotalElecPower = EIR * TotCoolingCapAHRI + FanPowerPerEvapAirFlowRate * RatedAirVolFlowRate;
    3570             :         // Calculate SEER value from the Energy Efficiency Ratio (EER) at the AHRI test conditions and the part load factor.
    3571             :         // First evaluate the Part Load Factor curve at PLR = 0.5 (AHRI Standard 210/240)
    3572        1222 :         PartLoadFactorUser = Curve::CurveValue(state, PLFFPLRCurveIndex, PLRforSEER);
    3573        1222 :         PartLoadFactorStandard = 1.0 - (1 - PLRforSEER) * CyclicDegradationCoefficient;
    3574             : 
    3575        1222 :         if (TotalElecPower > 0.0) {
    3576        1222 :             SEER_User = (NetCoolingCapAHRI / TotalElecPower) * PartLoadFactorUser;
    3577        1222 :             SEER_Standard = (NetCoolingCapAHRI / TotalElecPower) * PartLoadFactorStandard;
    3578             :         }
    3579        2444 :         return std::make_tuple(SEER_User, SEER_Standard);
    3580             :     }
    3581             : 
    3582         612 :     std::map<std::string, Real64> SingleSpeedDXCoolingCoilStandardRatings(
    3583             :         EnergyPlusData &state,
    3584             :         std::string const &DXCoilName,                         // Name of DX coil for which HSPF is calculated
    3585             :         std::string const &DXCoilType,                         // Type of DX coil - heating or cooling
    3586             :         int const CapFTempCurveIndex,                          // Index for the capacity as a function of temperature modifier curve
    3587             :         int const CapFFlowCurveIndex,                          // Index for the capacity as a function of flow fraction modifier curve
    3588             :         int const EIRFTempCurveIndex,                          // Index for the EIR as a function of temperature modifier curve
    3589             :         int const EIRFFlowCurveIndex,                          // Index for the EIR as a function of flow fraction modifier curve
    3590             :         int const PLFFPLRCurveIndex,                           // Index for the EIR vs part-load ratio curve
    3591             :         Real64 const RatedTotalCapacity,                       // Rated gross total cooling capacity
    3592             :         Real64 const RatedCOP,                                 // Rated gross COP
    3593             :         Real64 const RatedAirVolFlowRate,                      // air flow rate through the coil at rated condition
    3594             :         Real64 const FanPowerPerEvapAirFlowRateFromInput,      // 2017 Fan power per air volume flow rate through the evaporator coil
    3595             :         Real64 const FanPowerPerEvapAirFlowRateFromInput_2023, // 2023 Fan power per air volume flow rate through the evaportor coil
    3596             :         DataHeatBalance::RefrigCondenserType CondenserType)
    3597             :     {
    3598             :         // SUBROUTINE INFORMATION:
    3599             :         //       AUTHOR         B. Nigusse, FSEC
    3600             :         //       DATE WRITTEN   December 2012
    3601             :         //       MODIFIED
    3602             :         //       RE-ENGINEERED  na
    3603             : 
    3604             :         // PURPOSE OF THIS SUBROUTINE:
    3605             :         // Calculates the standard ratings net cooling capacity and, SEER, EER and IEER values for single speed
    3606             :         // DX cooling coils at the AHRI standard test condition(s).
    3607             : 
    3608             :         // METHODOLOGY EMPLOYED:
    3609             :         // na
    3610             : 
    3611             :         // REFERENCES:
    3612             :         // na
    3613             : 
    3614             :         // Using/Aliasing
    3615             :         using Curve::CurveValue;
    3616             : 
    3617             :         // Locals
    3618             :         // SUBROUTINE ARGUMENT DEFINITIONS:
    3619             : 
    3620             :         // SUBROUTINE PARAMETER DEFINITIONS:
    3621             : 
    3622             :         // INTERFACE BLOCK SPECIFICATIONS
    3623             :         // na
    3624             : 
    3625             :         // DERIVED TYPE DEFINITIONS
    3626             :         // na
    3627             : 
    3628             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    3629         612 :         Real64 TotCapFlowModFac(0.0);           // Total capacity modifier f(actual flow vs rated flow) for each speed [-]
    3630         612 :         Real64 EIRFlowModFac(0.0);              // EIR modifier f(actual supply air flow vs rated flow) for each speed [-]
    3631         612 :         Real64 TotCapTempModFac(0.0);           // Total capacity modifier (function of entering wetbulb, outside drybulb) [-]
    3632             :         Real64 FanPowerPerEvapAirFlowRate;      // 2017 Fan power per air volume flow rate through the evaporator coil [W/(m3/s)]
    3633             :         Real64 FanPowerPerEvapAirFlowRate_2023; // 2023 Fan power per air volume flow rate through the evaporator coil [W/(m3/s)]
    3634             : 
    3635         612 :         Real64 NetCoolingCapRated(0.0); // net cooling capacity of single speed DX cooling coil
    3636         612 :         Real64 SEER_User(0.0);          // seasonal energy efficiency ratio of single speed DX cooling coil, from user-input PLF curve and C_D value
    3637         612 :         Real64 SEER_Standard(0.0);      // seasonal energy efficiency ratio of single speed DX cooling coil, from user-input PLF curve and C_D value
    3638         612 :         Real64 EER(0.0);                // energy efficiency ratio of single speed DX cooling coil
    3639         612 :         Real64 IEER(0.0);               // Integareted energy efficiency ratio of single speed DX cooling coil
    3640             : 
    3641         612 :         Real64 NetCoolingCapRated2023(0.0); // net cooling capacity of single speed DX cooling coil
    3642         612 :         Real64 SEER2_User(0.0);     // seasonal energy efficiency ratio of single speed DX cooling coil, from user-input PLF curve and C_D value
    3643         612 :         Real64 SEER2_Standard(0.0); // seasonal energy efficiency ratio of single speed DX cooling coil, from user-input PLF curve and C_D value
    3644         612 :         Real64 EER_2022(0.0);       // energy efficiency ratio of single speed DX cooling coil
    3645         612 :         Real64 IEER_2022(0.0);      // Integrated energy efficiency ratio
    3646             : 
    3647         612 :         std::map<std::string, Real64> StandarRatingResults;
    3648             :         // StandarRatingResults["NetCoolingCapRated"] = NetCoolingCapRated;
    3649             :         // StandarRatingResults["SEER_User"] = SEER_User;
    3650             :         // StandarRatingResults["SEER_Standard"] = SEER_Standard;
    3651             :         // StandarRatingResults["EER"] = EER;
    3652             :         // StandarRatingResults["IEER"] = IEER;
    3653             :         // StandarRatingResults["NetCoolingCapRated2023"] = NetCoolingCapRated2023;
    3654             :         // StandarRatingResults["SEER2_User"] = SEER2_User;
    3655             :         // StandarRatingResults["SEER2_Standard"] = SEER2_Standard;
    3656             :         // StandarRatingResults["EER_2022"] = EER_2022;
    3657             :         // StandarRatingResults["IEER_2022"] = IEER_2022;
    3658             : 
    3659         612 :         if (FanPowerPerEvapAirFlowRateFromInput <= 0.0) {
    3660           0 :             FanPowerPerEvapAirFlowRate = DefaultFanPowerPerEvapAirFlowRate;
    3661             :         } else {
    3662         612 :             FanPowerPerEvapAirFlowRate = FanPowerPerEvapAirFlowRateFromInput;
    3663             :         }
    3664             : 
    3665         612 :         if (FanPowerPerEvapAirFlowRateFromInput_2023 <= 0.0) {
    3666           0 :             FanPowerPerEvapAirFlowRate_2023 = DefaultFanPowerPerEvapAirFlowRateSEER2;
    3667             :         } else {
    3668         612 :             FanPowerPerEvapAirFlowRate_2023 = FanPowerPerEvapAirFlowRateFromInput_2023;
    3669             :         }
    3670             : 
    3671             :         // SEER2 standard applies to factory-made Unitary Air-conditioners and Unitary Air-source Heat Pumps with
    3672             :         // capacities less than 65,000 Btu/h (19049.61955 Watts) | Section 2.1 (ANSI/AHRI 210-240 2023)
    3673         612 :         if (RatedTotalCapacity > 0.0 && RatedAirVolFlowRate > 0.0) {
    3674             :             // Standard Rating Cooling (net) Capacity calculations:
    3675         612 :             TotCapFlowModFac = CurveValue(state, CapFFlowCurveIndex, AirMassFlowRatioRated);
    3676         612 :             TotCapTempModFac = CurveValue(state, CapFTempCurveIndex, CoolingCoilInletAirWetBulbTempRated, OutdoorUnitInletAirDryBulbTempRated);
    3677             :             // Net Cooling = Gross Capacity - Fan Power Consumption
    3678         612 :             NetCoolingCapRated = RatedTotalCapacity * TotCapTempModFac * TotCapFlowModFac - FanPowerPerEvapAirFlowRate * RatedAirVolFlowRate;
    3679         612 :             StandarRatingResults["NetCoolingCapRated"] = NetCoolingCapRated;
    3680         612 :             NetCoolingCapRated2023 = RatedTotalCapacity * TotCapTempModFac * TotCapFlowModFac - FanPowerPerEvapAirFlowRate_2023 * RatedAirVolFlowRate;
    3681         612 :             StandarRatingResults["NetCoolingCapRated2023"] = NetCoolingCapRated2023;
    3682         612 :             EIRFlowModFac = Curve::CurveValue(state, EIRFFlowCurveIndex, AirMassFlowRatioRated);
    3683             : 
    3684             :             // IEER calculations
    3685             :             // EER calculations:
    3686         612 :             EER = EERSingleSpeedCooling(state,
    3687             :                                         CapFTempCurveIndex,
    3688             :                                         RatedTotalCapacity,
    3689             :                                         TotCapFlowModFac,
    3690             :                                         FanPowerPerEvapAirFlowRate,
    3691             :                                         RatedAirVolFlowRate,
    3692             :                                         EIRFTempCurveIndex,
    3693             :                                         RatedCOP,
    3694             :                                         EIRFlowModFac);
    3695         612 :             StandarRatingResults["EER"] = EER;
    3696             : 
    3697             :             // EER2 calculations:
    3698         612 :             EER_2022 = EERSingleSpeedCooling(state,
    3699             :                                              CapFTempCurveIndex,
    3700             :                                              RatedTotalCapacity,
    3701             :                                              TotCapFlowModFac,
    3702             :                                              FanPowerPerEvapAirFlowRate_2023,
    3703             :                                              RatedAirVolFlowRate,
    3704             :                                              EIRFTempCurveIndex,
    3705             :                                              RatedCOP,
    3706             :                                              EIRFlowModFac);
    3707         612 :             StandarRatingResults["EER_2022"] = EER_2022;
    3708             : 
    3709             :             // TODO: Commercial and industrial unitary air-conditioning condensing units with a capacity greater than 135,000 Btu/h (39564.59445
    3710             :             // Watts) as defined in ANSI/AHRI Standard 365(I-P). | Scope 2.2.6 (ANSI/AHRI 340-360 2022)
    3711             : 
    3712             :             // SEER2 standard applies to factory-made Unitary Air-conditioners and Unitary Air-source Heat Pumps with
    3713             :             // capacities less than 65,000 Btu/h (19049.61955 Watts) | Section 2.1 (ANSI/AHRI 210-240 2023)
    3714             :             // Removal of water-cooled and evaporatively-cooled products from the scope | Foreword (ANSI/AHRI 210-240 2023)
    3715             : 
    3716         612 :             std::tie(SEER_User, SEER_Standard) = SEERSingleStageCalculation(state,
    3717             :                                                                             CapFTempCurveIndex,
    3718             :                                                                             RatedTotalCapacity,
    3719             :                                                                             TotCapFlowModFac,
    3720             :                                                                             EIRFTempCurveIndex,
    3721             :                                                                             EIRFlowModFac,
    3722             :                                                                             EIRFFlowCurveIndex,
    3723             :                                                                             RatedCOP,
    3724             :                                                                             FanPowerPerEvapAirFlowRate,
    3725             :                                                                             RatedAirVolFlowRate,
    3726             :                                                                             PLFFPLRCurveIndex,
    3727         612 :                                                                             CyclicDegradationCoeff);
    3728         612 :             StandarRatingResults["SEER_User"] = SEER_User;
    3729         612 :             StandarRatingResults["SEER_Standard"] = SEER_Standard;
    3730         612 :             if (CondenserType == DataHeatBalance::RefrigCondenserType::Air) {
    3731         610 :                 std::tie(SEER2_User, SEER2_Standard) = SEERSingleStageCalculation(state,
    3732             :                                                                                   CapFTempCurveIndex,
    3733             :                                                                                   RatedTotalCapacity,
    3734             :                                                                                   TotCapFlowModFac,
    3735             :                                                                                   EIRFTempCurveIndex,
    3736             :                                                                                   EIRFlowModFac,
    3737             :                                                                                   EIRFFlowCurveIndex,
    3738             :                                                                                   RatedCOP,
    3739             :                                                                                   FanPowerPerEvapAirFlowRate_2023,
    3740             :                                                                                   RatedAirVolFlowRate,
    3741             :                                                                                   PLFFPLRCurveIndex,
    3742         610 :                                                                                   CyclicDegradationCoeffSEER2);
    3743         610 :                 StandarRatingResults["SEER2_User"] = SEER2_User;
    3744         610 :                 StandarRatingResults["SEER2_Standard"] = SEER2_Standard;
    3745             :             }
    3746             : 
    3747         612 :             std::tie(IEER, NetCoolingCapRated) = IEERSingleSpeedCooling(state,
    3748             :                                                                         CapFTempCurveIndex,
    3749             :                                                                         RatedTotalCapacity,
    3750             :                                                                         TotCapFlowModFac,
    3751             :                                                                         FanPowerPerEvapAirFlowRate,
    3752             :                                                                         RatedAirVolFlowRate,
    3753             :                                                                         EIRFTempCurveIndex,
    3754             :                                                                         RatedCOP,
    3755         612 :                                                                         EIRFlowModFac);
    3756             : 
    3757         612 :             StandarRatingResults["IEER"] = IEER;
    3758         612 :             StandarRatingResults["IEER"] = IEER;
    3759         612 :             StandarRatingResults["NetCoolingCapRated"] = NetCoolingCapRated;
    3760             : 
    3761             :             // IEER 2022 Calculations
    3762         612 :             if (DXCoilType == "Coil:Cooling:DX:SingleSpeed") {
    3763             : 
    3764         612 :                 std::tie(IEER_2022, NetCoolingCapRated2023, EER_2022) = IEERCalculationSingleSpeed(state,
    3765             :                                                                                                    DXCoilType,
    3766             :                                                                                                    CapFTempCurveIndex,
    3767             :                                                                                                    RatedTotalCapacity,
    3768             :                                                                                                    TotCapFlowModFac,
    3769             :                                                                                                    FanPowerPerEvapAirFlowRate_2023,
    3770             :                                                                                                    RatedAirVolFlowRate,
    3771             :                                                                                                    EIRFTempCurveIndex,
    3772             :                                                                                                    RatedCOP,
    3773             :                                                                                                    EIRFlowModFac,
    3774         612 :                                                                                                    CondenserType);
    3775         612 :                 StandarRatingResults["IEER_2022"] = IEER_2022;
    3776         612 :                 StandarRatingResults["EER_2022"] = EER_2022;
    3777         612 :                 StandarRatingResults["NetCoolingCapRated2023"] = NetCoolingCapRated2023;
    3778             :             }
    3779             : 
    3780             :         } else {
    3781           0 :             ShowSevereError(state,
    3782           0 :                             format("Standard Ratings: {} {} has esither zero rated total cooling capacity or zero rated air volume flow rate. "
    3783             :                                    "Standard ratings cannot be calculated.",
    3784             :                                    DXCoilType,
    3785             :                                    DXCoilName));
    3786             :         }
    3787        1224 :         return StandarRatingResults;
    3788           0 :     }
    3789             : 
    3790           8 :     void DXCoolingCoilDataCenterStandardRatings(
    3791             :         EnergyPlusData &state,
    3792             :         std::string const &DXCoilName,                    // Name of DX coil for which HSPF is calculated
    3793             :         std::string const &DXCoilType,                    // Type of DX coil - heating or cooling
    3794             :         int const CapFTempCurveIndex,                     // Index for the capacity as a function of temperature modifier curve
    3795             :         int const CapFFlowCurveIndex,                     // Index for the capacity as a function of flow fraction modifier curve
    3796             :         int const EIRFTempCurveIndex,                     // Index for the EIR as a function of temperature modifier curve
    3797             :         int const EIRFFlowCurveIndex,                     // Index for the EIR as a function of flow fraction modifier curve
    3798             :         [[maybe_unused]] int const PLFFPLRCurveIndex,     // Index for the EIR vs part-load ratio curve
    3799             :         Real64 const RatedTotalCapacity,                  // Rated gross total cooling capacity
    3800             :         Real64 const RatedCOP,                            // Rated gross COP
    3801             :         Real64 const RatedAirVolFlowRate,                 // air flow rate through the coil at rated condition
    3802             :         Real64 const FanPowerPerEvapAirFlowRateFromInput, // Fan power per air volume flow rate through the evaporator coil
    3803             :         Array1D<Real64> &NetCoolingCapRated,              // net cooling capacity of single speed DX cooling coil
    3804             :         Array1D<Real64> &TotElectricPowerRated            // total electric power including supply fan
    3805             :     )
    3806             :     {
    3807             : 
    3808             :         // SUBROUTINE INFORMATION:
    3809             :         //       AUTHOR         B. Nigusse, FSEC
    3810             :         //       DATE WRITTEN   October 2014
    3811             :         //       MODIFIED
    3812             :         //       RE-ENGINEERED  na
    3813             : 
    3814             :         // PURPOSE OF THIS SUBROUTINE:
    3815             :         // Calculates the standard ratings net cooling capacity and total electric power
    3816             :         // for room unitary air conditioners single speed DX cooling coils.
    3817             : 
    3818             :         // METHODOLOGY EMPLOYED:
    3819             :         // na
    3820             : 
    3821             :         // REFERENCES:
    3822             :         // ANSI/ASHRAE Standard 127-2012 - Method of Testing for Rating Computer and Data Processing
    3823             :         //                                 Room Unitary Air Conditioners
    3824             : 
    3825             :         // Using/Aliasing
    3826             :         using Curve::CurveValue;
    3827             :         using Psychrometrics::PsyTwbFnTdbWPb;
    3828             :         using Psychrometrics::PsyWFnTdpPb;
    3829             : 
    3830             :         // Locals
    3831             :         // SUBROUTINE ARGUMENT DEFINITIONS:
    3832             :         // na
    3833             : 
    3834             :         // SUBROUTINE PARAMETER DEFINITIONS:
    3835             :         // na
    3836             : 
    3837             :         // INTERFACE BLOCK SPECIFICATIONS
    3838             :         // na
    3839             : 
    3840             :         // DERIVED TYPE DEFINITIONS
    3841             :         // na
    3842             : 
    3843             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    3844           8 :         Real64 TotCapFlowModFac(0.0);      // Total capacity modifier f(actual flow vs rated flow) for each speed [-]
    3845           8 :         Real64 EIRFlowModFac(0.0);         // EIR modifier f(actual supply air flow vs rated flow) for each speed [-]
    3846           8 :         Real64 TotCapTempModFac(0.0);      // Total capacity modifier (function of entering wetbulb, outside drybulb) [-]
    3847           8 :         Real64 EIRTempModFac(0.0);         // EIR modifier (function of entering wetbulb, outside drybulb) [-]
    3848           8 :         Real64 TotCoolingCapRated(0.0);    // Total Cooling Coil capacity (gross) at one of the rated test conditions [W]
    3849           8 :         Real64 EIR(0.0);                   // Energy Efficiency Ratio at AHRI test conditions for SEER [-]
    3850             :         Real64 FanPowerPerEvapAirFlowRate; // Fan power per air volume flow rate through the evaporator coil [W/(m3/s)]
    3851             : 
    3852             :         Real64 TWBIndoor;  // indoor air dry bulb temperature
    3853             :         Real64 TDBOutdoor; // outdor air dry bulb temperature
    3854             :         int ClassNum;      // class number (Class I, II, II, IV)
    3855             :         int TestNum;       // test number (Test A, B, C, D)
    3856             :         int Num;           // text number counter
    3857             : 
    3858           8 :         if (FanPowerPerEvapAirFlowRateFromInput <= 0.0) {
    3859           0 :             FanPowerPerEvapAirFlowRate = DefaultFanPowerPerEvapAirFlowRate;
    3860             :         } else {
    3861           8 :             FanPowerPerEvapAirFlowRate = FanPowerPerEvapAirFlowRateFromInput;
    3862             :         }
    3863           8 :         if (RatedTotalCapacity > 0.0) {
    3864             : 
    3865          40 :             for (ClassNum = 1; ClassNum <= 4; ++ClassNum) {
    3866          96 :                 TWBIndoor = PsyTwbFnTdbWPb(state,
    3867          32 :                                            IndoorDBTempClassI2IV[ClassNum - 1],
    3868          32 :                                            PsyWFnTdpPb(state, IndoorTDPA2D, state.dataEnvrn->StdBaroPress),
    3869          32 :                                            state.dataEnvrn->StdBaroPress);
    3870         160 :                 for (TestNum = 1; TestNum <= 4; ++TestNum) {
    3871         128 :                     TDBOutdoor = OutdoorDBTempAllClassA2D[TestNum - 1];
    3872         128 :                     Num = (ClassNum - 1) * 4 + TestNum;
    3873             :                     // Standard Rating Net Cooling Capacity at Test A:
    3874         128 :                     TotCapFlowModFac = CurveValue(state, CapFFlowCurveIndex, AirMassFlowRatioRated);
    3875         128 :                     TotCapTempModFac = CurveValue(state, CapFTempCurveIndex, TWBIndoor, TDBOutdoor);
    3876         128 :                     TotCoolingCapRated = RatedTotalCapacity * TotCapTempModFac * TotCapFlowModFac;
    3877         128 :                     NetCoolingCapRated(Num) = TotCoolingCapRated - FanPowerPerEvapAirFlowRate * RatedAirVolFlowRate;
    3878             :                     // Standard Rating total electric power at Test A:
    3879         128 :                     EIRTempModFac = CurveValue(state, EIRFTempCurveIndex, TWBIndoor, TDBOutdoor);
    3880         128 :                     EIRFlowModFac = CurveValue(state, EIRFFlowCurveIndex, AirMassFlowRatioRated);
    3881         128 :                     EIR = 0.0;
    3882         128 :                     if (RatedCOP > 0.0) {
    3883         128 :                         EIR = EIRTempModFac * EIRFlowModFac / RatedCOP;
    3884             :                     }
    3885             :                     // Calculate net cooling capacity at Test A:
    3886         128 :                     TotElectricPowerRated(Num) = EIR * TotCoolingCapRated + FanPowerPerEvapAirFlowRate * RatedAirVolFlowRate;
    3887             :                 }
    3888             :             }
    3889             :         } else {
    3890           0 :             ShowSevereError(state,
    3891           0 :                             format("Standard Ratings: {} {} has zero rated total cooling capacity. Capacity and Power cannot be calculated.",
    3892             :                                    DXCoilType,
    3893             :                                    DXCoilName));
    3894             :         }
    3895           8 :     }
    3896             : 
    3897          49 :     std::tuple<Real64, Real64, Real64, Real64> MultiSpeedDXCoolingCoilSEER(EnergyPlusData &state,
    3898             :                                                                            int const nsp,
    3899             :                                                                            Array1A_int const CapFFlowCurveIndex,
    3900             :                                                                            Array1A<Real64> const RatedTotalCapacity,
    3901             :                                                                            Array1A_int const CapFTempCurveIndex,
    3902             :                                                                            Array1A<Real64> const FanPowerPerEvapAirFlowRateFromInput,
    3903             :                                                                            Array1A<Real64> const RatedAirVolFlowRate,
    3904             :                                                                            Array1A_int const EIRFFlowCurveIndex,
    3905             :                                                                            Array1A<Real64> const RatedCOP,
    3906             :                                                                            Array1A_int EIRFTempCurveIndex,
    3907             :                                                                            Array1A_int const PLFFPLRCurveIndex)
    3908             :     {
    3909             :         // Intermediate values calculated from the inputs in the idf file
    3910          49 :         Array1D<Real64> FanPowerPerEvapAirFlowRate(nsp); // 2017 Fan power per air volume flow rate through the evaporator coil [W/(m3/s)]
    3911          49 :         Array1D<Real64> TotCoolCapTestA2(nsp);           // Total cooling capacity at A2 test condition (High speed)
    3912          49 :         Array1D<Real64> TotCoolCapTestB2(nsp);           // Total cooling capacity at B2 test condition (High speed)
    3913          49 :         Array1D<Real64> TotCoolCapTestB1(nsp);           // Total cooling capacity at B1 test condition (Low speed)
    3914          49 :         Array1D<Real64> TotCoolCapTestF1(nsp);           // Total cooling capacity at F1 test condition (Low speed)
    3915          49 :         Array1D<Real64> OutdoorUnitPowerTestA2(nsp);     // Outdoor Unit electric power at A2 test condition (High speed)
    3916          49 :         Array1D<Real64> OutdoorUnitPowerTestB2(nsp);     // Outdoor Unit electric power at B2 test condition (High speed)
    3917          49 :         Array1D<Real64> OutdoorUnitPowerTestB1(nsp);     // Outdoor Unit electric power at B1 test condition (Low speed)
    3918          49 :         Array1D<Real64> OutdoorUnitPowerTestF1(nsp);     // Outdoor Unit electric power at F1 test condition
    3919             : 
    3920          49 :         Real64 PartLoadRatio(0.0);      // compressor cycling ratio between successive speeds, [-]
    3921          49 :         Real64 PartLoadFactorUser(0.0); // part-load factor based on user-input PLF curve and C_D value that accounts for the cyclic degradation, [-]
    3922          49 :         Real64 PartLoadFactorStandard(
    3923             :             0.0); // part-load factorn that accounts for the cyclic degradation from AHRI standard 210/240 default PLF curve and C_D value, [-]
    3924          49 :         Real64 NetCoolingCapWeighted(0.0);              // net tot cooling cap weighted by the fraction of the binned cooling hours [W]
    3925          49 :         Real64 TotCoolingElecPowerWeighted(0.0);        // net total cooling electric power input weighted by the fraction of the temperature bins
    3926          49 :         Real64 TotCoolingElecPowerWeightedDefault(0.0); // net total cooling electric power input weighted by the fraction of the temperature bins
    3927             :                                                         // from AHRI 201/240 default PLF curve and C_D value,
    3928             : 
    3929             :         // binned cooling hours
    3930          49 :         Real64 BuildingCoolingLoad(0.0);    // Building space cooling load corresponding to an outdoor bin temperature [W]
    3931          49 :         Real64 NetTotCoolCapBinned(0.0);    // Net tot cooling cap corresponding to an outdoor bin temperature [W]
    3932          49 :         Real64 TotCoolElecPowerBinned(0.0); // Total cooling electric power corresponding to an outdoor bin temperature [W]
    3933          49 :         Real64 TotCoolElecPowerBinnedDefault(
    3934             :             0.0); // Total cooling electric power corresponding to an outdoor bin temperature from AHRI 201/240 default PLF curve and C_D value, [W]
    3935          49 :         Real64 LoadFactor(0.0); // "on" time for last stage at the desired reduced capacity, (dimensionless)
    3936             : 
    3937             :         int BinNum;                              // bin number counter
    3938             :         int spnum;                               // compressor speed number
    3939          49 :         Array1D<Real64> NetCoolingCapRated(nsp); // net cooling capacity at each speed
    3940          49 :         Array1D<Real64> TotCapFlowModFac(nsp);   // Total capacity modifier f(actual flow vs rated flow) for each speed [-]
    3941          49 :         Array1D<Real64> EIRFlowModFac(nsp);      // EIR modifier f(actual supply air flow vs rated flow) for each speed [-]
    3942          49 :         Real64 CoolingCapacityLS(0.0);           // cooling capacity of Mult-speed DX coil at lower speed, [W]
    3943          49 :         Real64 CoolingCapacityHS(0.0);           // cooling capacity of Mult-speed DX coil at higher speed, [W]
    3944          49 :         Real64 CoolingElecPowerLS(0.0);          // outdoor unit electric power input at low speed, [W]
    3945          49 :         Real64 CoolingElecPowerHS(0.0);          // outdoor unit electric power input at high speed, [W]
    3946          49 :         Real64 CoolingCapacityMax(0.0);          // cooling capacity of Mult-speed DX coil at max speed, [W]
    3947          49 :         Real64 CoolingElecPowerMax(0.0);         // outdoor unit electric power input at Max speed, [W]
    3948             : 
    3949          49 :         Real64 constexpr SizingFactor(1.10); // sizing factor per AHRI Std 210/240-2008
    3950             : 
    3951          49 :         Real64 NetCoolingCapRatedMaxSpeed = 0.0;
    3952          49 :         Real64 SEER_User = 0.0;
    3953          49 :         Real64 SEER_Standard = 0.0;
    3954          49 :         Real64 EER = 0.0;
    3955             : 
    3956          49 :         NetCoolingCapWeighted = 0.0;
    3957          49 :         TotCoolingElecPowerWeighted = 0.0;
    3958          49 :         TotCoolingElecPowerWeightedDefault = 0.0;
    3959             : 
    3960         162 :         for (int spnum = 1; spnum <= nsp; ++spnum) {
    3961         113 :             FanPowerPerEvapAirFlowRate(spnum) = 0.0;
    3962         113 :             if (FanPowerPerEvapAirFlowRateFromInput(spnum) <= 0.0) {
    3963          64 :                 FanPowerPerEvapAirFlowRate(spnum) = DefaultFanPowerPerEvapAirFlowRate;
    3964             :             } else {
    3965          49 :                 FanPowerPerEvapAirFlowRate(spnum) = FanPowerPerEvapAirFlowRateFromInput(spnum);
    3966             :             }
    3967             :         }
    3968             : 
    3969             :         // Calculate the capacity and power for each speed
    3970         162 :         for (spnum = 1; spnum <= nsp; ++spnum) {
    3971         113 :             TotCapFlowModFac(spnum) = Curve::CurveValue(state, static_cast<int64_t>(CapFFlowCurveIndex(spnum)), AirMassFlowRatioRated);
    3972         226 :             TotCoolCapTestA2(spnum) =
    3973         113 :                 RatedTotalCapacity(spnum) *
    3974         113 :                     Curve::CurveValue(state, CapFTempCurveIndex(spnum), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestA2) *
    3975         113 :                     TotCapFlowModFac(spnum) -
    3976         113 :                 FanPowerPerEvapAirFlowRate(spnum) * RatedAirVolFlowRate(spnum);
    3977             : 
    3978         226 :             TotCoolCapTestB2(spnum) =
    3979         113 :                 RatedTotalCapacity(spnum) *
    3980         113 :                     Curve::CurveValue(state, CapFTempCurveIndex(spnum), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestB2) *
    3981         113 :                     TotCapFlowModFac(spnum) -
    3982         113 :                 FanPowerPerEvapAirFlowRate(spnum) * RatedAirVolFlowRate(spnum);
    3983             : 
    3984         226 :             TotCoolCapTestB1(spnum) =
    3985         113 :                 RatedTotalCapacity(spnum) *
    3986         113 :                     Curve::CurveValue(state, CapFTempCurveIndex(spnum), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestB1) *
    3987         113 :                     TotCapFlowModFac(spnum) -
    3988         113 :                 FanPowerPerEvapAirFlowRate(spnum) * RatedAirVolFlowRate(spnum);
    3989             : 
    3990         226 :             TotCoolCapTestF1(spnum) =
    3991         113 :                 RatedTotalCapacity(spnum) *
    3992         113 :                     Curve::CurveValue(state, CapFTempCurveIndex(spnum), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestF1) *
    3993         113 :                     TotCapFlowModFac(spnum) -
    3994         113 :                 FanPowerPerEvapAirFlowRate(spnum) * RatedAirVolFlowRate(spnum);
    3995             : 
    3996         113 :             EIRFlowModFac(spnum) = Curve::CurveValue(state, EIRFFlowCurveIndex(spnum), AirMassFlowRatioRated);
    3997         113 :             if (RatedCOP(spnum) > 0.0) {
    3998         226 :                 OutdoorUnitPowerTestA2(spnum) =
    3999         113 :                     TotCoolCapTestA2(spnum) * EIRFlowModFac(spnum) *
    4000         226 :                         Curve::CurveValue(
    4001         113 :                             state, EIRFTempCurveIndex(spnum), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestA2) /
    4002         113 :                         RatedCOP(spnum) +
    4003         113 :                     FanPowerPerEvapAirFlowRate(spnum) * RatedAirVolFlowRate(spnum);
    4004             : 
    4005         226 :                 OutdoorUnitPowerTestB2(spnum) =
    4006         113 :                     TotCoolCapTestB2(spnum) * EIRFlowModFac(spnum) *
    4007         226 :                         Curve::CurveValue(
    4008         113 :                             state, EIRFTempCurveIndex(spnum), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestB2) /
    4009         113 :                         RatedCOP(spnum) +
    4010         113 :                     FanPowerPerEvapAirFlowRate(spnum) * RatedAirVolFlowRate(spnum);
    4011             : 
    4012         226 :                 OutdoorUnitPowerTestB1(spnum) =
    4013         113 :                     TotCoolCapTestB1(spnum) * EIRFlowModFac(spnum) *
    4014         226 :                         Curve::CurveValue(
    4015         113 :                             state, EIRFTempCurveIndex(spnum), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestB1) /
    4016         113 :                         RatedCOP(spnum) +
    4017         113 :                     FanPowerPerEvapAirFlowRate(spnum) * RatedAirVolFlowRate(spnum);
    4018             : 
    4019         113 :                 OutdoorUnitPowerTestF1(spnum) =
    4020         113 :                     TotCoolCapTestF1(spnum) * EIRFlowModFac(spnum) *
    4021         226 :                         Curve::CurveValue(
    4022         113 :                             state, EIRFTempCurveIndex(spnum), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestF1) /
    4023         113 :                         RatedCOP(spnum) +
    4024         113 :                     FanPowerPerEvapAirFlowRate(spnum) * RatedAirVolFlowRate(spnum);
    4025             :             }
    4026             :         }
    4027             :         // Standard Rating cooling (net) capacity calculations:
    4028          49 :         NetCoolingCapRated(nsp) = TotCoolCapTestA2(nsp);
    4029          49 :         NetCoolingCapRatedMaxSpeed = NetCoolingCapRated(nsp);
    4030             : 
    4031             :         // EER2 calculation |  Section 3.1.16(AHRI 210/240 2017)
    4032             :         // A ratio of the cooling capacity in Btu/h to the Total Power in watts at AFull test conditions and expressed in Btu/(W-h)
    4033             :         // In case of Coil:Cooling:DX:MultiSpeed coil we're picking the max speed.
    4034          49 :         EER = TotCoolCapTestA2(nsp) / OutdoorUnitPowerTestA2(nsp);
    4035             : 
    4036             :         // Calculate the SEER value based on contribution of each outdoor air bin temperature
    4037         441 :         for (BinNum = 0; BinNum < NumOfOATempBins; ++BinNum) {
    4038             :             // Equation 11.60 (AHRI-2017)
    4039         392 :             BuildingCoolingLoad = (OutdoorBinTemperatureSEER[BinNum] - 18.3) / (35.0 - 18.3) * (TotCoolCapTestA2(nsp) / SizingFactor);
    4040             :             // determine the speed number
    4041         392 :             CoolingCapacityMax = TotCoolCapTestB2(nsp) + ((TotCoolCapTestA2(nsp) - TotCoolCapTestB2(nsp)) /
    4042         392 :                                                           (OutdoorCoilInletAirDryBulbTempTestA2 - OutdoorCoilInletAirDryBulbTempTestB2)) *
    4043         392 :                                                              (OutdoorBinTemperatureSEER[BinNum] - OutdoorCoilInletAirDryBulbTempTestB2);
    4044         392 :             CoolingElecPowerMax = OutdoorUnitPowerTestB2(nsp) + ((OutdoorUnitPowerTestA2(nsp) - OutdoorUnitPowerTestB2(nsp)) /
    4045         392 :                                                                  (OutdoorCoilInletAirDryBulbTempTestA2 - OutdoorCoilInletAirDryBulbTempTestB2)) *
    4046         392 :                                                                     (OutdoorBinTemperatureSEER[BinNum] - OutdoorCoilInletAirDryBulbTempTestB2);
    4047             : 
    4048         429 :             for (spnum = 1; spnum <= nsp - 1; ++spnum) {
    4049         429 :                 CoolingCapacityLS = TotCoolCapTestF1(spnum) + ((TotCoolCapTestB1(spnum) - TotCoolCapTestF1(spnum)) /
    4050         429 :                                                                (OutdoorCoilInletAirDryBulbTempTestB1 - OutdoorCoilInletAirDryBulbTempTestF1)) *
    4051         429 :                                                                   (OutdoorBinTemperatureSEER[BinNum] - OutdoorCoilInletAirDryBulbTempTestF1);
    4052         429 :                 CoolingElecPowerLS = OutdoorUnitPowerTestF1(spnum) + ((OutdoorUnitPowerTestB1(spnum) - OutdoorUnitPowerTestF1(spnum)) /
    4053         429 :                                                                       (OutdoorCoilInletAirDryBulbTempTestB1 - OutdoorCoilInletAirDryBulbTempTestF1)) *
    4054         429 :                                                                          (OutdoorBinTemperatureSEER[BinNum] - OutdoorCoilInletAirDryBulbTempTestF1);
    4055         429 :                 CoolingCapacityHS = TotCoolCapTestB2(spnum + 1) + ((TotCoolCapTestA2(spnum + 1) - TotCoolCapTestB2(spnum + 1)) /
    4056         429 :                                                                    (OutdoorCoilInletAirDryBulbTempTestA2 - OutdoorCoilInletAirDryBulbTempTestB2)) *
    4057         429 :                                                                       (OutdoorBinTemperatureSEER[BinNum] - OutdoorCoilInletAirDryBulbTempTestB2);
    4058         429 :                 CoolingElecPowerHS =
    4059         429 :                     OutdoorUnitPowerTestB2(spnum + 1) + ((OutdoorUnitPowerTestA2(spnum + 1) - OutdoorUnitPowerTestB2(spnum + 1)) /
    4060         429 :                                                          (OutdoorCoilInletAirDryBulbTempTestA2 - OutdoorCoilInletAirDryBulbTempTestB2)) *
    4061         429 :                                                             (OutdoorBinTemperatureSEER[BinNum] - OutdoorCoilInletAirDryBulbTempTestB2);
    4062             : 
    4063         429 :                 if (BuildingCoolingLoad <= CoolingCapacityLS) {
    4064         166 :                     PartLoadRatio = min(1.0, BuildingCoolingLoad / CoolingCapacityLS);
    4065         166 :                     NetTotCoolCapBinned = PartLoadRatio * CoolingCapacityLS;
    4066         166 :                     PartLoadFactorUser = Curve::CurveValue(state, PLFFPLRCurveIndex(spnum), PartLoadRatio);
    4067         166 :                     PartLoadFactorStandard = 1.0 - CyclicDegradationCoeff * (1.0 - PartLoadRatio);
    4068         166 :                     TotCoolElecPowerBinned = (PartLoadRatio / PartLoadFactorUser) * CoolingElecPowerLS;
    4069         166 :                     TotCoolElecPowerBinnedDefault = (PartLoadRatio / PartLoadFactorStandard) * CoolingElecPowerLS;
    4070         166 :                     goto SpeedLoop_exit;
    4071         263 :                 } else if ((BuildingCoolingLoad > CoolingCapacityLS) && (BuildingCoolingLoad < CoolingCapacityHS)) {
    4072             :                     // cycle between speed "spnum" and "spnum + 1"
    4073         177 :                     LoadFactor = min(1.0, (CoolingCapacityHS - BuildingCoolingLoad) / (CoolingCapacityHS - CoolingCapacityLS));
    4074         177 :                     LoadFactor = max(0.0, LoadFactor);
    4075         177 :                     NetTotCoolCapBinned = LoadFactor * CoolingCapacityLS + (1.0 - LoadFactor) * CoolingCapacityHS;
    4076         177 :                     TotCoolElecPowerBinned = LoadFactor * CoolingElecPowerLS + (1.0 - LoadFactor) * CoolingElecPowerHS;
    4077         177 :                     TotCoolElecPowerBinnedDefault = TotCoolElecPowerBinned;
    4078             : 
    4079             :                     // TBD:  // Suggestion for improvement as per 2017 Standard MCQ & MCE are differently calculated
    4080             :                     // and so does the load factor for Cooling and Power
    4081             :                     // Real64 LoadFactorQEnt_2023 =
    4082             :                     //     min(1.0, (TotCoolCapTestEint(spnum2023) - CoolingCapacityLS_2023) / (CoolingCapacityHS_2023 - CoolingCapacityLS_2023));
    4083             :                     // LoadFactorQEnt_2023 = max(0.0, LoadFactorQEnt_2023);
    4084             :                     // Real64 LoadFactorPEnt_2023 = min(
    4085             :                     //     1.0, (OutdoorUnitPowerTestEint(spnum2023) - CoolingElecPowerLS_2023) / (CoolingElecPowerHS_2023 -
    4086             :                     //     CoolingElecPowerLS_2023));
    4087             :                     // LoadFactorPEnt_2023 = max(0.0, LoadFactorPEnt_2023);
    4088             : 
    4089             :                     // NetTotCoolCapBinned_2023 = LoadFactorQEnt_2023 * CoolingCapacityHS_2023 + (1.0 - LoadFactorQEnt_2023) * CoolingCapacityLS_2023;
    4090             :                     // TotCoolElecPowerBinned_2023 =
    4091             :                     //     LoadFactorPEnt_2023 * CoolingElecPowerHS_2023 + (1.0 - LoadFactorPEnt_2023) * CoolingElecPowerLS_2023;
    4092             :                     // TotCoolElecPowerBinnedDefault_2023 = TotCoolElecPowerBinned_2023;
    4093         177 :                     goto SpeedLoop_exit;
    4094          86 :                 } else if (BuildingCoolingLoad >= CoolingCapacityMax) {
    4095          49 :                     NetTotCoolCapBinned = CoolingCapacityMax;
    4096          49 :                     TotCoolElecPowerBinned = CoolingElecPowerMax;
    4097          49 :                     TotCoolElecPowerBinnedDefault = CoolingElecPowerMax;
    4098          49 :                     goto SpeedLoop_exit;
    4099             :                 }
    4100             :             }
    4101           0 :         SpeedLoop_exit:;
    4102             : 
    4103         392 :             NetCoolingCapWeighted += NetTotCoolCapBinned * CoolFracBinHoursAtOutdoorBinTemp[BinNum];
    4104         392 :             TotCoolingElecPowerWeighted += TotCoolElecPowerBinned * CoolFracBinHoursAtOutdoorBinTemp[BinNum];
    4105         392 :             TotCoolingElecPowerWeightedDefault += TotCoolElecPowerBinnedDefault * CoolFracBinHoursAtOutdoorBinTemp[BinNum];
    4106             :         }
    4107          49 :         SEER_User = 0.0;
    4108          49 :         SEER_Standard = 0.0;
    4109          49 :         if (TotCoolingElecPowerWeighted > 0.0) {
    4110          49 :             SEER_User = NetCoolingCapWeighted / TotCoolingElecPowerWeighted;
    4111          49 :             SEER_Standard = NetCoolingCapWeighted / TotCoolingElecPowerWeightedDefault;
    4112             :         }
    4113             : 
    4114          98 :         return std::make_tuple(NetCoolingCapRatedMaxSpeed, SEER_User, SEER_Standard, EER);
    4115          49 :     }
    4116             : 
    4117         128 :     std::pair<Real64, int> GetMatchingSpeedFromBuildingLoad(Real64 buildingLoad, const Array1A<Real64> &speedList)
    4118             :     {
    4119         128 :         std::pair<int, Real64> result = {-1, -1}; // Initialize result to indicate no suitable number found
    4120         672 :         for (int i = 0; i < speedList.size(); ++i) {
    4121         672 :             Real64 scaledSpeed = speedList[i];
    4122         672 :             if (scaledSpeed >= buildingLoad) {
    4123         128 :                 result = {speedList[i], i};
    4124         128 :                 break;
    4125             :             }
    4126             :         }
    4127         128 :         return result;
    4128             :     }
    4129             : 
    4130             :     // Section 11.2.1.3.1 CASE 1 - Building load is no greater than unit capacity at low speed.
    4131             :     // q - total bin capacity for SEER2 Standard.
    4132             :     // e - total bin energy for SEER2 Standard.
    4133             :     // NetTotCoolCapBinned_2023 - total bin capacity for SEER2 User.
    4134             :     // TotCoolElecPowerBinned_2023 - total bin energy for SEER2 Standard.
    4135             :     std::tuple<Real64, Real64, Real64, Real64>
    4136         499 :     IntermediateCapacityAndPowerSEER2Case1(EnergyPlusData &state, Real64 bl, Real64 q_low, Real64 n, Real64 p_low, int PLFFPLRCurveIndex)
    4137             :     {
    4138             :         // Case I. Building load is less than Low Stage capacity, BL(tj) < qLow(tj). Calculate total bin capacity by using Equation 11.73
    4139             :         // and total bin energy by using Equation 11.74.
    4140         499 :         Real64 e(0.0);
    4141         499 :         Real64 q(0.0);
    4142         499 :         Real64 NetTotCoolCapBinned_2023(0.0);
    4143         499 :         Real64 TotCoolElecPowerBinned_2023(0.0);
    4144         499 :         Real64 clf_low = bl / q_low; // Equation 11.75 (AHRI-2023)
    4145             : 
    4146             :         // SEER2 STANDARD
    4147         499 :         Real64 plf_low = 1.0 - CyclicDegradationCoeff * (1.0 - clf_low); // Equation 11.76 (AHRI-2023)
    4148         499 :         q = clf_low * q_low * n;                                         // Total Bin Capacity, Equation 11.73 (AHRI-2023)
    4149         499 :         e = clf_low * p_low * n / plf_low;                               // Total Bin Energy, Equation 11.74 (AHRI-2023)
    4150             : 
    4151             :         // SEER2 USER
    4152         499 :         NetTotCoolCapBinned_2023 = clf_low * q_low * n;
    4153         499 :         Real64 PartLoadFactorUser_2023 = Curve::CurveValue(state, PLFFPLRCurveIndex, clf_low);
    4154         499 :         TotCoolElecPowerBinned_2023 = (clf_low / PartLoadFactorUser_2023) * p_low * n;
    4155         998 :         return std::make_tuple(q, e, NetTotCoolCapBinned_2023, TotCoolElecPowerBinned_2023);
    4156             :     }
    4157             : 
    4158             :     // Section 11.2.1.3.2 CASE 2 - Building load can be matched by modulating the compressor speed between low speed & full
    4159             :     // Speed
    4160             :     // q - total bin capacity for SEER2 Standard.
    4161             :     // e - total bin energy for SEER2 Standard.
    4162             :     // NetTotCoolCapBinned_2023 - total bin capacity for SEER2 User.
    4163             :     // TotCoolElecPowerBinned_2023 - total bin energy for SEER2 Standard.
    4164         157 :     std::tuple<Real64, Real64, Real64, Real64> IntermediateCapacityAndPowerSEER2Case2A(
    4165             :         Real64 p_int, Real64 q_int, Real64 q_low, Real64 bl, Real64 n, Real64 Q_E_Int, Real64 q_full, Real64 P_E_Int, Real64 p_full, Real64 p_low)
    4166             :     {
    4167         157 :         Real64 e(0.0);
    4168         157 :         Real64 q(0.0);
    4169             : 
    4170         157 :         Real64 cop_low = q_low / p_low;
    4171         157 :         Real64 cop_int = q_int / p_int;
    4172         157 :         Real64 cop_full = q_full / p_full;
    4173             :         // Low Speed
    4174         157 :         Real64 cop_int_bin = cop_low + (cop_int - cop_low) / (q_int - q_low) * (bl - q_low); // Equation 11.101 (AHRI-2023)
    4175         157 :         q = bl * n;                                                                          // 11.92 --> n is missing in the print ?
    4176         157 :         e = q / cop_int_bin;                                                                 // 11.93 --> adjusted to 11.101
    4177         157 :         Real64 NetTotCoolCapBinned_2023(0.0);
    4178         157 :         Real64 TotCoolElecPowerBinned_2023(0.0);
    4179             :         // full Speed
    4180         157 :         Real64 LoadFactorQEnt_2023 = min(1.0, (Q_E_Int - q_low) / (q_full - q_low));
    4181         157 :         LoadFactorQEnt_2023 = max(0.0, LoadFactorQEnt_2023);
    4182         157 :         Real64 LoadFactorPEnt_2023 = min(1.0, (P_E_Int - p_low) / (p_full - p_low));
    4183         157 :         LoadFactorPEnt_2023 = max(0.0, LoadFactorPEnt_2023);
    4184         157 :         NetTotCoolCapBinned_2023 = LoadFactorQEnt_2023 * q_full + (1.0 - LoadFactorQEnt_2023) * q_low;
    4185         157 :         TotCoolElecPowerBinned_2023 = LoadFactorPEnt_2023 * p_full + (1.0 - LoadFactorPEnt_2023) * p_low;
    4186         314 :         return std::make_tuple(q, e, NetTotCoolCapBinned_2023, TotCoolElecPowerBinned_2023);
    4187             :     }
    4188             : 
    4189             :     // Building load can be matched by modulating the compressor speed between low speed &
    4190             :     // full Speed |Section 11.2.1.3.2 CASE 2 (AHRI 210-240 2023)
    4191             :     // q - total bin capacity for SEER2 Standard.
    4192             :     // e - total bin energy for SEER2 Standard.
    4193             :     // NetTotCoolCapBinned_2023 - total bin capacity for SEER2 User.
    4194             :     // TotCoolElecPowerBinned_2023 - total bin energy for SEER2 Standard.
    4195         246 :     std::tuple<Real64, Real64, Real64, Real64> IntermediateCapacityAndPowerSEER2Case2B(
    4196             :         Real64 p_int, Real64 bl, Real64 q_int, Real64 n, Real64 Q_E_Int, Real64 P_E_Int, Real64 q_low, Real64 p_low, Real64 q_full, Real64 p_full)
    4197             :     {
    4198         246 :         Real64 e(0.0);
    4199         246 :         Real64 q(0.0);
    4200         246 :         Real64 NetTotCoolCapBinned_2023(0.0);
    4201         246 :         Real64 TotCoolElecPowerBinned_2023(0.0);
    4202         246 :         Real64 cop_low = q_low / p_low;
    4203         246 :         Real64 cop_int = q_int / p_int;
    4204         246 :         Real64 cop_full = q_full / p_full;
    4205         246 :         Real64 LoadFactorQEnt_2023 = min(1.0, (Q_E_Int - q_low) / (q_full - q_low));
    4206         246 :         LoadFactorQEnt_2023 = max(0.0, LoadFactorQEnt_2023);
    4207         246 :         Real64 LoadFactorPEnt_2023 = min(1.0, (P_E_Int - p_low) / (p_full - p_low));
    4208         246 :         LoadFactorPEnt_2023 = max(0.0, LoadFactorPEnt_2023);
    4209         246 :         NetTotCoolCapBinned_2023 = LoadFactorQEnt_2023 * q_full + (1.0 - LoadFactorQEnt_2023) * q_low;
    4210         246 :         TotCoolElecPowerBinned_2023 = LoadFactorPEnt_2023 * p_full + (1.0 - LoadFactorPEnt_2023) * p_low;
    4211             :         // Full Speed
    4212         246 :         Real64 cop_int_bin = cop_int + (cop_full - cop_int) / (q_full - q_int) * (bl - q_int); // Equation 11.102 (AHRI-2023)
    4213         246 :         q = bl * n;                                                                            // 11.92 --> n is missing in the print ?
    4214         246 :         e = q / cop_int_bin;                                                                   // 11.93 --> adjusted to 11.102
    4215         492 :         return std::make_tuple(q, e, NetTotCoolCapBinned_2023, TotCoolElecPowerBinned_2023);
    4216             :     }
    4217             : 
    4218             :     // Section 11.2.1.3.3 CASE 3 - Building load is equal to or greater than unit capacity at full stage
    4219             :     // q - total bin capacity for SEER2 Standard.
    4220             :     // e - total bin energy for SEER2 Standard.
    4221             :     // NetTotCoolCapBinned_2023 - total bin capacity for SEER2 User.
    4222             :     // TotCoolElecPowerBinned_2023 - total bin energy for SEER2 Standard.
    4223             :     std::tuple<Real64, Real64, Real64, Real64>
    4224         114 :     IntermediateCapacityAndPowerSEER2Case3(Real64 q_full, Real64 p_full, Real64 CoolingCapacityMax_2023, Real64 CoolingElecPowerMax_2023, Real64 n)
    4225             :     {
    4226         114 :         Real64 e(0.0);
    4227         114 :         Real64 q(0.0);
    4228         114 :         q = q_full * n; // Equation 11.88 (AHRI-2023)
    4229         114 :         e = p_full * n; // Equation 11.89 (AHRI-2023)
    4230         114 :         Real64 NetTotCoolCapBinned_2023(0.0);
    4231         114 :         Real64 TotCoolElecPowerBinned_2023(0.0);
    4232         114 :         NetTotCoolCapBinned_2023 = CoolingCapacityMax_2023 * n;
    4233         114 :         TotCoolElecPowerBinned_2023 = CoolingElecPowerMax_2023 * n;
    4234         228 :         return std::make_tuple(q, e, NetTotCoolCapBinned_2023, TotCoolElecPowerBinned_2023);
    4235             :     }
    4236             : 
    4237             :     // N_Cq - Capacity adjustment factor in cooling mode SEER2 #1
    4238             :     // M_Cq - Capacity adjustment factor in cooling mode SEER2 #2
    4239             :     std::tuple<Real64, Real64>
    4240        1295 :     CapacityAdjustmentFactorsInCoolingModeSEER2(Real64 q_F_low, Real64 q_B_low, Real64 BN, Real64 q_B_full, Real64 q_A_full, Real64 q_E_int)
    4241             :     {
    4242             :         // Equation 11.90 (AHRI-2023)
    4243        1295 :         Real64 q_87_low = q_F_low + (q_B_low - q_F_low) * ((OutdoorBinTemperatureSEER[BN] - 19.44 / 27.77 - 19.44));
    4244        1295 :         Real64 q_87_full = q_B_full + (q_A_full - q_B_full) * ((OutdoorBinTemperatureSEER[BN] - 19.44 / 27.77 - 19.44));
    4245             :         // Equation 11.96 (AHRI-2023)
    4246        1295 :         Real64 N_Cq = (q_E_int - q_87_low) / (q_87_full - q_87_low);
    4247             :         // Equation 11.95 (AHRI-2023)
    4248        1295 :         Real64 M_Cq = (q_B_low - q_F_low) / (27.77 - 19.44) * (1. - N_Cq) + (q_A_full - q_B_full) / (35.0 - 27.77) * N_Cq;
    4249        2590 :         return std::make_tuple(N_Cq, M_Cq);
    4250             :     }
    4251             : 
    4252             :     // N_CE - Energy adjustment factor in cooling mode SEER2 #1
    4253             :     // M_CE - Energy adjustment factor in cooling mode SEER2 #2
    4254             :     std::tuple<Real64, Real64>
    4255        1295 :     EnergyAdjustmentFactorsInCoolingModeSEER2(Real64 p_F_low, Real64 p_B_low, Real64 BN, Real64 p_B_full, Real64 p_A_full, Real64 p_E_int)
    4256             :     {
    4257             :         // Equation 11.91 (AHRI-2023)
    4258        1295 :         Real64 p_87_low = p_F_low + (p_B_low - p_F_low) * ((OutdoorBinTemperatureSEER[BN] - 19.44 / 27.77 - 19.44));
    4259        1295 :         Real64 p_87_full = p_B_full + (p_A_full - p_B_full) * ((OutdoorBinTemperatureSEER[BN] - 19.44 / 27.77 - 19.44));
    4260             : 
    4261             :         // Equation 11.99 (AHRI-2023)
    4262        1295 :         Real64 N_CE = (p_E_int - p_87_low) / (p_87_full - p_87_low);
    4263             : 
    4264             :         // Equaition 11.98 (AHRI-2023)
    4265        1295 :         Real64 M_CE = (p_B_low - p_F_low) / (27.77 - 19.44) * (1. - N_CE) + (p_A_full - p_B_full) / (35.0 - 27.77) * N_CE;
    4266        2590 :         return std::make_tuple(N_CE, M_CE);
    4267             :     }
    4268             : 
    4269             :     // q_int - Intermediate Steady State Capacity SEER2
    4270             :     // p_int - Intermediate Steady State Power SEER2
    4271        1295 :     std::tuple<Real64, Real64> IntermediateSteadyStateCpacityAndPowerSEER2(Real64 q_E_int, Real64 M_Cq, Real64 p_E_int, Real64 M_CE, Real64 t)
    4272             :     {
    4273             :         // Equation 11.94 (AHRI-2023)
    4274        1295 :         Real64 q_int = q_E_int + M_Cq * (t - 30.55);
    4275             : 
    4276             :         // Equation 11.97 (AHRI-2023)
    4277        1295 :         Real64 p_int = p_E_int + M_CE * (t - 30.55);
    4278        2590 :         return std::make_tuple(q_int, p_int);
    4279             :     }
    4280             : 
    4281          78 :     std::tuple<Real64, Real64, Real64, Real64> VariableSpeedDXCoolingCoilSEER2(EnergyPlusData &state,
    4282             :                                                                                int const nsp,
    4283             :                                                                                Array1A_int const CapFFlowCurveIndex,
    4284             :                                                                                Array1A<Real64> const GrossRatedCapacityAtSpeedLevel,
    4285             :                                                                                Array1A_int const CapFTempCurveIndex,
    4286             :                                                                                Array1A<Real64> const FanPowerPerEvapAirFlowRateFromInput_2023,
    4287             :                                                                                Array1A<Real64> const LoopVolumetricAirFlowRateAtSpeedLevel,
    4288             :                                                                                Array1A_int const EIRFFlowCurveIndex,
    4289             :                                                                                Array1A<Real64> const RatedCOP,
    4290             :                                                                                Array1A_int EIRFTempCurveIndex,
    4291             :                                                                                Array1A_int const PLFFPLRCurveIndex)
    4292             :     {
    4293             : 
    4294          78 :         Real64 NetCoolingCapRatedMaxSpeed2023 = 0.0;
    4295          78 :         Real64 SEER2_User = 0.0;
    4296          78 :         Real64 SEER2_Standard = 0.0;
    4297          78 :         Real64 EER2 = 0.0;
    4298             : 
    4299             :         // Intermediate values calculated from the inputs in the idf file
    4300             :         // ANSI/AHRI 210/240 Std. 2023
    4301          78 :         Array1D<Real64> FanPowerPerEvapAirFlowRate_2023(nsp); // 2023 Fan power per air volume flow rate through the evaporator coil [W/(m3/s)]
    4302          78 :         Array1D<Real64> Q_A_Full(nsp);                        // Total cooling capacity at A2 test condition (High speed) | q_A_Full
    4303          78 :         Array1D<Real64> Q_B_Full(nsp);                        // Total cooling capacity at B2 test condition (High speed) | q_B_Full
    4304          78 :         Array1D<Real64> Q_B_Low(nsp);                         // Total cooling capacity at B1 test condition (Low speed) | q_B_Low
    4305          78 :         Array1D<Real64> Q_F_Low(nsp);                         // Total cooling capacity at F1 test condition (Low speed) | q_F_Low
    4306          78 :         Array1D<Real64> Q_E_Int(nsp);                         // Total cooling capacity at Eint (Ev) test condition | q_E_Int
    4307          78 :         Array1D<Real64> P_A_Full(nsp);                        // Outdoor Unit electric power at A2 test condition (High speed) | p_A_Full
    4308          78 :         Array1D<Real64> P_B_Full(nsp);                        // Outdoor Unit electric power at B2 test condition (High speed) | p_B_Full
    4309          78 :         Array1D<Real64> P_B_Low(nsp);                         // Outdoor Unit electric power at B1 test condition (Low speed) | p_B_Low
    4310          78 :         Array1D<Real64> P_F_Low(nsp);                         // Outdoor Unit electric power at F1 test condition | p_F_Low
    4311          78 :         Array1D<Real64> P_E_Int(nsp);                         // Outdoor Unit electric power at Eint (Ev) test conditon | p_E_Int
    4312             : 
    4313             :         int spnum;                                    // compressor speed number
    4314          78 :         Array1D<Real64> TotCapFlowModFac(nsp);        // Total capacity modifier f(actual flow vs rated flow) for each speed [-]
    4315          78 :         Array1D<Real64> EIRFlowModFac(nsp);           // EIR modifier f(actual supply air flow vs rated flow) for each speed [-]
    4316          78 :         Array1D<Real64> NetCoolingCapRated_2023(nsp); // net cooling capacity at each speed
    4317          78 :         Real64 q_low(0.0);                            // cooling capacity of Mult-speed DX coil at lower speed, [W]
    4318          78 :         Real64 q_full(0.0);                           // cooling capacity of Mult-speed DX coil at higher speed, [W]
    4319          78 :         Real64 p_low(0.0);                            // outdoor unit electric power input at low speed, [W]
    4320          78 :         Real64 p_full(0.0);                           // outdoor unit electric power input at high speed, [W]
    4321          78 :         Real64 CoolingCapacityMax_2023(0.0);          // cooling capacity of Mult-speed DX coil at max speed, [W]
    4322          78 :         Real64 CoolingElecPowerMax_2023(0.0);         // outdoor unit electric power input at Max speed, [W]
    4323             : 
    4324             :         // binned cooling hours
    4325          78 :         Real64 BuildingCoolingLoad_2023(0.0);    // Building space cooling load corresponding to an outdoor bin temperature [W]
    4326          78 :         Real64 NetTotCoolCapBinned_2023(0.0);    // Net tot cooling cap corresponding to an outdoor bin temperature [W]
    4327          78 :         Real64 TotCoolElecPowerBinned_2023(0.0); // Total cooling electric power corresponding to an outdoor bin temperature [W]
    4328             : 
    4329          78 :         Real64 constexpr SF(1.10); // Sizing Factor as per AHRI Std 210/240-2023 | equation 11.68
    4330             :         // Real64 constexpr V(1);     // V = 0.93 for Variable Speed Heat Pumps, otherwise V = 1.0
    4331          78 :         Real64 constexpr V(0.93); // V = 0.93 for Variable Speed Heat Pumps, otherwise V = 1.0
    4332             :         // part-load factor based on user-input PLF curve and C_D value that accounts for the cyclic degradation, [-]
    4333          78 :         Real64 PartLoadFactorUser_2023(0.0);
    4334             : 
    4335         374 :         for (int spnum = 1; spnum <= nsp; ++spnum) {
    4336         296 :             FanPowerPerEvapAirFlowRate_2023(spnum) = 0.0;
    4337         296 :             if (FanPowerPerEvapAirFlowRateFromInput_2023(spnum) <= 0.0) {
    4338           0 :                 FanPowerPerEvapAirFlowRate_2023(spnum) = DefaultFanPowerPerEvapAirFlowRateSEER2;
    4339             :             } else {
    4340         296 :                 FanPowerPerEvapAirFlowRate_2023(spnum) = FanPowerPerEvapAirFlowRateFromInput_2023(spnum);
    4341             :             }
    4342             :         }
    4343             : 
    4344             :         // Calculate the capacity and power for each speed
    4345         374 :         for (spnum = 1; spnum <= nsp; ++spnum) {
    4346         296 :             TotCapFlowModFac(spnum) = Curve::CurveValue(state, CapFFlowCurveIndex(spnum), AirMassFlowRatioRated);
    4347             : 
    4348         592 :             Q_A_Full(spnum) =
    4349         296 :                 GrossRatedCapacityAtSpeedLevel(spnum) *
    4350         296 :                     Curve::CurveValue(state, CapFTempCurveIndex(spnum), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestA2) *
    4351         296 :                     TotCapFlowModFac(spnum) -
    4352         296 :                 FanPowerPerEvapAirFlowRate_2023(spnum) * LoopVolumetricAirFlowRateAtSpeedLevel(spnum);
    4353             : 
    4354         592 :             Q_B_Full(spnum) =
    4355         296 :                 GrossRatedCapacityAtSpeedLevel(spnum) *
    4356         296 :                     Curve::CurveValue(state, CapFTempCurveIndex(spnum), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestB2) *
    4357         296 :                     TotCapFlowModFac(spnum) -
    4358         296 :                 FanPowerPerEvapAirFlowRate_2023(spnum) * LoopVolumetricAirFlowRateAtSpeedLevel(spnum);
    4359             : 
    4360         592 :             Q_B_Low(spnum) =
    4361         296 :                 GrossRatedCapacityAtSpeedLevel(spnum) *
    4362         296 :                     Curve::CurveValue(state, CapFTempCurveIndex(spnum), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestB1) *
    4363         296 :                     TotCapFlowModFac(spnum) -
    4364         296 :                 FanPowerPerEvapAirFlowRate_2023(spnum) * LoopVolumetricAirFlowRateAtSpeedLevel(spnum);
    4365             : 
    4366         592 :             Q_F_Low(spnum) =
    4367         296 :                 GrossRatedCapacityAtSpeedLevel(spnum) *
    4368         296 :                     Curve::CurveValue(state, CapFTempCurveIndex(spnum), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestF1) *
    4369         296 :                     TotCapFlowModFac(spnum) -
    4370         296 :                 FanPowerPerEvapAirFlowRate_2023(spnum) * LoopVolumetricAirFlowRateAtSpeedLevel(spnum);
    4371             : 
    4372         592 :             Q_E_Int(spnum) =
    4373         296 :                 GrossRatedCapacityAtSpeedLevel(spnum) *
    4374         296 :                     Curve::CurveValue(state, CapFTempCurveIndex(spnum), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestEint) *
    4375         296 :                     TotCapFlowModFac(spnum) -
    4376         296 :                 FanPowerPerEvapAirFlowRate_2023(spnum) * LoopVolumetricAirFlowRateAtSpeedLevel(spnum);
    4377             : 
    4378         296 :             EIRFlowModFac(spnum) = Curve::CurveValue(state, EIRFFlowCurveIndex(spnum), AirMassFlowRatioRated);
    4379         296 :             if (RatedCOP(spnum) > 0.0) {
    4380         592 :                 P_A_Full(spnum) =
    4381         296 :                     Q_A_Full(spnum) * EIRFlowModFac(spnum) *
    4382         592 :                         Curve::CurveValue(
    4383         296 :                             state, EIRFTempCurveIndex(spnum), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestA2) /
    4384         296 :                         RatedCOP(spnum) +
    4385         296 :                     FanPowerPerEvapAirFlowRate_2023(spnum) * LoopVolumetricAirFlowRateAtSpeedLevel(spnum);
    4386             : 
    4387         592 :                 P_B_Full(spnum) =
    4388         296 :                     Q_B_Full(spnum) * EIRFlowModFac(spnum) *
    4389         592 :                         Curve::CurveValue(
    4390         296 :                             state, EIRFTempCurveIndex(spnum), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestB2) /
    4391         296 :                         RatedCOP(spnum) +
    4392         296 :                     FanPowerPerEvapAirFlowRate_2023(spnum) * LoopVolumetricAirFlowRateAtSpeedLevel(spnum);
    4393             : 
    4394         296 :                 P_B_Low(spnum) = Q_B_Low(spnum) * EIRFlowModFac(spnum) *
    4395         592 :                                      Curve::CurveValue(
    4396         296 :                                          state, EIRFTempCurveIndex(spnum), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestB1) /
    4397         296 :                                      RatedCOP(spnum) +
    4398         296 :                                  FanPowerPerEvapAirFlowRate_2023(spnum) * LoopVolumetricAirFlowRateAtSpeedLevel(spnum);
    4399             : 
    4400         296 :                 P_F_Low(spnum) = Q_F_Low(spnum) * EIRFlowModFac(spnum) *
    4401         592 :                                      Curve::CurveValue(
    4402         296 :                                          state, EIRFTempCurveIndex(spnum), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestF1) /
    4403         296 :                                      RatedCOP(spnum) +
    4404         296 :                                  FanPowerPerEvapAirFlowRate_2023(spnum) * LoopVolumetricAirFlowRateAtSpeedLevel(spnum);
    4405             : 
    4406         296 :                 P_E_Int(spnum) =
    4407         296 :                     Q_E_Int(spnum) * EIRFlowModFac(spnum) *
    4408         592 :                         Curve::CurveValue(
    4409         296 :                             state, EIRFTempCurveIndex(spnum), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestEint) /
    4410         296 :                         RatedCOP(spnum) +
    4411         296 :                     FanPowerPerEvapAirFlowRate_2023(spnum) * LoopVolumetricAirFlowRateAtSpeedLevel(spnum);
    4412             :             }
    4413             :         }
    4414             :         // Standard Rating cooling (net) capacity calculations:
    4415          78 :         NetCoolingCapRated_2023(nsp) = Q_A_Full(nsp);
    4416          78 :         NetCoolingCapRatedMaxSpeed2023 = NetCoolingCapRated_2023(nsp);
    4417             : 
    4418             :         // EER2 calculation |  Section 3.1.16(AHRI 210/240 2023)
    4419             :         // A ratio of the cooling capacity in Btu/h to the Total Power in watts at AFull test conditions and expressed in Btu/(W-h)
    4420             :         // In case of Coil:Cooling:DX:MultiSpeed coil we're picking the max speed.
    4421          78 :         EER2 = Q_A_Full(nsp) / P_A_Full(nsp);
    4422             :         // Calculate the SEER2 value based on contribution of each outdoor air bin temperature
    4423          78 :         Real64 q_sum = 0.0;
    4424          78 :         Real64 e_sum = 0.0;
    4425          78 :         Real64 NetCoolingCapWeighted2_2023 = 0.0;
    4426          78 :         Real64 TotCoolingElecPowerWeighted2_2023 = 0.0;
    4427          78 :         SEER2_User = 0.0;
    4428          78 :         SEER2_Standard = 0.0;
    4429          78 :         std::vector<int> speedsUsed;
    4430             :         // speedsUsed.push_back(1);
    4431         702 :         for (int BN = 0; BN < NumOfOATempBins; ++BN) {
    4432             :             // Equation 11.67 (AHRI-2023)
    4433         624 :             BuildingCoolingLoad_2023 = ((OutdoorBinTemperatureSEER[BN] - 18.3) / (35.0 - 18.3) * (Q_A_Full(nsp) / SF)) * V;
    4434             :             // determine the speed number
    4435         624 :             CoolingCapacityMax_2023 =
    4436         624 :                 Q_B_Full(nsp) + ((Q_A_Full(nsp) - Q_B_Full(nsp)) / (OutdoorCoilInletAirDryBulbTempTestA2 - OutdoorCoilInletAirDryBulbTempTestB2)) *
    4437         624 :                                     (OutdoorBinTemperatureSEER[BN] - OutdoorCoilInletAirDryBulbTempTestB2);
    4438         624 :             CoolingElecPowerMax_2023 =
    4439         624 :                 P_B_Full(nsp) + ((P_A_Full(nsp) - P_B_Full(nsp)) / (OutdoorCoilInletAirDryBulbTempTestA2 - OutdoorCoilInletAirDryBulbTempTestB2)) *
    4440         624 :                                     (OutdoorBinTemperatureSEER[BN] - OutdoorCoilInletAirDryBulbTempTestB2);
    4441             :             // Equation 11.69 (AHRI-2023)
    4442         624 :             q_low = Q_F_Low(1) + ((Q_B_Low(1) - Q_F_Low(1)) / (OutdoorCoilInletAirDryBulbTempTestB1 - OutdoorCoilInletAirDryBulbTempTestF1)) *
    4443         624 :                                      (OutdoorBinTemperatureSEER[BN] - OutdoorCoilInletAirDryBulbTempTestF1);
    4444             :             // Equation 11.70 (AHRI-2023)4
    4445         624 :             p_low = P_F_Low(1) + ((P_B_Low(1) - P_F_Low(1)) / (OutdoorCoilInletAirDryBulbTempTestB1 - OutdoorCoilInletAirDryBulbTempTestF1)) *
    4446         624 :                                      (OutdoorBinTemperatureSEER[BN] - OutdoorCoilInletAirDryBulbTempTestF1);
    4447             :             // Equation 11.71 (AHRI-2023)
    4448         624 :             q_full =
    4449         624 :                 Q_B_Full(nsp) + ((Q_A_Full(nsp) - Q_B_Full(nsp)) / (OutdoorCoilInletAirDryBulbTempTestA2 - OutdoorCoilInletAirDryBulbTempTestB2)) *
    4450         624 :                                     (OutdoorBinTemperatureSEER[BN] - OutdoorCoilInletAirDryBulbTempTestB2);
    4451             :             // Equation 11.72 (AHRI-2023)
    4452         624 :             p_full =
    4453         624 :                 P_B_Full(nsp) + ((P_A_Full(nsp) - P_B_Full(nsp)) / (OutdoorCoilInletAirDryBulbTempTestA2 - OutdoorCoilInletAirDryBulbTempTestB2)) *
    4454         624 :                                     (OutdoorBinTemperatureSEER[BN] - OutdoorCoilInletAirDryBulbTempTestB2);
    4455         624 :             Real64 q(0.0);
    4456         624 :             Real64 e(0.0);
    4457         624 :             bool skipSpeed = false;
    4458             : 
    4459             :             // # Intermediate Capacity
    4460         624 :             Real64 q_A_full = Q_A_Full(nsp);
    4461         624 :             Real64 q_B_full = Q_B_Full(nsp);
    4462         624 :             Real64 q_B_low = Q_B_Low(1);
    4463         624 :             Real64 q_F_low = Q_F_Low(1);
    4464             :             // # Intermediate Power
    4465         624 :             Real64 p_A_full = P_A_Full(nsp);
    4466         624 :             Real64 p_B_full = P_B_Full(nsp);
    4467         624 :             Real64 p_B_low = P_B_Low(1);
    4468         624 :             Real64 p_F_low = P_F_Low(1);
    4469             : 
    4470         624 :             Real64 N_Cq(0.0);
    4471         624 :             Real64 M_Cq(0.0);
    4472             : 
    4473         624 :             Real64 N_CE(0.0);
    4474         624 :             Real64 M_CE(0.0);
    4475             : 
    4476         624 :             Real64 q_int(0.0);
    4477         624 :             Real64 p_int(0.0);
    4478         624 :             Real64 t = OutdoorBinTemperatureSEER[BN];
    4479         624 :             Real64 n = CoolFracBinHoursAtOutdoorBinTemp[BN];
    4480         624 :             Real64 bl = BuildingCoolingLoad_2023;
    4481         624 :             if ((nsp >= 5 && nsp <= 10)) {
    4482             :                 // New speed selection strategy :
    4483         128 :                 auto result = GetMatchingSpeedFromBuildingLoad(BuildingCoolingLoad_2023, GrossRatedCapacityAtSpeedLevel);
    4484         128 :                 if (result.second != -1) {
    4485         128 :                     int spnum = result.second + 1;
    4486             :                     // found a speed that meets the building load
    4487             :                     // # Intermediate Capacity
    4488         128 :                     Real64 q_E_int = Q_E_Int(spnum);
    4489         128 :                     std::tie(N_Cq, M_Cq) = CapacityAdjustmentFactorsInCoolingModeSEER2(q_F_low, q_B_low, BN, q_B_full, q_A_full, q_E_int);
    4490             : 
    4491             :                     // # Intermediate Power
    4492         128 :                     Real64 p_E_int = P_E_Int(spnum);
    4493         128 :                     std::tie(N_CE, M_CE) = EnergyAdjustmentFactorsInCoolingModeSEER2(p_F_low, p_B_low, BN, p_B_full, p_A_full, p_E_int);
    4494             : 
    4495         128 :                     std::tie(q_int, p_int) = IntermediateSteadyStateCpacityAndPowerSEER2(q_E_int, M_Cq, p_E_int, M_CE, t);
    4496             : 
    4497             :                     // Section 11.2.1.3.1 CASE 1 - Building load is no greater than unit capacity at low speed.
    4498         128 :                     if (BuildingCoolingLoad_2023 <= q_low) {
    4499          32 :                         std::tie(q, e, NetTotCoolCapBinned_2023, TotCoolElecPowerBinned_2023) =
    4500          64 :                             IntermediateCapacityAndPowerSEER2Case1(state, bl, q_low, n, p_low, PLFFPLRCurveIndex(spnum));
    4501          32 :                         speedsUsed.push_back(spnum);
    4502         128 :                         goto SpeedLoop3_exit;
    4503          96 :                     } else if (BuildingCoolingLoad_2023 > q_low && BuildingCoolingLoad_2023 < q_full) {
    4504             :                         // Case 2A:
    4505          80 :                         if (bl < q_int) {
    4506             :                             // Section 11.2.1.3.2 CASE 2 - Building load can be matched by modulating the compressor speed between low speed &
    4507          54 :                             std::tie(q, e, NetTotCoolCapBinned_2023, TotCoolElecPowerBinned_2023) = IntermediateCapacityAndPowerSEER2Case2A(
    4508         108 :                                 p_int, q_int, q_low, bl, n, Q_E_Int(spnum), q_full, P_E_Int(spnum), p_full, p_low);
    4509          54 :                             speedsUsed.push_back(spnum);
    4510          54 :                             goto SpeedLoop3_exit;
    4511          26 :                         } else if (bl < q_full) {
    4512             :                             // Section 11.2.1.3.2 CASE 2 - Building load can be matched by modulating the compressor speed between low speed &
    4513             :                             // full Speed
    4514          26 :                             std::tie(q, e, NetTotCoolCapBinned_2023, TotCoolElecPowerBinned_2023) = IntermediateCapacityAndPowerSEER2Case2B(
    4515          52 :                                 p_int, bl, q_int, n, Q_E_Int(spnum), P_E_Int(spnum), q_low, p_low, q_full, p_full);
    4516          26 :                             speedsUsed.push_back(spnum);
    4517          26 :                             goto SpeedLoop3_exit;
    4518             :                         }
    4519          16 :                     } else if (BuildingCoolingLoad_2023 >= q_full) {
    4520             :                         // Case 3:
    4521             :                         // Section 11.2.1.3.3 CASE 3 - Building load is equal to or greater than unit capacity at full stage
    4522          16 :                         std::tie(q, e, NetTotCoolCapBinned_2023, TotCoolElecPowerBinned_2023) =
    4523          32 :                             IntermediateCapacityAndPowerSEER2Case3(q_full, p_full, CoolingCapacityMax_2023, CoolingElecPowerMax_2023, n);
    4524          16 :                         speedsUsed.push_back(spnum);
    4525          16 :                         goto SpeedLoop3_exit;
    4526             :                     }
    4527             :                 } else {
    4528             :                     // << ",, BIN NUMBER (C3), " << BN + 1 << ", NO SPEEDS MATCHED ??, " << spnum << std::endl;
    4529             :                 }
    4530         496 :             } else if (nsp == 4) {
    4531         240 :                 for (spnum = 1; spnum <= nsp; ++spnum) {
    4532             :                     // # Intermediate Capacity
    4533             :                     Real64 q_E_int;
    4534         240 :                     if (spnum == 2 || spnum == 3) {
    4535         105 :                         q_E_int = (Q_E_Int(2) + Q_E_Int(3)) * 0.5;
    4536             :                     } else {
    4537         135 :                         q_E_int = Q_E_Int(spnum);
    4538             :                     }
    4539             :                     // # Intermediate Power
    4540             :                     Real64 p_E_int;
    4541         240 :                     if (spnum == 2 || spnum == 3) {
    4542         105 :                         p_E_int = (P_E_Int(2) + P_E_Int(3)) * 0.5;
    4543             :                     } else {
    4544         135 :                         p_E_int = P_E_Int(spnum);
    4545             :                     }
    4546             : 
    4547         240 :                     std::tie(N_Cq, M_Cq) = CapacityAdjustmentFactorsInCoolingModeSEER2(q_F_low, q_B_low, BN, q_B_full, q_A_full, q_E_int);
    4548             : 
    4549         240 :                     std::tie(N_CE, M_CE) = EnergyAdjustmentFactorsInCoolingModeSEER2(p_F_low, p_B_low, BN, p_B_full, p_A_full, p_E_int);
    4550             : 
    4551         240 :                     std::tie(q_int, p_int) = IntermediateSteadyStateCpacityAndPowerSEER2(q_E_int, M_Cq, p_E_int, M_CE, t);
    4552             : 
    4553             :                     // Section 11.2.1.3.1 CASE 1 - Building load is no greater than unit capacity at low speed.
    4554         240 :                     if (bl <= q_low) {
    4555          30 :                         std::tie(q, e, NetTotCoolCapBinned_2023, TotCoolElecPowerBinned_2023) =
    4556          60 :                             IntermediateCapacityAndPowerSEER2Case1(state, bl, q_low, n, p_low, PLFFPLRCurveIndex(spnum));
    4557             :                         // This is the case and speed we're looking for now we exit and try calculating against the next bin
    4558          30 :                         goto SpeedLoop3_exit;
    4559         210 :                     } else if (bl > q_low && bl < q_full && (spnum == 2 || spnum == 3)) {
    4560             : 
    4561             :                         // Case 2A:
    4562          75 :                         if (bl < q_int) {
    4563             :                             // Section 11.2.1.3.2 CASE 2 - Building load can be matched by modulating the compressor speed between low speed & full
    4564             :                             // Speed
    4565          55 :                             std::tie(q, e, NetTotCoolCapBinned_2023, TotCoolElecPowerBinned_2023) = IntermediateCapacityAndPowerSEER2Case2A(
    4566         110 :                                 p_int, q_int, q_low, bl, n, Q_E_Int(spnum), q_full, P_E_Int(spnum), p_full, p_low);
    4567          55 :                             goto SpeedLoop3_exit;
    4568          20 :                         } else if (bl < q_full) {
    4569             :                             // Section 11.2.1.3.2 CASE 2 - Building load can be matched by modulating the compressor speed between low speed &
    4570             :                             // full Speed
    4571          20 :                             std::tie(q, e, NetTotCoolCapBinned_2023, TotCoolElecPowerBinned_2023) = IntermediateCapacityAndPowerSEER2Case2B(
    4572          40 :                                 p_int, bl, q_int, n, Q_E_Int(spnum), P_E_Int(spnum), q_low, p_low, q_full, p_full);
    4573          20 :                             goto SpeedLoop3_exit;
    4574             :                         }
    4575         135 :                     } else if (bl >= q_full && spnum > 3) {
    4576             :                         // Case 3:
    4577             :                         // Section 11.2.1.3.3 CASE 3 - Building load is equal to or greater than unit capacity at full stage
    4578          15 :                         std::tie(q, e, NetTotCoolCapBinned_2023, TotCoolElecPowerBinned_2023) =
    4579          30 :                             IntermediateCapacityAndPowerSEER2Case3(q_full, p_full, CoolingCapacityMax_2023, CoolingElecPowerMax_2023, n);
    4580          15 :                         goto SpeedLoop3_exit;
    4581             :                     }
    4582             :                 }
    4583         376 :             } else if (nsp == 3) {
    4584          32 :                 for (spnum = 1; spnum <= nsp; ++spnum) {
    4585             :                     // # Intermediate Capacity
    4586          32 :                     Real64 q_E_int = Q_E_Int(spnum);
    4587          32 :                     std::tie(N_Cq, M_Cq) = CapacityAdjustmentFactorsInCoolingModeSEER2(q_F_low, q_B_low, BN, q_B_full, q_A_full, q_E_int);
    4588             : 
    4589             :                     // # Intermediate Power
    4590          32 :                     Real64 p_E_int = P_E_Int(spnum);
    4591          32 :                     std::tie(N_CE, M_CE) = EnergyAdjustmentFactorsInCoolingModeSEER2(p_F_low, p_B_low, BN, p_B_full, p_A_full, p_E_int);
    4592             : 
    4593          32 :                     std::tie(q_int, p_int) = IntermediateSteadyStateCpacityAndPowerSEER2(q_E_int, M_Cq, p_E_int, M_CE, t);
    4594             : 
    4595             :                     // Section 11.2.1.3.1 CASE 1 - Building load is no greater than unit capacity at low speed.
    4596          32 :                     if (bl <= q_low) {
    4597          12 :                         std::tie(q, e, NetTotCoolCapBinned_2023, TotCoolElecPowerBinned_2023) =
    4598          24 :                             IntermediateCapacityAndPowerSEER2Case1(state, bl, q_low, n, p_low, PLFFPLRCurveIndex(spnum));
    4599             :                         // This is the case and speed we're looking for now we exit and try calculating against the next bin
    4600          12 :                         goto SpeedLoop3_exit;
    4601          20 :                     } else if (bl > q_low && bl < q_full) {
    4602             :                         // Case 2A:
    4603          16 :                         if (bl < q_int) {
    4604             :                             // Section 11.2.1.3.2 CASE 2 - Building load can be matched by modulating the compressor speed between low speed & full
    4605             :                             // Speed
    4606           0 :                             std::tie(q, e, NetTotCoolCapBinned_2023, TotCoolElecPowerBinned_2023) = IntermediateCapacityAndPowerSEER2Case2A(
    4607           0 :                                 p_int, q_int, q_low, bl, n, Q_E_Int(spnum), q_full, P_E_Int(spnum), p_full, p_low);
    4608           0 :                             goto SpeedLoop3_exit;
    4609          16 :                         } else if (bl < q_full) {
    4610             :                             // Section 11.2.1.3.2 CASE 2 - Building load can be matched by modulating the compressor speed between low speed &
    4611             :                             // full Speed
    4612          16 :                             std::tie(q, e, NetTotCoolCapBinned_2023, TotCoolElecPowerBinned_2023) = IntermediateCapacityAndPowerSEER2Case2B(
    4613          32 :                                 p_int, bl, q_int, n, Q_E_Int(spnum), P_E_Int(spnum), q_low, p_low, q_full, p_full);
    4614          16 :                             goto SpeedLoop3_exit;
    4615             :                         }
    4616           4 :                     } else if (bl >= q_full) {
    4617             :                         // Case 3:
    4618             :                         // Section 11.2.1.3.3 CASE 3 - Building load is equal to or greater than unit capacity at full stage
    4619           4 :                         std::tie(q, e, NetTotCoolCapBinned_2023, TotCoolElecPowerBinned_2023) =
    4620           8 :                             IntermediateCapacityAndPowerSEER2Case3(q_full, p_full, CoolingCapacityMax_2023, CoolingElecPowerMax_2023, n);
    4621           4 :                         goto SpeedLoop3_exit;
    4622             :                     }
    4623             :                 }
    4624         344 :             } else if (nsp == 2) {
    4625         189 :                 for (spnum = 1; spnum <= nsp; ++spnum) {
    4626             :                     // # Intermediate Capacity
    4627         189 :                     Real64 q_E_int = Q_E_Int(1);
    4628         189 :                     std::tie(N_Cq, M_Cq) = CapacityAdjustmentFactorsInCoolingModeSEER2(q_F_low, q_B_low, BN, q_B_full, q_A_full, q_E_int);
    4629             : 
    4630             :                     // # Intermediate Power
    4631         189 :                     Real64 p_E_int = P_E_Int(1);
    4632         189 :                     std::tie(N_CE, M_CE) = EnergyAdjustmentFactorsInCoolingModeSEER2(p_F_low, p_B_low, BN, p_B_full, p_A_full, p_E_int);
    4633             : 
    4634         189 :                     std::tie(q_int, p_int) = IntermediateSteadyStateCpacityAndPowerSEER2(q_E_int, M_Cq, p_E_int, M_CE, t);
    4635             : 
    4636             :                     // Section 11.2.1.3.1 CASE 1 - Building load is no greater than unit capacity at low speed.
    4637         189 :                     if (bl <= q_low) {
    4638          79 :                         std::tie(q, e, NetTotCoolCapBinned_2023, TotCoolElecPowerBinned_2023) =
    4639         158 :                             IntermediateCapacityAndPowerSEER2Case1(state, bl, q_low, n, p_low, PLFFPLRCurveIndex(spnum));
    4640             :                         // This is the case and speed we're looking for now we exit and try calculating against the next bin
    4641          79 :                         goto SpeedLoop3_exit;
    4642         110 :                     } else if (bl > q_low && bl < q_full) {
    4643             :                         // Case 2A:
    4644          68 :                         if (bl < q_int) {
    4645             :                             // Section 11.2.1.3.2 CASE 2 - Building load can be matched by modulating the compressor speed between low speed & full
    4646             :                             // Speed
    4647           5 :                             std::tie(q, e, NetTotCoolCapBinned_2023, TotCoolElecPowerBinned_2023) = IntermediateCapacityAndPowerSEER2Case2A(
    4648          10 :                                 p_int, q_int, q_low, bl, n, Q_E_Int(spnum), q_full, P_E_Int(spnum), p_full, p_low);
    4649           5 :                             goto SpeedLoop3_exit;
    4650          63 :                         } else if (bl < q_full) {
    4651             :                             // Section 11.2.1.3.2 CASE 2 - Building load can be matched by modulating the compressor speed between low speed &
    4652             :                             // full Speed
    4653          63 :                             std::tie(q, e, NetTotCoolCapBinned_2023, TotCoolElecPowerBinned_2023) = IntermediateCapacityAndPowerSEER2Case2B(
    4654         126 :                                 p_int, bl, q_int, n, Q_E_Int(spnum), P_E_Int(spnum), q_low, p_low, q_full, p_full);
    4655          63 :                             goto SpeedLoop3_exit;
    4656             :                         }
    4657          42 :                     } else if (bl >= q_full && spnum == nsp) {
    4658             :                         // Case 3:
    4659             :                         // Section 11.2.1.3.3 CASE 3 - Building load is equal to or greater than unit capacity at full stage
    4660          21 :                         std::tie(q, e, NetTotCoolCapBinned_2023, TotCoolElecPowerBinned_2023) =
    4661          42 :                             IntermediateCapacityAndPowerSEER2Case3(q_full, p_full, CoolingCapacityMax_2023, CoolingElecPowerMax_2023, n);
    4662          21 :                         goto SpeedLoop3_exit;
    4663             :                     }
    4664             :                 }
    4665         176 :             } else if (nsp == 1) {
    4666             :                 // Every calculation for each of the bins will be using only one speed i.e, Speed 1
    4667             :                 // Section 11.2.1.3.1 CASE 1 - Building load is no greater than unit capacity at low speed.
    4668             :                 // # Intermediate Capacity
    4669         176 :                 Real64 q_E_int = Q_E_Int(1);
    4670         176 :                 std::tie(N_Cq, M_Cq) = CapacityAdjustmentFactorsInCoolingModeSEER2(q_F_low, q_B_low, BN, q_B_full, q_A_full, q_E_int);
    4671             : 
    4672             :                 // # Intermediate Power
    4673         176 :                 Real64 p_E_int = P_E_Int(1);
    4674         176 :                 std::tie(N_CE, M_CE) = EnergyAdjustmentFactorsInCoolingModeSEER2(p_F_low, p_B_low, BN, p_B_full, p_A_full, p_E_int);
    4675             : 
    4676         176 :                 std::tie(q_int, p_int) = IntermediateSteadyStateCpacityAndPowerSEER2(q_E_int, M_Cq, p_E_int, M_CE, t);
    4677             : 
    4678             :                 // Section 11.2.1.3.1 CASE 1 - Building load is no greater than unit capacity at low speed.
    4679         176 :                 if (BuildingCoolingLoad_2023 <= q_low) {
    4680             :                     // Case 1:
    4681         154 :                     std::tie(q, e, NetTotCoolCapBinned_2023, TotCoolElecPowerBinned_2023) =
    4682         308 :                         IntermediateCapacityAndPowerSEER2Case1(state, bl, q_low, n, p_low, PLFFPLRCurveIndex(1));
    4683         154 :                     goto SpeedLoop3_exit;
    4684             : 
    4685          22 :                 } else if (BuildingCoolingLoad_2023 > q_low && BuildingCoolingLoad_2023 < q_full) {
    4686             :                     // Case 2:
    4687             :                     // Case 2A:
    4688           0 :                     if (bl < q_int) {
    4689             :                         // Section 11.2.1.3.2 CASE 2 - Building load can be matched by modulating the compressor speed between low speed & full
    4690             :                         // Speed
    4691           0 :                         std::tie(q, e, NetTotCoolCapBinned_2023, TotCoolElecPowerBinned_2023) =
    4692           0 :                             IntermediateCapacityAndPowerSEER2Case2A(p_int, q_int, q_low, bl, n, Q_E_Int(1), q_full, P_E_Int(1), p_full, p_low);
    4693           0 :                         goto SpeedLoop3_exit;
    4694           0 :                     } else if (bl < q_full) {
    4695             :                         // Section 11.2.1.3.2 CASE 2 - Building load can be matched by modulating the compressor speed between low speed &
    4696             :                         // full Speed
    4697           0 :                         std::tie(q, e, NetTotCoolCapBinned_2023, TotCoolElecPowerBinned_2023) =
    4698           0 :                             IntermediateCapacityAndPowerSEER2Case2B(p_int, bl, q_int, n, Q_E_Int(1), P_E_Int(1), q_low, p_low, q_full, p_full);
    4699           0 :                         goto SpeedLoop3_exit;
    4700             :                     }
    4701             :                     // Case 2B:
    4702          22 :                 } else if (BuildingCoolingLoad_2023 >= q_full) {
    4703             :                     // Case 3:
    4704             :                     // Section 11.2.1.3.3 CASE 3 - Building load is equal to or greater than unit capacity at full stage
    4705          22 :                     std::tie(q, e, NetTotCoolCapBinned_2023, TotCoolElecPowerBinned_2023) =
    4706          44 :                         IntermediateCapacityAndPowerSEER2Case3(q_full, p_full, CoolingCapacityMax_2023, CoolingElecPowerMax_2023, n);
    4707          22 :                     goto SpeedLoop3_exit;
    4708             :                 }
    4709             :             }
    4710           0 :         SpeedLoop3_exit:;
    4711         624 :             NetCoolingCapWeighted2_2023 += NetTotCoolCapBinned_2023;
    4712         624 :             TotCoolingElecPowerWeighted2_2023 += TotCoolElecPowerBinned_2023;
    4713             : 
    4714         624 :             q_sum += q;
    4715         624 :             e_sum += e;
    4716             :         }
    4717          78 :         if (e_sum > 0.0) {
    4718          78 :             SEER2_User = NetCoolingCapWeighted2_2023 / TotCoolingElecPowerWeighted2_2023;
    4719          78 :             SEER2_Standard = q_sum / e_sum; // Equation 11.66 (AHRI-2023)
    4720             :         }
    4721         156 :         return std::make_tuple(NetCoolingCapRatedMaxSpeed2023, SEER2_User, SEER2_Standard, EER2);
    4722          78 :     }
    4723             : 
    4724          66 :     std::tuple<Real64, Real64, Real64, Real64> TwoSpeedDXCoolingCoilSEER2(EnergyPlusData &state,
    4725             :                                                                           // int const nsp,
    4726             :                                                                           Array1A_int const CapFFlowCurveIndex,
    4727             :                                                                           Array1A<Real64> const RatedTotalCapacity,
    4728             :                                                                           Array1A_int const CapFTempCurveIndex,
    4729             :                                                                           Array1A<Real64> const FanPowerPerEvapAirFlowRateFromInput_2023,
    4730             :                                                                           Array1A<Real64> const RatedAirVolFlowRate,
    4731             :                                                                           Array1A_int const EIRFFlowCurveIndex,
    4732             :                                                                           Array1A<Real64> const RatedCOP,
    4733             :                                                                           Array1A_int EIRFTempCurveIndex,
    4734             :                                                                           Array1A_int const PLFFPLRCurveIndex)
    4735             :     {
    4736          66 :         int nsp = 2;
    4737          66 :         Real64 NetCoolingCapRatedMaxSpeed2023 = 0.0;
    4738          66 :         Real64 SEER2_User = 0.0;
    4739          66 :         Real64 SEER2_Standard = 0.0;
    4740          66 :         Real64 EER2 = 0.0;
    4741             : 
    4742          66 :         Real64 constexpr SF(1.10); // Sizing Factor as per AHRI Std 210/240-2023 | equation 11.68
    4743          66 :         Real64 constexpr V(1);     // V = 0.93 for Variable Speed Heat Pumps, otherwise V = 1.0
    4744             : 
    4745          66 :         Array1D<Real64> FanPowerPerEvapAirFlowRate_2023(nsp); // 2023 Fan power per air volume flow rate through the evaporator coil [W/(m3/s)]
    4746          66 :         Array1D<Real64> Q_A_Full(nsp);                        // Total cooling capacity at A2 test condition (High speed) | q_A_Full
    4747          66 :         Array1D<Real64> Q_B_Full(nsp);                        // Total cooling capacity at B2 test condition (High speed) | q_B_Full
    4748          66 :         Array1D<Real64> Q_B_Low(nsp);                         // Total cooling capacity at B1 test condition (Low speed) | q_B_Low
    4749          66 :         Array1D<Real64> Q_F_Low(nsp);                         // Total cooling capacity at F1 test condition (Low speed) | q_F_Low
    4750          66 :         Array1D<Real64> P_A_Full(nsp);                        // Outdoor Unit electric power at A2 test condition (High speed) | p_A_Full
    4751          66 :         Array1D<Real64> P_B_Full(nsp);                        // Outdoor Unit electric power at B2 test condition (High speed) | p_B_Full
    4752          66 :         Array1D<Real64> P_B_Low(nsp);                         // Outdoor Unit electric power at B1 test condition (Low speed) | p_B_Low
    4753          66 :         Array1D<Real64> P_F_Low(nsp);                         // Outdoor Unit electric power at F1 test condition | p_F_Low
    4754             : 
    4755          66 :         Real64 PartLoadFactorUser_2023(0.0); // part-load factor based on user-input PLF curve and C_D value that accounts
    4756             :         // for the cyclic degradation, [-]
    4757             : 
    4758             :         // binned cooling hours
    4759          66 :         Real64 BuildingCoolingLoad_2023(0.0);    // Building space cooling load corresponding to an outdoor bin temperature [W]
    4760          66 :         Real64 NetTotCoolCapBinned_2023(0.0);    // Net tot cooling cap corresponding to an outdoor bin temperature [W]
    4761          66 :         Real64 TotCoolElecPowerBinned_2023(0.0); // Total cooling electric power corresponding to an outdoor bin temperature [W]
    4762             : 
    4763             :         int spnum;
    4764          66 :         Array1D<Real64> TotCapFlowModFac(nsp);        // Total capacity modifier f(actual flow vs rated flow) for each speed [-]
    4765          66 :         Array1D<Real64> EIRFlowModFac(nsp);           // EIR modifier f(actual supply air flow vs rated flow) for each speed [-]
    4766          66 :         Array1D<Real64> NetCoolingCapRated_2023(nsp); // net cooling capacity at each speed
    4767             : 
    4768          66 :         Real64 FanPowerPerEvapAirFlowRate_2023_LS(0.0);
    4769          66 :         Real64 FanPowerPerEvapAirFlowRate_2023_HS(0.0);
    4770             :         // Low Stage
    4771          66 :         if (FanPowerPerEvapAirFlowRateFromInput_2023(2) <= 0.0) {
    4772           0 :             FanPowerPerEvapAirFlowRate_2023_LS = DefaultFanPowerPerEvapAirFlowRateSEER2;
    4773           0 :             FanPowerPerEvapAirFlowRate_2023(1) = DefaultFanPowerPerEvapAirFlowRateSEER2;
    4774             :         } else {
    4775          66 :             FanPowerPerEvapAirFlowRate_2023_LS = FanPowerPerEvapAirFlowRateFromInput_2023(2);
    4776          66 :             FanPowerPerEvapAirFlowRate_2023(1) = FanPowerPerEvapAirFlowRateFromInput_2023(2);
    4777             :         }
    4778             :         // High Stage
    4779          66 :         if (FanPowerPerEvapAirFlowRateFromInput_2023(1) <= 0.0) {
    4780           0 :             FanPowerPerEvapAirFlowRate_2023_HS = DefaultFanPowerPerEvapAirFlowRateSEER2;
    4781           0 :             FanPowerPerEvapAirFlowRate_2023(2) = DefaultFanPowerPerEvapAirFlowRateSEER2;
    4782             :         } else {
    4783          66 :             FanPowerPerEvapAirFlowRate_2023_HS = FanPowerPerEvapAirFlowRateFromInput_2023(1);
    4784          66 :             FanPowerPerEvapAirFlowRate_2023(2) = FanPowerPerEvapAirFlowRateFromInput_2023(1);
    4785             :         }
    4786             : 
    4787             :         // Calculate the capacity and power for each speed
    4788             :         // Low Stage
    4789          66 :         TotCapFlowModFac(1) = 1; // As per IO Reference there are no CCapFFlowCurve for Low Speed | Section ??
    4790          66 :         EIRFlowModFac(1) = 1;    // As per IO Reference there are no EIRFFlowCurve for Low Speed | Section ??
    4791             : 
    4792          66 :         Q_A_Full(1) = RatedTotalCapacity(2) *
    4793          66 :                           Curve::CurveValue(state, CapFTempCurveIndex(2), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestA2) *
    4794          66 :                           TotCapFlowModFac(1) -
    4795          66 :                       FanPowerPerEvapAirFlowRate_2023(1) * RatedAirVolFlowRate(2);
    4796             : 
    4797          66 :         Q_B_Full(1) = RatedTotalCapacity(2) *
    4798          66 :                           Curve::CurveValue(state, CapFTempCurveIndex(2), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestB2) *
    4799          66 :                           TotCapFlowModFac(1) -
    4800          66 :                       FanPowerPerEvapAirFlowRate_2023(1) * RatedAirVolFlowRate(2);
    4801             : 
    4802          66 :         Q_B_Low(1) = RatedTotalCapacity(2) *
    4803          66 :                          Curve::CurveValue(state, CapFTempCurveIndex(2), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestB1) *
    4804          66 :                          TotCapFlowModFac(1) -
    4805          66 :                      FanPowerPerEvapAirFlowRate_2023(1) * RatedAirVolFlowRate(2);
    4806             : 
    4807          66 :         Q_F_Low(1) = RatedTotalCapacity(2) *
    4808          66 :                          Curve::CurveValue(state, CapFTempCurveIndex(2), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestF1) *
    4809          66 :                          TotCapFlowModFac(1) -
    4810          66 :                      FanPowerPerEvapAirFlowRate_2023(1) * RatedAirVolFlowRate(2);
    4811             : 
    4812          66 :         if (RatedCOP(2) > 0.0) {
    4813         132 :             P_A_Full(1) =
    4814          66 :                 Q_A_Full(1) * EIRFlowModFac(1) *
    4815          66 :                     Curve::CurveValue(state, EIRFTempCurveIndex(2), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestA2) /
    4816          66 :                     RatedCOP(2) +
    4817          66 :                 FanPowerPerEvapAirFlowRate_2023(1) * RatedAirVolFlowRate(2);
    4818             : 
    4819         132 :             P_B_Full(1) =
    4820          66 :                 Q_B_Full(1) * EIRFlowModFac(1) *
    4821          66 :                     Curve::CurveValue(state, EIRFTempCurveIndex(2), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestB2) /
    4822          66 :                     RatedCOP(2) +
    4823          66 :                 FanPowerPerEvapAirFlowRate_2023(1) * RatedAirVolFlowRate(2);
    4824             : 
    4825         132 :             P_B_Low(1) =
    4826          66 :                 Q_B_Low(1) * EIRFlowModFac(1) *
    4827          66 :                     Curve::CurveValue(state, EIRFTempCurveIndex(2), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestB1) /
    4828          66 :                     RatedCOP(2) +
    4829          66 :                 FanPowerPerEvapAirFlowRate_2023(1) * RatedAirVolFlowRate(2);
    4830             : 
    4831          66 :             P_F_Low(1) =
    4832          66 :                 Q_F_Low(1) * EIRFlowModFac(1) *
    4833          66 :                     Curve::CurveValue(state, EIRFTempCurveIndex(2), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestF1) /
    4834          66 :                     RatedCOP(2) +
    4835          66 :                 FanPowerPerEvapAirFlowRate_2023(1) * RatedAirVolFlowRate(2);
    4836             :         }
    4837             :         // High Stage
    4838          66 :         TotCapFlowModFac(2) = Curve::CurveValue(state, CapFFlowCurveIndex(1), AirMassFlowRatioRated);
    4839          66 :         EIRFlowModFac(2) = Curve::CurveValue(state, EIRFFlowCurveIndex(1), AirMassFlowRatioRated);
    4840             : 
    4841          66 :         Q_A_Full(2) = RatedTotalCapacity(1) *
    4842          66 :                           Curve::CurveValue(state, CapFTempCurveIndex(1), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestA2) *
    4843          66 :                           TotCapFlowModFac(2) -
    4844          66 :                       FanPowerPerEvapAirFlowRate_2023(2) * RatedAirVolFlowRate(1);
    4845             : 
    4846          66 :         Q_B_Full(2) = RatedTotalCapacity(1) *
    4847          66 :                           Curve::CurveValue(state, CapFTempCurveIndex(1), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestB2) *
    4848          66 :                           TotCapFlowModFac(2) -
    4849          66 :                       FanPowerPerEvapAirFlowRate_2023(2) * RatedAirVolFlowRate(1);
    4850             : 
    4851          66 :         Q_B_Low(2) = RatedTotalCapacity(1) *
    4852          66 :                          Curve::CurveValue(state, CapFTempCurveIndex(1), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestB1) *
    4853          66 :                          TotCapFlowModFac(2) -
    4854          66 :                      FanPowerPerEvapAirFlowRate_2023(2) * RatedAirVolFlowRate(1);
    4855             : 
    4856          66 :         Q_F_Low(2) = RatedTotalCapacity(1) *
    4857          66 :                          Curve::CurveValue(state, CapFTempCurveIndex(1), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestF1) *
    4858          66 :                          TotCapFlowModFac(2) -
    4859          66 :                      FanPowerPerEvapAirFlowRate_2023(2) * RatedAirVolFlowRate(1);
    4860             : 
    4861          66 :         if (RatedCOP(1) > 0.0) {
    4862         132 :             P_A_Full(2) =
    4863          66 :                 Q_A_Full(2) * EIRFlowModFac(2) *
    4864          66 :                     Curve::CurveValue(state, EIRFTempCurveIndex(1), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestA2) /
    4865          66 :                     RatedCOP(1) +
    4866          66 :                 FanPowerPerEvapAirFlowRate_2023(2) * RatedAirVolFlowRate(1);
    4867             : 
    4868         132 :             P_B_Full(2) =
    4869          66 :                 Q_B_Full(2) * EIRFlowModFac(2) *
    4870          66 :                     Curve::CurveValue(state, EIRFTempCurveIndex(1), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestB2) /
    4871          66 :                     RatedCOP(1) +
    4872          66 :                 FanPowerPerEvapAirFlowRate_2023(2) * RatedAirVolFlowRate(1);
    4873             : 
    4874         132 :             P_B_Low(2) =
    4875          66 :                 Q_B_Low(2) * EIRFlowModFac(2) *
    4876          66 :                     Curve::CurveValue(state, EIRFTempCurveIndex(1), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestB1) /
    4877          66 :                     RatedCOP(1) +
    4878          66 :                 FanPowerPerEvapAirFlowRate_2023(2) * RatedAirVolFlowRate(1);
    4879             : 
    4880          66 :             P_F_Low(2) =
    4881          66 :                 Q_F_Low(2) * EIRFlowModFac(2) *
    4882          66 :                     Curve::CurveValue(state, EIRFTempCurveIndex(1), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestF1) /
    4883          66 :                     RatedCOP(1) +
    4884          66 :                 FanPowerPerEvapAirFlowRate_2023(2) * RatedAirVolFlowRate(1);
    4885             :         }
    4886             : 
    4887             :         // Standard Rating cooling (net) capacity calculations:
    4888          66 :         NetCoolingCapRated_2023(2) = Q_A_Full(2);
    4889          66 :         NetCoolingCapRatedMaxSpeed2023 = NetCoolingCapRated_2023(2);
    4890             : 
    4891             :         // EER2 calculation |  Section 3.1.16(AHRI 210/240 2023)
    4892             :         // A ratio of the cooling capacity in Btu/h to the Total Power in watts at AFull test conditions and expressed in Btu/(W-h)
    4893             :         // In case of Coil:Cooling:DX:TwoSpeed coil we're picking the High Speed for the same.
    4894          66 :         EER2 = Q_A_Full(2) / P_A_Full(2);
    4895             : 
    4896             :         // Calculate the SEER value based on contribution of each outdoor air bin temperature
    4897          66 :         Real64 q_sum = 0.0;
    4898          66 :         Real64 e_sum = 0.0;
    4899          66 :         Real64 NetCoolingCapWeighted2_2023 = 0.0;
    4900          66 :         Real64 TotCoolingElecPowerWeighted2_2023 = 0.0;
    4901             : 
    4902          66 :         Real64 CoolingCapacityMax_2023(0.0);
    4903          66 :         Real64 CoolingElecPowerMax_2023(0.0);
    4904             : 
    4905          66 :         Real64 q_low(0.0);
    4906          66 :         Real64 p_low(0.0);
    4907          66 :         Real64 q_full(0.0);
    4908          66 :         Real64 p_full(0.0);
    4909             : 
    4910          66 :         Real64 SEER2_USER_C2(0.0);
    4911          66 :         Real64 SEER2_STANDARD_C2(0.0);
    4912             : 
    4913          66 :         q_sum = 0.0;
    4914          66 :         e_sum = 0.0;
    4915          66 :         NetCoolingCapWeighted2_2023 = 0.0;
    4916          66 :         TotCoolingElecPowerWeighted2_2023 = 0.0;
    4917             : 
    4918         594 :         for (int BN = 0; BN < NumOfOATempBins; ++BN) {
    4919             :             // Equation 11.67 (AHRI-2023)
    4920         528 :             BuildingCoolingLoad_2023 = ((OutdoorBinTemperatureSEER[BN] - 18.3) / (35.0 - 18.3) * (Q_A_Full(nsp) / SF)) * V;
    4921             : 
    4922             :             // determine the speed number
    4923         528 :             CoolingCapacityMax_2023 =
    4924         528 :                 Q_B_Full(nsp) + ((Q_A_Full(nsp) - Q_B_Full(nsp)) / (OutdoorCoilInletAirDryBulbTempTestA2 - OutdoorCoilInletAirDryBulbTempTestB2)) *
    4925         528 :                                     (OutdoorBinTemperatureSEER[BN] - OutdoorCoilInletAirDryBulbTempTestB2);
    4926         528 :             CoolingElecPowerMax_2023 =
    4927         528 :                 P_B_Full(nsp) + ((P_A_Full(nsp) - P_B_Full(nsp)) / (OutdoorCoilInletAirDryBulbTempTestA2 - OutdoorCoilInletAirDryBulbTempTestB2)) *
    4928         528 :                                     (OutdoorBinTemperatureSEER[BN] - OutdoorCoilInletAirDryBulbTempTestB2);
    4929             : 
    4930             :             // LOW STAGE :
    4931             :             // The calculated Low Stage system capacity rate at each bin temperature shall be calculated by Equation 11.69
    4932             :             // Equation 11.69 (AHRI-2023)
    4933         528 :             q_low = Q_F_Low(1) + ((Q_B_Low(1) - Q_F_Low(1)) / (OutdoorCoilInletAirDryBulbTempTestB1 - OutdoorCoilInletAirDryBulbTempTestF1)) *
    4934         528 :                                      (OutdoorBinTemperatureSEER[BN] - OutdoorCoilInletAirDryBulbTempTestF1);
    4935             : 
    4936             :             // The calculated Low Stage energy consumption at each bin temperature shall be calculated by Equation 11.70
    4937             :             // Equation 11.70 (AHRI-2023)
    4938         528 :             p_low = P_F_Low(1) + ((P_B_Low(1) - P_F_Low(1)) / (OutdoorCoilInletAirDryBulbTempTestB1 - OutdoorCoilInletAirDryBulbTempTestF1)) *
    4939         528 :                                      (OutdoorBinTemperatureSEER[BN] - OutdoorCoilInletAirDryBulbTempTestF1);
    4940             : 
    4941             :             // HIGH STAGE :
    4942             :             // The calculated Full Stage system capacity at each bin temperature shall be calculated by Equation 11.71.
    4943             :             // Equation 11.71 (AHRI-2023)
    4944         528 :             q_full = Q_B_Full(2) + ((Q_A_Full(2) - Q_B_Full(2)) / (OutdoorCoilInletAirDryBulbTempTestA2 - OutdoorCoilInletAirDryBulbTempTestB2)) *
    4945         528 :                                        (OutdoorBinTemperatureSEER[BN] - OutdoorCoilInletAirDryBulbTempTestB2);
    4946             : 
    4947             :             // The calculated Full Stage energy consumption at each bin temperature shall be calculated by Equation 11.72.
    4948             :             // Equation 11.72 (AHRI-2023)
    4949         528 :             p_full = P_B_Full(2) + ((P_A_Full(2) - P_B_Full(2)) / (OutdoorCoilInletAirDryBulbTempTestA2 - OutdoorCoilInletAirDryBulbTempTestB2)) *
    4950         528 :                                        (OutdoorBinTemperatureSEER[BN] - OutdoorCoilInletAirDryBulbTempTestB2);
    4951             : 
    4952         528 :             Real64 bl = BuildingCoolingLoad_2023;
    4953         528 :             Real64 t = OutdoorBinTemperatureSEER[BN];
    4954         528 :             Real64 n = CoolFracBinHoursAtOutdoorBinTemp[BN];
    4955         528 :             Real64 q(0.0);
    4956         528 :             Real64 e(0.0);
    4957             :             // Section 6.1.3.1.2 | For Two-capacity Systems, if the optional CLow and DLow tests are not performed, a default value of 0.20 shall
    4958             :             // be used for the Low Stage cooling Degradation Coefficient, cd_low. In this case, if using default value for cd_low, use default
    4959             :             // value for cd_full. For Two-capacity Systems that lock out low capacity operation at high outdoor temperatures, if the optional
    4960             :             // CFull and DFull tests are not performed, the default value for Full Stage shall be the value used for Low Stage.
    4961         528 :             Real64 CyclicDegradationCoefficient(0.20);
    4962         528 :             if (bl < q_low) {
    4963             :                 // Case I. Building load is less than Low Stage capacity, BL(tj) < qLow(tj). Calculate total bin capacity by using Equation 11.73
    4964             :                 // and total bin energy by using Equation 11.74.
    4965         138 :                 Real64 clf_low = bl / q_low; // Equation 11.75 (AHRI-2023)
    4966             : 
    4967             :                 // SEER2 USER
    4968         138 :                 PartLoadFactorUser_2023 = Curve::CurveValue(state, PLFFPLRCurveIndex(1), clf_low);
    4969         138 :                 NetTotCoolCapBinned_2023 = clf_low * q_low * CoolFracBinHoursAtOutdoorBinTemp[BN];
    4970         138 :                 TotCoolElecPowerBinned_2023 = (clf_low / PartLoadFactorUser_2023) * p_low * CoolFracBinHoursAtOutdoorBinTemp[BN];
    4971             : 
    4972             :                 // SEER2 STANDARD
    4973         138 :                 Real64 plf_low = 1.0 - CyclicDegradationCoefficient * (1.0 - clf_low); // Equation 11.76 (AHRI-2023)
    4974         138 :                 q = clf_low * q_low * n;                                               // Total Bin Capacity, Equation 11.73 (AHRI-2023)
    4975         138 :                 e = clf_low * p_low * n / plf_low;                                     // Total Bin Energy, Equation 11.74 (AHRI-2023)
    4976             : 
    4977         390 :             } else if (q_low < bl && bl < q_full) {
    4978             :                 // Case II. Building load is greater than the Low Stage capacity, but less than the Full Stage capacity, qLow(tj) < BL(tj) <
    4979             :                 // qFull(tj) and the unit cycles between "Low Stage" operation and "Full Stage" operation. Calculate total bin capacity by using
    4980             :                 // Equation 11.79 and total bin energy by using Equation 11.80
    4981             : 
    4982             :                 // Prerequisites for Equations 11.79 & 11.80
    4983         324 :                 Real64 clf_low_c2 = (q_full - bl) / (q_full - q_low); // Equation 11.81 (AHRI-2023)
    4984         324 :                 Real64 clf_full_c2 = 1 - clf_low_c2;                  // Equation 11.82 (AHRI-2023)
    4985             : 
    4986             :                 // SEER2 USER
    4987             :                 // Real64 LoadFactor_Low_2023 = min(1.0, (Q_E_Int(spnum) - q_low) / (q_full - q_low));
    4988             :                 // LoadFactorQEnt_2023 = max(0.0, LoadFactorQEnt_2023);
    4989             :                 // TODO:BPS : Visit again to figure out if there is a way to leverage Coil Data/Curve to get this.
    4990         324 :                 Real64 NetTotCoolCapBinned_2023_c2 = ((clf_low_c2 * q_low) + (clf_full_c2 * q_full)) * CoolFracBinHoursAtOutdoorBinTemp[BN];
    4991         324 :                 Real64 TotCoolElecPowerBinned_2023_c2 = ((clf_low_c2 * p_low) + (clf_full_c2 * p_full)) * CoolFracBinHoursAtOutdoorBinTemp[BN];
    4992             : 
    4993             :                 // SEER2 STANDARD
    4994         324 :                 Real64 q_c2 = ((clf_low_c2 * q_low) + (clf_full_c2 * q_full)) * n; // Total Bin Capacity, Equation 11.79 (AHRI-2023)
    4995         324 :                 Real64 e_c2 = ((clf_low_c2 * p_low) + (clf_full_c2 * p_full)) * n; // Total Bin Energy, Equation 11.80 (AHRI-2023)
    4996             : 
    4997             :                 // Case III. Building load is greater than the Low Stage capacity, but less than the Full Stage capacity, qLow(tj) < BL(tj) <
    4998             :                 // qFull(tj) and the unit cycles between "off" and "Full Stage" operation.Calculate total bin capacity by using Equation 11.83 and
    4999             :                 // total bin energy by using Equation 11.84
    5000             : 
    5001             :                 // Prerequisites for Equations 11.83 & 11.84
    5002             :                 // If the optional c_full and d_full Tests (see Table 7 AHRI-2023) are not conducted, set ccd_full equal to the lower of a) the
    5003             :                 // ccd_low value calculated as per Equation 11.77 or b) the default value identified in Section 6.1.3.1
    5004         324 :                 Real64 ccd_full_c3 = CyclicDegradationCoefficient;
    5005         324 :                 Real64 clf_full_c3 = bl / q_full; // Equation 11.85 (AHRI-2023)
    5006             : 
    5007             :                 // SEER2 USER
    5008         324 :                 Real64 PartLoadFactorUser_2023_c3 = Curve::CurveValue(state, PLFFPLRCurveIndex(1), clf_full_c3);
    5009         324 :                 Real64 NetTotCoolCapBinned_2023_c3 = clf_full_c3 * q_full * CoolFracBinHoursAtOutdoorBinTemp[BN];
    5010         324 :                 Real64 TotCoolElecPowerBinned_2023_c3 = (clf_full_c3 / PartLoadFactorUser_2023_c3) * p_full * CoolFracBinHoursAtOutdoorBinTemp[BN];
    5011             : 
    5012             :                 // The code below calculates coil Capacity and Energy for the case when a coil support for 'locked out'
    5013             :                 // of the low stage on the compressor when outdoor air is very hot.  In this case, the compressor will cycle
    5014             :                 // directly from off to the High Stage, bypassing the low stage.
    5015             :                 // EnergyPlus DX Cooling Coil data does not include a property for indicating if the coil supports this behavior,
    5016             :                 // so these values are not currently used.
    5017             : 
    5018             :                 // SEER2 STANDARD
    5019         324 :                 Real64 plf_full_c3 = 1 - (ccd_full_c3 * (1 - clf_full_c3)); // Equation 11.86 (AHRI-2023)
    5020         324 :                 Real64 q_c3 = clf_full_c3 * q_full * n;                     // Total Bin Capacity, Equation  11.83 (AHRI-2023)
    5021         324 :                 Real64 e_c3 = (clf_full_c3 * p_full * n) / plf_full_c3;     // Total Bin Energy, Equation 11.84 (AHRI-2023)
    5022             : 
    5023             :                 // SEER2 USER
    5024         324 :                 NetTotCoolCapBinned_2023 = NetTotCoolCapBinned_2023_c2;
    5025         324 :                 TotCoolElecPowerBinned_2023 = TotCoolElecPowerBinned_2023_c2;
    5026             :                 // SEER2 STANDARD
    5027         324 :                 q = q_c2;
    5028         324 :                 e = e_c2;
    5029             : 
    5030         390 :             } else if (bl >= q_full) {
    5031             :                 // Case IV. Building load is greater than or equal to the unit capacity, BL(tj) >= qFull(tj).Calculate total bin capacity by using
    5032             :                 // Equation 11.88 and total bin energy by using Equation 11.89.
    5033             :                 // Section 11.2.1.3.3 CASE 4 - Building load is equal to or greater than unit capacity at full stage
    5034             : 
    5035             :                 // SEER2 USER
    5036          66 :                 NetTotCoolCapBinned_2023 = CoolingCapacityMax_2023 * CoolFracBinHoursAtOutdoorBinTemp[BN];
    5037          66 :                 TotCoolElecPowerBinned_2023 = CoolingElecPowerMax_2023 * CoolFracBinHoursAtOutdoorBinTemp[BN];
    5038             : 
    5039             :                 // SEER2 STANDARD
    5040          66 :                 q = q_full * n; // Equation 11.88 (AHRI-2023)
    5041          66 :                 e = p_full * n; // Equation 11.89 (AHRI-2023)
    5042             :             }
    5043             : 
    5044             :             // SEER2 USER | Sum up Bin Capacity and Bin Energy
    5045         528 :             NetCoolingCapWeighted2_2023 += NetTotCoolCapBinned_2023;
    5046         528 :             TotCoolingElecPowerWeighted2_2023 += TotCoolElecPowerBinned_2023;
    5047             : 
    5048             :             // SEER2 STANDARD | Sum up Bin Capacity and Bin Energy
    5049         528 :             q_sum += q;
    5050         528 :             e_sum += e;
    5051             :         }
    5052             : 
    5053          66 :         SEER2_User = 0.0;
    5054          66 :         SEER2_Standard = 0.0;
    5055          66 :         if (e_sum > 0.0) {
    5056          66 :             SEER2_User = NetCoolingCapWeighted2_2023 / TotCoolingElecPowerWeighted2_2023;
    5057          66 :             SEER2_Standard = q_sum / e_sum; // Equation 11.66 (AHRI-2023)
    5058             :         }
    5059             : 
    5060         132 :         return std::make_tuple(NetCoolingCapRatedMaxSpeed2023, SEER2_User, SEER2_Standard, EER2);
    5061          66 :     }
    5062             : 
    5063          49 :     std::tuple<Real64, Real64, Real64, Real64> MultiSpeedDXCoolingCoilSEER2(EnergyPlusData &state,
    5064             :                                                                             int const nsp,
    5065             :                                                                             Array1A_int const CapFFlowCurveIndex,
    5066             :                                                                             Array1A<Real64> const RatedTotalCapacity,
    5067             :                                                                             Array1A_int const CapFTempCurveIndex,
    5068             :                                                                             Array1A<Real64> const FanPowerPerEvapAirFlowRateFromInput_2023,
    5069             :                                                                             Array1A<Real64> const RatedAirVolFlowRate,
    5070             :                                                                             Array1A_int const EIRFFlowCurveIndex,
    5071             :                                                                             Array1A<Real64> const RatedCOP,
    5072             :                                                                             Array1A_int EIRFTempCurveIndex,
    5073             :                                                                             Array1A_int const PLFFPLRCurveIndex)
    5074             :     {
    5075             :         // Intermediate values calculated from the inputs in the idf file
    5076             :         // ANSI/AHRI 210/240 Std. 2023
    5077          49 :         Array1D<Real64> FanPowerPerEvapAirFlowRate_2023(nsp); // 2023 Fan power per air volume flow rate through the evaporator coil [W/(m3/s)]
    5078          49 :         Array1D<Real64> Q_A_Full(nsp);                        // Total cooling capacity at A2 test condition (High speed) | q_A_Full
    5079          49 :         Array1D<Real64> Q_B_Full(nsp);                        // Total cooling capacity at B2 test condition (High speed) | q_B_Full
    5080          49 :         Array1D<Real64> Q_B_Low(nsp);                         // Total cooling capacity at B1 test condition (Low speed) | q_B_Low
    5081          49 :         Array1D<Real64> Q_F_Low(nsp);                         // Total cooling capacity at F1 test condition (Low speed) | q_F_Low
    5082          49 :         Array1D<Real64> Q_E_Int(nsp);                         // Total cooling capacity at Eint (Ev) test condition | q_E_Int
    5083          49 :         Array1D<Real64> P_A_Full(nsp);                        // Outdoor Unit electric power at A2 test condition (High speed) | p_A_Full
    5084          49 :         Array1D<Real64> P_B_Full(nsp);                        // Outdoor Unit electric power at B2 test condition (High speed) | p_B_Full
    5085          49 :         Array1D<Real64> P_B_Low(nsp);                         // Outdoor Unit electric power at B1 test condition (Low speed) | p_B_Low
    5086          49 :         Array1D<Real64> P_F_Low(nsp);                         // Outdoor Unit electric power at F1 test condition | p_F_Low
    5087          49 :         Array1D<Real64> P_E_Int(nsp);                         // Outdoor Unit electric power at Eint (Ev) test conditon | p_E_Int
    5088             : 
    5089          49 :         Real64 PartLoadFactorUser_2023(
    5090             :             0.0); // part-load factor based on user-input PLF curve and C_D value that accounts for the cyclic degradation, [-]
    5091             : 
    5092          49 :         Real64 NetCoolingCapWeighted_2023(0.0);         // net tot cooling cap weighted by the fraction of the binned cooling hours [W]
    5093          49 :         Real64 TotCoolingElecPowerWeighted_2023(0.0);   // net total cooling electric power input weighted by the fraction of the temperature bins
    5094          49 :         Real64 TotCoolingElecPowerWeightedDefault(0.0); // net total cooling electric power input weighted by the fraction of the temperature bins
    5095             :                                                         // from AHRI 201/240 default PLF curve and C_D value,
    5096             : 
    5097             :         // binned cooling hours
    5098          49 :         Real64 BuildingCoolingLoad_2023(0.0);    // Building space cooling load corresponding to an outdoor bin temperature [W]
    5099          49 :         Real64 NetTotCoolCapBinned_2023(0.0);    // Net tot cooling cap corresponding to an outdoor bin temperature [W]
    5100          49 :         Real64 TotCoolElecPowerBinned_2023(0.0); // Total cooling electric power corresponding to an outdoor bin temperature [W]
    5101             : 
    5102             :         int spnum;                                    // compressor speed number
    5103          49 :         Array1D<Real64> TotCapFlowModFac(nsp);        // Total capacity modifier f(actual flow vs rated flow) for each speed [-]
    5104          49 :         Array1D<Real64> EIRFlowModFac(nsp);           // EIR modifier f(actual supply air flow vs rated flow) for each speed [-]
    5105          49 :         Array1D<Real64> NetCoolingCapRated_2023(nsp); // net cooling capacity at each speed
    5106          49 :         Real64 q_low(0.0);                            // cooling capacity of Mult-speed DX coil at lower speed, [W]
    5107          49 :         Real64 q_full(0.0);                           // cooling capacity of Mult-speed DX coil at higher speed, [W]
    5108          49 :         Real64 p_low(0.0);                            // outdoor unit electric power input at low speed, [W]
    5109          49 :         Real64 p_full(0.0);                           // outdoor unit electric power input at high speed, [W]
    5110          49 :         Real64 CoolingCapacityMax_2023(0.0);          // cooling capacity of Mult-speed DX coil at max speed, [W]
    5111          49 :         Real64 CoolingElecPowerMax_2023(0.0);         // outdoor unit electric power input at Max speed, [W]
    5112             : 
    5113          49 :         Real64 constexpr SF(1.10); // Sizing Factor as per AHRI Std 210/240-2023 | equation 11.68
    5114             :         // Real64 constexpr V(1);     // V = 0.93 for Variable Speed Heat Pumps, otherwise V = 1.0
    5115          49 :         Real64 constexpr V(0.93); // V = 0.93 for Variable Speed Heat Pumps, otherwise V = 1.0
    5116             : 
    5117          49 :         Real64 NetCoolingCapRatedMaxSpeed2023 = 0.0;
    5118          49 :         Real64 SEER2_User = 0.0;
    5119          49 :         Real64 SEER2_Standard = 0.0;
    5120          49 :         Real64 EER2 = 0.0;
    5121             : 
    5122          49 :         NetCoolingCapWeighted_2023 = 0.0;
    5123          49 :         TotCoolingElecPowerWeighted_2023 = 0.0;
    5124          49 :         TotCoolingElecPowerWeightedDefault = 0.0;
    5125             : 
    5126         162 :         for (int spnum = 1; spnum <= nsp; ++spnum) {
    5127         113 :             FanPowerPerEvapAirFlowRate_2023(spnum) = 0.0;
    5128         113 :             if (FanPowerPerEvapAirFlowRateFromInput_2023(spnum) <= 0.0) {
    5129           0 :                 FanPowerPerEvapAirFlowRate_2023(spnum) = DefaultFanPowerPerEvapAirFlowRateSEER2;
    5130             :             } else {
    5131         113 :                 FanPowerPerEvapAirFlowRate_2023(spnum) = FanPowerPerEvapAirFlowRateFromInput_2023(spnum);
    5132             :             }
    5133             :         }
    5134             : 
    5135             :         // Calculate the capacity and power for each speed
    5136         162 :         for (spnum = 1; spnum <= nsp; ++spnum) {
    5137         113 :             TotCapFlowModFac(spnum) = Curve::CurveValue(state, CapFFlowCurveIndex(spnum), AirMassFlowRatioRated);
    5138             : 
    5139         226 :             Q_A_Full(spnum) =
    5140         113 :                 RatedTotalCapacity(spnum) *
    5141         113 :                     Curve::CurveValue(state, CapFTempCurveIndex(spnum), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestA2) *
    5142         113 :                     TotCapFlowModFac(spnum) -
    5143         113 :                 FanPowerPerEvapAirFlowRate_2023(spnum) * RatedAirVolFlowRate(spnum);
    5144             : 
    5145         226 :             Q_B_Full(spnum) =
    5146         113 :                 RatedTotalCapacity(spnum) *
    5147         113 :                     Curve::CurveValue(state, CapFTempCurveIndex(spnum), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestB2) *
    5148         113 :                     TotCapFlowModFac(spnum) -
    5149         113 :                 FanPowerPerEvapAirFlowRate_2023(spnum) * RatedAirVolFlowRate(spnum);
    5150             : 
    5151         226 :             Q_B_Low(spnum) =
    5152         113 :                 RatedTotalCapacity(spnum) *
    5153         113 :                     Curve::CurveValue(state, CapFTempCurveIndex(spnum), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestB1) *
    5154         113 :                     TotCapFlowModFac(spnum) -
    5155         113 :                 FanPowerPerEvapAirFlowRate_2023(spnum) * RatedAirVolFlowRate(spnum);
    5156             : 
    5157         226 :             Q_F_Low(spnum) =
    5158         113 :                 RatedTotalCapacity(spnum) *
    5159         113 :                     Curve::CurveValue(state, CapFTempCurveIndex(spnum), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestF1) *
    5160         113 :                     TotCapFlowModFac(spnum) -
    5161         113 :                 FanPowerPerEvapAirFlowRate_2023(spnum) * RatedAirVolFlowRate(spnum);
    5162             : 
    5163         226 :             Q_E_Int(spnum) =
    5164         113 :                 RatedTotalCapacity(spnum) *
    5165         113 :                     Curve::CurveValue(state, CapFTempCurveIndex(spnum), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestEint) *
    5166         113 :                     TotCapFlowModFac(spnum) -
    5167         113 :                 FanPowerPerEvapAirFlowRate_2023(spnum) * RatedAirVolFlowRate(spnum);
    5168             : 
    5169         113 :             EIRFlowModFac(spnum) = Curve::CurveValue(state, EIRFFlowCurveIndex(spnum), AirMassFlowRatioRated);
    5170         113 :             if (RatedCOP(spnum) > 0.0) {
    5171         226 :                 P_A_Full(spnum) =
    5172         113 :                     Q_A_Full(spnum) * EIRFlowModFac(spnum) *
    5173         226 :                         Curve::CurveValue(
    5174         113 :                             state, EIRFTempCurveIndex(spnum), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestA2) /
    5175         113 :                         RatedCOP(spnum) +
    5176         113 :                     FanPowerPerEvapAirFlowRate_2023(spnum) * RatedAirVolFlowRate(spnum);
    5177             : 
    5178         226 :                 P_B_Full(spnum) =
    5179         113 :                     Q_B_Full(spnum) * EIRFlowModFac(spnum) *
    5180         226 :                         Curve::CurveValue(
    5181         113 :                             state, EIRFTempCurveIndex(spnum), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestB2) /
    5182         113 :                         RatedCOP(spnum) +
    5183         113 :                     FanPowerPerEvapAirFlowRate_2023(spnum) * RatedAirVolFlowRate(spnum);
    5184             : 
    5185         113 :                 P_B_Low(spnum) = Q_B_Low(spnum) * EIRFlowModFac(spnum) *
    5186         226 :                                      Curve::CurveValue(
    5187         113 :                                          state, EIRFTempCurveIndex(spnum), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestB1) /
    5188         113 :                                      RatedCOP(spnum) +
    5189         113 :                                  FanPowerPerEvapAirFlowRate_2023(spnum) * RatedAirVolFlowRate(spnum);
    5190             : 
    5191         113 :                 P_F_Low(spnum) = Q_F_Low(spnum) * EIRFlowModFac(spnum) *
    5192         226 :                                      Curve::CurveValue(
    5193         113 :                                          state, EIRFTempCurveIndex(spnum), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestF1) /
    5194         113 :                                      RatedCOP(spnum) +
    5195         113 :                                  FanPowerPerEvapAirFlowRate_2023(spnum) * RatedAirVolFlowRate(spnum);
    5196             : 
    5197         113 :                 P_E_Int(spnum) =
    5198         113 :                     Q_E_Int(spnum) * EIRFlowModFac(spnum) *
    5199         226 :                         Curve::CurveValue(
    5200         113 :                             state, EIRFTempCurveIndex(spnum), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestEint) /
    5201         113 :                         RatedCOP(spnum) +
    5202         113 :                     FanPowerPerEvapAirFlowRate_2023(spnum) * RatedAirVolFlowRate(spnum);
    5203             :             }
    5204             :         }
    5205             :         // Standard Rating cooling (net) capacity calculations:
    5206          49 :         NetCoolingCapRated_2023(nsp) = Q_A_Full(nsp);
    5207          49 :         NetCoolingCapRatedMaxSpeed2023 = NetCoolingCapRated_2023(nsp);
    5208             : 
    5209             :         // EER2 calculation |  Section 3.1.16(AHRI 210/240 2023)
    5210             :         // A ratio of the cooling capacity in Btu/h to the Total Power in watts at AFull test conditions and expressed in Btu/(W-h)
    5211             :         // In case of Coil:Cooling:DX:MultiSpeed coil we're picking the max speed.
    5212          49 :         EER2 = Q_A_Full(nsp) / P_A_Full(nsp);
    5213             : 
    5214             :         // Calculate the SEER value based on contribution of each outdoor air bin temperature
    5215          49 :         Real64 q_sum = 0.0;
    5216          49 :         Real64 e_sum = 0.0;
    5217          49 :         Real64 NetCoolingCapWeighted2_2023 = 0.0;
    5218          49 :         Real64 TotCoolingElecPowerWeighted2_2023 = 0.0;
    5219         441 :         for (int BN = 0; BN < NumOfOATempBins; ++BN) {
    5220             :             // Equation 11.67 (AHRI-2023)
    5221         392 :             BuildingCoolingLoad_2023 = ((OutdoorBinTemperatureSEER[BN] - 18.3) / (35.0 - 18.3) * (Q_A_Full(nsp) / SF)) * V;
    5222             :             // determine the speed number
    5223         392 :             CoolingCapacityMax_2023 =
    5224         392 :                 Q_B_Full(nsp) + ((Q_A_Full(nsp) - Q_B_Full(nsp)) / (OutdoorCoilInletAirDryBulbTempTestA2 - OutdoorCoilInletAirDryBulbTempTestB2)) *
    5225         392 :                                     (OutdoorBinTemperatureSEER[BN] - OutdoorCoilInletAirDryBulbTempTestB2);
    5226         392 :             CoolingElecPowerMax_2023 =
    5227         392 :                 P_B_Full(nsp) + ((P_A_Full(nsp) - P_B_Full(nsp)) / (OutdoorCoilInletAirDryBulbTempTestA2 - OutdoorCoilInletAirDryBulbTempTestB2)) *
    5228         392 :                                     (OutdoorBinTemperatureSEER[BN] - OutdoorCoilInletAirDryBulbTempTestB2);
    5229             : 
    5230             :             // Equation 11.69 (AHRI-2023)
    5231         392 :             q_low = Q_F_Low(1) + ((Q_B_Low(1) - Q_F_Low(1)) / (OutdoorCoilInletAirDryBulbTempTestB1 - OutdoorCoilInletAirDryBulbTempTestF1)) *
    5232         392 :                                      (OutdoorBinTemperatureSEER[BN] - OutdoorCoilInletAirDryBulbTempTestF1);
    5233             :             // Equation 11.70 (AHRI-2023)
    5234         392 :             p_low = P_F_Low(1) + ((P_B_Low(1) - P_F_Low(1)) / (OutdoorCoilInletAirDryBulbTempTestB1 - OutdoorCoilInletAirDryBulbTempTestF1)) *
    5235         392 :                                      (OutdoorBinTemperatureSEER[BN] - OutdoorCoilInletAirDryBulbTempTestF1);
    5236             :             // Equation 11.71 (AHRI-2023)
    5237         392 :             q_full =
    5238         392 :                 Q_B_Full(nsp) + ((Q_A_Full(nsp) - Q_B_Full(nsp)) / (OutdoorCoilInletAirDryBulbTempTestA2 - OutdoorCoilInletAirDryBulbTempTestB2)) *
    5239         392 :                                     (OutdoorBinTemperatureSEER[BN] - OutdoorCoilInletAirDryBulbTempTestB2);
    5240             :             // Equation 11.72 (AHRI-2023)
    5241         392 :             p_full =
    5242         392 :                 P_B_Full(nsp) + ((P_A_Full(nsp) - P_B_Full(nsp)) / (OutdoorCoilInletAirDryBulbTempTestA2 - OutdoorCoilInletAirDryBulbTempTestB2)) *
    5243         392 :                                     (OutdoorBinTemperatureSEER[BN] - OutdoorCoilInletAirDryBulbTempTestB2);
    5244             : 
    5245         392 :             Real64 q(0.0);
    5246         392 :             Real64 e(0.0);
    5247         392 :             Real64 N_Cq(0.0);
    5248         392 :             Real64 M_Cq(0.0);
    5249         392 :             Real64 N_CE(0.0);
    5250         392 :             Real64 M_CE(0.0);
    5251         392 :             Real64 q_int(0.0);
    5252         392 :             Real64 p_int(0.0);
    5253         392 :             Real64 t = OutdoorBinTemperatureSEER[BN];
    5254         392 :             Real64 n = CoolFracBinHoursAtOutdoorBinTemp[BN];
    5255         392 :             Real64 bl = BuildingCoolingLoad_2023;
    5256         530 :             for (spnum = 1; spnum <= nsp; ++spnum) {
    5257             :                 // # Intermediate Capacity
    5258         530 :                 Real64 q_A_full = Q_A_Full(spnum);
    5259         530 :                 Real64 q_B_full = Q_B_Full(spnum);
    5260         530 :                 Real64 q_B_low = Q_B_Low(spnum);
    5261         530 :                 Real64 q_F_low = Q_F_Low(spnum);
    5262         530 :                 Real64 q_E_int = Q_E_Int(spnum);
    5263             : 
    5264         530 :                 std::tie(N_Cq, M_Cq) = CapacityAdjustmentFactorsInCoolingModeSEER2(q_F_low, q_B_low, BN, q_B_full, q_A_full, q_E_int);
    5265             : 
    5266             :                 // # Intermediate Power
    5267         530 :                 Real64 p_A_full = P_A_Full(spnum);
    5268         530 :                 Real64 p_B_full = P_B_Full(spnum);
    5269         530 :                 Real64 p_B_low = P_B_Low(spnum);
    5270         530 :                 Real64 p_F_low = P_F_Low(spnum);
    5271         530 :                 Real64 p_E_int = P_E_Int(spnum);
    5272             : 
    5273         530 :                 std::tie(N_CE, M_CE) = EnergyAdjustmentFactorsInCoolingModeSEER2(p_F_low, p_B_low, BN, p_B_full, p_A_full, p_E_int);
    5274             : 
    5275         530 :                 std::tie(q_int, p_int) = IntermediateSteadyStateCpacityAndPowerSEER2(q_E_int, M_Cq, p_E_int, M_CE, t);
    5276             : 
    5277             :                 // Section 11.2.1.3.1 CASE 1 - Building load is no greater than unit capacity at low speed.
    5278         530 :                 if (bl <= q_low) {
    5279         192 :                     std::tie(q, e, NetTotCoolCapBinned_2023, TotCoolElecPowerBinned_2023) =
    5280         384 :                         IntermediateCapacityAndPowerSEER2Case1(state, bl, q_low, n, p_low, PLFFPLRCurveIndex(spnum));
    5281             :                     // This is the case and speed we're looking for now we exit and try calculating against the next bin
    5282         192 :                     goto SpeedLoop3_exit;
    5283             :                 } else {
    5284             :                     //
    5285         338 :                     if (spnum < nsp - 1) {
    5286             :                         // As part of our new experiment if the first case is not satisfied then we'll go and try the next speed
    5287             :                         // instead of going to the next case.
    5288             :                     } else {
    5289             :                         // if we're here then all the speeds (apart from max speed) failed to satisfy the first case.
    5290             :                         // Now we've to try second case.
    5291         249 :                         if (bl < q_int) {
    5292             :                             // Section 11.2.1.3.2 CASE 2 - Building load can be matched by modulating the compressor speed between low speed & full
    5293             :                             // Speed
    5294          43 :                             std::tie(q, e, NetTotCoolCapBinned_2023, TotCoolElecPowerBinned_2023) = IntermediateCapacityAndPowerSEER2Case2A(
    5295          86 :                                 p_int, q_int, q_low, bl, n, Q_E_Int(spnum), q_full, P_E_Int(spnum), p_full, p_low);
    5296          43 :                             goto SpeedLoop3_exit;
    5297             :                         } else {
    5298             :                             // if we're here then all the speeds (apart from max speed) failed to staisfy the case 2A
    5299         206 :                             if (bl < q_full) {
    5300             :                                 // Section 11.2.1.3.2 CASE 2 - Building load can be matched by modulating the compressor speed between low speed &
    5301             :                                 // full Speed
    5302         121 :                                 std::tie(q, e, NetTotCoolCapBinned_2023, TotCoolElecPowerBinned_2023) = IntermediateCapacityAndPowerSEER2Case2B(
    5303         242 :                                     p_int, bl, q_int, n, Q_E_Int(spnum), P_E_Int(spnum), q_low, p_low, q_full, p_full);
    5304         121 :                                 goto SpeedLoop3_exit;
    5305             :                             } else {
    5306             :                                 // if we're here then all the speeds (apart form max speed ?? ) failed to staisfy the case 2B
    5307             :                                 // max speed shoudl include in cases 1,2A,2B or not ?? TBD:
    5308          85 :                                 if (bl >= q_full) { // bl >= q_full
    5309             : 
    5310          85 :                                     if (spnum == nsp - 1) {
    5311             :                                         // Case 4 if applicable for nsp-1 then we're skipping it to nsp( max speed )
    5312             :                                     } else {
    5313             :                                         // Section 11.2.1.3.3 CASE 3 - Building load is equal to or greater than unit capacity at full stage
    5314          36 :                                         std::tie(q, e, NetTotCoolCapBinned_2023, TotCoolElecPowerBinned_2023) =
    5315          36 :                                             IntermediateCapacityAndPowerSEER2Case3(
    5316          36 :                                                 q_full, p_full, CoolingCapacityMax_2023, CoolingElecPowerMax_2023, n);
    5317          36 :                                         goto SpeedLoop3_exit;
    5318             :                                     }
    5319             :                                 } else {
    5320             :                                     // << ",, BIN NUMBER, " << BN + 1 << ", NO CASES MATCHED, " << spnum << std::endl;
    5321             :                                 }
    5322             :                             }
    5323             :                         }
    5324             :                     }
    5325             :                 }
    5326             :             }
    5327           0 :         SpeedLoop3_exit:;
    5328         392 :             NetCoolingCapWeighted2_2023 += NetTotCoolCapBinned_2023;
    5329         392 :             TotCoolingElecPowerWeighted2_2023 += TotCoolElecPowerBinned_2023;
    5330             : 
    5331         392 :             q_sum += q;
    5332         392 :             e_sum += e;
    5333             :         }
    5334          49 :         SEER2_User = 0.0;
    5335          49 :         SEER2_Standard = 0.0;
    5336          49 :         if (e_sum > 0.0) {
    5337          49 :             SEER2_User = NetCoolingCapWeighted2_2023 / TotCoolingElecPowerWeighted2_2023;
    5338          49 :             SEER2_Standard = q_sum / e_sum; // Equation 11.66 (AHRI-2023)
    5339             :         }
    5340             : 
    5341          98 :         return std::make_tuple(NetCoolingCapRatedMaxSpeed2023, SEER2_User, SEER2_Standard, EER2);
    5342          49 :     }
    5343             : 
    5344          49 :     std::map<std::string, Real64> MultiSpeedDXCoolingCoilStandardRatings(
    5345             :         EnergyPlusData &state,
    5346             :         std::string const &DXCoilType,                                  // Type of DX coil for which HSPF is calculated
    5347             :         std::string const &DXCoilName,                                  // Type of DX coil for which standard Ratings are calculated
    5348             :         Array1A_int const CapFTempCurveIndex,                           // Index for the capacity as a function of temperature modifier curve
    5349             :         Array1A_int const CapFFlowCurveIndex,                           // Index for the capacity as a function of flow fraction modifier curve
    5350             :         Array1A_int const EIRFTempCurveIndex,                           // Index for the EIR as a function of temperature modifier curve
    5351             :         Array1A_int const EIRFFlowCurveIndex,                           // Index for the EIR as a function of flow fraction modifier curve
    5352             :         Array1A_int const PLFFPLRCurveIndex,                            // Index for the PLF vs part-load ratio curve
    5353             :         Array1A<Real64> const RatedTotalCapacity,                       // Reference capacity of DX coil [W]
    5354             :         Array1A<Real64> const RatedCOP,                                 // Reference coefficient of performance [W/W]
    5355             :         Array1A<Real64> const RatedAirVolFlowRate,                      // Reference air flow rate of DX coil [m3/s]
    5356             :         Array1A<Real64> const FanPowerPerEvapAirFlowRateFromInput,      // 2017 rated fan power per evap air flow rate [W/(m3/s)]
    5357             :         Array1A<Real64> const FanPowerPerEvapAirFlowRateFromInput_2023, // 2023 rated fan power per evap air flow rate [W/(m3/s)]
    5358             :         int const nsp,                                                  // Number of compressor speeds
    5359             :         Array1D<DataHeatBalance::RefrigCondenserType> const &CondenserType)
    5360             :     {
    5361             : 
    5362             :         // SUBROUTINE INFORMATION:
    5363             :         //       AUTHOR         B. Nigusse, FSEC
    5364             :         //       DATE WRITTEN   December 2012
    5365             :         //       MODIFIED
    5366             :         //       RE-ENGINEERED  na
    5367             : 
    5368             :         // PURPOSE OF THIS SUBROUTINE:
    5369             :         // Calculates the standard ratings net cooling capacity and SEER values for multi speed DX cooling coils
    5370             :         // at the AHRI standard test condition(s).
    5371             : 
    5372             :         // METHODOLOGY EMPLOYED:
    5373             :         // na
    5374             : 
    5375             :         // REFERENCES:
    5376             :         // na
    5377             : 
    5378             :         // Using/Aliasing
    5379             :         using Curve::CurveValue;
    5380             : 
    5381             :         // Argument array dimensioning
    5382          49 :         CapFTempCurveIndex.dim(nsp);
    5383          49 :         CapFFlowCurveIndex.dim(nsp);
    5384          49 :         EIRFTempCurveIndex.dim(nsp);
    5385          49 :         EIRFFlowCurveIndex.dim(nsp);
    5386          49 :         PLFFPLRCurveIndex.dim(nsp);
    5387          49 :         RatedTotalCapacity.dim(nsp);
    5388          49 :         RatedCOP.dim(nsp);
    5389          49 :         RatedAirVolFlowRate.dim(nsp);
    5390          49 :         FanPowerPerEvapAirFlowRateFromInput.dim(nsp);
    5391             : 
    5392             :         // Locals
    5393             :         // SUBROUTINE ARGUMENT DEFINITIONS:
    5394             : 
    5395             :         // SUBROUTINE PARAMETER DEFINITIONS:
    5396             :         // CHARACTER(len=*), PARAMETER    :: RoutineName='MultiSpeedDXCoolingCoilStandardRatings: ' ! Include trailing blank space
    5397             :         // INTERFACE BLOCK SPECIFICATIONS
    5398             :         // na
    5399             : 
    5400             :         // DERIVED TYPE DEFINITIONS
    5401             :         // na
    5402             : 
    5403             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    5404             : 
    5405             :         // Intermediate values calculated from the inputs in the idf file
    5406             : 
    5407          49 :         Real64 NetCoolingCapRatedMaxSpeed(0.0); // net cooling capacity at maximum speed
    5408          49 :         Real64 SEER_User(0.0);     // seasonal energy efficiency ratio of multi speed DX cooling coil, from user-input PLF curve and C_D value
    5409          49 :         Real64 SEER_Standard(0.0); // seasonal energy efficiency ratio of multi speed DX cooling coil, from AHRI Std 210/240-2008 default PLF
    5410             :                                    // curve and
    5411             :                                    // C_D value
    5412          49 :         Real64 EER(0.0);
    5413             : 
    5414             :         // Ratings Based on ANSI/AHRI 210/140
    5415          49 :         Real64 NetCoolingCapRatedMaxSpeed2023(0.0); // net cooling capacity at maximum speed
    5416          49 :         Real64 SEER2_User(0.0);     // seasonal energy efficiency ratio of multi speed DX cooling coil, from user-input PLF curve and C_D value
    5417          49 :         Real64 SEER2_Standard(0.0); // seasonal energy efficiency ratio of multi speed DX cooling coil, from AHRI Std 210/240-2008 default PLF
    5418             :                                     // curve and
    5419             :                                     // C_D value
    5420          49 :         Real64 EER2(0.0);
    5421             : 
    5422             :         // IEER Calculation 2022
    5423          49 :         Real64 IEER_2022(0.0);
    5424          49 :         Real64 NetCoolingCapRated2023(0.0); // ?? for which speed (NetCoolingCapRatedMaxSpeed2023)
    5425          49 :         Real64 EER_2022(0.0);
    5426          49 :         std::map<std::string, Real64> StandardRatingsResult;
    5427             :         // StandardRatingsResult["NetCoolingCapRatedMaxSpeed"] = NetCoolingCapRatedMaxSpeed;
    5428             :         // StandardRatingsResult["SEER_User"] = SEER_User;
    5429             :         // StandardRatingsResult["SEER_Standard"] = SEER_Standard;
    5430             :         // StandardRatingsResult["NetCoolingCapRatedMaxSpeed2023"] = NetCoolingCapRatedMaxSpeed2023;
    5431             :         // StandardRatingsResult["SEER2_User"] = SEER2_User;
    5432             :         // StandardRatingsResult["SEER2_Standard"] = SEER2_Standard;
    5433          49 :         Real64 TotCapFlowModFac = Curve::CurveValue(state, CapFFlowCurveIndex(nsp), AirMassFlowRatioRated);
    5434          49 :         NetCoolingCapRatedMaxSpeed =
    5435          49 :             RatedTotalCapacity(nsp) *
    5436          49 :                 Curve::CurveValue(state, CapFTempCurveIndex(nsp), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestA2) *
    5437          49 :                 TotCapFlowModFac -
    5438          49 :             FanPowerPerEvapAirFlowRateFromInput(nsp) * RatedAirVolFlowRate(nsp);
    5439          49 :         if (RatedTotalCapacity(nsp) > 0.0 && RatedAirVolFlowRate(nsp) > 0.0) {
    5440             : 
    5441          49 :             NetCoolingCapRated2023 =
    5442          49 :                 RatedTotalCapacity(nsp) *
    5443          49 :                     Curve::CurveValue(state, CapFTempCurveIndex(nsp), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestA2) *
    5444          49 :                     TotCapFlowModFac -
    5445          49 :                 FanPowerPerEvapAirFlowRateFromInput_2023(nsp) * RatedAirVolFlowRate(nsp);
    5446          49 :             StandardRatingsResult["NetCoolingCapRatedMaxSpeed2023"] = NetCoolingCapRated2023;
    5447             :             // TODO: Commercial and industrial unitary air-conditioning condensing units with a capacity greater than 135,000 Btu/h (39564.59445
    5448             :             // Watts) as defined in ANSI/AHRI Standard 365(I-P). | Scope 2.2.6 (ANSI/AHRI 340-360 2022)
    5449             : 
    5450          98 :             std::tie(NetCoolingCapRatedMaxSpeed, SEER_User, SEER_Standard, EER) = MultiSpeedDXCoolingCoilSEER(state,
    5451             :                                                                                                               nsp,
    5452             :                                                                                                               CapFFlowCurveIndex,
    5453             :                                                                                                               RatedTotalCapacity,
    5454             :                                                                                                               CapFTempCurveIndex,
    5455             :                                                                                                               FanPowerPerEvapAirFlowRateFromInput,
    5456             :                                                                                                               RatedAirVolFlowRate,
    5457             :                                                                                                               EIRFFlowCurveIndex,
    5458             :                                                                                                               RatedCOP,
    5459             :                                                                                                               EIRFTempCurveIndex,
    5460          49 :                                                                                                               PLFFPLRCurveIndex);
    5461             : 
    5462          49 :             if (CondenserType(1) == DataHeatBalance::RefrigCondenserType::Air) {
    5463             :                 // SEER2 standard applies to factory-made Unitary Air-conditioners and Unitary Air-source Heat Pumps with
    5464             :                 // capacities less than 65,000 Btu/h (19049.61955 Watts) | Section 2.1 (ANSI/AHRI 210-240 2023)
    5465             :                 // Removal of water-cooled and evaporatively-cooled products from the scope | Foreword (ANSI/AHRI 210-240 2023)
    5466             :                 //
    5467             :                 // SEER2 Calculations ANSI/AHRI 210/240 Standard 2023
    5468          49 :                 std::tie(NetCoolingCapRatedMaxSpeed2023, SEER2_User, SEER2_Standard, EER2) =
    5469          98 :                     MultiSpeedDXCoolingCoilSEER2(state,
    5470             :                                                  nsp,
    5471             :                                                  CapFFlowCurveIndex,
    5472             :                                                  RatedTotalCapacity,
    5473             :                                                  CapFTempCurveIndex,
    5474             :                                                  FanPowerPerEvapAirFlowRateFromInput_2023,
    5475             :                                                  RatedAirVolFlowRate,
    5476             :                                                  EIRFFlowCurveIndex,
    5477             :                                                  RatedCOP,
    5478             :                                                  EIRFTempCurveIndex,
    5479          49 :                                                  PLFFPLRCurveIndex);
    5480          49 :                 StandardRatingsResult["NetCoolingCapRatedMaxSpeed2023"] = NetCoolingCapRatedMaxSpeed2023;
    5481             :             }
    5482             :             // Gross total cooling capacity is greater than 65,000 Btu/h (19049.61955 Watts)
    5483             :             // Section 2.1 (ANSI/AHRI 210-240 2023)
    5484          49 :             std::tie(IEER_2022, NetCoolingCapRated2023, EER_2022) = IEERCalculationMultiSpeed(state,
    5485             :                                                                                               DXCoilType,
    5486             :                                                                                               nsp,
    5487             :                                                                                               CapFTempCurveIndex,
    5488             :                                                                                               RatedTotalCapacity,
    5489             :                                                                                               CapFFlowCurveIndex,
    5490             :                                                                                               // TotCapFlowModFac, // calculate for each speed
    5491             :                                                                                               FanPowerPerEvapAirFlowRateFromInput_2023,
    5492             :                                                                                               RatedAirVolFlowRate,
    5493             :                                                                                               EIRFTempCurveIndex,
    5494             :                                                                                               RatedCOP,
    5495             :                                                                                               EIRFFlowCurveIndex,
    5496             :                                                                                               // EIRFlowModFac, // calculate for each speed
    5497          49 :                                                                                               CondenserType);
    5498          49 :             StandardRatingsResult["NetCoolingCapRatedMaxSpeed2023"] = NetCoolingCapRated2023;
    5499             : 
    5500             :         } else {
    5501           0 :             ShowSevereError(state,
    5502             :                             "Standard Ratings: Coil:Cooling:DX:MultiSpeed has eiher zero rated total cooling capacity or zero rated air vol flow "
    5503             :                             "rate. Standard ratings cannot be calculated.");
    5504             :         }
    5505             : 
    5506          49 :         StandardRatingsResult["NetCoolingCapRatedMaxSpeed"] = NetCoolingCapRatedMaxSpeed;
    5507          49 :         StandardRatingsResult["SEER_User"] = SEER_User;
    5508          49 :         StandardRatingsResult["SEER_Standard"] = SEER_Standard;
    5509          49 :         StandardRatingsResult["EER"] = EER;
    5510             : 
    5511          49 :         StandardRatingsResult["SEER2_User"] = SEER2_User;
    5512          49 :         StandardRatingsResult["SEER2_Standard"] = SEER2_Standard;
    5513          49 :         StandardRatingsResult["EER2"] = EER2;
    5514             : 
    5515          49 :         StandardRatingsResult["IEER_2022"] = IEER_2022;
    5516          49 :         StandardRatingsResult["EER_2022"] = EER_2022;
    5517             : 
    5518          98 :         return StandardRatingsResult;
    5519           0 :     }
    5520             : 
    5521          24 :     std::map<std::string, Real64> VariableSpeedDXCoolingCoilStandardRatings(
    5522             :         EnergyPlusData &state,
    5523             :         std::string const &DXCoilType,                                  // Type of DX coil for which HSPF is calculated
    5524             :         std::string const &DXCoilName,                                  // Name of the DX Coil for which Standard Ratings are calculated.
    5525             :         Array1A_int const CapFTempCurveIndex,                           // Index for the capacity as a function of temperature modifier curve
    5526             :         Array1A_int const CapFFlowCurveIndex,                           // Index for the capacity as a function of flow fraction modifier curve
    5527             :         Array1A_int const EIRFTempCurveIndex,                           // Index for the EIR as a function of temperature modifier curve
    5528             :         Array1A_int const EIRFFlowCurveIndex,                           // Index for the EIR as a function of flow fraction modifier curve
    5529             :         int const PLFFPLRCurveIndex,                                    // Index for the PLF vs part-load ratio curve
    5530             :         Array1A<Real64> const RatedTotalCapacity,                       // Reference capacity of DX coil [W]
    5531             :         Array1A<Real64> const RatedCOP,                                 // Reference coefficient of performance [W/W]
    5532             :         Array1A<Real64> const RatedAirVolFlowRate,                      // Reference air flow rate of DX coil [m3/s]
    5533             :         Array1A<Real64> const FanPowerPerEvapAirFlowRateFromInput,      // 2017 rated fan power per evap air flow rate [W/(m3/s)]
    5534             :         Array1A<Real64> const FanPowerPerEvapAirFlowRateFromInput_2023, // 2023 rated fan power per evap air flow rate [W/(m3/s)]
    5535             :         int const nsp,                                                  // Number of compressor speeds
    5536             :         DataHeatBalance::RefrigCondenserType const &CondenserType,
    5537             :         Real64 VSGrossRatedTotalCoolingCapacity,
    5538             :         Real64 VSRatedVolumetricAirFlowRate)
    5539             :     {
    5540             :         // Using/Aliasing
    5541             :         using Curve::CurveValue;
    5542             : 
    5543             :         // Argument array dimensioning
    5544          24 :         CapFTempCurveIndex.dim(nsp);
    5545          24 :         CapFFlowCurveIndex.dim(nsp);
    5546          24 :         EIRFTempCurveIndex.dim(nsp);
    5547          24 :         EIRFFlowCurveIndex.dim(nsp);
    5548             :         // PLFFPLRCurveIndex.dim(nsp);
    5549          24 :         RatedTotalCapacity.dim(nsp);
    5550          24 :         RatedCOP.dim(nsp);
    5551          24 :         RatedAirVolFlowRate.dim(nsp);
    5552          24 :         FanPowerPerEvapAirFlowRateFromInput.dim(nsp);
    5553             : 
    5554             :         // Ratings Based on ANSI/AHRI 210/140
    5555          24 :         Real64 NetCoolingCapRatedMaxSpeed2023(0.0); // net cooling capacity at maximum speed
    5556          24 :         Real64 SEER2_User(0.0);     // seasonal energy efficiency ratio of multi speed DX cooling coil, from user-input PLF curve and C_D value
    5557          24 :         Real64 SEER2_Standard(0.0); // seasonal energy efficiency ratio of multi speed DX cooling coil, from AHRI Std 210/240-2008 default PLF
    5558             :                                     // curve and
    5559             :                                     // C_D value
    5560          24 :         Real64 EER2(0.0);
    5561             : 
    5562          24 :         Real64 IEER_2022(0.0);
    5563          24 :         Real64 NetCoolingCapRated2022(0.0); // ?? for which speed (NetCoolingCapRatedMaxSpeed2023)
    5564          24 :         Real64 EER_2022(0.0);
    5565             : 
    5566          24 :         std::map<std::string, Real64> StandardRatingsResult;
    5567             : 
    5568          24 :         Real64 GrossRatedTotalCoolingCapacityVS(0.0);
    5569          24 :         if (VSGrossRatedTotalCoolingCapacity < 0) {
    5570           0 :             GrossRatedTotalCoolingCapacityVS = RatedTotalCapacity(nsp);
    5571             :         } else {
    5572          24 :             GrossRatedTotalCoolingCapacityVS = VSGrossRatedTotalCoolingCapacity;
    5573             :         }
    5574          24 :         Real64 RatedVolumetricAirFlowRateVS(0.0);
    5575          24 :         if (VSRatedVolumetricAirFlowRate < 0) {
    5576           0 :             RatedVolumetricAirFlowRateVS = RatedAirVolFlowRate(nsp);
    5577             :         } else {
    5578          24 :             RatedVolumetricAirFlowRateVS = VSRatedVolumetricAirFlowRate;
    5579             :         }
    5580             : 
    5581          24 :         Real64 CapacityScaleFactor(0.0);
    5582          24 :         Real64 GrossRatedTotalCoolingCapacity(0.0);
    5583          24 :         Real64 ReferenceUnitCapacityAtNominalSpeedLevel(0.0);
    5584             : 
    5585          24 :         Array1D<Real64> GrossRatedCapacityAtSpeedLevel(nsp);
    5586          24 :         Array1D<Real64> ReferenceUnitCapacityAtSpeedLevel(nsp);
    5587             : 
    5588          24 :         Real64 AirFlowScaleFactor(0.0);
    5589          24 :         Real64 RatedVolumetricAirFlowRate(0.0);
    5590          24 :         Real64 ReferenceUnitVolAirFlowRateAtNominalSpeedLevel(0.0);
    5591             : 
    5592          24 :         Array1D<Real64> LoopVolumetricAirFlowRateAtSpeedLevel(nsp);
    5593          24 :         Array1D<Real64> ReferenceUnitVolAirFlowRateAtSpeedLevel(nsp);
    5594             : 
    5595          24 :         int NominalSpeedLevel = nsp;
    5596         204 :         for (int spnum = 1; spnum <= nsp; ++spnum) {
    5597         180 :             ReferenceUnitCapacityAtSpeedLevel(spnum) = RatedTotalCapacity(spnum);
    5598         180 :             ReferenceUnitVolAirFlowRateAtSpeedLevel(spnum) = RatedAirVolFlowRate(spnum);
    5599             :         }
    5600          24 :         GrossRatedTotalCoolingCapacity = GrossRatedTotalCoolingCapacityVS;
    5601          24 :         ReferenceUnitCapacityAtNominalSpeedLevel = ReferenceUnitCapacityAtSpeedLevel(NominalSpeedLevel);
    5602          24 :         CapacityScaleFactor =
    5603             :             GrossRatedTotalCoolingCapacity / ReferenceUnitCapacityAtNominalSpeedLevel; // Section 1.41.21.1.6 | Equation (1.160) | IO-Ref
    5604             : 
    5605          24 :         RatedVolumetricAirFlowRate = RatedVolumetricAirFlowRateVS;
    5606          24 :         ReferenceUnitVolAirFlowRateAtNominalSpeedLevel = ReferenceUnitVolAirFlowRateAtSpeedLevel(NominalSpeedLevel);
    5607          24 :         AirFlowScaleFactor = RatedVolumetricAirFlowRate / (ReferenceUnitVolAirFlowRateAtNominalSpeedLevel *
    5608             :                                                            CapacityScaleFactor); // Section 1.41.21.1.7 | Equation (1.162) | IO-Ref
    5609             : 
    5610         204 :         for (int sp = 1; sp <= nsp; ++sp) {
    5611         360 :             GrossRatedCapacityAtSpeedLevel(sp) =
    5612         180 :                 CapacityScaleFactor * ReferenceUnitCapacityAtSpeedLevel(sp); //  Section 1.41.21.1.6 | Equation (1.161) | IO-Ref
    5613             : 
    5614         180 :             LoopVolumetricAirFlowRateAtSpeedLevel(sp) = AirFlowScaleFactor * ReferenceUnitVolAirFlowRateAtSpeedLevel(sp) *
    5615             :                                                         CapacityScaleFactor; // Section 1.41.21.1.7 | Equation (1.163) | IO-Ref
    5616             :         }
    5617             : 
    5618          24 :         if (GrossRatedTotalCoolingCapacityVS > 0.0 && RatedVolumetricAirFlowRateVS > 0.0) {
    5619             : 
    5620          24 :             Real64 TotCapFlowModFac = Curve::CurveValue(state, CapFFlowCurveIndex(nsp), AirMassFlowRatioRated);
    5621             :             Real64 NetCoolingCapRated =
    5622          24 :                 GrossRatedCapacityAtSpeedLevel(nsp) *
    5623          24 :                     Curve::CurveValue(state, CapFTempCurveIndex(nsp), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestA2) *
    5624             :                     TotCapFlowModFac -
    5625          24 :                 FanPowerPerEvapAirFlowRateFromInput(nsp) * LoopVolumetricAirFlowRateAtSpeedLevel(nsp);
    5626          24 :             StandardRatingsResult["NetCoolingCapRatedMaxSpeed"] = NetCoolingCapRated;
    5627             : 
    5628          24 :             NetCoolingCapRatedMaxSpeed2023 =
    5629          24 :                 GrossRatedCapacityAtSpeedLevel(nsp) *
    5630          24 :                     Curve::CurveValue(state, CapFTempCurveIndex(nsp), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestA2) *
    5631          24 :                     TotCapFlowModFac -
    5632          24 :                 FanPowerPerEvapAirFlowRateFromInput_2023(nsp) * LoopVolumetricAirFlowRateAtSpeedLevel(nsp);
    5633          24 :             StandardRatingsResult["NetCoolingCapRatedMaxSpeed2023"] = NetCoolingCapRatedMaxSpeed2023;
    5634             :             // TODO: Commercial and industrial unitary air-conditioning condensing units with a capacity greater than 135,000 Btu/h (39564.59445
    5635             :             // Watts) as defined in ANSI/AHRI Standard 365(I-P). | Scope 2.2.6 (ANSI/AHRI 340-360 2022)
    5636             : 
    5637          24 :             if (CondenserType == DataHeatBalance::RefrigCondenserType::Air) {
    5638             :                 // SEER2 standard applies to factory-made Unitary Air-conditioners and Unitary Air-source Heat Pumps with
    5639             :                 // capacities less than 65,000 Btu/h (19049.61955 Watts) | Section 2.1 (ANSI/AHRI 210-240 2023)
    5640             :                 // Removal of water-cooled and evaporatively-cooled products from the scope | Foreword (ANSI/AHRI 210-240 2023)
    5641          24 :                 Array1D<int> VSPLRFPLF;
    5642         204 :                 for (int spnum = 1; spnum <= nsp; ++spnum) {
    5643         180 :                     VSPLRFPLF.push_back(PLFFPLRCurveIndex);
    5644             :                 }
    5645             : 
    5646             :                 // SEER2 Calculations ANSI/AHRI 210/240 Standard 2023
    5647          24 :                 std::tie(NetCoolingCapRatedMaxSpeed2023, SEER2_User, SEER2_Standard, EER2) =
    5648          48 :                     VariableSpeedDXCoolingCoilSEER2(state,
    5649             :                                                     nsp,
    5650             :                                                     CapFFlowCurveIndex,
    5651             :                                                     GrossRatedCapacityAtSpeedLevel, // RatedTotalCapacity,
    5652             :                                                     CapFTempCurveIndex,
    5653             :                                                     FanPowerPerEvapAirFlowRateFromInput_2023,
    5654             :                                                     LoopVolumetricAirFlowRateAtSpeedLevel, // RatedAirVolFlowRate,
    5655             :                                                     EIRFFlowCurveIndex,
    5656             :                                                     RatedCOP,
    5657             :                                                     EIRFTempCurveIndex,
    5658          24 :                                                     VSPLRFPLF);
    5659          24 :                 StandardRatingsResult["NetCoolingCapRatedMaxSpeed2023"] = NetCoolingCapRatedMaxSpeed2023;
    5660          24 :             }
    5661             :             // IEER Calculation 2022
    5662          24 :             std::tie(IEER_2022, NetCoolingCapRatedMaxSpeed2023, EER_2022) =
    5663          48 :                 IEERCalculationVariableSpeed(state,
    5664             :                                              DXCoilType,
    5665             :                                              nsp,
    5666             :                                              CapFTempCurveIndex,
    5667             :                                              GrossRatedCapacityAtSpeedLevel, // RatedTotalCapacity,
    5668             :                                              CapFFlowCurveIndex,
    5669             :                                              FanPowerPerEvapAirFlowRateFromInput_2023,
    5670             :                                              LoopVolumetricAirFlowRateAtSpeedLevel, // RatedAirVolFlowRate,
    5671             :                                              EIRFTempCurveIndex,
    5672             :                                              RatedCOP,
    5673             :                                              EIRFFlowCurveIndex,
    5674          24 :                                              CondenserType);
    5675          24 :             StandardRatingsResult["NetCoolingCapRatedMaxSpeed2023"] = NetCoolingCapRatedMaxSpeed2023;
    5676             : 
    5677          24 :         } else {
    5678           0 :             ShowSevereError(state,
    5679           0 :                             "Standard Ratings: Coil:Cooling:DX " + DXCoilType + // TODO: Use dynamic COIL TYPE and COIL INSTANCE name later
    5680             :                                 " has zero rated total cooling capacity. Standard ratings cannot be calculated.");
    5681             :         }
    5682             : 
    5683             :         // From SEER2 implementation
    5684          24 :         StandardRatingsResult["SEER2_User"] = SEER2_User;
    5685          24 :         StandardRatingsResult["SEER2_Standard"] = SEER2_Standard;
    5686          24 :         StandardRatingsResult["EER2"] = EER2;
    5687             : 
    5688             :         // From IEER2 implementation
    5689          24 :         StandardRatingsResult["IEER_2022"] = IEER_2022;
    5690          24 :         StandardRatingsResult["EER_2022"] = EER_2022;
    5691             : 
    5692          48 :         return StandardRatingsResult;
    5693          24 :     }
    5694             : 
    5695          22 :     std::tuple<Real64, Real64, Real64> MultiSpeedDXHeatingCoilHSPF(
    5696             :         EnergyPlusData &state,
    5697             :         int const nsp,                                              // Number of compressor speed
    5698             :         Array1A<Real64> const MSFanPowerPerEvapAirFlowRateInput,    // 2017 rated fan power per evap air flow rate [W/(m3/s)]
    5699             :         Array1A_int const CapFTempCurveIndex,                       // Index for the capacity as a function of temperature modifier curve
    5700             :         Array1A_int const CapFFlowCurveIndex,                       // Index for the capacity as a function of flow fraction modifier curve
    5701             :         Array1A<Real64> const RatedTotalCapacity,                   // Reference capacity of DX coil [W]
    5702             :         Array1A<Real64> const RatedAirVolFlowRate,                  // Reference air flow rate of DX coil [m3/s]
    5703             :         Array1A_int const EIRFFlowCurveIndex,                       // Index for the EIR as a function of flow fraction modifier curve
    5704             :         Array1A_int const EIRFTempCurveIndex,                       // Index for the EIR as a function of temperature modifier curve
    5705             :         Array1A<Real64> const RatedCOP,                             // Reference coefficient of performance [W/W]
    5706             :         ObjexxFCL::Optional_int_const RegionNum,                    // Region number for calculating HSPF of single speed DX heating coil
    5707             :         ObjexxFCL::Optional<Real64 const> MinOATCompressor,         // Minimum OAT for heat pump compressor operation [C]
    5708             :         ObjexxFCL::Optional<Real64 const> OATempCompressorOn,       // The outdoor temperature when the compressor is automatically turned
    5709             :         ObjexxFCL::Optional_bool_const OATempCompressorOnOffBlank,  // Flag used to determine low temperature cut out factor
    5710             :         ObjexxFCL::Optional<HPdefrostControl const> DefrostControl) // defrost control; 1=timed, 2=on-demand
    5711             :     {
    5712             : 
    5713             :         // Intermediate values calculated from the inputs in the idf file
    5714          22 :         Real64 HSPF(0.0);
    5715          22 :         Real64 NetHeatingCapRatedHighTemp(0.0);
    5716          22 :         Real64 NetHeatingCapRatedLowTemp(0.0);
    5717             : 
    5718             :         int BinNum;         // bin number counter
    5719             :         int spnum;          // compressor speed number
    5720             :         int StandardDHRNum; // Integer counter for standardized DHRs
    5721             : 
    5722          22 :         Array1D<Real64> FanPowerPerEvapAirFlowRate(nsp); // Fan power per air volume flow rate through the evaporator coil [W/(m3/s)]
    5723          22 :         Array1D<Real64> TotHeatCapTestH0(nsp);           // Total cooling capacity at A2 test condition (High speed)
    5724          22 :         Array1D<Real64> TotHeatCapTestH1(nsp);           // Total cooling capacity at B2 test condition (High speed)
    5725          22 :         Array1D<Real64> TotHeatCapTestH2(nsp);           // Total cooling capacity at B1 test condition (Low speed)
    5726          22 :         Array1D<Real64> TotHeatCapTestH3(nsp);           // Total cooling capacity at F1 test condition (Low speed)
    5727          22 :         Array1D<Real64> OutdoorUnitPowerTestH0(nsp);     // Outdoor Unit electric power at A2 test condition (High speed)
    5728          22 :         Array1D<Real64> OutdoorUnitPowerTestH1(nsp);     // Outdoor Unit electric power at B2 test condition (High speed)
    5729          22 :         Array1D<Real64> OutdoorUnitPowerTestH2(nsp);     // Outdoor Unit electric power at B1 test condition (Low speed)
    5730          22 :         Array1D<Real64> OutdoorUnitPowerTestH3(nsp);     // Outdoor Unit electric power at F1 test condition (Low speed)
    5731             :         Real64 HeatingCapacityLS;                        // cooling capacity of Mult-speed DX coil at lower speed, [W]
    5732             :         Real64 HeatingCapacityHS;                        // cooling capacity of Mult-speed DX coil at higher speed, [W]
    5733             :         Real64 HeatingElecPowerLS;                       // outdoor unit electric power input at low speed, [W]
    5734             :         Real64 HeatingElecPowerHS;                       // outdoor unit electric power input at high speed, [W]
    5735             :         Real64 HeatingCapacityMax;                       // cooling capacity of Mult-speed DX coil at max speed, [W]
    5736             :         Real64 HeatingElecPowerMax;                      // outdoor unit electric power input at Max speed, [W]
    5737          22 :         Array1D<Real64> TotHeatCapTestH1High(nsp);       // net heating capacity high speed at H1 test conditon, [W]
    5738             : 
    5739             :         // Intermediate values calculated from the inputs in the idf file
    5740          22 :         Array1D<Real64> TotCapFlowModFac(nsp); // Total capacity modifier f(actual flow vs rated flow) for each speed [-]
    5741          22 :         Array1D<Real64> EIRFlowModFac(nsp);    // EIR modifier f(actual supply air flow vs rated flow) for each speed [-]
    5742             : 
    5743          22 :         Real64 TotCapTempModFacH0(0.0); // Tot capacity modifier (function of entering wetbulb, outside drybulb) at H0 Test [-]
    5744          22 :         Real64 EIRTempModFacH0(0.0);    // EIR modifier (function of entering wetbulb, outside drybulb)  at H0 Test[-]
    5745          22 :         Real64 TotCapTempModFacH1(0.0); // Tot capacity modifier (function of entering wetbulb, outside drybulb) at H1 Test [-]
    5746          22 :         Real64 EIRTempModFacH1(0.0);    // EIR modifier (function of entering wetbulb, outside drybulb)  at H1 Test[-]
    5747          22 :         Real64 TotCapTempModFacH2(0.0); // Tot capacity modifier (function of entering wetbulb, outside drybulb) at H2 Test [-]
    5748          22 :         Real64 EIRTempModFacH2(0.0);    // EIR modifier (function of entering wetbulb, outside drybulb)  at H2 Test[-]
    5749          22 :         Real64 TotCapTempModFacH3(0.0); // Tot capacity modifier (function of entering wetbulb, outside drybulb) at H3 Test [-]
    5750          22 :         Real64 EIRTempModFacH3(0.0);    // EIR modifier (function of entering wetbulb, outside drybulb)  at H3 Test[-]
    5751             : 
    5752          22 :         Real64 OATempCompressorOff(0.0); // Minimum outdoor air temperature to turn the commpressor off
    5753          22 :         Real64 PartLoadRatio(0.0);       // compressor cycling ratio between successive speeds, [-]
    5754          22 :         Real64 PartLoadFraction(0.0);    // part-load fraction that account for the cyclic degradation, [-]
    5755             : 
    5756          22 :         Real64 NetHeatingCapWeighted(0.0);       // net total heating cap weighted by the fraction of the binned cooling hours [W]
    5757          22 :         Real64 TotHeatingElecPowerWeighted(0.0); // net total heat pump and resistance heating electric Energy input weighted by
    5758             :         // the fraction of the binned cooling hours
    5759          22 :         Real64 BuildingHeatingLoad(0.0);      // Building space heating load corresponding to an outdoor bin temperature [W]
    5760          22 :         Real64 NetTotHeatCapBinned(0.0);      // Net tot heatinging cap corresponding to an outdoor bin temperature [W]
    5761          22 :         Real64 TotHeatElecPowerBinnedHP(0.0); // Total Heat Pump heating electric power consumption at outdoor bin temp [W]
    5762          22 :         Real64 TotHeatElecPowerBinnedRH(0.0); // Total Resistance heating electric power consumption at outdoor bin temp [W]
    5763             : 
    5764             :         Real64 LoadFactor;               // Fractional "on" time for last stage at the desired reduced capacity, (dimensionless)
    5765          22 :         Real64 LowTempCutOutFactor(0.0); // Factor which corresponds to compressor operation depending on outdoor temperature
    5766             : 
    5767          22 :         Real64 FractionalBinHours(0.0);       // Fractional bin hours for the heating season  [-]
    5768          22 :         Real64 DemandDeforstCredit(1.0);      // A factor to adjust HSPF if coil has demand defrost control  [-]
    5769          22 :         Real64 DesignHeatingRequirement(0.0); // The amount of heating required to maintain a given indoor temperature
    5770             :         // at a particular outdoor design temperature.  [W]
    5771          22 :         Real64 DesignHeatingRequirementMin(0.0); // minimum design heating requirement [W]
    5772          22 :         Real64 DesignHeatingRequirementMax(0.0); // maximum design heating requirement [W]
    5773             : 
    5774          22 :         NetHeatingCapWeighted = 0.0;
    5775          22 :         TotHeatingElecPowerWeighted = 0.0;
    5776             : 
    5777          92 :         for (spnum = 1; spnum <= nsp; ++spnum) {
    5778          70 :             FanPowerPerEvapAirFlowRate(spnum) = 0.0;
    5779          70 :             if (MSFanPowerPerEvapAirFlowRateInput(spnum) <= 0.0) {
    5780           0 :                 FanPowerPerEvapAirFlowRate(spnum) = DefaultFanPowerPerEvapAirFlowRate;
    5781             :             } else {
    5782          70 :                 FanPowerPerEvapAirFlowRate(spnum) = MSFanPowerPerEvapAirFlowRateInput(spnum);
    5783             :             }
    5784             :         }
    5785             : 
    5786             :         // Proceed withe HSPF value calculation
    5787          92 :         for (spnum = 1; spnum <= nsp; ++spnum) {
    5788          70 :             TotCapFlowModFac(spnum) = Curve::CurveValue(state, CapFFlowCurveIndex(spnum), AirMassFlowRatioRated);
    5789             :             {
    5790          70 :                 if (state.dataCurveManager->PerfCurve(CapFTempCurveIndex(spnum))->numDims == 1) {
    5791          52 :                     TotCapTempModFacH0 = Curve::CurveValue(state, CapFTempCurveIndex(spnum), HeatingOutdoorCoilInletAirDBTempH0Test);
    5792          52 :                     TotCapTempModFacH1 = Curve::CurveValue(state, CapFTempCurveIndex(spnum), HeatingOutdoorCoilInletAirDBTempRated);
    5793          52 :                     TotCapTempModFacH2 = Curve::CurveValue(state, CapFTempCurveIndex(spnum), HeatingOutdoorCoilInletAirDBTempH2Test);
    5794          52 :                     TotCapTempModFacH3 = Curve::CurveValue(state, CapFTempCurveIndex(spnum), HeatingOutdoorCoilInletAirDBTempH3Test);
    5795             :                 } else {
    5796          36 :                     TotCapTempModFacH0 = Curve::CurveValue(
    5797          18 :                         state, CapFTempCurveIndex(spnum), HeatingIndoorCoilInletAirDBTempRated, HeatingOutdoorCoilInletAirDBTempH0Test);
    5798          36 :                     TotCapTempModFacH1 = Curve::CurveValue(
    5799          18 :                         state, CapFTempCurveIndex(spnum), HeatingIndoorCoilInletAirDBTempRated, HeatingOutdoorCoilInletAirDBTempRated);
    5800          36 :                     TotCapTempModFacH2 = Curve::CurveValue(
    5801          18 :                         state, CapFTempCurveIndex(spnum), HeatingIndoorCoilInletAirDBTempRated, HeatingOutdoorCoilInletAirDBTempH2Test);
    5802          18 :                     TotCapTempModFacH3 = Curve::CurveValue(
    5803          18 :                         state, CapFTempCurveIndex(spnum), HeatingIndoorCoilInletAirDBTempRated, HeatingOutdoorCoilInletAirDBTempH3Test);
    5804             :                 }
    5805             :             }
    5806             : 
    5807          70 :             TotHeatCapTestH0(spnum) = RatedTotalCapacity(spnum) * TotCapTempModFacH0 * TotCapFlowModFac(spnum) +
    5808          70 :                                       FanPowerPerEvapAirFlowRate(spnum) * RatedAirVolFlowRate(spnum);
    5809          70 :             TotHeatCapTestH1(spnum) = RatedTotalCapacity(spnum) * TotCapTempModFacH1 * TotCapFlowModFac(spnum) +
    5810          70 :                                       FanPowerPerEvapAirFlowRate(spnum) * RatedAirVolFlowRate(spnum);
    5811          70 :             TotHeatCapTestH2(spnum) = RatedTotalCapacity(spnum) * TotCapTempModFacH2 * TotCapFlowModFac(spnum) +
    5812          70 :                                       FanPowerPerEvapAirFlowRate(spnum) * RatedAirVolFlowRate(spnum);
    5813          70 :             TotHeatCapTestH3(spnum) = RatedTotalCapacity(spnum) * TotCapTempModFacH3 * TotCapFlowModFac(spnum) +
    5814          70 :                                       FanPowerPerEvapAirFlowRate(spnum) * RatedAirVolFlowRate(spnum);
    5815             : 
    5816          70 :             EIRFlowModFac(spnum) = Curve::CurveValue(state, EIRFFlowCurveIndex(spnum), AirMassFlowRatioRated);
    5817             : 
    5818             :             {
    5819          70 :                 if (state.dataCurveManager->PerfCurve(EIRFTempCurveIndex(spnum))->numDims == 1) {
    5820          52 :                     EIRTempModFacH0 = Curve::CurveValue(state, EIRFTempCurveIndex(spnum), HeatingOutdoorCoilInletAirDBTempH0Test);
    5821          52 :                     EIRTempModFacH1 = Curve::CurveValue(state, EIRFTempCurveIndex(spnum), HeatingOutdoorCoilInletAirDBTempRated);
    5822          52 :                     EIRTempModFacH2 = Curve::CurveValue(state, EIRFTempCurveIndex(spnum), HeatingOutdoorCoilInletAirDBTempH2Test);
    5823          52 :                     EIRTempModFacH3 = Curve::CurveValue(state, EIRFTempCurveIndex(spnum), HeatingOutdoorCoilInletAirDBTempH3Test);
    5824             :                 } else {
    5825          36 :                     EIRTempModFacH0 = Curve::CurveValue(
    5826          18 :                         state, EIRFTempCurveIndex(spnum), HeatingIndoorCoilInletAirDBTempRated, HeatingOutdoorCoilInletAirDBTempH0Test);
    5827          36 :                     EIRTempModFacH1 = Curve::CurveValue(
    5828          18 :                         state, EIRFTempCurveIndex(spnum), HeatingIndoorCoilInletAirDBTempRated, HeatingOutdoorCoilInletAirDBTempRated);
    5829          36 :                     EIRTempModFacH2 = Curve::CurveValue(
    5830          18 :                         state, EIRFTempCurveIndex(spnum), HeatingIndoorCoilInletAirDBTempRated, HeatingOutdoorCoilInletAirDBTempH2Test);
    5831          18 :                     EIRTempModFacH3 = Curve::CurveValue(
    5832          18 :                         state, EIRFTempCurveIndex(spnum), HeatingIndoorCoilInletAirDBTempRated, HeatingOutdoorCoilInletAirDBTempH3Test);
    5833             :                 }
    5834             :             }
    5835          70 :             if (RatedCOP(spnum) > 0.0) {
    5836          70 :                 OutdoorUnitPowerTestH0(spnum) = TotHeatCapTestH0(spnum) * EIRFlowModFac(spnum) * EIRTempModFacH0 / RatedCOP(spnum) +
    5837          70 :                                                 FanPowerPerEvapAirFlowRate(spnum) * RatedAirVolFlowRate(spnum);
    5838          70 :                 OutdoorUnitPowerTestH1(spnum) = TotHeatCapTestH1(spnum) * EIRFlowModFac(spnum) * EIRTempModFacH1 / RatedCOP(spnum) +
    5839          70 :                                                 FanPowerPerEvapAirFlowRate(spnum) * RatedAirVolFlowRate(spnum);
    5840          70 :                 OutdoorUnitPowerTestH2(spnum) = TotHeatCapTestH2(spnum) * EIRFlowModFac(spnum) * EIRTempModFacH2 / RatedCOP(spnum) +
    5841          70 :                                                 FanPowerPerEvapAirFlowRate(spnum) * RatedAirVolFlowRate(spnum);
    5842         140 :                 OutdoorUnitPowerTestH3(spnum) = TotHeatCapTestH3(spnum) * EIRFlowModFac(spnum) * EIRTempModFacH3 / RatedCOP(spnum) +
    5843          70 :                                                 FanPowerPerEvapAirFlowRate(spnum) * RatedAirVolFlowRate(spnum);
    5844             :             }
    5845             :         }
    5846             : 
    5847             :         // determine the HP capacity at the rated condition (AHRI H1 high speed test Condition); and determine the
    5848             :         // the building heat requirement for the user specified region
    5849          22 :         NetHeatingCapRatedHighTemp = TotHeatCapTestH1(nsp);
    5850          22 :         NetHeatingCapRatedLowTemp = TotHeatCapTestH3(nsp);
    5851             : 
    5852          22 :         if (RegionNum == 5) {
    5853           0 :             DesignHeatingRequirementMin = NetHeatingCapRatedHighTemp;
    5854           0 :             DesignHeatingRequirementMax = 2.20 * NetHeatingCapRatedHighTemp;
    5855             :         } else {
    5856          22 :             DesignHeatingRequirementMin = NetHeatingCapRatedHighTemp * (18.33 - OutdoorDesignTemperature[RegionNum - 1]) / (60.0 / 1.80);
    5857          22 :             DesignHeatingRequirementMax = 2.20 * DesignHeatingRequirementMin;
    5858             :         }
    5859             :         // Set the Design Heating Requirement to nearest standard value (From Table 18, AHRI/ANSI Std 210/240)
    5860         352 :         for (StandardDHRNum = 0; StandardDHRNum < TotalNumOfStandardDHRs - 1; ++StandardDHRNum) {
    5861         330 :             if (DesignHeatingRequirementMin < StandardDesignHeatingRequirement[0]) {
    5862             : 
    5863           0 :                 DesignHeatingRequirement = min(StandardDesignHeatingRequirement[0], DesignHeatingRequirementMax);
    5864             : 
    5865         505 :             } else if (DesignHeatingRequirementMin >= StandardDesignHeatingRequirement[StandardDHRNum] &&
    5866         175 :                        DesignHeatingRequirementMin < StandardDesignHeatingRequirement[StandardDHRNum + 1]) {
    5867          22 :                 if ((DesignHeatingRequirementMin - StandardDesignHeatingRequirement[StandardDHRNum]) >
    5868          22 :                     (StandardDesignHeatingRequirement[StandardDHRNum + 1] - DesignHeatingRequirementMin)) {
    5869             : 
    5870          13 :                     DesignHeatingRequirement = min(StandardDesignHeatingRequirement[StandardDHRNum + 1], DesignHeatingRequirementMax);
    5871             :                 } else {
    5872           9 :                     DesignHeatingRequirement = min(StandardDesignHeatingRequirement[StandardDHRNum], DesignHeatingRequirementMax);
    5873             :                 }
    5874         308 :             } else if (DesignHeatingRequirementMin >= StandardDesignHeatingRequirement[TotalNumOfStandardDHRs - 1]) {
    5875           0 :                 DesignHeatingRequirement = min(StandardDesignHeatingRequirement[StandardDHRNum], DesignHeatingRequirementMax);
    5876             :             }
    5877             :         }
    5878             :         // The minimum temperature below which the compressor is turned off
    5879          22 :         OATempCompressorOff = MinOATCompressor;
    5880             : 
    5881         352 :         for (BinNum = 0; BinNum < TotalNumOfTemperatureBins[RegionNum - 1]; ++BinNum) { // NumOfOATempBins
    5882             : 
    5883         330 :             FractionalBinHours = FracBinHoursAtOutdoorBinTemp[RegionNum - 1][BinNum];
    5884             : 
    5885             :             // Calculate the building heating load
    5886         330 :             BuildingHeatingLoad = (18.33 - OutdoorBinTemperature[BinNum]) / (18.33 - OutdoorDesignTemperature[RegionNum - 1]) * CorrectionFactor *
    5887             :                                   DesignHeatingRequirement;
    5888             : 
    5889         330 :             if ((OutdoorBinTemperature[BinNum] <= -8.33) || (OutdoorBinTemperature[BinNum] >= 7.20)) {
    5890         220 :                 HeatingCapacityMax = TotHeatCapTestH3(nsp) + ((TotHeatCapTestH1(nsp) - TotHeatCapTestH3(nsp)) *
    5891         220 :                                                               (OutdoorBinTemperature[BinNum] - HeatingOutdoorCoilInletAirDBTempH3Test) /
    5892             :                                                               (HeatingOutdoorCoilInletAirDBTempRated - HeatingOutdoorCoilInletAirDBTempH3Test));
    5893         220 :                 HeatingElecPowerMax =
    5894         220 :                     OutdoorUnitPowerTestH3(nsp) + ((OutdoorUnitPowerTestH1(nsp) - OutdoorUnitPowerTestH3(nsp)) *
    5895         220 :                                                    (OutdoorBinTemperature[BinNum] - HeatingOutdoorCoilInletAirDBTempH3Test) /
    5896             :                                                    (HeatingOutdoorCoilInletAirDBTempRated - HeatingOutdoorCoilInletAirDBTempH3Test));
    5897             :             } else {
    5898         110 :                 HeatingCapacityMax = TotHeatCapTestH3(nsp) + ((TotHeatCapTestH2(nsp) - TotHeatCapTestH3(nsp)) *
    5899         110 :                                                               (OutdoorBinTemperature[BinNum] - HeatingOutdoorCoilInletAirDBTempH3Test) /
    5900             :                                                               (HeatingOutdoorCoilInletAirDBTempH2Test - HeatingOutdoorCoilInletAirDBTempH3Test));
    5901         110 :                 HeatingElecPowerMax =
    5902         110 :                     OutdoorUnitPowerTestH3(nsp) + ((OutdoorUnitPowerTestH2(nsp) - OutdoorUnitPowerTestH3(nsp)) *
    5903         110 :                                                    (OutdoorBinTemperature[BinNum] - HeatingOutdoorCoilInletAirDBTempH3Test) /
    5904             :                                                    (HeatingOutdoorCoilInletAirDBTempH2Test - HeatingOutdoorCoilInletAirDBTempH3Test));
    5905             :             }
    5906             : 
    5907             :             // determine the speed number
    5908         387 :             for (spnum = 1; spnum <= nsp - 1; ++spnum) {
    5909             :                 // Low Speed
    5910         387 :                 if (OutdoorBinTemperature[BinNum] < -8.33) {
    5911         110 :                     HeatingCapacityLS = TotHeatCapTestH3(spnum) + ((TotHeatCapTestH1(spnum) - TotHeatCapTestH3(spnum)) *
    5912         110 :                                                                    (OutdoorBinTemperature[BinNum] - HeatingOutdoorCoilInletAirDBTempH3Test) /
    5913             :                                                                    (HeatingOutdoorCoilInletAirDBTempRated - HeatingOutdoorCoilInletAirDBTempH3Test));
    5914         110 :                     HeatingElecPowerLS =
    5915         110 :                         OutdoorUnitPowerTestH3(spnum) + ((OutdoorUnitPowerTestH1(spnum) - OutdoorUnitPowerTestH3(spnum)) *
    5916         110 :                                                          (OutdoorBinTemperature[BinNum] - HeatingOutdoorCoilInletAirDBTempH3Test) /
    5917             :                                                          (HeatingOutdoorCoilInletAirDBTempRated - HeatingOutdoorCoilInletAirDBTempH3Test));
    5918             : 
    5919         277 :                 } else if (OutdoorBinTemperature[BinNum] >= 4.44) {
    5920         110 :                     HeatingCapacityLS = TotHeatCapTestH1(spnum) + ((TotHeatCapTestH0(spnum) - TotHeatCapTestH1(spnum)) *
    5921         110 :                                                                    (OutdoorBinTemperature[BinNum] - HeatingOutdoorCoilInletAirDBTempRated) /
    5922             :                                                                    (HeatingOutdoorCoilInletAirDBTempH0Test - HeatingOutdoorCoilInletAirDBTempRated));
    5923         110 :                     HeatingElecPowerLS =
    5924         110 :                         OutdoorUnitPowerTestH1(spnum) + ((OutdoorUnitPowerTestH0(spnum) - OutdoorUnitPowerTestH1(spnum)) *
    5925         110 :                                                          (OutdoorBinTemperature[BinNum] - HeatingOutdoorCoilInletAirDBTempRated) /
    5926             :                                                          (HeatingOutdoorCoilInletAirDBTempH0Test - HeatingOutdoorCoilInletAirDBTempRated));
    5927             :                 } else {
    5928         167 :                     HeatingCapacityLS = TotHeatCapTestH3(spnum) + ((TotHeatCapTestH2(spnum) - TotHeatCapTestH3(spnum)) *
    5929         167 :                                                                    (OutdoorBinTemperature[BinNum] - HeatingOutdoorCoilInletAirDBTempH3Test) /
    5930             :                                                                    (HeatingOutdoorCoilInletAirDBTempH2Test - HeatingOutdoorCoilInletAirDBTempH3Test));
    5931         167 :                     HeatingElecPowerLS =
    5932         167 :                         OutdoorUnitPowerTestH3(spnum) + ((OutdoorUnitPowerTestH2(spnum) - OutdoorUnitPowerTestH3(spnum)) *
    5933         167 :                                                          (OutdoorBinTemperature[BinNum] - HeatingOutdoorCoilInletAirDBTempH3Test) /
    5934             :                                                          (HeatingOutdoorCoilInletAirDBTempH2Test - HeatingOutdoorCoilInletAirDBTempH3Test));
    5935             :                 }
    5936             :                 // High Speed
    5937         387 :                 if ((OutdoorBinTemperature[BinNum] <= -8.33) || (OutdoorBinTemperature[BinNum] >= 7.20)) {
    5938         220 :                     HeatingCapacityHS =
    5939         220 :                         TotHeatCapTestH3(spnum + 1) + ((TotHeatCapTestH1(spnum + 1) - TotHeatCapTestH3(spnum + 1)) *
    5940         220 :                                                        (OutdoorBinTemperature[BinNum] - HeatingOutdoorCoilInletAirDBTempH3Test) /
    5941             :                                                        (HeatingOutdoorCoilInletAirDBTempRated - HeatingOutdoorCoilInletAirDBTempH3Test));
    5942         220 :                     HeatingElecPowerHS =
    5943         220 :                         OutdoorUnitPowerTestH3(spnum + 1) + ((OutdoorUnitPowerTestH1(spnum + 1) - OutdoorUnitPowerTestH3(spnum + 1)) *
    5944         220 :                                                              (OutdoorBinTemperature[BinNum] - HeatingOutdoorCoilInletAirDBTempH3Test) /
    5945             :                                                              (HeatingOutdoorCoilInletAirDBTempRated - HeatingOutdoorCoilInletAirDBTempH3Test));
    5946             :                 } else {
    5947         167 :                     HeatingCapacityHS =
    5948         167 :                         TotHeatCapTestH3(spnum + 1) + ((TotHeatCapTestH2(spnum + 1) - TotHeatCapTestH3(spnum + 1)) *
    5949         167 :                                                        (OutdoorBinTemperature[BinNum] - HeatingOutdoorCoilInletAirDBTempH3Test) /
    5950             :                                                        (HeatingOutdoorCoilInletAirDBTempH2Test - HeatingOutdoorCoilInletAirDBTempH3Test));
    5951         167 :                     HeatingElecPowerHS =
    5952         167 :                         OutdoorUnitPowerTestH3(spnum + 1) + ((OutdoorUnitPowerTestH2(spnum + 1) - OutdoorUnitPowerTestH3(spnum + 1)) *
    5953         167 :                                                              (OutdoorBinTemperature[BinNum] - HeatingOutdoorCoilInletAirDBTempH3Test) /
    5954             :                                                              (HeatingOutdoorCoilInletAirDBTempH2Test - HeatingOutdoorCoilInletAirDBTempH3Test));
    5955             :                 }
    5956         387 :                 LowTempCutOutFactor = 0.0;
    5957         387 :                 if (!OATempCompressorOnOffBlank) {
    5958         387 :                     if (OutdoorBinTemperature[BinNum] <= OATempCompressorOff) {
    5959         102 :                         LowTempCutOutFactor = 0.0;
    5960         285 :                     } else if (OutdoorBinTemperature[BinNum] > OATempCompressorOff && OutdoorBinTemperature[BinNum] <= OATempCompressorOn) {
    5961          92 :                         LowTempCutOutFactor = 0.5;
    5962             :                     } else {
    5963         193 :                         LowTempCutOutFactor = 1.0;
    5964             :                     }
    5965             :                 } else {
    5966           0 :                     LowTempCutOutFactor = 1.0;
    5967             :                 }
    5968             : 
    5969         387 :                 if (BuildingHeatingLoad <= HeatingCapacityLS) {
    5970         115 :                     if (HeatingCapacityLS > 0.0) PartLoadRatio = min(1.0, BuildingHeatingLoad / HeatingCapacityLS);
    5971         115 :                     NetTotHeatCapBinned = BuildingHeatingLoad;
    5972         115 :                     PartLoadFraction = 1.0 - CyclicDegradationCoeff * (1.0 - PartLoadRatio);
    5973         115 :                     TotHeatElecPowerBinnedHP = (PartLoadRatio / PartLoadFraction) * HeatingElecPowerLS * LowTempCutOutFactor;
    5974         115 :                     TotHeatElecPowerBinnedRH = BuildingHeatingLoad * (1.0 - LowTempCutOutFactor);
    5975         115 :                     goto HeatSpeedLoop_exit;
    5976             : 
    5977         272 :                 } else if ((BuildingHeatingLoad > HeatingCapacityLS) && (BuildingHeatingLoad < HeatingCapacityHS)) {
    5978             :                     // cycle between speed "spnum" and "spnum + 1"
    5979          87 :                     LoadFactor = min(1.0, (HeatingCapacityHS - BuildingHeatingLoad) / (HeatingCapacityHS - HeatingCapacityLS));
    5980          87 :                     LoadFactor = max(0.0, LoadFactor);
    5981             : 
    5982          87 :                     NetTotHeatCapBinned = BuildingHeatingLoad;
    5983          87 :                     TotHeatElecPowerBinnedHP = LoadFactor * HeatingElecPowerLS + (1.0 - LoadFactor) * HeatingElecPowerHS;
    5984          87 :                     TotHeatElecPowerBinnedHP *= LowTempCutOutFactor;
    5985          87 :                     TotHeatElecPowerBinnedRH = BuildingHeatingLoad * (1.0 - LowTempCutOutFactor);
    5986          87 :                     goto HeatSpeedLoop_exit;
    5987             : 
    5988         185 :                 } else if (BuildingHeatingLoad >= HeatingCapacityMax) {
    5989         128 :                     NetTotHeatCapBinned = BuildingHeatingLoad;
    5990         128 :                     if (!OATempCompressorOnOffBlank && HeatingElecPowerMax > 0.0) {
    5991         128 :                         if ((OutdoorBinTemperature[BinNum] <= OATempCompressorOff) || (HeatingCapacityMax / HeatingElecPowerMax < 1.0)) {
    5992         102 :                             LowTempCutOutFactor = 0.0;
    5993          47 :                         } else if ((OutdoorBinTemperature[BinNum] > OATempCompressorOff && OutdoorBinTemperature[BinNum] <= OATempCompressorOn) &&
    5994          21 :                                    (HeatingCapacityMax / HeatingElecPowerMax > 1.0)) {
    5995          21 :                             LowTempCutOutFactor = 0.5;
    5996           5 :                         } else if ((OutdoorBinTemperature[BinNum] > OATempCompressorOn) && (HeatingCapacityMax / HeatingElecPowerMax > 1.0)) {
    5997           5 :                             LowTempCutOutFactor = 1.0;
    5998             :                         }
    5999             :                     } else {
    6000           0 :                         LowTempCutOutFactor = 1.0;
    6001             :                     }
    6002             : 
    6003         128 :                     TotHeatElecPowerBinnedHP = HeatingElecPowerMax * LowTempCutOutFactor;
    6004         128 :                     TotHeatElecPowerBinnedRH = BuildingHeatingLoad - HeatingCapacityMax * LowTempCutOutFactor;
    6005         128 :                     goto HeatSpeedLoop_exit;
    6006             :                 }
    6007             :             }
    6008           0 :         HeatSpeedLoop_exit:;
    6009             : 
    6010         330 :             NetHeatingCapWeighted += NetTotHeatCapBinned * FractionalBinHours;
    6011         330 :             TotHeatingElecPowerWeighted += (TotHeatElecPowerBinnedHP + TotHeatElecPowerBinnedRH) * FractionalBinHours;
    6012             :         }
    6013             : 
    6014          22 :         if (DefrostControl == HPdefrostControl::Timed) {
    6015          22 :             DemandDeforstCredit = 1.0; // Timed defrost control
    6016             :         } else {
    6017           0 :             DemandDeforstCredit = 1.03; // Demand defrost control
    6018             :         }
    6019             : 
    6020          22 :         if (TotHeatingElecPowerWeighted > 0.0) {
    6021          22 :             HSPF = NetHeatingCapWeighted * DemandDeforstCredit / TotHeatingElecPowerWeighted;
    6022             :         } else {
    6023           0 :             HSPF = 0.0;
    6024             :         }
    6025             : 
    6026          44 :         return std::make_tuple(NetHeatingCapRatedHighTemp, NetHeatingCapRatedLowTemp, HSPF);
    6027          22 :     }
    6028             : 
    6029          22 :     std::tuple<Real64, Real64, Real64> MultiSpeedDXHeatingCoilHSPF2(
    6030             :         EnergyPlusData &state,
    6031             :         int const nsp,                                                // Number of compressor speed
    6032             :         Array1A<Real64> const MSFanPowerPerEvapAirFlowRateInput_2023, // 2023 rated fan power per evap air flow rate [W/(m3/s)]
    6033             :         Array1A_int const CapFTempCurveIndex,                         // Index for the capacity as a function of temperature modifier curve
    6034             :         Array1A_int const CapFFlowCurveIndex,                         // Index for the capacity as a function of flow fraction modifier curve
    6035             :         Array1A<Real64> const RatedTotalCapacity,                     // Reference capacity of DX coil [W]
    6036             :         Array1A<Real64> const RatedAirVolFlowRate,                    // Reference air flow rate of DX coil [m3/s]
    6037             :         Array1A_int const EIRFFlowCurveIndex,                         // Index for the EIR as a function of flow fraction modifier curve
    6038             :         Array1A_int const EIRFTempCurveIndex,                         // Index for the EIR as a function of temperature modifier curve
    6039             :         Array1A<Real64> const RatedCOP,                               // Reference coefficient of performance [W/W]
    6040             :         ObjexxFCL::Optional_int_const RegionNum,                      // Region number for calculating HSPF of single speed DX heating coil
    6041             :         ObjexxFCL::Optional<Real64 const> MinOATCompressor,           // Minimum OAT for heat pump compressor operation [C]
    6042             :         ObjexxFCL::Optional<Real64 const> OATempCompressorOn,         // The outdoor temperature when the compressor is automatically turned
    6043             :         ObjexxFCL::Optional_bool_const OATempCompressorOnOffBlank,    // Flag used to determine low temperature cut out factor
    6044             :         ObjexxFCL::Optional<HPdefrostControl const> DefrostControl)   // defrost control; 1=timed, 2=on-demand
    6045             :     {
    6046             : 
    6047             :         // Intermediate values calculated from the inputs in the idf file
    6048          22 :         Real64 HSPF2_2023(0.0);
    6049          22 :         Real64 NetHeatingCapRatedHighTemp_2023(0.0);
    6050          22 :         Real64 NetHeatingCapRatedLowTemp_2023(0.0);
    6051             : 
    6052             :         int BinNum2023; // bin number counter
    6053             :         int spnum;      // compressor speed number
    6054             : 
    6055          22 :         Array1D<Real64> FanPowerPerEvapAirFlowRate_2023(nsp); // Fan power per air volume flow rate through the evaporator coil [W/(m3/s)]
    6056             : 
    6057             :         // Real64 HeatingCapacityLS;                  // cooling capacity of Mult-speed DX coil at lower speed, [W]
    6058             :         // Real64 HeatingCapacityHS;                  // cooling capacity of Mult-speed DX coil at higher speed, [W]
    6059             :         // Real64 HeatingElecPowerLS;                 // outdoor unit electric power input at low speed, [W]
    6060             :         // Real64 HeatingElecPowerHS;                 // outdoor unit electric power input at high speed, [W]
    6061             :         // Real64 HeatingCapacityMax;                 // cooling capacity of Mult-speed DX coil at max speed, [W]
    6062             :         // Real64 HeatingElecPowerMax;                // outdoor unit electric power input at Max speed, [W]
    6063             :         // Array1D<Real64> TotHeatCapTestH1High(nsp); // net heating capacity high speed at H1 test conditon, [W]
    6064             : 
    6065             :         // Intermediate values calculated from the inputs in the idf file
    6066          22 :         Array1D<Real64> TotCapFlowModFac(nsp); // Total capacity modifier f(actual flow vs rated flow) for each speed [-]
    6067          22 :         Array1D<Real64> EIRFlowModFac(nsp);    // EIR modifier f(actual supply air flow vs rated flow) for each speed [-]
    6068             : 
    6069          22 :         Real64 TotCapTempModFacH0Low(0.0);  // Tot capacity modifier (function of entering wetbulb, outside drybulb) at H0 Low Test [-]
    6070          22 :         Real64 EIRTempModFacH0Low(0.0);     // EIR modifier (function of entering wetbulb, outside drybulb) at H0 Low Test[-]
    6071          22 :         Real64 TotCapTempModFacH1Low(0.0);  // Tot capacity modifier (function of entering wetbulb, outside drybulb) at H1 Low Test [-]
    6072          22 :         Real64 EIRTempModFacH1Low(0.0);     // EIR modifier (function of entering wetbulb, outside drybulb) at H1 Low Test[-]
    6073          22 :         Real64 TotCapTempModFacH2Int(0.0);  // Tot capacity modifier (function of entering wetbulb, outside drybulb) at H2 Int Test [-]
    6074          22 :         Real64 EIRTempModFacH2Int(0.0);     // EIR modifier (function of entering wetbulb, outside drybulb) at H2 Int Test[-]
    6075          22 :         Real64 TotCapTempModFacH1Full(0.0); // Tot capacity modifier (function of entering wetbulb, outside drybulb) at H1 Full Test [-]
    6076          22 :         Real64 EIRTempModFacH1Full(0.0);    // EIR modifier (function of entering wetbulb, outside drybulb) at H1 Full Test[-]
    6077          22 :         Real64 TotCapTempModFacH2Full(0.0); // Tot capacity modifier (function of entering wetbulb, outside drybulb) at H2 Full Test [-]
    6078          22 :         Real64 EIRTempModFacH2Full(0.0);    // EIR modifier (function of entering wetbulb, outside drybulb) at H2 Full Test[-]
    6079          22 :         Real64 TotCapTempModFacH3Full(0.0); // Tot capacity modifier (function of entering wetbulb, outside drybulb) at H3 Full Test [-]
    6080          22 :         Real64 EIRTempModFacH3Full(0.0);    // EIR modifier (function of entering wetbulb, outside drybulb) at H3 Full Test[-]
    6081          22 :         Real64 TotCapTempModFacH4Full(0.0); // Tot capacity modifier (function of entering wetbulb, outside drybulb) at H4 Full Test [-]
    6082          22 :         Real64 EIRTempModFacH4Full(0.0);    // EIR modifier (function of entering wetbulb, outside drybulb) at H4 Full Test[-]
    6083             : 
    6084          22 :         Real64 OATempCompressorOff(0.0); // Minimum outdoor air temperature to turn the commpressor off
    6085             : 
    6086          22 :         Real64 NetHeatingCapWeighted(0.0);       // net total heating cap weighted by the fraction of the binned cooling hours [W]
    6087          22 :         Real64 TotHeatingElecPowerWeighted(0.0); // net total heat pump and resistance heating electric Energy input weighted by
    6088             :         // the fraction of the binned cooling hours
    6089             : 
    6090          22 :         Real64 n(0.0);     // Fractional bin hours for the heating season  [-]
    6091          22 :         Real64 f_def(1.0); // Demand Defrost Credit, A factor to adjust HSPF if coil has demand defrost control  [-]
    6092             : 
    6093          22 :         NetHeatingCapWeighted = 0.0;
    6094          22 :         TotHeatingElecPowerWeighted = 0.0;
    6095             : 
    6096          92 :         for (spnum = 1; spnum <= nsp; ++spnum) {
    6097          70 :             FanPowerPerEvapAirFlowRate_2023(spnum) = 0.0;
    6098          70 :             if (MSFanPowerPerEvapAirFlowRateInput_2023(spnum) <= 0.0) {
    6099           0 :                 FanPowerPerEvapAirFlowRate_2023(spnum) = DefaultFanPowerPerEvapAirFlowRateSEER2;
    6100             :             } else {
    6101          70 :                 FanPowerPerEvapAirFlowRate_2023(spnum) = MSFanPowerPerEvapAirFlowRateInput_2023(spnum);
    6102             :             }
    6103             :         }
    6104             : 
    6105          22 :         Real64 HeatingOutdoorCoilInletAirDBTemp_H0LowTest = 16.66; // Outdoor air dry-bulb temp in degrees 16.66 C (62 F)
    6106          22 :         Real64 HeatingIndoorCoilInletAirDBTemp_H0LowTest = 21.11;  // Indoor air dry-bulb temp in degrees 21.11 C (70 F)
    6107             : 
    6108          22 :         Real64 HeatingOutdoorCoilInletAirDBTemp_H1LowTest = 8.33; // Outdoor air dry-bulb temp in degrees 8.33 C (47 F)
    6109          22 :         Real64 HeatingIndoorCoilInletAirDBTemp_H1LowTest = 21.11; // Indoor air dry-bulb temp in degrees 21.11 C (70 F)
    6110             : 
    6111          22 :         Real64 HeatingOutdoorCoilInletAirDBTemp_H2IntTest = 1.66; // Outdoor air dry-bulb temp in degrees 1.66 C (35 F)
    6112          22 :         Real64 HeatingIndoorCoilInletAirDBTemp_H2IntTest = 21.11; // Indoor air dry-bulb temp in degrees 21.11 C (70 F)
    6113             : 
    6114          22 :         Real64 HeatingOutdoorCoilInletAirDBTemp_H1FullTest = 8.33; // Outdoor air dry-bulb temp in degrees 8.33 C (47 F)
    6115          22 :         Real64 HeatingIndoorCoilInletAirDBTemp_H1FullTest = 21.11; // Indoor air dry-bulb temp in degrees 21.11 C (70 F)
    6116             : 
    6117          22 :         Real64 HeatingOutdoorCoilInletAirDBTemp_H2FullTest = 1.66; // Outdoor air dry-bulb temp in degrees  C (35 F)
    6118          22 :         Real64 HeatingIndoorCoilInletAirDBTemp_H2FullTest = 21.11; // Indoor air dry-bulb temp in degrees 21.11 C (70 F)
    6119             : 
    6120          22 :         Real64 HeatingOutdoorCoilInletAirDBTemp_H3FullTest = -8.33; // Outdoor air dry-bulb temp in degrees  C (17 F)
    6121          22 :         Real64 HeatingIndoorCoilInletAirDBTemp_H3FullTest = 21.11;  // Indoor air dry-bulb temp in degrees 21.11 C (70 F)
    6122             : 
    6123          22 :         Real64 HeatingOutdoorCoilInletAirDBTemp_H4FullTest = -15;  // Outdoor air dry-bulb temp in degrees  C (5 F)
    6124          22 :         Real64 HeatingIndoorCoilInletAirDBTemp_H4FullTest = 21.11; // Indoor air dry-bulb temp in degrees 21.11 C (70 F)
    6125             : 
    6126          22 :         Array1D<Real64> Q_A_Full(nsp);
    6127             : 
    6128          22 :         Array1D<Real64> Q_H0_Low(nsp);  // Total cooling capacity at H0 Low test condition (Low speed)
    6129          22 :         Array1D<Real64> Q_H1_Low(nsp);  // Total cooling capacity at H1 Low test condition (Low speed)
    6130          22 :         Array1D<Real64> Q_H2_Int(nsp);  // Total cooling capacity at H2 Int test condition
    6131          22 :         Array1D<Real64> Q_H1_Full(nsp); // Total cooling capacity at H1 Full test condition (High speed)
    6132          22 :         Array1D<Real64> Q_H2_Full(nsp); // Total cooling capacity at H2 Full test condition (High speed)
    6133          22 :         Array1D<Real64> Q_H3_Full(nsp); // Total cooling capacity at H3 Full test condition (High speed)
    6134          22 :         Array1D<Real64> Q_H4_Full(nsp); // Total cooling capacity at H4 Full test condition (High speed)
    6135             : 
    6136          22 :         Array1D<Real64> P_H0_Low(nsp);  // Outdoor Unit electric power at H0 Low test condition (Low speed)
    6137          22 :         Array1D<Real64> P_H1_Low(nsp);  // Outdoor Unit electric power at H1 Low test condition (Low speed)
    6138          22 :         Array1D<Real64> P_H2_Int(nsp);  // Outdoor Unit electric power at H2 Int test condition
    6139          22 :         Array1D<Real64> P_H1_Full(nsp); // Outdoor Unit electric power at H1 Full test condition (Full speed)
    6140          22 :         Array1D<Real64> P_H2_Full(nsp); // Outdoor Unit electric power at H2 Full test condition (Full speed)
    6141          22 :         Array1D<Real64> P_H3_Full(nsp); // Outdoor Unit electric power at H3 Full test condition (Full speed)
    6142          22 :         Array1D<Real64> P_H4_Full(nsp); // Outdoor Unit electric power at H4 Full test condition (Full speed)
    6143             : 
    6144             :         // Proceed withe HSPF2 value calculation
    6145          92 :         for (spnum = 1; spnum <= nsp; ++spnum) {
    6146          70 :             TotCapFlowModFac(spnum) = Curve::CurveValue(state, CapFFlowCurveIndex(spnum), AirMassFlowRatioRated);
    6147             : 
    6148          70 :             if (state.dataCurveManager->PerfCurve(CapFTempCurveIndex(spnum))->numDims == 1) {
    6149             : 
    6150          52 :                 TotCapTempModFacH0Low = Curve::CurveValue(state, CapFTempCurveIndex(spnum), HeatingOutdoorCoilInletAirDBTemp_H0LowTest);
    6151          52 :                 TotCapTempModFacH1Low = Curve::CurveValue(state, CapFTempCurveIndex(spnum), HeatingOutdoorCoilInletAirDBTemp_H1LowTest);
    6152          52 :                 TotCapTempModFacH2Int = Curve::CurveValue(state, CapFTempCurveIndex(spnum), HeatingOutdoorCoilInletAirDBTemp_H2IntTest);
    6153          52 :                 TotCapTempModFacH1Full = Curve::CurveValue(state, CapFTempCurveIndex(spnum), HeatingOutdoorCoilInletAirDBTemp_H1FullTest);
    6154          52 :                 TotCapTempModFacH2Full = Curve::CurveValue(state, CapFTempCurveIndex(spnum), HeatingOutdoorCoilInletAirDBTemp_H2FullTest);
    6155          52 :                 TotCapTempModFacH3Full = Curve::CurveValue(state, CapFTempCurveIndex(spnum), HeatingOutdoorCoilInletAirDBTemp_H3FullTest);
    6156          52 :                 TotCapTempModFacH4Full = Curve::CurveValue(state, CapFTempCurveIndex(spnum), HeatingOutdoorCoilInletAirDBTemp_H4FullTest);
    6157             :             } else {
    6158          36 :                 TotCapTempModFacH0Low = Curve::CurveValue(
    6159          18 :                     state, CapFTempCurveIndex(spnum), HeatingIndoorCoilInletAirDBTemp_H0LowTest, HeatingOutdoorCoilInletAirDBTemp_H0LowTest);
    6160          36 :                 TotCapTempModFacH1Low = Curve::CurveValue(
    6161          18 :                     state, CapFTempCurveIndex(spnum), HeatingIndoorCoilInletAirDBTemp_H1LowTest, HeatingOutdoorCoilInletAirDBTemp_H1LowTest);
    6162          36 :                 TotCapTempModFacH2Int = Curve::CurveValue(
    6163          18 :                     state, CapFTempCurveIndex(spnum), HeatingIndoorCoilInletAirDBTemp_H2IntTest, HeatingOutdoorCoilInletAirDBTemp_H2IntTest);
    6164          36 :                 TotCapTempModFacH1Full = Curve::CurveValue(
    6165          18 :                     state, CapFTempCurveIndex(spnum), HeatingIndoorCoilInletAirDBTemp_H1FullTest, HeatingOutdoorCoilInletAirDBTemp_H1FullTest);
    6166          36 :                 TotCapTempModFacH2Full = Curve::CurveValue(
    6167          18 :                     state, CapFTempCurveIndex(spnum), HeatingIndoorCoilInletAirDBTemp_H2FullTest, HeatingOutdoorCoilInletAirDBTemp_H2FullTest);
    6168          36 :                 TotCapTempModFacH3Full = Curve::CurveValue(
    6169          18 :                     state, CapFTempCurveIndex(spnum), HeatingIndoorCoilInletAirDBTemp_H3FullTest, HeatingOutdoorCoilInletAirDBTemp_H3FullTest);
    6170          18 :                 TotCapTempModFacH4Full = Curve::CurveValue(
    6171          18 :                     state, CapFTempCurveIndex(spnum), HeatingIndoorCoilInletAirDBTemp_H4FullTest, HeatingOutdoorCoilInletAirDBTemp_H4FullTest);
    6172             :             }
    6173             : 
    6174             :             Real64 curveVal;
    6175          70 :             switch (state.dataCurveManager->PerfCurve(CapFTempCurveIndex(spnum))->numDims) {
    6176          52 :             case 1:
    6177          52 :                 curveVal = Curve::CurveValue(state, CapFTempCurveIndex(spnum), IndoorCoilInletAirWetBulbTempRated);
    6178          52 :                 break;
    6179          18 :             case 2:
    6180             :             default: // this default allows the simulation to continue, but will issue a warning, should be removed eventually
    6181             :                 curveVal =
    6182          18 :                     Curve::CurveValue(state, CapFTempCurveIndex(spnum), IndoorCoilInletAirWetBulbTempRated, OutdoorCoilInletAirDryBulbTempTestA2);
    6183          18 :                 break;
    6184             :             }
    6185         140 :             Q_A_Full(spnum) =
    6186          70 :                 RatedTotalCapacity(spnum) * curveVal * TotCapFlowModFac(spnum) - FanPowerPerEvapAirFlowRate_2023(spnum) * RatedAirVolFlowRate(spnum);
    6187             : 
    6188          70 :             Q_H0_Low(spnum) = RatedTotalCapacity(spnum) * TotCapTempModFacH0Low * TotCapFlowModFac(spnum) +
    6189          70 :                               FanPowerPerEvapAirFlowRate_2023(spnum) * RatedAirVolFlowRate(spnum);
    6190          70 :             Q_H1_Low(spnum) = RatedTotalCapacity(spnum) * TotCapTempModFacH1Low * TotCapFlowModFac(spnum) +
    6191          70 :                               FanPowerPerEvapAirFlowRate_2023(spnum) * RatedAirVolFlowRate(spnum);
    6192          70 :             Q_H2_Int(spnum) = RatedTotalCapacity(spnum) * TotCapTempModFacH2Int * TotCapFlowModFac(spnum) +
    6193          70 :                               FanPowerPerEvapAirFlowRate_2023(spnum) * RatedAirVolFlowRate(spnum);
    6194          70 :             Q_H1_Full(spnum) = RatedTotalCapacity(spnum) * TotCapTempModFacH1Full * TotCapFlowModFac(spnum) +
    6195          70 :                                FanPowerPerEvapAirFlowRate_2023(spnum) * RatedAirVolFlowRate(spnum);
    6196          70 :             Q_H2_Full(spnum) = RatedTotalCapacity(spnum) * TotCapTempModFacH2Full * TotCapFlowModFac(spnum) +
    6197          70 :                                FanPowerPerEvapAirFlowRate_2023(spnum) * RatedAirVolFlowRate(spnum);
    6198          70 :             Q_H3_Full(spnum) = RatedTotalCapacity(spnum) * TotCapTempModFacH3Full * TotCapFlowModFac(spnum) +
    6199          70 :                                FanPowerPerEvapAirFlowRate_2023(spnum) * RatedAirVolFlowRate(spnum);
    6200          70 :             Q_H4_Full(spnum) = RatedTotalCapacity(spnum) * TotCapTempModFacH4Full * TotCapFlowModFac(spnum) +
    6201          70 :                                FanPowerPerEvapAirFlowRate_2023(spnum) * RatedAirVolFlowRate(spnum);
    6202             : 
    6203          70 :             EIRFlowModFac(spnum) = Curve::CurveValue(state, EIRFFlowCurveIndex(spnum), AirMassFlowRatioRated);
    6204             : 
    6205          70 :             if (state.dataCurveManager->PerfCurve(EIRFTempCurveIndex(spnum))->numDims == 1) {
    6206             : 
    6207          52 :                 EIRTempModFacH0Low = Curve::CurveValue(state, EIRFTempCurveIndex(spnum), HeatingOutdoorCoilInletAirDBTemp_H0LowTest);
    6208             : 
    6209          52 :                 EIRTempModFacH1Low = Curve::CurveValue(state, EIRFTempCurveIndex(spnum), HeatingOutdoorCoilInletAirDBTemp_H1LowTest);
    6210          52 :                 EIRTempModFacH2Int = Curve::CurveValue(state, EIRFTempCurveIndex(spnum), HeatingOutdoorCoilInletAirDBTemp_H2IntTest);
    6211          52 :                 EIRTempModFacH1Full = Curve::CurveValue(state, EIRFTempCurveIndex(spnum), HeatingOutdoorCoilInletAirDBTemp_H1FullTest);
    6212          52 :                 EIRTempModFacH2Full = Curve::CurveValue(state, EIRFTempCurveIndex(spnum), HeatingOutdoorCoilInletAirDBTemp_H2FullTest);
    6213          52 :                 EIRTempModFacH3Full = Curve::CurveValue(state, EIRFTempCurveIndex(spnum), HeatingOutdoorCoilInletAirDBTemp_H3FullTest);
    6214          52 :                 EIRTempModFacH4Full = Curve::CurveValue(state, EIRFTempCurveIndex(spnum), HeatingOutdoorCoilInletAirDBTemp_H4FullTest);
    6215             : 
    6216             :             } else {
    6217             : 
    6218          36 :                 EIRTempModFacH0Low = Curve::CurveValue(
    6219          18 :                     state, EIRFTempCurveIndex(spnum), HeatingIndoorCoilInletAirDBTemp_H0LowTest, HeatingOutdoorCoilInletAirDBTemp_H0LowTest);
    6220          36 :                 EIRTempModFacH1Low = Curve::CurveValue(
    6221          18 :                     state, EIRFTempCurveIndex(spnum), HeatingIndoorCoilInletAirDBTemp_H1LowTest, HeatingOutdoorCoilInletAirDBTemp_H1LowTest);
    6222          36 :                 EIRTempModFacH2Int = Curve::CurveValue(
    6223          18 :                     state, EIRFTempCurveIndex(spnum), HeatingIndoorCoilInletAirDBTemp_H2IntTest, HeatingOutdoorCoilInletAirDBTemp_H2IntTest);
    6224          36 :                 EIRTempModFacH1Full = Curve::CurveValue(
    6225          18 :                     state, EIRFTempCurveIndex(spnum), HeatingIndoorCoilInletAirDBTemp_H1FullTest, HeatingOutdoorCoilInletAirDBTemp_H1FullTest);
    6226          36 :                 EIRTempModFacH2Full = Curve::CurveValue(
    6227          18 :                     state, EIRFTempCurveIndex(spnum), HeatingIndoorCoilInletAirDBTemp_H2FullTest, HeatingOutdoorCoilInletAirDBTemp_H2FullTest);
    6228          36 :                 EIRTempModFacH3Full = Curve::CurveValue(
    6229          18 :                     state, EIRFTempCurveIndex(spnum), HeatingIndoorCoilInletAirDBTemp_H3FullTest, HeatingOutdoorCoilInletAirDBTemp_H3FullTest);
    6230          18 :                 EIRTempModFacH4Full = Curve::CurveValue(
    6231          18 :                     state, EIRFTempCurveIndex(spnum), HeatingIndoorCoilInletAirDBTemp_H4FullTest, HeatingOutdoorCoilInletAirDBTemp_H4FullTest);
    6232             :             }
    6233             : 
    6234          70 :             if (RatedCOP(spnum) > 0.0) {
    6235             : 
    6236          70 :                 P_H0_Low(spnum) = Q_H0_Low(spnum) * EIRFlowModFac(spnum) * EIRTempModFacH0Low / RatedCOP(spnum) +
    6237          70 :                                   FanPowerPerEvapAirFlowRate_2023(spnum) * RatedAirVolFlowRate(spnum);
    6238          70 :                 P_H1_Low(spnum) = Q_H1_Low(spnum) * EIRFlowModFac(spnum) * EIRTempModFacH1Low / RatedCOP(spnum) +
    6239          70 :                                   FanPowerPerEvapAirFlowRate_2023(spnum) * RatedAirVolFlowRate(spnum);
    6240          70 :                 P_H2_Int(spnum) = Q_H2_Int(spnum) * EIRFlowModFac(spnum) * EIRTempModFacH2Int / RatedCOP(spnum) +
    6241          70 :                                   FanPowerPerEvapAirFlowRate_2023(spnum) * RatedAirVolFlowRate(spnum);
    6242          70 :                 P_H1_Full(spnum) = Q_H1_Full(spnum) * EIRFlowModFac(spnum) * EIRTempModFacH1Full / RatedCOP(spnum) +
    6243          70 :                                    FanPowerPerEvapAirFlowRate_2023(spnum) * RatedAirVolFlowRate(spnum);
    6244          70 :                 P_H2_Full(spnum) = Q_H2_Full(spnum) * EIRFlowModFac(spnum) * EIRTempModFacH2Full / RatedCOP(spnum) +
    6245          70 :                                    FanPowerPerEvapAirFlowRate_2023(spnum) * RatedAirVolFlowRate(spnum);
    6246          70 :                 P_H3_Full(spnum) = Q_H3_Full(spnum) * EIRFlowModFac(spnum) * EIRTempModFacH3Full / RatedCOP(spnum) +
    6247          70 :                                    FanPowerPerEvapAirFlowRate_2023(spnum) * RatedAirVolFlowRate(spnum);
    6248         140 :                 P_H4_Full(spnum) = Q_H4_Full(spnum) * EIRFlowModFac(spnum) * EIRTempModFacH4Full / RatedCOP(spnum) +
    6249          70 :                                    FanPowerPerEvapAirFlowRate_2023(spnum) * RatedAirVolFlowRate(spnum);
    6250             :             }
    6251             :         }
    6252             : 
    6253             :         // determine the HP capacity at the rated condition (AHRI H1 high speed test Condition); and determine the
    6254             :         // the building heat requirement for the user specified region
    6255          22 :         NetHeatingCapRatedHighTemp_2023 = Q_H1_Full(nsp);
    6256          22 :         NetHeatingCapRatedLowTemp_2023 = Q_H3_Full(nsp);
    6257             : 
    6258             :         // The minimum temperature below which the compressor is turned off
    6259          22 :         Real64 t_Off = MinOATCompressor; // Heating off | outdoor Minimum temperature below which the compressor ceases to operate
    6260             :         // The outdoor temperature when the compressor is automatically turned
    6261          22 :         Real64 t_On = OATempCompressorOn; // Heating On | outdoor temperature at which the compressor reinitiates operation
    6262             : 
    6263          22 :         Int64 RN = static_cast<int64_t>(RegionNum);
    6264             : 
    6265          22 :         Real64 q_sum(0.0);
    6266          22 :         Real64 e_sum(0.0);
    6267          22 :         Real64 rh_sum(0.0);
    6268             : 
    6269             :         // The minimum temperature below which the compressor is turned off
    6270          22 :         OATempCompressorOff = MinOATCompressor;
    6271             : 
    6272             :         // Equation 11.111 AHRI-2023
    6273          22 :         Real64 t_ob = 7.22; //  temperature at which frosting influence on full stage performance begins 7.22 C (45 F)
    6274         418 :         for (BinNum2023 = 0; BinNum2023 < 18; ++BinNum2023) { // NumOfOATempBins
    6275             : 
    6276         396 :             Real64 t = OutdoorBinTemperature[BinNum2023];
    6277         396 :             n = FracBinHoursAtOutdoorBinTempHSPF2[RN - 1][BinNum2023];
    6278         396 :             if (n == 0.0) {
    6279             :                 // we're skipping load calculations for any Temperature bin against which fractional hours are 0.0
    6280         110 :                 continue;
    6281             :             }
    6282         286 :             Real64 t_zl = ZoneLoadTemperature[RN - 1];
    6283         286 :             Real64 t_od = OutdoorDesignTemperature[RN - 1];
    6284         286 :             Real64 c_x = VariableSpeedLoadFactor[RN - 1];
    6285             : 
    6286             :             // For ANSI/AHRI 210/240 Standard 2023 | Concept of DHRI min and max is removed
    6287             :             // Section 11.2.2.1 Equation 11.104  which suggests QAFull is used instead of DHRI min
    6288             :             // While Calculaiting the Building load For heating-only heat pump units, replace Q_A_Full with Q_H_Full
    6289             :             // Q_H_Full = the heating capacity at 47F determined from the H1N test for variable capacity systems and
    6290             :             // from the H1Full test for other systems, Btu/h.
    6291         286 :             Real64 bl = (t_zl - t) / (t_zl - t_od) * c_x * Q_H1_Full(nsp);
    6292             : 
    6293         286 :             Real64 q_full(0.0);
    6294         286 :             Real64 p_full(0.0);
    6295         286 :             Real64 cop_full(0.0);
    6296             : 
    6297         286 :             Real64 delta_full(0.0);
    6298         286 :             Real64 hlf_full(0.0);
    6299         286 :             Real64 e(0.0);
    6300         286 :             Real64 rh(0.0);
    6301             : 
    6302         286 :             if (t >= t_ob) {
    6303          44 :                 q_full = Q_H3_Full(nsp) + (Q_H1_Full(nsp) - Q_H3_Full(nsp)) * ((t - (-8.33)) / (8.33 - (-8.33))); // Equation 11.112 AHRI-2023
    6304          44 :                 p_full = P_H3_Full(nsp) + (P_H1_Full(nsp) - P_H3_Full(nsp)) * ((t - (-8.33)) / (8.33 - (-8.33))); // Equation 11.117 AHRI-2023
    6305         242 :             } else if (t >= (-8.33) && t < t_ob) {
    6306         132 :                 q_full = Q_H3_Full(nsp) + (Q_H2_Full(nsp) - Q_H3_Full(nsp)) * ((t - (-8.33)) / (1.66 - (-8.33)));  // Equation 11.113 AHRI-2023
    6307         132 :                 p_full = P_H3_Full(nsp) + (P_H2_Full(nsp) - P_H3_Full(nsp)) * ((t - (-8.33)) / (1.66 - (-8.33)));  // Equation 11.118 AHRI-2023
    6308         110 :             } else if (t < (-8.33)) {                                                                              // if(t<(-8.33))
    6309         110 :                 q_full = Q_H4_Full(nsp) + (Q_H3_Full(nsp) - Q_H4_Full(nsp)) * ((t - (-8.33)) / ((-8.33) - (-15))); // Equation 11.114 AHRI-2023
    6310         110 :                 p_full = P_H4_Full(nsp) + (P_H3_Full(nsp) - P_H4_Full(nsp)) * ((t - (-8.33)) / ((-8.33) - (-15))); // Equation 11.119 AHRI-2023
    6311             :             }
    6312             : 
    6313         286 :             cop_full = q_full / p_full;
    6314             : 
    6315         286 :             if (t <= t_Off || cop_full < 1.0) {
    6316         102 :                 delta_full = 0.0; // #Equation 11.125 AHRI-2023
    6317         184 :             } else if (t > t_On) {
    6318         134 :                 delta_full = 1.0; // Equation 11.127 AHRI-2023
    6319             :             } else {
    6320          50 :                 delta_full = 0.5; // #Equation 11.126 AHRI-2023
    6321             :             }
    6322             : 
    6323         286 :             if (q_full > bl) {
    6324         141 :                 hlf_full = bl / q_full; // Equation 11.107 AHRI-2023
    6325             :             } else {
    6326         145 :                 hlf_full = 1.0; // Equation 11.108 AHRI-2023
    6327             :             }
    6328             : 
    6329         325 :             for (spnum = 1; spnum <= nsp - 1; ++spnum) {
    6330             : 
    6331             :                 // Intermediate capacity
    6332         325 :                 Real64 q_H0_low = Q_H0_Low(spnum);
    6333         325 :                 Real64 q_H1_low = Q_H1_Low(spnum);
    6334         325 :                 Real64 q_H2_int = Q_H2_Int(spnum);
    6335         325 :                 Real64 q_H1_full = Q_H1_Full(spnum);
    6336         325 :                 Real64 q_H2_full = Q_H2_Full(spnum);
    6337         325 :                 Real64 q_H3_full = Q_H3_Full(spnum);
    6338         325 :                 Real64 q_H4_full = Q_H4_Full(spnum);
    6339             :                 // Equation 11.177 AHRI-2023
    6340             :                 //?? (replaced 62 with 35) in Ratio expression // (t=>35-47/62-47)
    6341         325 :                 Real64 q_35_low = // q_H1_low + (q_H0_low - q_H1_low) * ((t - (8.33)) / (1.66 - (8.33)));
    6342         325 :                     q_H1_low + (q_H0_low - q_H1_low) * ((1.67 - (8.33)) / (16.67 - (8.33)));
    6343             : 
    6344             :                 // Equation 11.191 AHRI-2023
    6345         325 :                 Real64 N_Hq = min(1.0, (q_H2_int - q_35_low) / (q_H2_full - q_35_low));
    6346         325 :                 N_Hq = max(0.0, N_Hq);
    6347             :                 // Equation 11.190 AHRI-2023
    6348         325 :                 Real64 M_Hq = (q_H0_low - q_H1_low) / (16.66 - 8.33) * (1.0 - N_Hq) + (q_H2_full - q_H3_full) / (1.66 - (-8.33)) * N_Hq;
    6349             : 
    6350             :                 // Intermediate Power
    6351         325 :                 Real64 p_H0_low = P_H0_Low(spnum);
    6352         325 :                 Real64 p_H1_low = P_H1_Low(spnum);
    6353         325 :                 Real64 p_H2_int = P_H2_Int(spnum);
    6354         325 :                 Real64 p_H1_full = P_H1_Full(spnum);
    6355         325 :                 Real64 p_H2_full = P_H2_Full(spnum);
    6356         325 :                 Real64 p_H3_full = P_H3_Full(spnum);
    6357         325 :                 Real64 p_H4_full = P_H4_Full(spnum);
    6358             :                 // Equation 11.178 AHRI - 2023
    6359             :                 //?? (replaced 62 with 35) in Ratio expression (t=>35 F-47/35-47)
    6360         325 :                 Real64 p_35_low = // p_H1_low + (p_H0_low - p_H1_low) * ((t - (8.33)) / (1.66 - (8.33)));
    6361         325 :                     p_H1_low + (p_H0_low - p_H1_low) * ((1.67 - (8.33)) / (16.67 - (8.33)));
    6362             : 
    6363             :                 // Equation 11.194 AHRI-2023
    6364         325 :                 Real64 N_HE = min(1.0, (p_H2_int - p_35_low) / (p_H2_full - p_35_low));
    6365         325 :                 N_HE = max(0.0, N_HE);
    6366             : 
    6367             :                 // Equation 11.193 AHRI-2023
    6368         325 :                 Real64 M_HE = (p_H0_low - p_H1_low) / (16.66 - 8.33) * (1.0 - N_HE) + (p_H2_full - p_H3_full) / (1.66 - (-8.33)) * N_HE;
    6369             : 
    6370             :                 // Note: this is strange that there is no defrost cut in the low speed and doesn't use H2 or H3 low
    6371             :                 // Equation 11.177 AHRI-2023
    6372         325 :                 Real64 q_low = q_H1_low + (q_H0_low - q_H1_low) * ((t - (8.33)) / (16.66 - (8.33)));
    6373             :                 // Equation 11.178 AHRI-2023
    6374         325 :                 Real64 p_low = p_H1_low + (p_H0_low - p_H1_low) * ((t - (8.33)) / (16.66 - (8.33)));
    6375         325 :                 Real64 q_hs(0.0);
    6376         325 :                 Real64 p_hs(0.0);
    6377             :                 // Low Speed
    6378         325 :                 if (t < -8.33) {
    6379         110 :                     q_low = Q_H3_Full(spnum) + ((Q_H1_Low(spnum) - Q_H3_Full(spnum)) * (t - HeatingOutdoorCoilInletAirDBTempH3Test) /
    6380             :                                                 (HeatingOutdoorCoilInletAirDBTempRated - HeatingOutdoorCoilInletAirDBTempH3Test));
    6381             : 
    6382         110 :                     p_low = P_H3_Full(spnum) + ((P_H1_Low(spnum) - P_H3_Full(spnum)) * (t - HeatingOutdoorCoilInletAirDBTempH3Test) /
    6383             :                                                 (HeatingOutdoorCoilInletAirDBTempRated - HeatingOutdoorCoilInletAirDBTempH3Test));
    6384         215 :                 } else if (t >= 4.44) {
    6385          66 :                     q_low = Q_H1_Low(spnum) + ((Q_H0_Low(spnum) - Q_H1_Low(spnum)) * (t - HeatingOutdoorCoilInletAirDBTempRated) /
    6386             :                                                (HeatingOutdoorCoilInletAirDBTempH0Test - HeatingOutdoorCoilInletAirDBTempRated));
    6387          66 :                     p_low = P_H1_Low(spnum) + ((P_H0_Low(spnum) - P_H1_Low(spnum)) * (t - HeatingOutdoorCoilInletAirDBTempRated) /
    6388             :                                                (HeatingOutdoorCoilInletAirDBTempH0Test - HeatingOutdoorCoilInletAirDBTempRated));
    6389             :                 } else {
    6390         149 :                     q_low = Q_H3_Full(spnum) + ((Q_H2_Full(spnum) - Q_H3_Full(spnum)) * (t - HeatingOutdoorCoilInletAirDBTempH3Test) /
    6391             :                                                 (HeatingOutdoorCoilInletAirDBTempH2Test - HeatingOutdoorCoilInletAirDBTempH3Test));
    6392         149 :                     p_low = P_H3_Full(spnum) + ((P_H2_Full(spnum) - P_H3_Full(spnum)) * (t - HeatingOutdoorCoilInletAirDBTempH3Test) /
    6393             :                                                 (HeatingOutdoorCoilInletAirDBTempH2Test - HeatingOutdoorCoilInletAirDBTempH3Test));
    6394             :                 }
    6395             : 
    6396             :                 // High Speed
    6397         325 :                 if ((t <= -8.33) || (t >= 7.20)) {
    6398         176 :                     q_hs = Q_H3_Full(spnum + 1) + ((Q_H1_Full(spnum + 1) - Q_H3_Full(spnum + 1)) * (t - HeatingOutdoorCoilInletAirDBTempH3Test) /
    6399             :                                                    (HeatingOutdoorCoilInletAirDBTempRated - HeatingOutdoorCoilInletAirDBTempH3Test));
    6400         176 :                     p_hs = P_H3_Full(spnum + 1) + ((P_H1_Full(spnum + 1) - P_H3_Full(spnum + 1)) * (t - HeatingOutdoorCoilInletAirDBTempH3Test) /
    6401             :                                                    (HeatingOutdoorCoilInletAirDBTempRated - HeatingOutdoorCoilInletAirDBTempH3Test));
    6402             :                 } else {
    6403         149 :                     q_hs = Q_H3_Full(spnum + 1) + ((Q_H2_Full(spnum + 1) - Q_H3_Full(spnum + 1)) * (t - HeatingOutdoorCoilInletAirDBTempH3Test) /
    6404             :                                                    (HeatingOutdoorCoilInletAirDBTempH2Test - HeatingOutdoorCoilInletAirDBTempH3Test));
    6405         149 :                     p_hs = P_H3_Full(spnum + 1) + ((P_H2_Full(spnum + 1) - P_H3_Full(spnum + 1)) * (t - HeatingOutdoorCoilInletAirDBTempH3Test) /
    6406             :                                                    (HeatingOutdoorCoilInletAirDBTempH2Test - HeatingOutdoorCoilInletAirDBTempH3Test));
    6407             :                 }
    6408             : 
    6409         325 :                 Real64 cop_low = q_low / p_low;
    6410             : 
    6411         325 :                 Real64 q_int = q_H2_int + M_Hq * (t - (1.66));
    6412         325 :                 Real64 p_int = p_H2_int + M_HE * (t - (1.66));
    6413         325 :                 Real64 cop_int = q_int / p_int;
    6414             : 
    6415         325 :                 Real64 delta_low(0.0);
    6416         325 :                 if (bl <= q_low) {
    6417             :                     // CASE 1 : Section 11.2.2.3.1 AHRI-2023
    6418             :                     // Building Load is less than the capacity of the unit at the Low Compressor Speed (q_low >= bl)
    6419          67 :                     if (t <= t_Off || cop_low < 1.0) {
    6420           0 :                         delta_low = 0.0; //  Equation 11.159 AHRI-2023
    6421          67 :                     } else if (t > t_On) {
    6422          67 :                         delta_low = 1.0; // Equation 11.160 AHRI-2023
    6423             :                     } else {
    6424           0 :                         delta_low = 0.5; // Equation 11.161 AHRI-2023
    6425             :                     }
    6426             : 
    6427          67 :                     Real64 hlf_low(0.0); // Par tLoad Ratio
    6428          67 :                     if (q_low > 0.0) {
    6429          67 :                         hlf_low = min(1.0, bl / q_low); // Equation 11.155 AHRI-2023
    6430             :                     }
    6431             :                     // Section 6.1.3.2.3 (AHRI-2023) For Variable Capacity Systems, if the optional H1CFull and H1CLow tests are not
    6432             :                     // performed, a default value of 0.25 shall be used for the heating Degradation Coefficient
    6433          67 :                     Real64 CyclicMSHeatingDegradationCoeffHSPF2 = 0.25;
    6434             :                     // Part Load Fration
    6435          67 :                     Real64 plf_low = 1.0 - CyclicMSHeatingDegradationCoeffHSPF2 * (1.0 - hlf_low); // Equation 11.156 AHRI-2023
    6436             :                     // e = p_low * hlf_low * delta_low * n / plf_low;                                 // Equation 11.153 AHRI-2023
    6437          67 :                     e = (hlf_low / plf_low) * p_low * delta_low * n;
    6438          67 :                     rh = bl * (1.0 - delta_low) * n; // Equation 11.154 AHRI-2023
    6439          67 :                     goto HeatSpeedLoop4_exit;
    6440         258 :                 } else if (bl > q_low && bl < q_hs) {
    6441             :                     // (bl > q_low && bl < q_full) {
    6442             :                     // CASE 2 : 11.2.2.3.2 AHRI-2023
    6443             :                     // Building load can be matched by modulating the compressor speed between low speed and full speed, q_low < bl < q_full
    6444          74 :                     Real64 cop_int_bin(0.0);
    6445          74 :                     Real64 delta_int_bin(0.0);
    6446          74 :                     if (bl <= q_int) {
    6447           0 :                         cop_int_bin = cop_low + ((cop_int - cop_low) / (q_int - q_low)) * (bl - q_low);   // Equation 11.187 AHRI-2023
    6448             :                     } else {                                                                              // if bl > q_int
    6449          74 :                         cop_int_bin = cop_int + ((cop_full - cop_int) / (q_full - q_int)) * (bl - q_int); // Equation 11.188 AHRI-2023
    6450             :                     }
    6451             : 
    6452          74 :                     delta_int_bin = 0.0;
    6453          74 :                     if (!OATempCompressorOnOffBlank) {
    6454          74 :                         if (t <= t_Off) {
    6455           0 :                             delta_int_bin = 0.0;
    6456          74 :                         } else if (t > t_Off && t <= t_On) {
    6457          16 :                             delta_int_bin = 0.5;
    6458             :                         } else {
    6459          58 :                             delta_int_bin = 1.0;
    6460             :                         }
    6461             :                     } else {
    6462           0 :                         delta_int_bin = 1.0;
    6463             :                     }
    6464             : 
    6465          74 :                     rh = bl * (1.0 - delta_int_bin) * n;
    6466          74 :                     Real64 q = bl * n;                   // Equation 11.185 AHRI-2023
    6467          74 :                     e = q / cop_int_bin * delta_int_bin; // Equaiton 11.186 AHRI-2023
    6468          74 :                     goto HeatSpeedLoop4_exit;
    6469         184 :                 } else if (bl >= q_full) {
    6470             :                     // CASE 3 : 11.2.2.3.3 AHRI-2023
    6471             :                     // Building Load is greater than the capacity of the unit at the Full Compressor Speed, q_full <= bl or (bl >= q_full:)
    6472         145 :                     if (t > (-15) || t <= (-8.33)) {
    6473         145 :                         Real64 t_ratio = (t - (-15)) / ((-8.33) - (-15));
    6474             :                         // Equation 11.203 AHRI-2023
    6475         145 :                         q_full = q_H4_full + (q_H3_full - q_H4_full) * t_ratio;
    6476             :                         // Equation 11.204 AHRI-2023
    6477         145 :                         p_full = p_H4_full + (p_H3_full - p_H4_full) * t_ratio;
    6478         145 :                     } else if (t < (-15)) {
    6479           0 :                         Real64 t_ratio = (t - (-15)) / (8.33 - (-8.33));
    6480             :                         // Equation 11.205 AHRI-2023
    6481           0 :                         q_full = q_H4_full + (q_H1_full - q_H3_full) * t_ratio;
    6482             :                         // Equation 11.206 AHRI-2023
    6483           0 :                         p_full = p_H4_full + (p_H1_full - p_H3_full) * t_ratio;
    6484             :                     }
    6485             : 
    6486             :                     // if not conducting H4 Test then use this block
    6487             :                     // if (t >= t_ob || t <= (-8.33)) {
    6488             :                     //     Real64 t_ratio = (t - (-8.33)) / ((8.33) - (-8.33));
    6489             :                     //     // Equation 11.199 AHRI-2023
    6490             :                     //     q_full = q_H3_full + (q_H1_full - q_H3_full) * t_ratio;
    6491             :                     //     // Equation 11.200 AHRI-2023
    6492             :                     //     p_full = p_H3_full + (p_H1_full - p_H3_full) * t_ratio;
    6493             :                     // } else if ((-8.33) < t && t < t_ob) {
    6494             :                     //     Real64 t_ratio = (t - (-8.33)) / (1.66 - (-8.33));
    6495             :                     //     // Equation 11.201 AHRI-2023
    6496             :                     //     q_full = q_H3_full + (q_H2_full - q_H3_full) * t_ratio;
    6497             :                     //     // Equation 11.202 AHRI-2023
    6498             :                     //     p_full = p_H3_full + (p_H2_full - p_H3_full) * t_ratio;
    6499             :                     // }
    6500             : 
    6501         145 :                     if (!OATempCompressorOnOffBlank && p_full > 0.0) {
    6502         145 :                         if ((t <= OATempCompressorOff) || (q_full / p_full < 1.0)) {
    6503         102 :                             delta_full = 0.0;
    6504          43 :                         } else if ((t > OATempCompressorOff && t <= OATempCompressorOn) && (q_full / p_full > 1.0)) {
    6505          34 :                             delta_full = 0.5;
    6506           9 :                         } else if ((t > OATempCompressorOn) && (q_full / p_full > 1.0)) {
    6507           9 :                             delta_full = 1.0;
    6508             :                         }
    6509             :                     } else {
    6510           0 :                         delta_full = 1.0;
    6511             :                     }
    6512             : 
    6513         145 :                     hlf_full = 1.0; // Equation 11.170 AHRI-2023
    6514             : 
    6515             :                     // Equaiton 11.168 AHRI-2023
    6516         145 :                     e = p_full * hlf_full * delta_full * n;
    6517             :                     // Equation 11.169 AHRI - 2023
    6518         145 :                     rh = (bl - q_full * hlf_full * delta_full) * n;
    6519         145 :                     goto HeatSpeedLoop4_exit;
    6520             :                 }
    6521             :             }
    6522             : 
    6523           0 :         HeatSpeedLoop4_exit:;
    6524         286 :             q_sum += n * bl;
    6525         286 :             e_sum += e;
    6526         286 :             rh_sum += rh;
    6527             :         }
    6528             : 
    6529          22 :         Real64 defrost_period = 90;   // Time between defrost terminations (for testing) in minutes
    6530          22 :         Real64 defrost_MaxTime = 720; // Maximum time between defrosts allowed by controls in minutes
    6531          22 :         Real64 t_Test_90 = max(defrost_period, 90.00);
    6532          22 :         Real64 t_Max_90 = min(defrost_MaxTime, 720.00);
    6533             :         // default t_Test_90/t_Max_90 = 0.125
    6534          22 :         if (DefrostControl == HPdefrostControl::Timed) {
    6535             :             // Equation 11.106 AHRI-2023
    6536          22 :             f_def = 1.0; // Timed defrost control
    6537             :         } else {
    6538             :             // Equation 11.105 AHRI-2023
    6539           0 :             f_def = 1 + 0.03 * (1 - (t_Test_90 / t_Max_90)); // Demand defrost control
    6540             :             // f_def = 1.03;
    6541             :         }
    6542             : 
    6543          22 :         if (e_sum > 0.0) {
    6544          22 :             HSPF2_2023 = (q_sum / (e_sum + rh_sum)) * f_def; // Equation 11.103
    6545             :         } else {
    6546           0 :             HSPF2_2023 = 0.0;
    6547             :         }
    6548             : 
    6549          44 :         return std::make_tuple(NetHeatingCapRatedHighTemp_2023, NetHeatingCapRatedLowTemp_2023, HSPF2_2023);
    6550          22 :     }
    6551             : 
    6552          22 :     std::map<std::string, Real64> MultiSpeedDXHeatingCoilStandardRatings(
    6553             :         EnergyPlusData &state,
    6554             :         [[maybe_unused]] std::string const &DXCoilName,               // Name of DX coil for which HSPF is calculated
    6555             :         [[maybe_unused]] std::string const &DXCoilType,               // Type of DX coil for which HSPF is calculated
    6556             :         Array1A_int const CapFTempCurveIndex,                         // Index for the capacity as a function of temperature modifier curve
    6557             :         Array1A_int const CapFFlowCurveIndex,                         // Index for the capacity as a function of flow fraction modifier curve
    6558             :         Array1A_int const EIRFTempCurveIndex,                         // Index for the EIR as a function of temperature modifier curve
    6559             :         Array1A_int const EIRFFlowCurveIndex,                         // Index for the EIR as a function of flow fraction modifier curve
    6560             :         Array1A_int const PLFFPLRCurveIndex,                          // Index for the PLF vs part-load ratio curve
    6561             :         Array1A<Real64> const RatedTotalCapacity,                     // Reference capacity of DX coil [W]
    6562             :         Array1A<Real64> const RatedCOP,                               // Reference coefficient of performance [W/W]
    6563             :         Array1A<Real64> const RatedAirVolFlowRate,                    // Reference air flow rate of DX coil [m3/s]
    6564             :         Array1A<Real64> const MSFanPowerPerEvapAirFlowRateInput,      // 2017 rated fan power per evap air flow rate [W/(m3/s)]
    6565             :         Array1A<Real64> const MSFanPowerPerEvapAirFlowRateInput_2023, // 2023 rated fan power per evap air flow rate [W/(m3/s)]
    6566             :         int const nsp,                                                // Number of compressor speeds
    6567             :         ObjexxFCL::Optional_int_const RegionNum,                      // Region number for calculating HSPF of single speed DX heating coil
    6568             :         ObjexxFCL::Optional<Real64 const> MinOATCompressor,           // Minimum OAT for heat pump compressor operation [C]
    6569             :         ObjexxFCL::Optional<Real64 const> OATempCompressorOn,         // The outdoor temperature when the compressor is automatically turned
    6570             :         ObjexxFCL::Optional_bool_const OATempCompressorOnOffBlank,    // Flag used to determine low temperature cut out factor
    6571             :         ObjexxFCL::Optional<HPdefrostControl const> DefrostControl    // defrost control; 1=timed, 2=on-demand
    6572             :     )
    6573             :     {
    6574             : 
    6575             :         // SUBROUTINE INFORMATION:
    6576             :         //       AUTHOR         B. Nigusse, FSEC
    6577             :         //       DATE WRITTEN   December 2012
    6578             :         //       MODIFIED
    6579             :         //       RE-ENGINEERED  na
    6580             : 
    6581             :         // PURPOSE OF THIS SUBROUTINE:
    6582             :         // Calculates the standard ratings net heating capacity and HSPF values for multi speed DX heating coils
    6583             :         // at the AHRI standard test condition(s).
    6584             : 
    6585             :         // METHODOLOGY EMPLOYED:
    6586             :         // na
    6587             : 
    6588             :         // REFERENCES:
    6589             :         // na
    6590             : 
    6591             :         // Using/Aliasing
    6592             :         using Curve::CurveValue;
    6593             : 
    6594             :         // Argument array dimensioning
    6595          22 :         CapFTempCurveIndex.dim(nsp);
    6596          22 :         CapFFlowCurveIndex.dim(nsp);
    6597          22 :         EIRFTempCurveIndex.dim(nsp);
    6598          22 :         EIRFFlowCurveIndex.dim(nsp);
    6599          22 :         PLFFPLRCurveIndex.dim(nsp);
    6600          22 :         RatedTotalCapacity.dim(nsp);
    6601          22 :         RatedCOP.dim(nsp);
    6602          22 :         RatedAirVolFlowRate.dim(nsp);
    6603          22 :         MSFanPowerPerEvapAirFlowRateInput.dim(nsp);
    6604          22 :         MSFanPowerPerEvapAirFlowRateInput_2023.dim(nsp);
    6605             : 
    6606             :         // Locals
    6607             :         // SUBROUTINE ARGUMENT DEFINITIONS:
    6608             : 
    6609             :         // back on, if applicable, following automatic shut off. This field is
    6610             :         // used only for HSPF calculation. [C]
    6611             : 
    6612             :         // SUBROUTINE PARAMETER DEFINITIONS:
    6613             :         // CHARACTER(len=*), PARAMETER      :: RoutineName='MultiSpeedDXHeatingCoilStandardRatings: ' ! Include trailing blank space
    6614             : 
    6615             :         // INTERFACE BLOCK SPECIFICATIONS
    6616             :         // na
    6617             : 
    6618             :         // DERIVED TYPE DEFINITIONS
    6619             :         // na
    6620             : 
    6621             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    6622             : 
    6623          22 :         Real64 NetHeatingCapRatedHighTemp = 0.0; // net heating capacity at maximum speed and High Temp
    6624          22 :         Real64 NetHeatingCapRatedLowTemp = 0.0;  // net heating capacity at maximum speed and low Temp
    6625          22 :         Real64 HSPF = 0.0;                       // seasonale energy efficiency ratio of multi speed DX cooling coil
    6626             : 
    6627          22 :         Real64 NetHeatingCapRatedHighTemp_2023 = 0.0; // net heating capacity at maximum speed and High Temp
    6628          22 :         Real64 NetHeatingCapRatedLowTemp_2023 = 0.0;  // net heating capacity at maximum speed and low Temp
    6629          22 :         Real64 HSPF2_2023 = 0.0;                      // seasonale energy efficiency ratio of multi speed DX cooling coil
    6630             : 
    6631          22 :         std::map<std::string, Real64> StandardRatingsResult;
    6632             :         // StandardRatingsResult["NetHeatingCapRatedHighTemp"] = NetHeatingCapRatedHighTemp;
    6633             :         // StandardRatingsResult["NetHeatingCapRatedLowTemp"] = NetHeatingCapRatedLowTemp;
    6634             :         // StandardRatingsResult["HSPF"] = HSPF;
    6635             :         // StandardRatingsResult["NetHeatingCapRatedHighTemp_2023"] = NetHeatingCapRatedHighTemp_2023;
    6636             :         // StandardRatingsResult["NetHeatingCapRatedLowTemp_2023"] = NetHeatingCapRatedLowTemp_2023;
    6637             :         // StandardRatingsResult["HSPF2_2023"] = HSPF2_2023;
    6638             : 
    6639             :         // HSPF Calculation | AHRI 2017 Std.
    6640          44 :         std::tie(NetHeatingCapRatedHighTemp, NetHeatingCapRatedLowTemp, HSPF) = MultiSpeedDXHeatingCoilHSPF(state,
    6641             :                                                                                                             nsp,
    6642             :                                                                                                             MSFanPowerPerEvapAirFlowRateInput,
    6643             :                                                                                                             CapFTempCurveIndex,
    6644             :                                                                                                             CapFFlowCurveIndex,
    6645             :                                                                                                             RatedTotalCapacity,
    6646             :                                                                                                             RatedAirVolFlowRate,
    6647             :                                                                                                             EIRFFlowCurveIndex,
    6648             :                                                                                                             EIRFTempCurveIndex,
    6649             :                                                                                                             RatedCOP,
    6650             :                                                                                                             RegionNum,
    6651             :                                                                                                             MinOATCompressor,
    6652             :                                                                                                             OATempCompressorOn,
    6653             :                                                                                                             OATempCompressorOnOffBlank,
    6654          22 :                                                                                                             DefrostControl);
    6655             : 
    6656          22 :         StandardRatingsResult["NetHeatingCapRatedHighTemp"] = NetHeatingCapRatedHighTemp;
    6657          22 :         StandardRatingsResult["NetHeatingCapRatedLowTemp"] = NetHeatingCapRatedLowTemp;
    6658          22 :         StandardRatingsResult["HSPF"] = HSPF;
    6659             : 
    6660             :         // HSPF2 Calculation | AHRI 2023 Std.
    6661          22 :         std::tie(NetHeatingCapRatedHighTemp_2023, NetHeatingCapRatedLowTemp_2023, HSPF2_2023) =
    6662          44 :             MultiSpeedDXHeatingCoilHSPF2(state,
    6663             :                                          nsp,
    6664             :                                          MSFanPowerPerEvapAirFlowRateInput_2023,
    6665             :                                          CapFTempCurveIndex,
    6666             :                                          CapFFlowCurveIndex,
    6667             :                                          RatedTotalCapacity,
    6668             :                                          RatedAirVolFlowRate,
    6669             :                                          EIRFFlowCurveIndex,
    6670             :                                          EIRFTempCurveIndex,
    6671             :                                          RatedCOP,
    6672             :                                          RegionNum,
    6673             :                                          MinOATCompressor,
    6674             :                                          OATempCompressorOn,
    6675             :                                          OATempCompressorOnOffBlank,
    6676          22 :                                          DefrostControl);
    6677             : 
    6678          22 :         StandardRatingsResult["NetHeatingCapRatedHighTemp_2023"] = NetHeatingCapRatedHighTemp_2023;
    6679          22 :         StandardRatingsResult["NetHeatingCapRatedLowTemp_2023"] = NetHeatingCapRatedLowTemp_2023;
    6680          22 :         StandardRatingsResult["HSPF2_2023"] = HSPF2_2023;
    6681             : 
    6682          44 :         return StandardRatingsResult;
    6683           0 :     }
    6684             : 
    6685        1607 :     void ReportDXCoilRating(EnergyPlusData &state,
    6686             :                             std::string const &CompType,    // Type of component
    6687             :                             std::string_view CompName,      // Name of component
    6688             :                             int const CompTypeNum,          // TypeNum of component
    6689             :                             Real64 const CoolCapVal,        // Standard total (net) cooling capacity for AHRI Std. 210/240 {W}
    6690             :                             Real64 const SEERUserIP,        // SEER value in IP units from user PLR curve {Btu/W-h}
    6691             :                             Real64 const SEERStandardIP,    // SEER value in IP units from AHRI Std 210/240-2008 default PLF curve and C_D {Btu/W-h}
    6692             :                             Real64 const EERValueSI,        // EER value in SI units {W/W}
    6693             :                             Real64 const EERValueIP,        // EER value in IP units {Btu/W-h}
    6694             :                             Real64 const IEERValueIP,       // IEER value in IP units {Btu/W-h}
    6695             :                             Real64 const HighHeatingCapVal, // High Temperature Heating Standard (Net) Rating Capacity
    6696             :                             Real64 const LowHeatingCapVal,  // Low Temperature Heating Standard (Net) Rating Capacity
    6697             :                             Real64 const HSPFValueIP,       // IEER value in IP units {Btu/W-h}
    6698             :                             int const RegionNum,            // Region Number for which HSPF is calculated
    6699             :                             bool const AHRI2023StandardRatings) // True if required AHRI/ANSI 210/240 Std. 2023 SEER2,HSPF2 Ratings.
    6700             :     {
    6701             : 
    6702             :         // SUBROUTINE INFORMATION:
    6703             :         //       AUTHOR         Bereket Nigusse, Chandan Sharma
    6704             :         //       DATE WRITTEN   February 2010
    6705             :         //       MODIFIED       May 2010 (Added EER and IEER entries)
    6706             :         //                      March 2012 (Added HSPF and High/Low Heating Capacity entries)
    6707             :         //       RE-ENGINEERED  na
    6708             : 
    6709             :         // PURPOSE OF THIS SUBROUTINE:
    6710             :         // This subroutine writes the standard rating (net) cooling capacity, SEER, EER and IEER values to
    6711             :         // the "eio" and tabular output files for Single Speed compressor DX Cooling Coils.
    6712             : 
    6713             :         // METHODOLOGY EMPLOYED:
    6714             :         // na
    6715             : 
    6716             :         // REFERENCES:
    6717             :         // na
    6718             : 
    6719             :         // Using/Aliasing
    6720             : 
    6721             :         using namespace OutputReportPredefined;
    6722             :         using HVAC::Coil_CoolingAirToAirVariableSpeed;
    6723             :         using HVAC::CoilDX_CoolingSingleSpeed;
    6724             :         using HVAC::CoilDX_CoolingTwoSpeed;
    6725             :         using HVAC::CoilDX_HeatingEmpirical;
    6726             :         using HVAC::CoilDX_MultiSpeedCooling;
    6727             :         using HVAC::CoilDX_MultiSpeedHeating;
    6728             : 
    6729             :         // Locals
    6730             :         // SUBROUTINE ARGUMENT DEFINITIONS:
    6731             :         //   or ANSI/AHRI Std. 340/360 {W}
    6732             : 
    6733             :         // for AHRI Std. 210/240 {W}
    6734             :         // for AHRI Std. 210/240 {W}
    6735             : 
    6736             :         // SUBROUTINE PARAMETER DEFINITIONS:
    6737             : 
    6738             :         // INTERFACE BLOCK SPECIFICATIONS
    6739             :         // na
    6740             : 
    6741             :         // DERIVED TYPE DEFINITIONS
    6742             :         // na
    6743             : 
    6744             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    6745             : 
    6746        1607 :         switch (CompTypeNum) {
    6747             : 
    6748        1224 :         case CoilDX_CoolingSingleSpeed: {
    6749        1224 :             if (!AHRI2023StandardRatings) {
    6750         612 :                 if (state.dataHVACGlobal->StandardRatingsMyCoolOneTimeFlag) {
    6751             :                     static constexpr std::string_view Format_994(
    6752             :                         "! <DX Cooling Coil Standard Rating Information>, Component Type, Component Name, Standard Rating (Net) "
    6753             :                         "Cooling Capacity {W}, Standard Rating Net COP {W/W}, EER {Btu/W-h}, SEER User {Btu/W-h}, SEER Standard {Btu/W-h}, "
    6754             :                         "IEER "
    6755             :                         "{Btu/W-h}");
    6756         163 :                     print(state.files.eio, "{}\n", Format_994);
    6757         163 :                     state.dataHVACGlobal->StandardRatingsMyCoolOneTimeFlag = false;
    6758             :                 }
    6759             : 
    6760             :                 static constexpr std::string_view Format_991(
    6761             :                     " DX Cooling Coil Standard Rating Information, {}, {}, {:.1R}, {:.2R}, {:.2R}, {:.2R}, {:.2R}, {:.1R}\n");
    6762         612 :                 print(state.files.eio, Format_991, CompType, CompName, CoolCapVal, EERValueSI, EERValueIP, SEERUserIP, SEERStandardIP, IEERValueIP);
    6763             : 
    6764         612 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilType, CompName, CompType);
    6765         612 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilNetCapSI, CompName, CoolCapVal, 1);
    6766             :                 // W/W is the same as Btuh/Btuh so that's fine too
    6767         612 :                 if (EERValueSI > 0.0) {
    6768         612 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilCOP, CompName, EERValueSI, 2);
    6769             :                 } else {
    6770           0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilCOP, CompName, "N/A");
    6771             :                 }
    6772             :                 // Btu/W-h will convert to itself
    6773         612 :                 if (EERValueIP > 0.0) {
    6774         612 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilEERIP, CompName, EERValueIP, 2);
    6775             :                 } else {
    6776           0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilEERIP, CompName, "N/A");
    6777             :                 }
    6778         612 :                 if (SEERUserIP > 0.0) {
    6779         612 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilSEERUserIP, CompName, SEERUserIP, 2);
    6780             :                 } else {
    6781           0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilSEERUserIP, CompName, "N/A");
    6782             :                 }
    6783         612 :                 if (SEERStandardIP > 0.0) {
    6784         612 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilSEERStandardIP, CompName, SEERStandardIP, 2);
    6785             :                 } else {
    6786           0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilSEERStandardIP, CompName, "N/A");
    6787             :                 }
    6788         612 :                 if (IEERValueIP > 0.0) {
    6789         612 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilIEERIP, CompName, IEERValueIP, 1);
    6790             :                 } else {
    6791           0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilIEERIP, CompName, "N/A");
    6792             :                 }
    6793        1224 :                 addFootNoteSubTable(state,
    6794         612 :                                     state.dataOutRptPredefined->pdstDXCoolCoil,
    6795             :                                     "ANSI/AHRI ratings account for supply air fan heat and electric power. <br/>"
    6796             :                                     "1 - EnergyPlus object type. <br/>"
    6797             :                                     "2 - Capacity less than 65K Btu/h (19050 W) - calculated as per AHRI Standard 210/240-2017. <br/>"
    6798             :                                     "&emsp;&nbsp;Capacity of 65K Btu/h (19050 W) to less than 135K Btu/hv (39565 W) - calculated as per AHRI "
    6799             :                                     "Standard 340/360-2007. <br/>"
    6800             :                                     "&emsp;&nbsp;Capacity from 135K (39565 W) to 250K Btu/hr (73268 W) - calculated as per AHRI Standard 365-2009 - "
    6801             :                                     "Ratings not yet supported in EnergyPlus. <br/>"
    6802             :                                     "3 - SEER (User) is calculated using user-input PLF curve and cooling coefficient of degradation. <br/>"
    6803             :                                     "&emsp;&nbsp;SEER (Standard) is calculated using the default PLF curve and cooling coefficient of degradation"
    6804             :                                     "from the appropriate AHRI standard.");
    6805             :             } else {
    6806             :                 // ANSI/AHRI 210/240 Standard 2023 Ratings | SEER2
    6807         612 :                 if (state.dataHVACGlobal->StandardRatingsMyCoolOneTimeFlag2) {
    6808             :                     static constexpr std::string_view Format_991_(
    6809             :                         "! <DX Cooling Coil AHRI 2023 Standard Rating Information>, Component Type, Component Name, Standard Rating (Net) "
    6810             :                         "Cooling Capacity {W}, Standard Rating Net COP2 {W/W}, EER2 {Btu/W-h}, SEER2 User {Btu/W-h}, SEER2 Standard "
    6811             :                         "{Btu/W-h}, "
    6812             :                         "IEER 2022 "
    6813             :                         "{Btu/W-h}");
    6814         159 :                     print(state.files.eio, "{}\n", Format_991_);
    6815         159 :                     state.dataHVACGlobal->StandardRatingsMyCoolOneTimeFlag2 = false;
    6816             :                 }
    6817             : 
    6818             :                 static constexpr std::string_view Format_991_(
    6819             :                     " DX Cooling Coil AHRI 2023 Standard Rating Information, {}, {}, {:.1R}, {:.2R}, {:.2R}, {:.2R}, {:.2R}, {:.1R}\n");
    6820         612 :                 print(state.files.eio, Format_991_, CompType, CompName, CoolCapVal, EERValueSI, EERValueIP, SEERUserIP, SEERStandardIP, IEERValueIP);
    6821             : 
    6822         612 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilType_2023, CompName, CompType);
    6823         612 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilNetCapSI_2023, CompName, CoolCapVal, 1);
    6824             :                 // W/W is the same as Btuh/Btuh so that's fine too
    6825         612 :                 if (EERValueSI > 0.0) {
    6826         612 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilCOP_2023, CompName, EERValueSI, 2);
    6827             :                 } else {
    6828           0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilCOP_2023, CompName, "N/A");
    6829             :                 }
    6830             :                 // Btu/W-h will convert to itself
    6831         612 :                 if (EERValueIP > 0.0) {
    6832         612 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilEERIP_2023, CompName, EERValueIP, 2);
    6833             :                 } else {
    6834           0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilEERIP_2023, CompName, "N/A");
    6835             :                 }
    6836         612 :                 if (SEERUserIP > 0.0) {
    6837         610 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilSEER2UserIP_2023, CompName, SEERUserIP, 2);
    6838             :                 } else {
    6839           2 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilSEER2UserIP_2023, CompName, "N/A");
    6840             :                 }
    6841         612 :                 if (SEERStandardIP > 0.0) {
    6842         610 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilSEER2StandardIP_2023, CompName, SEERStandardIP, 2);
    6843             :                 } else {
    6844           2 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilSEER2StandardIP_2023, CompName, "N/A");
    6845             :                 }
    6846         612 :                 if (IEERValueIP > 0.0) {
    6847         612 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilIEERIP_2023, CompName, IEERValueIP, 1);
    6848             :                 } else {
    6849           0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilIEERIP_2023, CompName, "N/A");
    6850             :                 }
    6851        1224 :                 addFootNoteSubTable(state,
    6852         612 :                                     state.dataOutRptPredefined->pdstDXCoolCoil_2023,
    6853             :                                     "ANSI/AHRI ratings account for supply air fan heat and electric power. <br/>"
    6854             :                                     "1 - EnergyPlus object type. <br/>"
    6855             :                                     "2 - Capacity less than 65K Btu/h (19050 W) - calculated as per AHRI Standard 210/240-2023. <br/>"
    6856             :                                     "&emsp;&nbsp;Capacity of 65K Btu/h (19050 W) to less than 135K Btu/h (39565 W) - calculated as per AHRI Standard "
    6857             :                                     "340/360-2022. <br/>"
    6858             :                                     "&emsp;&nbsp;Capacity from 135K (39565 W) to 250K Btu/hr (73268 W) - calculated as per AHRI Standard 365-2009 - "
    6859             :                                     "Ratings not yet supported in EnergyPlus. <br/>"
    6860             :                                     "3 - SEER2 (User) is calculated using user-input PLF curve and cooling coefficient of degradation. <br/>"
    6861             :                                     "&emsp;&nbsp;SEER2 (Standard) is calculated using the default PLF curve and cooling coefficient of degradation"
    6862             :                                     "from the appropriate AHRI standard. <br/>"
    6863             :                                     "4 - Value for the Full Speed of the coil.");
    6864             :             }
    6865        1224 :             break;
    6866             :         }
    6867         194 :         case CoilDX_HeatingEmpirical:
    6868             :         case CoilDX_MultiSpeedHeating: {
    6869         194 :             if (!AHRI2023StandardRatings) {
    6870          97 :                 if (state.dataHVACGlobal->StandardRatingsMyHeatOneTimeFlag) {
    6871             :                     static constexpr std::string_view Format_992(
    6872             :                         "! <DX Heating Coil Standard Rating Information>, Component Type, Component Name, High Temperature Heating "
    6873             :                         "(net) Rating Capacity {W}, Low Temperature Heating (net) Rating Capacity {W}, HSPF {Btu/W-h}, Region "
    6874             :                         "Number\n");
    6875          62 :                     print(state.files.eio, "{}", Format_992);
    6876          62 :                     state.dataHVACGlobal->StandardRatingsMyHeatOneTimeFlag = false;
    6877             :                 }
    6878             : 
    6879             :                 static constexpr std::string_view Format_993(" DX Heating Coil Standard Rating Information, {}, {}, {:.1R}, {:.1R}, {:.2R}, {}\n");
    6880          97 :                 print(state.files.eio, Format_993, CompType, CompName, HighHeatingCapVal, LowHeatingCapVal, HSPFValueIP, RegionNum);
    6881             : 
    6882          97 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXHeatCoilType, CompName, CompType);
    6883          97 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXHeatCoilHighCap, CompName, HighHeatingCapVal, 1);
    6884          97 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXHeatCoilLowCap, CompName, LowHeatingCapVal, 1);
    6885             :                 // Btu/W-h will convert to itself
    6886          97 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXHeatCoilHSPFIP, CompName, HSPFValueIP, 2);
    6887          97 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXHeatCoilRegionNum, CompName, RegionNum);
    6888         194 :                 addFootNoteSubTable(
    6889          97 :                     state, state.dataOutRptPredefined->pdstDXHeatCoil, "ANSI/AHRI ratings account for supply air fan heat and electric power.");
    6890             :             } else {
    6891             :                 // ANSI/AHRI 210/240 Standard 2023 Ratings | HSPF2
    6892          97 :                 if (state.dataHVACGlobal->StandardRatingsMyHeatOneTimeFlag2) {
    6893             :                     static constexpr std::string_view Format_992_(
    6894             :                         "! <DX Heating Coil AHRI 2023 Standard Rating Information>, Component Type, Component Name, High Temperature Heating "
    6895             :                         "(net) Rating Capacity {W}, Low Temperature Heating (net) Rating Capacity {W}, HSPF2 {Btu/W-h}, Region "
    6896             :                         "Number\n");
    6897          62 :                     print(state.files.eio, "{}", Format_992_);
    6898          62 :                     state.dataHVACGlobal->StandardRatingsMyHeatOneTimeFlag2 = false;
    6899             :                 }
    6900             : 
    6901             :                 static constexpr std::string_view Format_993_(
    6902             :                     " DX Heating Coil AHRI 2023 Standard Rating Information, {}, {}, {:.1R}, {:.1R}, {:.2R}, {}\n");
    6903          97 :                 print(state.files.eio, Format_993_, CompType, CompName, HighHeatingCapVal, LowHeatingCapVal, HSPFValueIP, RegionNum);
    6904             : 
    6905          97 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXHeatCoilType_2023, CompName, CompType);
    6906          97 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXHeatCoilHighCap_2023, CompName, HighHeatingCapVal, 1);
    6907          97 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXHeatCoilLowCap_2023, CompName, LowHeatingCapVal, 1);
    6908             :                 // Btu/W-h will convert to itself
    6909          97 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXHeatCoilHSPF2IP_2023, CompName, HSPFValueIP, 2);
    6910          97 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXHeatCoilRegionNum_2023, CompName, RegionNum);
    6911         194 :                 addFootNoteSubTable(state,
    6912          97 :                                     state.dataOutRptPredefined->pdstDXHeatCoil_2023,
    6913             :                                     "ANSI/AHRI 2023 (HSPF2) ratings account for supply air fan heat and electric power.");
    6914             :             }
    6915         194 :             break;
    6916             :         }
    6917         189 :         case CoilDX_CoolingTwoSpeed:
    6918             :         case Coil_CoolingAirToAirVariableSpeed:
    6919             :         case CoilDX_MultiSpeedCooling: {
    6920         189 :             if (!AHRI2023StandardRatings) {
    6921          49 :                 if (state.dataHVACGlobal->StandardRatingsMyCoolOneTimeFlag) {
    6922             :                     static constexpr std::string_view Format_994(
    6923             :                         "! <DX Cooling Coil Standard Rating Information>, Component Type, Component Name, Standard Rating (Net) "
    6924             :                         "Cooling Capacity {W}, Standard Rating Net COP {W/W}, EER {Btu/W-h}, SEER User {Btu/W-h}, SEER Standard {Btu/W-h}, "
    6925             :                         "IEER "
    6926             :                         "{Btu/W-h}");
    6927          22 :                     print(state.files.eio, "{}\n", Format_994);
    6928          22 :                     state.dataHVACGlobal->StandardRatingsMyCoolOneTimeFlag = false;
    6929             :                 }
    6930             : 
    6931             :                 static constexpr std::string_view Format_995(
    6932             :                     " DX Cooling Coil Standard Rating Information, {}, {}, {:.1R}, {:.2R}, {:.2R}, {:.2R}, {:.2R}, {}\n");
    6933          49 :                 print(state.files.eio, Format_995, CompType, CompName, CoolCapVal, EERValueSI, EERValueIP, SEERUserIP, SEERStandardIP, IEERValueIP);
    6934             : 
    6935          49 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilType, CompName, CompType);
    6936          49 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilNetCapSI, CompName, CoolCapVal, 1);
    6937          49 :                 if (EERValueSI > 0.0) {
    6938          49 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilCOP, CompName, EERValueSI, 2);
    6939             :                 } else {
    6940           0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilCOP, CompName, "N/A");
    6941             :                 }
    6942          49 :                 if (EERValueIP > 0.0) {
    6943          49 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilEERIP, CompName, EERValueIP, 2);
    6944             :                 } else {
    6945           0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilEERIP, CompName, "N/A");
    6946             :                 }
    6947          49 :                 if (SEERUserIP > 0.0) {
    6948          49 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilSEERUserIP, CompName, SEERUserIP, 2);
    6949             :                 } else {
    6950           0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilSEERUserIP, CompName, "N/A");
    6951             :                 }
    6952          49 :                 if (SEERStandardIP > 0.0) {
    6953          49 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilSEERStandardIP, CompName, SEERStandardIP, 2);
    6954             :                 } else {
    6955           0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilSEERStandardIP, CompName, "N/A");
    6956             :                 }
    6957          49 :                 if (IEERValueIP > 0.0) {
    6958           0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilIEERIP, CompName, IEERValueIP, 1);
    6959             :                 } else {
    6960          49 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilIEERIP, CompName, "N/A");
    6961             :                 }
    6962          98 :                 addFootNoteSubTable(state,
    6963          49 :                                     state.dataOutRptPredefined->pdstDXCoolCoil,
    6964             :                                     "ANSI/AHRI ratings account for supply air fan heat and electric power. <br/>"
    6965             :                                     "1 - EnergyPlus object type. <br/>"
    6966             :                                     "2 - Capacity less than 65K Btu/h (19050 W) - calculated as per AHRI Standard 210/240-2017. <br/>"
    6967             :                                     "&emsp;&nbsp;Capacity of 65K Btu/h (19050 W) to less than 135K Btu/h (39565 W) - calculated as per AHRI Standard "
    6968             :                                     "340/360-2007. <br/>"
    6969             :                                     "&emsp;&nbsp;Capacity from 135K (39565 W) to 250K Btu/hr (73268 W) - calculated as per AHRI Standard 365-2009 - "
    6970             :                                     "Ratings not yet supported in EnergyPlus. <br/>"
    6971             :                                     "3 - SEER (User) is calculated using user-input PLF curve and cooling coefficient of degradation. <br/>"
    6972             :                                     "&emsp;&nbsp;SEER (Standard) is calculated using the default PLF curve and cooling coefficient of degradation"
    6973             :                                     "from the appropriate AHRI standard.");
    6974             :             } else {
    6975             :                 // ANSI/AHRI 210/240 Standard 2023 Ratings | SEER2
    6976         140 :                 if (state.dataHVACGlobal->StandardRatingsMyCoolOneTimeFlag2) {
    6977             :                     static constexpr std::string_view Format_991_(
    6978             :                         "! <DX Cooling Coil AHRI 2023 Standard Rating Information>, Component Type, Component Name, Standard Rating (Net) "
    6979             :                         "Cooling Capacity {W}, Standard Rating Net COP2 {W/W}, EER2 {Btu/W-h}, SEER2 User {Btu/W-h}, SEER2 Standard "
    6980             :                         "{Btu/W-h}, "
    6981             :                         "IEER 2022 "
    6982             :                         "{Btu/W-h}");
    6983          61 :                     print(state.files.eio, "{}\n", Format_991_);
    6984          61 :                     state.dataHVACGlobal->StandardRatingsMyCoolOneTimeFlag2 = false;
    6985             :                 }
    6986             : 
    6987             :                 static constexpr std::string_view Format_995_(
    6988             :                     " DX Cooling Coil AHRI 2023 Standard Rating Information, {}, {}, {:.1R}, {:.2R}, {:.2R}, {:.2R}, {:.2R}, {:.1R}\n");
    6989         140 :                 print(state.files.eio, Format_995_, CompType, CompName, CoolCapVal, EERValueSI, EERValueIP, SEERUserIP, SEERStandardIP, IEERValueIP);
    6990         140 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilType_2023, CompName, CompType);
    6991         140 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilNetCapSI_2023, CompName, CoolCapVal, 1);
    6992             :                 // W/W is the same as Btuh/Btuh so that's fine too
    6993         140 :                 if (EERValueSI > 0.0) {
    6994         140 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilCOP_2023, CompName, EERValueSI, 2);
    6995             :                 } else {
    6996           0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilCOP_2023, CompName, "N/A");
    6997             :                 }
    6998             :                 // Btu/W-h will convert to itself
    6999         140 :                 if (EERValueIP > 0.0) {
    7000         140 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilEERIP_2023, CompName, EERValueIP, 2);
    7001             :                 } else {
    7002           0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilEERIP_2023, CompName, "N/A");
    7003             :                 }
    7004         140 :                 if (SEERUserIP > 0.0) {
    7005         139 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilSEER2UserIP_2023, CompName, SEERUserIP, 2);
    7006             :                 } else {
    7007           1 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilSEER2UserIP_2023, CompName, "N/A");
    7008             :                 }
    7009         140 :                 if (SEERStandardIP > 0.0) {
    7010         139 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilSEER2StandardIP_2023, CompName, SEERStandardIP, 2);
    7011             :                 } else {
    7012           1 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilSEER2StandardIP_2023, CompName, "N/A");
    7013             :                 }
    7014         140 :                 if (IEERValueIP > 0.0) {
    7015         140 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilIEERIP_2023, CompName, IEERValueIP, 1);
    7016             :                 } else {
    7017           0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilIEERIP_2023, CompName, "N/A");
    7018             :                 }
    7019         280 :                 addFootNoteSubTable(state,
    7020         140 :                                     state.dataOutRptPredefined->pdstDXCoolCoil_2023,
    7021             :                                     "ANSI/AHRI ratings account for supply air fan heat and electric power. <br/>"
    7022             :                                     "1 - EnergyPlus object type. <br/>"
    7023             :                                     "2 - Capacity less than 65K Btu/h (19050 W) - calculated as per AHRI Standard 210/240-2023. <br/>"
    7024             :                                     "&emsp;&nbsp;Capacity of 65K Btu/h (19050 W) to less than 135K Btu/h (39565 W) - calculated as per AHRI Standard "
    7025             :                                     "340/360-2022. <br/>"
    7026             :                                     "&emsp;&nbsp;Capacity from 135K (39565 W) to 250K Btu/hr (73268 W) - calculated as per AHRI Standard 365-2009 - "
    7027             :                                     "Ratings not yet supported in EnergyPlus. <br/>"
    7028             :                                     "3 - SEER2 (User) is calculated using user-input PLF curve and cooling coefficient of degradation. <br/>"
    7029             :                                     "&emsp;&nbsp;SEER2 (Standard) is calculated using the default PLF curve and cooling coefficient of degradation"
    7030             :                                     "from the appropriate AHRI standard. <br/>"
    7031             :                                     "4 - Value for the Full Speed of the coil.");
    7032             :             }
    7033             : 
    7034         189 :             break;
    7035             :         }
    7036           0 :         default:
    7037           0 :             break;
    7038             :         }
    7039        1607 :     }
    7040             : 
    7041           8 :     void ReportDXCoolCoilDataCenterApplication(EnergyPlusData &state,
    7042             :                                                std::string const &CompType,           // Type of component
    7043             :                                                std::string_view CompName,             // Name of component
    7044             :                                                int const CompTypeNum,                 // TypeNum of component
    7045             :                                                Array1D<Real64> &NetCoolingCapRated,   // net cooling capacity of single speed DX cooling coil
    7046             :                                                Array1D<Real64> &TotElectricPowerRated // total electric power including supply fan
    7047             :     )
    7048             :     {
    7049             : 
    7050             :         // SUBROUTINE INFORMATION:
    7051             :         //       AUTHOR         Bereket Nigusse
    7052             :         //       DATE WRITTEN   October 2014
    7053             :         //       MODIFIED       na
    7054             :         //
    7055             :         //       RE-ENGINEERED  na
    7056             : 
    7057             :         // PURPOSE OF THIS SUBROUTINE:
    7058             :         // This subroutine writes the standard rating (net) cooling capacity and Electric Power for
    7059             :         // for room unitary air conditioners single speed DX cooling coils to the "eio" and tabular
    7060             :         // output files.
    7061             : 
    7062             :         // METHODOLOGY EMPLOYED:
    7063             :         // na
    7064             : 
    7065             :         // REFERENCES:
    7066             :         // ANSI/ASHRAE Standard 127-2012 - Method of Testing for Rating Computer and Data Processing
    7067             :         //                                 Room Unitary Air Conditioners
    7068             : 
    7069             :         // Using/Aliasing
    7070             : 
    7071             :         using namespace OutputReportPredefined;
    7072             :         using HVAC::CoilDX_CoolingSingleSpeed;
    7073             : 
    7074             :         // Locals
    7075             :         // SUBROUTINE ARGUMENT DEFINITIONS:
    7076             :         // na
    7077             : 
    7078             :         // SUBROUTINE PARAMETER DEFINITIONS:
    7079             : 
    7080             :         // INTERFACE BLOCK SPECIFICATIONS
    7081             :         // na
    7082             : 
    7083             :         // DERIVED TYPE DEFINITIONS
    7084             :         // na
    7085             : 
    7086             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    7087             :         int ClassNum; // class number (Class I, II, II, IV)
    7088             :         int Num;      // text number counter
    7089             : 
    7090             :         // Formats
    7091             : 
    7092           8 :         if (CompTypeNum == CoilDX_CoolingSingleSpeed) {
    7093           8 :             if (state.dataHVACGlobal->StandardRatingsMyCoolOneTimeFlag3) {
    7094             :                 static constexpr std::string_view Format_101(
    7095             :                     "! <DX Cooling Coil ASHRAE 127 Standard Ratings Information>, Component Type, Component Name, Standard 127 "
    7096             :                     "Classification, Rated Net Cooling Capacity Test A {W}, Rated Total Electric Power Test A {W}, Rated Net "
    7097             :                     "Cooling Capacity Test B {W}, Rated Total Electric Power Test B {W}, Rated Net Cooling Capacity Test C {W}, "
    7098             :                     "Rated Total Electric Power Test C {W}, Rated Net Cooling Capacity Test D {W}, Rated Total Electric "
    7099             :                     "Power Test D {W} \n");
    7100           6 :                 print(state.files.eio, "{}", Format_101);
    7101           6 :                 state.dataHVACGlobal->StandardRatingsMyCoolOneTimeFlag3 = false;
    7102             :             }
    7103          40 :             for (ClassNum = 1; ClassNum <= 4; ++ClassNum) {
    7104          32 :                 Num = (ClassNum - 1) * 4;
    7105          32 :                 std::string ClassName = format("Class {}", ClassNum);
    7106           0 :                 std::string CompNameNew = fmt::format("{}({})", CompName, ClassName);
    7107             :                 static constexpr std::string_view Format_102(
    7108             :                     " DX Cooling Coil ASHRAE 127 Standard Ratings Information, {}, {}, {}, {:.1R}, {:.1R}, {:.1R}, "
    7109             :                     "{:.1R}, {:.1R}, {:.1R}, {:.1R}, {:.1R}\n");
    7110          32 :                 print(state.files.eio,
    7111             :                       Format_102,
    7112             :                       CompType,
    7113             :                       CompName,
    7114             :                       ClassName,
    7115             :                       NetCoolingCapRated(Num + 1),
    7116             :                       TotElectricPowerRated(Num + 1),
    7117             :                       NetCoolingCapRated(Num + 2),
    7118             :                       TotElectricPowerRated(Num + 2),
    7119             :                       NetCoolingCapRated(Num + 3),
    7120             :                       TotElectricPowerRated(Num + 3),
    7121             :                       NetCoolingCapRated(Num + 4),
    7122             :                       TotElectricPowerRated(Num + 4));
    7123          32 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilType2, CompNameNew, CompType);
    7124             :                 // Note: If you call format("{:.1R}", NetCoolingCapRated(Num + 1)),
    7125             :                 // Then it's not the OutputReportPredefined::PreDefTableEntry prototype with Real64 that is called.
    7126             :                 // As a result, the entry isn't marked as being Real (origEntryIsReal) and unit conversion does not occur
    7127             :                 // Bad: PreDefTableEntry(state, pdchDXCoolCoilNetCapSIA, CompNameNew, format("{:.1R}", NetCoolingCapRated(Num + 1)));
    7128          32 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilNetCapSIA, CompNameNew, NetCoolingCapRated(Num + 1), 1);
    7129          32 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilNetCapSIB, CompNameNew, NetCoolingCapRated(Num + 2), 1);
    7130          32 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilNetCapSIC, CompNameNew, NetCoolingCapRated(Num + 3), 1);
    7131          32 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilNetCapSID, CompNameNew, NetCoolingCapRated(Num + 4), 1);
    7132             : 
    7133             :                 // These will stay in W, so it doesn't matter as much, but let's be consistent
    7134          32 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilElecPowerA, CompNameNew, TotElectricPowerRated(Num + 1), 1);
    7135          32 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilElecPowerB, CompNameNew, TotElectricPowerRated(Num + 2), 1);
    7136          32 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilElecPowerC, CompNameNew, TotElectricPowerRated(Num + 3), 1);
    7137          32 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchDXCoolCoilElecPowerD, CompNameNew, TotElectricPowerRated(Num + 4), 1);
    7138             : 
    7139          64 :                 addFootNoteSubTable(state,
    7140          32 :                                     state.dataOutRptPredefined->pdstDXCoolCoil2,
    7141             :                                     "ANSI/ASHRAE Standard 127 includes supply fan heat effect and electric power.");
    7142          32 :             }
    7143             :         }
    7144           8 :     }
    7145             : 
    7146        1184 :     void CheckCurveLimitsForStandardRatings(EnergyPlusData &state,
    7147             :                                             std::string const &DXCoilName, // Name of DX coil for which HSPF is calculated
    7148             :                                             std::string const &DXCoilType, // Type of DX coil - heating or cooling
    7149             :                                             int const DXCoilTypeNum,       // Integer type of DX coil - heating or cooling
    7150             :                                             int const CapFTempCurveIndex,  // Index for the capacity as a function of temperature modifier curve
    7151             :                                             int const CapFFlowCurveIndex,  // Index for the capacity as a function of flow fraction modifier curve
    7152             :                                             int const EIRFTempCurveIndex,  // Index for the EIR as a function of temperature modifier curve
    7153             :                                             int const EIRFFlowCurveIndex,  // Index for the EIR as a function of flow fraction modifier curve
    7154             :                                             int const PLFFPLRCurveIndex    // Index for the EIR vs part-load ratio curve
    7155             :     )
    7156             :     {
    7157             : 
    7158             :         // SUBROUTINE INFORMATION:
    7159             :         //       AUTHOR         D. Shirey/B. Nigusse, FSEC
    7160             :         //       DATE WRITTEN   May 2010
    7161             :         //       MODIFIED       Chandan Sharma, March 2012
    7162             :         //       RE-ENGINEERED  na
    7163             : 
    7164             :         // PURPOSE OF THIS SUBROUTINE:
    7165             :         // Checks the limits of the various curves used in DXCoil and returns .FALSE. if the limits do not include
    7166             :         // the standard test condition(s).
    7167             : 
    7168             :         // METHODOLOGY EMPLOYED:
    7169             :         // na
    7170             : 
    7171             :         // REFERENCES:
    7172             :         // na
    7173             : 
    7174             :         // Using/Aliasing
    7175             :         using Curve::CurveValue;
    7176             :         using Curve::GetCurveIndex;
    7177             :         using Curve::GetCurveMinMaxValues;
    7178             :         using Curve::GetCurveName;
    7179             :         using HVAC::CoilDX_CoolingSingleSpeed;
    7180             :         using HVAC::CoilDX_HeatingEmpirical;
    7181             :         using HVAC::CoilDX_MultiSpeedCooling;
    7182             :         using HVAC::CoilDX_MultiSpeedHeating;
    7183             : 
    7184             :         // Locals
    7185             :         // SUBROUTINE ARGUMENT DEFINITIONS:
    7186             : 
    7187             :         // SUBROUTINE PARAMETER DEFINITIONS:
    7188             : 
    7189             :         static constexpr std::string_view RoutineName("CheckCurveLimitsForStandardRatings: "); // Include trailing blank space
    7190             : 
    7191             :         // INTERFACE BLOCK SPECIFICATIONS
    7192             :         // na
    7193             : 
    7194             :         // DERIVED TYPE DEFINITIONS
    7195             :         // na
    7196             : 
    7197             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    7198             : 
    7199             :         //  Minimum and Maximum independent variable limits from Total Cooling Capacity Function of Temperature Curve
    7200        1184 :         Real64 CapacityWBTempMin(0.0); // Capacity modifier Min value (wet bulb temperature), from the Curve:BiQuadratic object
    7201        1184 :         Real64 CapacityWBTempMax(0.0); // Capacity modifier Max value (wet bulb temperature), from the Curve:BiQuadratic object
    7202        1184 :         Real64 CapacityDBTempMin(0.0); // Capacity modifier Min value (dry bulb temperature), from the Curve:BiQuadratic object
    7203        1184 :         Real64 CapacityDBTempMax(0.0); // Capacity modifier Max value (dry bulb temperature), from the Curve:BiQuadratic object
    7204             : 
    7205             :         //  Minimum and Maximum independent variable limits from Energy Input Ratio (EIR) Function of Temperature Curve
    7206        1184 :         Real64 EIRWBTempMin(0.0); // EIR modifier Min value (wet bulb temperature), from the Curve:BiQuadratic object
    7207        1184 :         Real64 EIRWBTempMax(0.0); // EIR modifier Max value (wet bulb temperature), from the Curve:BiQuadratic object
    7208        1184 :         Real64 EIRDBTempMin(0.0); // EIR modifier Min value (dry bulb temperature), from the Curve:BiQuadratic object
    7209        1184 :         Real64 EIRDBTempMax(0.0); // EIR modifier Max value (dry bulb temperature), from the Curve:BiQuadratic object
    7210             : 
    7211             :         //  Minimum and Maximum independent variable limits from Part Load Fraction Correlation Curve
    7212        1184 :         Real64 PLFFPLRMin(0.0); // Maximum value for Part Load Ratio, from the corresponding curve object
    7213        1184 :         Real64 PLFFPLRMax(0.0); // Minimum value for Part Load Ratio, from the corresponding curve object
    7214             : 
    7215             :         //  Minimum and Maximum independent variable limits from Total Cooling Capacity Function of Flow Fraction Curve
    7216        1184 :         Real64 CapacityFlowRatioMin(0.0); // Minimum value for flow fraction, from the corresponding curve object
    7217        1184 :         Real64 CapacityFlowRatioMax(0.0); // Maximum value for flow fraction, from the corresponding curve object
    7218             : 
    7219             :         //  Minimum and Maximum independent variable limits from Energy Input Ratio Function of Flow Fraction Curve
    7220        1184 :         Real64 EIRFlowRatioMin(0.0); // Minimum value for flow fraction, from the corresponding curve object
    7221        1184 :         Real64 EIRFlowRatioMax(0.0); // Maximum value for flow fraction, from the corresponding curve object
    7222             : 
    7223             :         //  Minimum and Maximum independent variable limits from Total Cooling Capacity Function of Temperature Curve
    7224        1184 :         Real64 HeatingCapODBTempMin(0.0); // Capacity modifier Min value (outdoor dry bulb temperature)
    7225        1184 :         Real64 HeatingCapODBTempMax(0.0); // Capacity modifier Max value (outdoor dry bulb temperature)
    7226        1184 :         Real64 HeatingCapIDBTempMin(0.0); // Capacity modifier Min value (indoor dry bulb temperature)
    7227        1184 :         Real64 HeatingCapIDBTempMax(0.0); // Capacity modifier Max value (indoor dry bulb temperature)
    7228             : 
    7229             :         //  Minimum and Maximum independent variable limits from Energy Input Ratio (EIR) Function of Temperature Curve
    7230        1184 :         Real64 HeatingEIRODBTempMin(0.0); // EIR modifier Min value (outdoor dry bulb temperature)
    7231        1184 :         Real64 HeatingEIRODBTempMax(0.0); // EIR modifier Max value (outdoor dry bulb temperature)
    7232        1184 :         Real64 HeatingEIRIDBTempMin(0.0); // EIR modifier Min value (indoor dry bulb temperature)
    7233        1184 :         Real64 HeatingEIRIDBTempMax(0.0); // EIR modifier Max value (indoor dry bulb temperature)
    7234             : 
    7235        1184 :         bool CapCurveOATLimitsExceeded(false);     // Logical for capacity curve OD temp. limits being exceeded (low and High)
    7236        1184 :         bool CapCurveHighOATLimitsExceeded(false); // Logical for capacity curve temperature limits being exceeded (high temp)
    7237        1184 :         bool CapCurveFlowLimitsExceeded(false);    // Logical for capacity curve flow fraction limits being exceeded
    7238        1184 :         bool EIRCurveHighOATLimitsExceeded(false); // Logical for EIR curve temperature limits being exceeded (high temp)
    7239        1184 :         bool EIRCurveFlowLimitsExceeded(false);    // Logical for EIR curve flow fraction limits being exceeded
    7240             : 
    7241        1184 :         bool CapCurveMidOATLimitsExceeded(false); // Logical for capacity curve temperature limits being exceeded (mid temp)
    7242        1184 :         bool EIRCurveMidOATLimitsExceeded(false); // Logical for EIR curve temperature limits being exceeded (mid temp)
    7243        1184 :         bool CapCurveLowOATLimitsExceeded(false); // Logical for capacity curve temperature limits being exceeded (low temp)
    7244        1184 :         bool EIRCurveLowOATLimitsExceeded(false); // Logical for EIR curve temperature limits being exceeded (Low temp)
    7245        1184 :         bool PLFfPLRforSEERLimitsExceeded(false); // Logical for PLF function of PLR limits being exceeded
    7246             : 
    7247        1184 :         bool CapCurveIEERLimitsExceeded(false); // Logical for capacity curve temperature limits being exceeded (IEER calcs)
    7248        1184 :         bool EIRCurveIEERLimitsExceeded(false); // Logical for EIR temperature limits being exceeded (IEER calcs)
    7249             : 
    7250        1184 :         bool HeatingCapCurveHSPFLimitsExceeded(false); // Logical for capacity curve temperature limits being exceeded
    7251             :         // (HSPF calcs)
    7252        1184 :         bool HeatingEIRCurveHSPFLimitsExceeded(false); // Logical for EIR curve temperature limits being exceeded
    7253             :         // (HSPF calcs)
    7254             : 
    7255        1184 :         switch (DXCoilTypeNum) {
    7256             : 
    7257         612 :         case CoilDX_CoolingSingleSpeed: {
    7258         612 :             GetCurveMinMaxValues(state, CapFTempCurveIndex, CapacityWBTempMin, CapacityWBTempMax, CapacityDBTempMin, CapacityDBTempMax);
    7259         612 :             GetCurveMinMaxValues(state, EIRFTempCurveIndex, EIRWBTempMin, EIRWBTempMax, EIRDBTempMin, EIRDBTempMax);
    7260         612 :             GetCurveMinMaxValues(state, CapFFlowCurveIndex, CapacityFlowRatioMin, CapacityFlowRatioMax);
    7261         612 :             GetCurveMinMaxValues(state, EIRFFlowCurveIndex, EIRFlowRatioMin, EIRFlowRatioMax);
    7262         612 :             GetCurveMinMaxValues(state, PLFFPLRCurveIndex, PLFFPLRMin, PLFFPLRMax);
    7263             : 
    7264             :             // Checking the limits of capacity modifying curve for temperatures
    7265         612 :             if (CapacityDBTempMax < OutdoorCoilInletAirDryBulbTempRated || CapacityDBTempMin > OutdoorCoilInletAirDryBulbTempRated ||
    7266         612 :                 CapacityWBTempMax < CoolingCoilInletAirWetBulbTempRated || CapacityWBTempMin > CoolingCoilInletAirWetBulbTempRated) {
    7267           0 :                 CapCurveHighOATLimitsExceeded = true;
    7268             :             }
    7269             :             // Checking the limits of capacity modifying curve for flow fraction
    7270         612 :             if (CapacityFlowRatioMax < AirMassFlowRatioRated || CapacityFlowRatioMin > AirMassFlowRatioRated) {
    7271           0 :                 CapCurveFlowLimitsExceeded = true;
    7272             :             }
    7273             :             // Checking the limits of EIR modifying curve for temperatures
    7274         612 :             if (EIRDBTempMax < OutdoorCoilInletAirDryBulbTempRated || EIRDBTempMin > OutdoorCoilInletAirDryBulbTempRated ||
    7275         612 :                 EIRWBTempMax < CoolingCoilInletAirWetBulbTempRated || EIRWBTempMin > CoolingCoilInletAirWetBulbTempRated) {
    7276           0 :                 EIRCurveHighOATLimitsExceeded = true;
    7277             :             }
    7278             :             // Checking the limits of EIR modifying curve for flow fraction
    7279         612 :             if (EIRFlowRatioMax < AirMassFlowRatioRated || EIRFlowRatioMin > AirMassFlowRatioRated) {
    7280           0 :                 EIRCurveFlowLimitsExceeded = true;
    7281             :             }
    7282             :             // Checking the limits of capacity modifying curve for temperatures (SEER calculation)
    7283         612 :             if (CapacityDBTempMax < OutdoorCoilInletAirDryBulbTempTestB2 || CapacityDBTempMin > OutdoorCoilInletAirDryBulbTempTestB2 ||
    7284         612 :                 CapacityWBTempMax < CoolingCoilInletAirWetBulbTempRated || CapacityWBTempMin > CoolingCoilInletAirWetBulbTempRated) {
    7285           0 :                 CapCurveMidOATLimitsExceeded = true;
    7286             :             }
    7287             :             // Checking the limits of EIR modifying curve for temperatures (SEER calculation)
    7288         612 :             if (EIRDBTempMax < OutdoorCoilInletAirDryBulbTempTestB2 || EIRDBTempMin > OutdoorCoilInletAirDryBulbTempTestB2 ||
    7289         612 :                 EIRWBTempMax < CoolingCoilInletAirWetBulbTempRated || EIRWBTempMin > CoolingCoilInletAirWetBulbTempRated) {
    7290           0 :                 EIRCurveMidOATLimitsExceeded = true;
    7291             :             }
    7292             :             // Checking the limits of Part Load Fraction for PLR (SEER calculation)
    7293         612 :             if (PLFFPLRMax < PLRforSEER || PLFFPLRMin > PLRforSEER) {
    7294           0 :                 PLFfPLRforSEERLimitsExceeded = true;
    7295             :             }
    7296             :             // Checking the limits of capacity modifying curve for temperatures (IEER high and low test conditions)
    7297         612 :             if (CapacityDBTempMax < OutdoorCoilInletAirDryBulbTempRated || CapacityDBTempMin > OADBTempLowReducedCapacityTest ||
    7298         539 :                 CapacityWBTempMax < CoolingCoilInletAirWetBulbTempRated || CapacityWBTempMin > CoolingCoilInletAirWetBulbTempRated) {
    7299          73 :                 CapCurveIEERLimitsExceeded = true;
    7300             :             }
    7301             :             // Checking the limits of EIR modifying curve for temperatures (IEER high and low test conditions)
    7302         612 :             if (EIRDBTempMax < OutdoorCoilInletAirDryBulbTempRated || EIRDBTempMin > OADBTempLowReducedCapacityTest ||
    7303         537 :                 EIRWBTempMax < CoolingCoilInletAirWetBulbTempRated || EIRWBTempMin > CoolingCoilInletAirWetBulbTempRated) {
    7304          75 :                 EIRCurveIEERLimitsExceeded = true;
    7305             :             }
    7306             : 
    7307         612 :             if (CapCurveHighOATLimitsExceeded || CapCurveFlowLimitsExceeded || EIRCurveHighOATLimitsExceeded || EIRCurveFlowLimitsExceeded ||
    7308         612 :                 CapCurveMidOATLimitsExceeded || EIRCurveMidOATLimitsExceeded || PLFfPLRforSEERLimitsExceeded || CapCurveIEERLimitsExceeded ||
    7309             :                 EIRCurveIEERLimitsExceeded) {
    7310             : 
    7311         150 :                 ShowWarningError(
    7312             :                     state,
    7313         150 :                     format("The Standard Ratings is calculated for {} = {} but not at the AHRI test condition due to curve out of bound.",
    7314             :                            DXCoilType,
    7315             :                            DXCoilName));
    7316          75 :                 ShowContinueError(state,
    7317             :                                   " Review the Standard Ratings calculations in the Engineering Reference for this coil type. Also, use "
    7318             :                                   "Output:Diagnostics, DisplayExtraWarnings for further guidance.");
    7319             : 
    7320          75 :                 if (state.dataGlobal->DisplayExtraWarnings) {
    7321           0 :                     ShowContinueError(state, format("{}The max and/or min limits specified in the corresponding curve objects", RoutineName));
    7322           0 :                     ShowContinueError(state,
    7323             :                                       " do not include the AHRI test conditions required to calculate one or more of the Standard Rating values.");
    7324             :                 }
    7325             : 
    7326             :                 // For Standard Rating Cooling Capacity:
    7327          75 :                 if (CapCurveHighOATLimitsExceeded || CapCurveFlowLimitsExceeded) {
    7328           0 :                     if (state.dataGlobal->DisplayExtraWarnings) {
    7329           0 :                         ShowContinueError(
    7330             :                             state,
    7331           0 :                             format("{}={}:  Standard Rating Cooling Capacity calculated is not at the AHRI test condition.", DXCoilType, DXCoilName));
    7332           0 :                         if (CapCurveHighOATLimitsExceeded) {
    7333           0 :                             ShowContinueError(
    7334             :                                 state,
    7335           0 :                                 format(" Check limits in Total Cooling Capacity Function of Temperature Curve, Curve Type = {}, Curve Name = {}",
    7336           0 :                                        Curve::objectNames[static_cast<int>(state.dataCurveManager->PerfCurve(CapFTempCurveIndex)->curveType)],
    7337           0 :                                        GetCurveName(state, CapFTempCurveIndex)));
    7338             :                         }
    7339           0 :                         if (CapCurveFlowLimitsExceeded) {
    7340           0 :                             ShowContinueError(
    7341             :                                 state,
    7342           0 :                                 format(" Check limits in Total Cooling Capacity Function of Flow Fraction Curve, Curve Type = {}, Curve Name = {}",
    7343           0 :                                        Curve::objectNames[static_cast<int>(state.dataCurveManager->PerfCurve(CapFFlowCurveIndex)->curveType)],
    7344           0 :                                        GetCurveName(state, CapFFlowCurveIndex)));
    7345             :                         }
    7346             :                     }
    7347             :                 }
    7348             : 
    7349             :                 // For EER:
    7350          75 :                 if (CapCurveHighOATLimitsExceeded || CapCurveFlowLimitsExceeded || EIRCurveHighOATLimitsExceeded || EIRCurveFlowLimitsExceeded) {
    7351           0 :                     if (state.dataGlobal->DisplayExtraWarnings) {
    7352           0 :                         ShowContinueError(
    7353             :                             state,
    7354           0 :                             format("{}={}:  Energy Efficiency Ratio (EER) calculated is not at the AHRI test condition.", DXCoilType, DXCoilName));
    7355           0 :                         if (CapCurveHighOATLimitsExceeded) {
    7356           0 :                             ShowContinueError(
    7357             :                                 state,
    7358           0 :                                 format(" Check limits in Total Cooling Capacity Function of Temperature Curve, Curve Type = {}, Curve Name = {}",
    7359           0 :                                        Curve::objectNames[static_cast<int>(state.dataCurveManager->PerfCurve(CapFTempCurveIndex)->curveType)],
    7360           0 :                                        GetCurveName(state, CapFTempCurveIndex)));
    7361             :                         }
    7362           0 :                         if (CapCurveFlowLimitsExceeded) {
    7363           0 :                             ShowContinueError(
    7364             :                                 state,
    7365           0 :                                 format(" Check limits in Total Cooling Capacity Function of Flow Fraction Curve, Curve Type = {}, Curve Name = {}",
    7366           0 :                                        Curve::objectNames[static_cast<int>(state.dataCurveManager->PerfCurve(CapFFlowCurveIndex)->curveType)],
    7367           0 :                                        GetCurveName(state, CapFFlowCurveIndex)));
    7368             :                         }
    7369           0 :                         if (EIRCurveHighOATLimitsExceeded) {
    7370           0 :                             ShowContinueError(
    7371             :                                 state,
    7372           0 :                                 format(" Check limits in Energy Input Ratio Function of Temperature Curve, Curve Type = {}, Curve Name = {}",
    7373           0 :                                        Curve::objectNames[static_cast<int>(state.dataCurveManager->PerfCurve(EIRFTempCurveIndex)->curveType)],
    7374           0 :                                        GetCurveName(state, EIRFTempCurveIndex)));
    7375             :                         }
    7376           0 :                         if (EIRCurveFlowLimitsExceeded) {
    7377           0 :                             ShowContinueError(
    7378             :                                 state,
    7379           0 :                                 format(" Check limits in Energy Input Ratio Function of Flow Fraction Curve, Curve Type = {}, Curve Name = {}",
    7380           0 :                                        Curve::objectNames[static_cast<int>(state.dataCurveManager->PerfCurve(EIRFFlowCurveIndex)->curveType)],
    7381           0 :                                        GetCurveName(state, EIRFFlowCurveIndex)));
    7382             :                         }
    7383             :                     }
    7384             :                 }
    7385             : 
    7386             :                 // For SEER:
    7387          75 :                 if (CapCurveMidOATLimitsExceeded || EIRCurveMidOATLimitsExceeded || CapCurveFlowLimitsExceeded || EIRCurveFlowLimitsExceeded ||
    7388             :                     PLFfPLRforSEERLimitsExceeded) {
    7389           0 :                     if (state.dataGlobal->DisplayExtraWarnings) {
    7390           0 :                         ShowContinueError(state,
    7391           0 :                                           format("{}={}:  Seasonal Energy Efficiency Ratio (SEER) calculated is not at the AHRI test condition.",
    7392             :                                                  DXCoilType,
    7393             :                                                  DXCoilName));
    7394           0 :                         if (CapCurveMidOATLimitsExceeded) {
    7395           0 :                             ShowContinueError(
    7396             :                                 state,
    7397           0 :                                 format(" Check limits in Total Cooling Capacity Function of Temperature Curve, Curve Type = {}, Curve Name = {}",
    7398           0 :                                        Curve::objectNames[static_cast<int>(state.dataCurveManager->PerfCurve(CapFTempCurveIndex)->curveType)],
    7399           0 :                                        GetCurveName(state, CapFTempCurveIndex)));
    7400             :                         }
    7401           0 :                         if (CapCurveFlowLimitsExceeded) {
    7402           0 :                             ShowContinueError(
    7403             :                                 state,
    7404           0 :                                 format(" Check limits in Total Cooling Capacity Function of Flow Fraction Curve, Curve Type = {}, Curve Name = {}",
    7405           0 :                                        Curve::objectNames[static_cast<int>(state.dataCurveManager->PerfCurve(CapFFlowCurveIndex)->curveType)],
    7406           0 :                                        GetCurveName(state, CapFFlowCurveIndex)));
    7407             :                         }
    7408           0 :                         if (EIRCurveMidOATLimitsExceeded) {
    7409           0 :                             ShowContinueError(
    7410             :                                 state,
    7411           0 :                                 format(" Check limits in Energy Input Ratio Function of Temperature Curve, Curve Type = {}, Curve Name = {}",
    7412           0 :                                        Curve::objectNames[static_cast<int>(state.dataCurveManager->PerfCurve(EIRFTempCurveIndex)->curveType)],
    7413           0 :                                        GetCurveName(state, EIRFTempCurveIndex)));
    7414             :                         }
    7415           0 :                         if (EIRCurveFlowLimitsExceeded) {
    7416           0 :                             ShowContinueError(
    7417             :                                 state,
    7418           0 :                                 format(" Check limits in Energy Input Ratio Function of Flow Fraction Curve, Curve Type = {}, Curve Name = {}",
    7419           0 :                                        Curve::objectNames[static_cast<int>(state.dataCurveManager->PerfCurve(EIRFFlowCurveIndex)->curveType)],
    7420           0 :                                        GetCurveName(state, EIRFFlowCurveIndex)));
    7421             :                         }
    7422           0 :                         if (PLFfPLRforSEERLimitsExceeded) {
    7423           0 :                             ShowContinueError(
    7424             :                                 state,
    7425           0 :                                 format(" Check limits in Part Load Fraction Correlation Curve, Curve Type = {}, Curve Name = {}",
    7426           0 :                                        Curve::objectNames[static_cast<int>(state.dataCurveManager->PerfCurve(PLFFPLRCurveIndex)->curveType)],
    7427           0 :                                        GetCurveName(state, PLFFPLRCurveIndex)));
    7428             :                         }
    7429             :                     }
    7430             :                 }
    7431             : 
    7432             :                 // For IEER:
    7433          75 :                 if (CapCurveIEERLimitsExceeded || CapCurveFlowLimitsExceeded || EIRCurveIEERLimitsExceeded || EIRCurveFlowLimitsExceeded) {
    7434          75 :                     if (state.dataGlobal->DisplayExtraWarnings) {
    7435           0 :                         ShowContinueError(state,
    7436           0 :                                           format("{}={}:  Integrated Energy Efficiency Ratio (IEER) calculated is not at the AHRI test condition.",
    7437             :                                                  DXCoilType,
    7438             :                                                  DXCoilName));
    7439           0 :                         if (CapCurveIEERLimitsExceeded) {
    7440           0 :                             ShowContinueError(
    7441             :                                 state,
    7442           0 :                                 format(" Check limits in Total Cooling Capacity Function of Temperature Curve, Curve Type = {}, Curve Name = {}",
    7443           0 :                                        Curve::objectNames[static_cast<int>(state.dataCurveManager->PerfCurve(CapFTempCurveIndex)->curveType)],
    7444           0 :                                        GetCurveName(state, CapFTempCurveIndex)));
    7445             :                         }
    7446           0 :                         if (CapCurveFlowLimitsExceeded) {
    7447           0 :                             ShowContinueError(
    7448             :                                 state,
    7449           0 :                                 format(" Check limits in Total Cooling Capacity Function of Flow Fraction Curve, Curve Type = {}, Curve Name = {}",
    7450           0 :                                        Curve::objectNames[static_cast<int>(state.dataCurveManager->PerfCurve(CapFFlowCurveIndex)->curveType)],
    7451           0 :                                        GetCurveName(state, CapFFlowCurveIndex)));
    7452             :                         }
    7453           0 :                         if (EIRCurveIEERLimitsExceeded) {
    7454           0 :                             ShowContinueError(
    7455             :                                 state,
    7456           0 :                                 format(" Check limits in EIR Function of Temperature Curve, Curve Type = {}, Curve Name = {}",
    7457           0 :                                        Curve::objectNames[static_cast<int>(state.dataCurveManager->PerfCurve(EIRFTempCurveIndex)->curveType)],
    7458           0 :                                        GetCurveName(state, EIRFTempCurveIndex)));
    7459             :                         }
    7460           0 :                         if (EIRCurveFlowLimitsExceeded) {
    7461           0 :                             ShowContinueError(
    7462             :                                 state,
    7463           0 :                                 format(" Check limits in Energy Input Ratio Function of Flow Fraction Curve, Curve Type = {}, Curve Name = {}",
    7464           0 :                                        Curve::objectNames[static_cast<int>(state.dataCurveManager->PerfCurve(EIRFFlowCurveIndex)->curveType)],
    7465           0 :                                        GetCurveName(state, EIRFFlowCurveIndex)));
    7466             :                         }
    7467             :                     }
    7468             :                 }
    7469             : 
    7470             :             } // End of curve error messages
    7471         612 :             break;
    7472             :         }
    7473          75 :         case CoilDX_HeatingEmpirical: {
    7474             :             {
    7475          75 :                 if (state.dataCurveManager->PerfCurve(CapFTempCurveIndex)->numDims == 1) {
    7476          74 :                     GetCurveMinMaxValues(state, CapFTempCurveIndex, HeatingCapODBTempMin, HeatingCapODBTempMax);
    7477             : 
    7478             :                     // Checking the limits of capacity modifying curve for temperatures (IEER high and low test conditions)
    7479          74 :                     if (HeatingCapODBTempMax < HeatingOutdoorCoilInletAirDBTempRated ||
    7480          74 :                         HeatingCapODBTempMin > HeatingOutdoorCoilInletAirDBTempH3Test) {
    7481           0 :                         HeatingCapCurveHSPFLimitsExceeded = true;
    7482             :                     }
    7483             :                 } else {
    7484           1 :                     GetCurveMinMaxValues(
    7485             :                         state, CapFTempCurveIndex, HeatingCapIDBTempMin, HeatingCapIDBTempMax, HeatingCapODBTempMin, HeatingCapODBTempMax);
    7486             : 
    7487             :                     // Checking the limits of capacity modifying curve for temperatures (IEER high and low test conditions)
    7488           1 :                     if (HeatingCapODBTempMax < HeatingOutdoorCoilInletAirDBTempRated ||
    7489           1 :                         HeatingCapODBTempMin > HeatingOutdoorCoilInletAirDBTempH3Test ||
    7490           1 :                         HeatingCapIDBTempMax < HeatingIndoorCoilInletAirDBTempRated || HeatingCapIDBTempMin > HeatingIndoorCoilInletAirDBTempRated) {
    7491           0 :                         HeatingCapCurveHSPFLimitsExceeded = true;
    7492             :                     }
    7493             :                 }
    7494             :             }
    7495             :             {
    7496          75 :                 if (state.dataCurveManager->PerfCurve(EIRFTempCurveIndex)->numDims == 1) {
    7497          74 :                     GetCurveMinMaxValues(state, EIRFTempCurveIndex, HeatingEIRODBTempMin, HeatingEIRODBTempMax);
    7498             : 
    7499             :                     // Checking the limits of EIR modifying curve for temperatures (HSPF high and low test conditions)
    7500          74 :                     if (HeatingEIRODBTempMax < HeatingOutdoorCoilInletAirDBTempRated ||
    7501          74 :                         HeatingEIRODBTempMin > HeatingOutdoorCoilInletAirDBTempH3Test) {
    7502           0 :                         HeatingEIRCurveHSPFLimitsExceeded = true;
    7503             :                     }
    7504             :                 } else {
    7505           1 :                     GetCurveMinMaxValues(
    7506             :                         state, EIRFTempCurveIndex, HeatingEIRIDBTempMin, HeatingEIRIDBTempMax, HeatingEIRODBTempMin, HeatingEIRODBTempMax);
    7507             : 
    7508             :                     // Checking the limits of EIR modifying curve for temperatures (HSPF high and low test conditions)
    7509           1 :                     if (HeatingEIRODBTempMax < HeatingOutdoorCoilInletAirDBTempRated ||
    7510           1 :                         HeatingEIRODBTempMin > HeatingOutdoorCoilInletAirDBTempH3Test ||
    7511           1 :                         HeatingEIRIDBTempMax < HeatingIndoorCoilInletAirDBTempRated || HeatingEIRIDBTempMin > HeatingIndoorCoilInletAirDBTempRated) {
    7512           0 :                         HeatingEIRCurveHSPFLimitsExceeded = true;
    7513             :                     }
    7514             :                 }
    7515             :             }
    7516          75 :             if (HeatingCapCurveHSPFLimitsExceeded || HeatingEIRCurveHSPFLimitsExceeded) {
    7517           0 :                 ShowWarningError(
    7518             :                     state,
    7519           0 :                     format("The Standard Ratings is calculated for {} = {} but not at the AHRI test condition due to curve out of bound.",
    7520             :                            DXCoilType,
    7521             :                            DXCoilName));
    7522           0 :                 ShowContinueError(state,
    7523             :                                   " Review the Standard Ratings calculations in the Engineering Reference for this coil type. Also, use "
    7524             :                                   "Output:Diagnostics, DisplayExtraWarnings for further guidance.");
    7525           0 :                 if (state.dataGlobal->DisplayExtraWarnings) {
    7526           0 :                     ShowContinueError(state, format("{}The max and/or min limits specified in the corresponding curve objects", RoutineName));
    7527           0 :                     ShowContinueError(state,
    7528             :                                       " do not include the AHRI test conditions required to calculate one or more of the Standard Rating values.");
    7529             :                 }
    7530           0 :                 if (state.dataGlobal->DisplayExtraWarnings) {
    7531           0 :                     ShowWarningError(
    7532             :                         state,
    7533           0 :                         format("{}={}:  Heating Seasonal Performance Factor calculated is not at the AHRI test condition.", DXCoilType, DXCoilName));
    7534           0 :                     ShowContinueError(state, " Review the Standard Ratings calculations in the Engineering Reference for this coil type.");
    7535           0 :                     if (HeatingCapCurveHSPFLimitsExceeded) {
    7536           0 :                         ShowContinueError(
    7537             :                             state,
    7538           0 :                             format(" Check limits in Total Heating Capacity Function of Temperature Curve, Curve Type = {}, Curve Name = {}",
    7539           0 :                                    Curve::objectNames[static_cast<int>(state.dataCurveManager->PerfCurve(CapFTempCurveIndex)->curveType)],
    7540           0 :                                    GetCurveName(state, CapFTempCurveIndex)));
    7541             :                     }
    7542           0 :                     if (HeatingEIRCurveHSPFLimitsExceeded) {
    7543           0 :                         ShowContinueError(
    7544             :                             state,
    7545           0 :                             format(" Check limits in EIR Function of Temperature Curve, Curve Type = {}, Curve Name = {}",
    7546           0 :                                    Curve::objectNames[static_cast<int>(state.dataCurveManager->PerfCurve(EIRFTempCurveIndex)->curveType)],
    7547           0 :                                    GetCurveName(state, EIRFTempCurveIndex)));
    7548             :                     }
    7549             :                 }
    7550             :             }
    7551             : 
    7552             :             //   MultiSpeed DX Coil Net Cooling Capacity and SEER:
    7553          75 :             break;
    7554             :         }
    7555         113 :         case CoilDX_MultiSpeedCooling: {
    7556         113 :             GetCurveMinMaxValues(state, CapFTempCurveIndex, CapacityWBTempMin, CapacityWBTempMax, CapacityDBTempMin, CapacityDBTempMax);
    7557         113 :             GetCurveMinMaxValues(state, EIRFTempCurveIndex, EIRWBTempMin, EIRWBTempMax, EIRDBTempMin, EIRDBTempMax);
    7558         113 :             GetCurveMinMaxValues(state, CapFFlowCurveIndex, CapacityFlowRatioMin, CapacityFlowRatioMax);
    7559         113 :             GetCurveMinMaxValues(state, EIRFFlowCurveIndex, EIRFlowRatioMin, EIRFlowRatioMax);
    7560             : 
    7561             :             // Checking the limits of capacity modifying curve for temperatures
    7562         113 :             if (CapacityDBTempMax < OutdoorCoilInletAirDryBulbTempRated || CapacityDBTempMin > OutdoorCoilInletAirDryBulbTempRated ||
    7563         113 :                 CapacityWBTempMax < CoolingCoilInletAirWetBulbTempRated || CapacityWBTempMin > CoolingCoilInletAirWetBulbTempRated) {
    7564           0 :                 CapCurveHighOATLimitsExceeded = true;
    7565             :             }
    7566             :             // Checking the limits of capacity modifying curve for flow fraction
    7567         113 :             if (CapacityFlowRatioMax < AirMassFlowRatioRated || CapacityFlowRatioMin > AirMassFlowRatioRated) {
    7568           0 :                 CapCurveFlowLimitsExceeded = true;
    7569             :             }
    7570             :             // Checking the limits of EIR modifying curve for temperatures
    7571         113 :             if (EIRDBTempMax < OutdoorCoilInletAirDryBulbTempRated || EIRDBTempMin > OutdoorCoilInletAirDryBulbTempRated ||
    7572         113 :                 EIRWBTempMax < CoolingCoilInletAirWetBulbTempRated || EIRWBTempMin > CoolingCoilInletAirWetBulbTempRated) {
    7573           0 :                 EIRCurveHighOATLimitsExceeded = true;
    7574             :             }
    7575             :             // Checking the limits of EIR modifying curve for flow fraction
    7576         113 :             if (EIRFlowRatioMax < AirMassFlowRatioRated || EIRFlowRatioMin > AirMassFlowRatioRated) {
    7577           0 :                 EIRCurveFlowLimitsExceeded = true;
    7578             :             }
    7579             :             // Checking the limits of capacity modifying curve for temperatures (SEER calculation)
    7580         113 :             if (CapacityDBTempMax < OutdoorCoilInletAirDryBulbTempTestF1 || CapacityDBTempMin > OutdoorCoilInletAirDryBulbTempTestF1 ||
    7581          25 :                 CapacityWBTempMax < CoolingCoilInletAirWetBulbTempRated || CapacityWBTempMin > CoolingCoilInletAirWetBulbTempRated) {
    7582          88 :                 CapCurveLowOATLimitsExceeded = true;
    7583             :             }
    7584             :             // Checking the limits of EIR modifying curve for temperatures (SEER calculation)
    7585         113 :             if (EIRDBTempMax < OutdoorCoilInletAirDryBulbTempTestF1 || EIRDBTempMin > OutdoorCoilInletAirDryBulbTempTestF1 ||
    7586          25 :                 EIRWBTempMax < CoolingCoilInletAirWetBulbTempRated || EIRWBTempMin > CoolingCoilInletAirWetBulbTempRated) {
    7587          88 :                 EIRCurveLowOATLimitsExceeded = true;
    7588             :             }
    7589             : 
    7590         113 :             if (CapCurveHighOATLimitsExceeded || CapCurveFlowLimitsExceeded || EIRCurveHighOATLimitsExceeded || EIRCurveFlowLimitsExceeded ||
    7591          25 :                 CapCurveLowOATLimitsExceeded || EIRCurveLowOATLimitsExceeded) {
    7592             : 
    7593         176 :                 ShowWarningError(
    7594             :                     state,
    7595         176 :                     format("The Standard Ratings is calculated for {} = {} but not at the AHRI test condition due to curve out of bound.",
    7596             :                            DXCoilType,
    7597             :                            DXCoilName));
    7598          88 :                 ShowContinueError(state,
    7599             :                                   " Review the Standard Ratings calculations in the Engineering Reference for this coil type. Also, use "
    7600             :                                   "Output:Diagnostics, DisplayExtraWarnings for further guidance.");
    7601             : 
    7602          88 :                 if (state.dataGlobal->DisplayExtraWarnings) {
    7603           0 :                     ShowContinueError(state, format("{}The max and/or min limits specified in the corresponding curve objects", RoutineName));
    7604           0 :                     ShowContinueError(state,
    7605             :                                       " do not include the AHRI test conditions required to calculate one or more of the Standard Rating values.");
    7606             :                 }
    7607             : 
    7608             :                 // For Standard Rating Cooling Capacity:
    7609          88 :                 if (CapCurveHighOATLimitsExceeded || CapCurveFlowLimitsExceeded) {
    7610           0 :                     if (state.dataGlobal->DisplayExtraWarnings) {
    7611           0 :                         ShowContinueError(state,
    7612           0 :                                           format("{}={}:  The Standard Rating Cooling Capacity calculated is not at the AHRI test condition.",
    7613             :                                                  DXCoilType,
    7614             :                                                  DXCoilName));
    7615           0 :                         if (CapCurveHighOATLimitsExceeded) {
    7616           0 :                             ShowContinueError(
    7617             :                                 state,
    7618           0 :                                 format(" Check limits in Total Cooling Capacity Function of Temperature Curve, Curve Type = {}, Curve Name = {}",
    7619           0 :                                        Curve::objectNames[static_cast<int>(state.dataCurveManager->PerfCurve(CapFTempCurveIndex)->curveType)],
    7620           0 :                                        GetCurveName(state, CapFTempCurveIndex)));
    7621             :                         }
    7622           0 :                         if (CapCurveFlowLimitsExceeded) {
    7623           0 :                             ShowContinueError(
    7624             :                                 state,
    7625           0 :                                 format(" Check limits in Total Cooling Capacity Function of Flow Fraction Curve, Curve Type = {}, Curve Name = {}",
    7626           0 :                                        Curve::objectNames[static_cast<int>(state.dataCurveManager->PerfCurve(CapFFlowCurveIndex)->curveType)],
    7627           0 :                                        GetCurveName(state, CapFFlowCurveIndex)));
    7628             :                         }
    7629             :                     }
    7630             :                 }
    7631             : 
    7632             :                 // For MultiSpeed DX Coil SEER:
    7633             : 
    7634          88 :                 if (CapCurveLowOATLimitsExceeded || EIRCurveLowOATLimitsExceeded || CapCurveFlowLimitsExceeded || EIRCurveFlowLimitsExceeded) {
    7635          88 :                     if (state.dataGlobal->DisplayExtraWarnings) {
    7636           0 :                         ShowContinueError(state,
    7637           0 :                                           format("{}={}:  The Seasonal Energy Efficiency Ratio (SEER) calculated is not at the AHRI test condition.",
    7638             :                                                  DXCoilType,
    7639             :                                                  DXCoilName));
    7640           0 :                         if (CapCurveLowOATLimitsExceeded) {
    7641           0 :                             ShowContinueError(
    7642             :                                 state,
    7643           0 :                                 format(" Check limits in Total Cooling Capacity Function of Temperature Curve, Curve Type = {}, Curve Name = {}",
    7644           0 :                                        Curve::objectNames[static_cast<int>(state.dataCurveManager->PerfCurve(CapFTempCurveIndex)->curveType)],
    7645           0 :                                        GetCurveName(state, CapFTempCurveIndex)));
    7646             :                         }
    7647           0 :                         if (CapCurveFlowLimitsExceeded) {
    7648           0 :                             ShowContinueError(
    7649             :                                 state,
    7650           0 :                                 format(" Check limits in Total Cooling Capacity Function of Flow Fraction Curve, Curve Type = {}, Curve Name = {}",
    7651           0 :                                        Curve::objectNames[static_cast<int>(state.dataCurveManager->PerfCurve(CapFFlowCurveIndex)->curveType)],
    7652           0 :                                        GetCurveName(state, CapFFlowCurveIndex)));
    7653             :                         }
    7654           0 :                         if (EIRCurveLowOATLimitsExceeded) {
    7655           0 :                             ShowContinueError(
    7656             :                                 state,
    7657           0 :                                 format(" Check limits in Energy Input Ratio Function of Temperature Curve, Curve Type = {}, Curve Name = {}",
    7658           0 :                                        Curve::objectNames[static_cast<int>(state.dataCurveManager->PerfCurve(EIRFTempCurveIndex)->curveType)],
    7659           0 :                                        GetCurveName(state, EIRFTempCurveIndex)));
    7660             :                         }
    7661           0 :                         if (EIRCurveFlowLimitsExceeded) {
    7662           0 :                             ShowContinueError(
    7663             :                                 state,
    7664           0 :                                 format(" Check limits in Energy Input Ratio Function of Flow Fraction Curve, Curve Type = {}, Curve Name = {}",
    7665           0 :                                        Curve::objectNames[static_cast<int>(state.dataCurveManager->PerfCurve(EIRFFlowCurveIndex)->curveType)],
    7666           0 :                                        GetCurveName(state, EIRFFlowCurveIndex)));
    7667             :                         }
    7668             :                     }
    7669             :                 }
    7670             : 
    7671             :             } // End of curve error messages
    7672             : 
    7673         113 :             break;
    7674             :         }
    7675          70 :         case CoilDX_MultiSpeedHeating: {
    7676             : 
    7677             :             {
    7678          70 :                 if (state.dataCurveManager->PerfCurve(CapFTempCurveIndex)->numDims == 1) {
    7679          52 :                     GetCurveMinMaxValues(state, CapFTempCurveIndex, HeatingCapODBTempMin, HeatingCapODBTempMax);
    7680             : 
    7681          52 :                     if (HeatingCapODBTempMax < HeatingOutdoorCoilInletAirDBTempRated ||
    7682          52 :                         HeatingCapODBTempMin > HeatingOutdoorCoilInletAirDBTempH3Test) {
    7683           0 :                         CapCurveOATLimitsExceeded = true;
    7684             :                     }
    7685             :                     // Checking the limits of capacity modifying curve for temperatures (HSPF high and low test conditions)
    7686          52 :                     if (HeatingCapODBTempMax < HeatingOutdoorCoilInletAirDBTempRated ||
    7687          52 :                         HeatingCapODBTempMin > HeatingOutdoorCoilInletAirDBTempH3Test ||
    7688          52 :                         HeatingCapODBTempMax < HeatingOutdoorCoilInletAirDBTempH0Test) {
    7689           0 :                         HeatingCapCurveHSPFLimitsExceeded = true;
    7690             :                     }
    7691             : 
    7692             :                 } else {
    7693          18 :                     GetCurveMinMaxValues(
    7694             :                         state, CapFTempCurveIndex, HeatingCapIDBTempMin, HeatingCapIDBTempMax, HeatingCapODBTempMin, HeatingCapODBTempMax);
    7695             : 
    7696             :                     // Checking the limits of capacity modifying curve for temperatures (HSPF high and low test conditions)
    7697          18 :                     if (HeatingCapODBTempMax < HeatingOutdoorCoilInletAirDBTempRated ||
    7698          18 :                         HeatingCapODBTempMin > HeatingOutdoorCoilInletAirDBTempH3Test ||
    7699          18 :                         HeatingCapIDBTempMax < HeatingIndoorCoilInletAirDBTempRated || HeatingCapIDBTempMin > HeatingIndoorCoilInletAirDBTempRated ||
    7700          18 :                         HeatingCapODBTempMax < HeatingOutdoorCoilInletAirDBTempH0Test) {
    7701           0 :                         HeatingCapCurveHSPFLimitsExceeded = true;
    7702             :                     }
    7703             :                 }
    7704             :             }
    7705             : 
    7706             :             {
    7707          70 :                 if (state.dataCurveManager->PerfCurve(EIRFTempCurveIndex)->numDims == 1) {
    7708          52 :                     GetCurveMinMaxValues(state, EIRFTempCurveIndex, HeatingEIRODBTempMin, HeatingEIRODBTempMax);
    7709             :                     // Checking the limits of EIR modifying curve for temperatures (HSPF high and low test conditions)
    7710          52 :                     if (HeatingEIRODBTempMax < HeatingOutdoorCoilInletAirDBTempRated ||
    7711          52 :                         HeatingEIRODBTempMin > HeatingOutdoorCoilInletAirDBTempH3Test ||
    7712          52 :                         HeatingCapODBTempMax < HeatingOutdoorCoilInletAirDBTempH0Test) {
    7713           0 :                         HeatingEIRCurveHSPFLimitsExceeded = true;
    7714             :                     }
    7715             :                 } else {
    7716          18 :                     GetCurveMinMaxValues(
    7717             :                         state, EIRFTempCurveIndex, HeatingEIRIDBTempMin, HeatingEIRIDBTempMax, HeatingEIRODBTempMin, HeatingEIRODBTempMax);
    7718             : 
    7719             :                     // Checking the limits of EIR modifying curve for temperatures (HSPF high and low test conditions)
    7720          18 :                     if (HeatingEIRODBTempMax < HeatingOutdoorCoilInletAirDBTempRated ||
    7721          18 :                         HeatingEIRODBTempMin > HeatingOutdoorCoilInletAirDBTempH3Test ||
    7722          18 :                         HeatingEIRIDBTempMax < HeatingIndoorCoilInletAirDBTempRated || HeatingEIRIDBTempMin > HeatingIndoorCoilInletAirDBTempRated ||
    7723          18 :                         HeatingCapODBTempMax < HeatingOutdoorCoilInletAirDBTempH0Test) {
    7724           0 :                         HeatingEIRCurveHSPFLimitsExceeded = true;
    7725             :                     }
    7726             :                 }
    7727             :             }
    7728          70 :             if (HeatingCapCurveHSPFLimitsExceeded || HeatingEIRCurveHSPFLimitsExceeded || CapCurveOATLimitsExceeded) {
    7729             : 
    7730           0 :                 ShowWarningError(
    7731             :                     state,
    7732           0 :                     format("The Standard Ratings is calculated for {} = {} but not at the AHRI test condition due to curve out of bound.",
    7733             :                            DXCoilType,
    7734             :                            DXCoilName));
    7735           0 :                 ShowContinueError(state,
    7736             :                                   " Review the Standard Ratings calculations in the Engineering Reference for this coil type. Also, use "
    7737             :                                   "Output:Diagnostics, DisplayExtraWarnings for further guidance.");
    7738             : 
    7739           0 :                 if (state.dataGlobal->DisplayExtraWarnings) {
    7740           0 :                     ShowContinueError(state, format("{}The max and/or min limits specified in the corresponding curve objects", RoutineName));
    7741           0 :                     ShowContinueError(state,
    7742             :                                       " do not include the AHRI test conditions required to calculate one or more of the Standard Rating values.");
    7743             :                 }
    7744             :             }
    7745          70 :             if (CapCurveOATLimitsExceeded) {
    7746           0 :                 if (state.dataGlobal->DisplayExtraWarnings) {
    7747           0 :                     ShowWarningError(
    7748           0 :                         state, format("{}={}:  The Net Heating Capacity Calculated is not at the AHRI test condition.", DXCoilType, DXCoilName));
    7749           0 :                     ShowContinueError(
    7750             :                         state,
    7751           0 :                         format(" Check limits in Total Heating Capacity Function of Temperature Curve, Curve Type = {}, Curve Name = {}",
    7752           0 :                                Curve::objectNames[static_cast<int>(state.dataCurveManager->PerfCurve(CapFTempCurveIndex)->curveType)],
    7753           0 :                                GetCurveName(state, CapFTempCurveIndex)));
    7754             :                 }
    7755             :             }
    7756             : 
    7757          70 :             if (HeatingCapCurveHSPFLimitsExceeded || HeatingEIRCurveHSPFLimitsExceeded) {
    7758           0 :                 if (state.dataGlobal->DisplayExtraWarnings) {
    7759           0 :                     ShowWarningError(state,
    7760           0 :                                      format("{}={}:  The Heating Seasonal Performance Factor calculated is not at the AHRI test condition.",
    7761             :                                             DXCoilType,
    7762             :                                             DXCoilName));
    7763           0 :                     if (HeatingCapCurveHSPFLimitsExceeded) {
    7764           0 :                         ShowContinueError(
    7765             :                             state,
    7766           0 :                             format(" Check limits in Total Heating Capacity Function of Temperature Curve, Curve Type = {}, Curve Name = {}",
    7767           0 :                                    Curve::objectNames[static_cast<int>(state.dataCurveManager->PerfCurve(CapFTempCurveIndex)->curveType)],
    7768           0 :                                    GetCurveName(state, CapFTempCurveIndex)));
    7769             :                     }
    7770           0 :                     if (HeatingEIRCurveHSPFLimitsExceeded) {
    7771           0 :                         ShowContinueError(
    7772             :                             state,
    7773           0 :                             format(" Check limits in EIR Function of Temperature Curve, Curve Type = {}, Curve Name = {}",
    7774           0 :                                    Curve::objectNames[static_cast<int>(state.dataCurveManager->PerfCurve(EIRFTempCurveIndex)->curveType)],
    7775           0 :                                    GetCurveName(state, EIRFTempCurveIndex)));
    7776             :                     }
    7777             :                 }
    7778             :             }
    7779          70 :             break;
    7780             :         }
    7781             :             // case CoilDX_CoolingTwoSpeed: {
    7782             :             //     GetCurveMinMaxValues(state, CapFTempCurveIndex, CapacityWBTempMin, CapacityWBTempMax, CapacityDBTempMin, CapacityDBTempMax);
    7783             :             //     GetCurveMinMaxValues(state, EIRFTempCurveIndex, EIRWBTempMin, EIRWBTempMax, EIRDBTempMin, EIRDBTempMax);
    7784             :             //     GetCurveMinMaxValues(state, CapFFlowCurveIndex, CapacityFlowRatioMin, CapacityFlowRatioMax);
    7785             :             //     GetCurveMinMaxValues(state, EIRFFlowCurveIndex, EIRFlowRatioMin, EIRFlowRatioMax);
    7786             :             //     GetCurveMinMaxValues(state, PLFFPLRCurveIndex, PLFFPLRMin, PLFFPLRMax);
    7787             :             //     break;
    7788             :             // }
    7789         314 :         default:
    7790         314 :             break;
    7791             :         }
    7792        1184 :     }
    7793             : 
    7794         744 :     Real64 CondenserEnteringFluidTemperature(DataPlant::CondenserType const CondenserType,
    7795             :                                              StandardRatings::AhriChillerStd const ChillerStd,
    7796             :                                              Real64 LoadRatio)
    7797             :     {
    7798         744 :         Real64 CondenserEnteringFluidTemp = 0.0;
    7799         744 :         if (ChillerStd == StandardRatings::AhriChillerStd::AHRI550_590) {
    7800             : 
    7801         372 :             if (CondenserType == DataPlant::CondenserType::WaterCooled) {
    7802             :                 // get the condenser entering water temperature for a given load ratio in deg C
    7803         336 :                 Real64 enteringWaterTemp = 18.33;
    7804         336 :                 if (LoadRatio > 0.50) {
    7805         168 :                     enteringWaterTemp = 7.22 + 22.22 * LoadRatio;
    7806             :                 }
    7807         336 :                 CondenserEnteringFluidTemp = enteringWaterTemp;
    7808          36 :             } else if (CondenserType == DataPlant::CondenserType::AirCooled) {
    7809             :                 // get the outdoor air dry bulb temperature for a given load ratio in deg C
    7810          32 :                 Real64 enteringAirDBTemp = 12.78;
    7811          32 :                 if (LoadRatio > 0.33) {
    7812          24 :                     enteringAirDBTemp = 1.67 + 33.33 * LoadRatio;
    7813             :                 }
    7814          32 :                 CondenserEnteringFluidTemp = enteringAirDBTemp;
    7815             :             } else { // EvaporativelyCooled Condenser
    7816             :                 // get the outdoor air wet bulb temperature for a given load ratio in deg C
    7817           4 :                 Real64 enteringAirWBTemp = 10.0 + 13.89 * LoadRatio;
    7818           4 :                 CondenserEnteringFluidTemp = enteringAirWBTemp;
    7819             :             }
    7820             : 
    7821         372 :         } else if (ChillerStd == StandardRatings::AhriChillerStd::AHRI551_591) {
    7822             : 
    7823         372 :             if (CondenserType == DataPlant::CondenserType::WaterCooled) {
    7824             :                 // get the condenser entering water temperature for a given load ratio in deg C
    7825         336 :                 Real64 enteringWaterTemp = 19.0;
    7826         336 :                 if (LoadRatio > 0.50) {
    7827         168 :                     enteringWaterTemp = 8.0 + 22.0 * LoadRatio;
    7828             :                 }
    7829         336 :                 CondenserEnteringFluidTemp = enteringWaterTemp;
    7830          36 :             } else if (CondenserType == DataPlant::CondenserType::AirCooled) {
    7831             :                 // get the outdoor air dry bulb temperature for a given load ratio in deg C
    7832          32 :                 Real64 enteringAirDBTemp = 13.0;
    7833          32 :                 if (LoadRatio > 0.3125) {
    7834          24 :                     enteringAirDBTemp = 3.0 + 32.0 * LoadRatio;
    7835             :                 }
    7836          32 :                 CondenserEnteringFluidTemp = enteringAirDBTemp;
    7837             :             } else { // EvaporativelyCooled Condenser
    7838             :                 // get the outdoor air wet bulb temperature for a given load ratio in deg C
    7839           4 :                 Real64 enteringAirWBTemp = 10.0 + 14.0 * LoadRatio;
    7840           4 :                 CondenserEnteringFluidTemp = enteringAirWBTemp;
    7841             :             }
    7842             :         }
    7843         744 :         return CondenserEnteringFluidTemp;
    7844             :     }
    7845             : 
    7846             : } // namespace StandardRatings
    7847             : 
    7848             : } // namespace EnergyPlus

Generated by: LCOV version 1.14