LCOV - code coverage report
Current view: top level - EnergyPlus - StandardRatings.cc (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 88.2 % 3760 3316
Test Date: 2025-06-02 07:23:51 Functions: 100.0 % 45 45

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

Generated by: LCOV version 2.0-1