LCOV - code coverage report
Current view: top level - EnergyPlus - StandardRatings.cc (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 89.4 % 3748 3351
Test Date: 2025-05-22 16:09:37 Functions: 95.6 % 45 43

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

Generated by: LCOV version 2.0-1