LCOV - code coverage report
Current view: top level - EnergyPlus - RefrigeratedCase.cc (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 71.2 % 8317 5920
Test Date: 2025-06-02 07:23:51 Functions: 95.1 % 41 39

            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 <cmath>
      50              : #include <string>
      51              : 
      52              : // ObjexxFCL Headers
      53              : #include <ObjexxFCL/Array.functions.hh>
      54              : #include <ObjexxFCL/Array2D.hh>
      55              : // #include <ObjexxFCL/Fmath.hh>
      56              : 
      57              : // EnergyPlus Headers
      58              : #include <EnergyPlus/BranchNodeConnections.hh>
      59              : #include <EnergyPlus/CurveManager.hh>
      60              : #include <EnergyPlus/Data/EnergyPlusData.hh>
      61              : #include <EnergyPlus/DataEnvironment.hh>
      62              : #include <EnergyPlus/DataHVACGlobals.hh>
      63              : #include <EnergyPlus/DataHeatBalFanSys.hh>
      64              : #include <EnergyPlus/DataHeatBalance.hh>
      65              : #include <EnergyPlus/DataIPShortCuts.hh>
      66              : #include <EnergyPlus/DataLoopNode.hh>
      67              : #include <EnergyPlus/DataWater.hh>
      68              : #include <EnergyPlus/DataZoneEnergyDemands.hh>
      69              : #include <EnergyPlus/DataZoneEquipment.hh>
      70              : #include <EnergyPlus/EMSManager.hh>
      71              : #include <EnergyPlus/FluidProperties.hh>
      72              : #include <EnergyPlus/General.hh>
      73              : #include <EnergyPlus/GlobalNames.hh>
      74              : #include <EnergyPlus/HeatBalanceInternalHeatGains.hh>
      75              : #include <EnergyPlus/InputProcessing/InputProcessor.hh>
      76              : #include <EnergyPlus/NodeInputManager.hh>
      77              : #include <EnergyPlus/OutAirNodeManager.hh>
      78              : #include <EnergyPlus/OutputProcessor.hh>
      79              : #include <EnergyPlus/Plant/DataPlant.hh>
      80              : #include <EnergyPlus/PlantUtilities.hh>
      81              : #include <EnergyPlus/Psychrometrics.hh>
      82              : #include <EnergyPlus/RefrigeratedCase.hh>
      83              : #include <EnergyPlus/ScheduleManager.hh>
      84              : #include <EnergyPlus/UtilityRoutines.hh>
      85              : #include <EnergyPlus/WaterManager.hh>
      86              : 
      87              : namespace EnergyPlus::RefrigeratedCase {
      88              : 
      89              : // MODULE INFORMATION:
      90              : //       AUTHOR         Richard Raustad, FSEC
      91              : //       DATE WRITTEN   Oct/Nov 2004
      92              : //       MODIFIED       Shirey, FSEC Dec 2004; Hudson, ORNL Feb 2007, July 2007
      93              : //       MODIFIED       Stovall, ORNL, April 2008 added detailed refrigeration systems
      94              : //       MODIFIED       Stovall, ORNL, Fall 2009 added cascade condensers, secondary loops, and walk-ins.
      95              : //       MODIFIED       Griffith, NREL, 2010, Plant upgrade, generalize plant fluid properties.
      96              : //       MODIFIED       Fricke, ORNL, Fall 2011, added detailed transcritical CO2 refrigeration system.
      97              : //       RE-ENGINEERED  na
      98              : 
      99              : // PURPOSE OF THIS MODULE:
     100              : // To simulate refrigerated cases,walk-in coolers, secondary loops,
     101              : //             compressor racks, and detailed refrigeration systems.
     102              : // Case performance is varied based on specific operating conditions within the zone.
     103              : 
     104              : // METHODOLOGY EMPLOYED:
     105              : // Refrigerated cases are simulated based on performance information available from manufacturers
     106              : // and knowing the latent heat ratio of the case cooling load which can be obtained from ASHRAE or
     107              : // others who have completed research to quantify this value. The sensible case credits
     108              : // (sensible cooling provided to the surrounding zone air) are calculated during input
     109              : // processing by subtracting the fan, lighting, and anti-sweat heater energy from the
     110              : // design sensible capacity (TotCap * (1-LHR) * RTF).  The actual latent cooling provided
     111              : // by the case (at the actual operating conditions) is calculated based on the latent performance
     112              : // curve supplied by the user.  The actual sensible cooling provided by the case (at the actual
     113              : // operating conditions) is calculated by summing all sensible components (fan + light + anti-sweat +
     114              : // sensible case credit). The case (evaporator) fans are assumed to be disabled during hot-gas or
     115              : // electric defrost modes. A stocking schedule (W/m) is available for added load if desired.
     116              : // Walk-In coolers are simulated based on the specified sum of the conductance*area of each wall and door facing
     117              : // up to three (extensible) zones.  Two types of doors are specified, stock doors and glass doors.  For each category
     118              : // of doors, schedules for door openings are used with ASHRAE models for infiltration
     119              : // which are a function of the height of the door.  That
     120              : // infiltration is used to calculate the latent load on the cooler and the latent case credits for each zone.
     121              : // The sensible case credit for each zone is the sum of the conductive and sensible infiltration load
     122              : // for each surface/door facing that zone.  Note that the latent portion of the infiltration is unused
     123              : // during defrost to be consistent with decision for refrigerated cases.
     124              : // Compressor racks are simulated by summing the attached refrigerated case and walk-in cooler
     125              : // capacities.  The energy use of the
     126              : // compressor rack is then calculated with a simplified model for COP variation with temperature. Condenser fan power
     127              : // is based on a user-supplied curve object. Racks are not scheduled.
     128              : // Compressor racks may have indoor (in-zone) or outdoor condensers.  If outdoors, the condensers may be cooled
     129              : // by dry air cooling or evaporative cooling. A water-cooled condenser is also available by specifying water-cooling
     130              : // as the Condenser Type.  If a water-cooled condenser is utilized, a second entry to this module will
     131              : // occur during the HVAC simulation as called from the NonZoneEquipmentManager.
     132              : // Detailed refrigeration systems model each compressor individually using the manufacturer's rating curves.
     133              : // A collection of such curves has been added in the datasets library. The curves produce the refrigeration
     134              : // capacity and power consumption. The capacity needed is based on the sum of the case and walk-in loads (as is done
     135              : // for the compressor racks).  The compressors are dispatched to meet this load according to the order
     136              : // prescribed in the compressor list input object. The condenser for each system can be air-cooled,
     137              : // evaporative-cooled, or water cooled.  For air and evap-cooled condensers, manufacturer's rating data
     138              : // is input to describe the performance and to determine the required air flow rate, which is used to
     139              : // calculate the fan power requirements.  The fans can be described as single-speed, two-speed, or variable
     140              : // speed. The condenser performance data also is used to calculate the condensing temperature, which is a function
     141              : // of the heat sink temperature and the load on the condenser.  This must be solved iteratively, checking on
     142              : // the calculated refrigerant mass flow through the compressors.  The solution usually requires less than 5 iterations.
     143              : // The refrigerant state exiting the compressor group is known so the amount of heat available for
     144              : // desuperheat reclaim is explicitly known.
     145              : // The detailed refrigeration model allows the use of subcoolers,secondary loops, and cascade condensers
     146              : // to transfer load from one suction group to another. This introduces the need for further iterations among
     147              : // the systems.  Three loops through the
     148              : // systems are adequate to model these interactions.  The detailed model will also calculate a variable suction
     149              : // pressure for systems with controls that allow the suction temperature/pressure to float
     150              : // up when the case loads are less than their design capacity.
     151              : 
     152              : // Secondary Systems include case and walk-in refrigeration loads.  However, the balance of the system is
     153              : // made up of a heat exchanger and circulating pump(s) instead of a condenser and compressors.
     154              : // The total load on the heat exchanger is the sum of the refrigeration loads, any pipe heat gains,
     155              : // and the portion of the pump power that is absorbed by the circulating fluid. If the total load is
     156              : // greater than the rated capacity of the secondary loop, the unmet load for any time step is carried over
     157              : // to the next time step.  Each secondary system appears as a load on a detailed refrigeration system. If
     158              : // any of the cases or walk-ins served by a secondary are defrosted using hot brine, the primary system
     159              : // serving the secondary loop receives the defrost energy credits (i.e., heat reclaim used to generate defrost
     160              : // energy).
     161              : 
     162              : // Cascade Condensers allow the use of a higher temperature refrigeration system (primary system) to serve as a
     163              : // heat rejection sink for a lower temperature refrigeration system (secondary system). The condensing
     164              : // temperature can be fixed or can be allowed to float according to the minimum required evaporating temperature
     165              : // for other loads upon the primary system. For cases and walk-ins served by cascade condensers, energy associated
     166              : // with hot gas defrost is reclaimed from the primary system.  The refrigeration load the cascade condenser
     167              : // places upon the primary system is the sum of all case and walk-in loads served by the secondary system plus
     168              : // the sum of the secondary loop's compressor power. The same name used to identify the condenser in the
     169              : // secondary loop is used to identify the cascade load on the primary system.
     170              : 
     171              : // Detailed transcritical CO2 refrigeration systems model each compressor individually using the manufacturer's
     172              : // performance data. A collection of CO2 compressor performance curves has been added in the datasets library.
     173              : // The curves produce the refrigeration capacity and power consumption. The capacity required is based on the sum
     174              : // of the case and walk-in loads and the compressors are dispatched to meet this load according to the order
     175              : // prescribed in the compressor list input object. Currently, an air-cooled gas cooler is modeled, and
     176              : // manufacturer's rating data is input to describe the performance and to determine the required fan power
     177              : // requirements. The gas cooler fans can be described as single-speed, two-speed, or variable speed. During
     178              : // transcritical operation, the optimal gas cooler pressure, which maximizes the system's COP, is determined as
     179              : // a function of the ambient air temperature. During subcritical operation, the condensing pressure is allowed to
     180              : // float with ambient temperature in order to achieve maximum performance.
     181              : 
     182              : // This module was designed to be accessed once for each time step.  It uses several accumulating variables
     183              : //  to carry unmet loads from one time step to the next (cases/walk-ins and compressors.  Also, it meets
     184              : //  heat reclaim needs with the loads from the previous time step (because they are unknown for the current
     185              : //  zone time step).  However, the loads time step may be repeated, such as when a demand manager is used.
     186              : //  For that purpose, the values for these accumulating variables are saved at the start of each time step
     187              : //  and reset whenever the time step is repeated.  (see the init subroutine.)
     188              : // This correction is also applied when working on the system time step for coil-type loads by setting the saved values
     189              : //  at the start of each system time step to the value at the end of the previous time step. They are reset
     190              : //  to that value at each sys time step iteration. (see InitRefrigeration)
     191              : 
     192              : // REFERENCES:
     193              : // Specific references are provided for the equipment simulation subroutines below.
     194              : 
     195              : // True at the start of each time step, False after first subtime step of time step
     196              : // includes DataGlobals::CurrentTime, in fractional hours, from start of day. Uses Loads time step.
     197              : // includes DataGlobals::NumOfZones
     198              : 
     199              : // Following constant approp for R22, future may make f(refrigerant)
     200              : Real64 constexpr CaseSuperheat(4.0);       // case superheat used to control thermal expansion valve, ASHRAE 2006 p 44.6 (C)
     201              : Real64 constexpr TransCaseSuperheat(10.0); // case superheat for transcritical CO2 systems (C)
     202              : 
     203              : // Next two constants used to autosize evap condenser
     204              : Real64 constexpr CondPumpRatePower(0.004266);  // evap condenser pump rated, Wpump/Wcapacity (15 W/ton)
     205              : Real64 constexpr AirVolRateEvapCond(0.000144); // evap cond air flow rate for autosize, equiv 850 cfm/ton (m3/W-s)
     206              : Real64 constexpr EvapCutOutTdb(4.0);           // shut off evap water flow if outdoor drybulb < evapcutOutTdb (C)
     207              : 
     208              : // Miscellaneous constants
     209              : Real64 constexpr MyLargeNumber(1.0e9);
     210              : Real64 constexpr MySmallNumber(1.0e-9);
     211              : Real64 constexpr Rair(0.3169);                   // Air resistance used with Heat Balance anti-sweat (AS) heater
     212              : Real64 constexpr IceMeltEnthalpy(335000.0);      // heat of fusion of water J/kg
     213              : Real64 constexpr TempTooHotToFrost(5.0);         // C, used to check for frosting conditions on evaporator coils
     214              : Real64 constexpr IcetoVaporEnthalpy(2833000.0);  // J/kg to freeze water vapor to ice
     215              : Real64 constexpr SpecificHeatIce(2000.0);        // in the likely range (2040 at 0C and 1950 at -20C) (J/kg-C)
     216              : Real64 constexpr CondAirVolExponentDry(1.58);    // exponent for forced air over a cylinder, = 1/.633 per ASHRAE 2005 (page 3.15)
     217              : Real64 constexpr CondAirVolExponentEvap(1.32);   // exponent for evap condenser air vol flow, = 1/.76 per Manske, 1999
     218              : Real64 constexpr EvaporatorAirVolExponent(1.54); // exponent for evaporator air vol flow, = 1/.65 per Manske, 1999, page 35
     219              : Real64 constexpr FanHalfSpeedRatio(0.1768);      // = 1/(2**2.5) for power step for two speed fan
     220              : Real64 constexpr CapFac60Percent(0.60);          // = 60%, load served by half power 2-speed fan
     221              : 
     222              : static constexpr std::array<Real64, 5> EuropeanWetCoilFactor = {1.35, 1.15, 1.05, 1.01, 1.0};
     223              : static constexpr std::array<Real64, 5> EuropeanAirInletTemp = {10.0, 0.0, -18.0, -25.0, -34.0};
     224              : 
     225              : constexpr std::array<std::string_view, (int)WIStockDoor::Num> wiStockDoorNames = {"None", "AirCurtain", "StripCurtain"};
     226              : constexpr std::array<std::string_view, (int)WIStockDoor::Num> wiStockDoorNamesUC = {"NONE", "AIRCURTAIN", "STRIPCURTAIN"};
     227              : 
     228              : constexpr std::array<std::string_view, (int)CompressorSuctionPressureCtrl::Num> compressorSuctionPressureCtrlNames = {"FloatSuctionTemperature",
     229              :                                                                                                                       "ConstantSuctionTemperature"};
     230              : constexpr std::array<std::string_view, (int)CompressorSuctionPressureCtrl::Num> compressorSuctionPressureCtrlNamesUC = {"FLOATSUCTIONTEMPERATURE",
     231              :                                                                                                                         "CONSTANTSUCTIONTEMPERATURE"};
     232              : 
     233              : constexpr std::array<std::string_view, (int)SubcoolerType::Num> subcoolerTypeNames = {"LiquidSuction", "Mechanical"};
     234              : constexpr std::array<std::string_view, (int)SubcoolerType::Num> subcoolerTypeNamesUC = {"LIQUIDSUCTION", "MECHANICAL"};
     235              : 
     236              : constexpr std::array<std::string_view, (int)DefrostCtrlType::Num> defrostCtrlTypeNames = {"TimeSchedule", "TemperatureTermination"};
     237              : constexpr std::array<std::string_view, (int)DefrostCtrlType::Num> defrostCtrlTypeNamesUC = {"TIMESCHEDULE", "TEMPERATURETERMINATION"};
     238              : 
     239              : constexpr std::array<std::string_view, (int)SecFluidType::Num> secFluidTypeNames = {"FluidAlwaysLiquid", "FluidPhaseChange"};
     240              : constexpr std::array<std::string_view, (int)SecFluidType::Num> secFluidTypeNamesUC = {"FLUIDALWAYSLIQUID", "FLUIDPHASECHANGE"};
     241              : 
     242              : constexpr std::array<std::string_view, (int)SecPumpCtrl::Num> secPumpCtrlNames = {"Constant", "Variable"};
     243              : constexpr std::array<std::string_view, (int)SecPumpCtrl::Num> secPumpCtrlNamesUC = {"CONSTANT", "VARIABLE"};
     244              : 
     245              : constexpr std::array<std::string_view, (int)EnergyEqnForm::Num> energyEqnFormNames = {
     246              :     "None", "CaseTemperatureMethod", "RelativeHumidityMethod", "DewpointMethod"};
     247              : constexpr std::array<std::string_view, (int)EnergyEqnForm::Num> energyEqnFormNamesUC = {
     248              :     "NONE", "CASETEMPERATUREMETHOD", "RELATIVEHUMIDITYMETHOD", "DEWPOINTMETHOD"};
     249              : 
     250              : constexpr std::array<std::string_view, (int)CascadeCndsrTempCtrlType::Num> cascaseCndsrTempCtrlTypeNames = {"Fixed", "Float"};
     251              : constexpr std::array<std::string_view, (int)CascadeCndsrTempCtrlType::Num> cascaseCndsrTempCtrlTypeNamesUC = {"FIXED", "FLOAT"};
     252              : 
     253              : constexpr std::array<std::string_view, (int)CndsrFlowType::Num> cndsrFlowTypeNames = {"VariableFlow", "ConstantFlow"};
     254              : constexpr std::array<std::string_view, (int)CndsrFlowType::Num> cndsrFlowTypeNamesUC = {"VARIABLEFLOW", "CONSTANTFLOW"};
     255              : 
     256              : constexpr std::array<std::string_view, (int)FanSpeedCtrlType::Num> fanSpeedCtrlTypeNames = {"VariableSpeed", "FixedLinear", "TwoSpeed", "Fixed"};
     257              : constexpr std::array<std::string_view, (int)FanSpeedCtrlType::Num> fanSpeedCtrlTypeNamesUC = {"VARIABLESPEED", "FIXEDLINEAR", "TWOSPEED", "FIXED"};
     258              : 
     259              : constexpr std::array<std::string_view, (int)FanSpeedCtrlType::Num> heatRejLocationNames = {"Outdoors", "Zone"};
     260              : constexpr std::array<std::string_view, (int)FanSpeedCtrlType::Num> heatRejLocationNamesUC = {"OUTDOORS", "ZONE"};
     261              : 
     262              : constexpr std::array<std::string_view, (int)RefCaseDefrostType::Num> refCaseDefrostTypeNames = {
     263              :     "None", "OffCycle", "HotFluid", "HotFluidWithTemperatureTermination", "Electric", "ElectricOnDemand", "ElectricWithTemperatureTermination"};
     264              : constexpr std::array<std::string_view, (int)RefCaseDefrostType::Num> refCaseDefrostTypeNamesUC = {
     265              :     "NONE", "OFFCYCLE", "HOTFLUID", "HOTFLUIDWITHTEMPERATURETERMINATION", "ELECTRIC", "ELECTRICONDEMAND", "ELECTRICWITHTEMPERATURETERMINATION"};
     266              : 
     267              : constexpr std::array<std::string_view, (int)ASHtrCtrlType::Num> asHtrCtrlTypeNames = {
     268              :     "None", "Constant", "Linear", "DewpointMethod", "HeatBalanceMethod"};
     269              : constexpr std::array<std::string_view, (int)ASHtrCtrlType::Num> asHtrCtrlTypeNamesUC = {
     270              :     "NONE", "CONSTANT", "LINEAR", "DEWPOINTMETHOD", "HEATBALANCEMETHOD"};
     271              : 
     272              : constexpr std::array<std::string_view, (int)RatingType::Num> ratingTypeNames = {"CapacityTotalSpecificConditions",
     273              :                                                                                 "EuropeanSC1Standard",
     274              :                                                                                 "EuropeanSC1NominalWet",
     275              :                                                                                 "EuropeanSC2Standard",
     276              :                                                                                 "EuropeanSC2NominalWet",
     277              :                                                                                 "EuropeanSC3Standard",
     278              :                                                                                 "EuropeanSC3NominalWet",
     279              :                                                                                 "EuropeanSC4Standard",
     280              :                                                                                 "EuropeanSC4NominalWet",
     281              :                                                                                 "EuropeanSC5Standard",
     282              :                                                                                 "EuropeanSC5NominalWet",
     283              :                                                                                 "UnitLoadFactorSensibleOnly"};
     284              : constexpr std::array<std::string_view, (int)RatingType::Num> ratingTypeNamesUC = {"CAPACITYTOTALSPECIFICCONDITIONS",
     285              :                                                                                   "EUROPEANSC1STANDARD",
     286              :                                                                                   "EUROPEANSC1NOMINALWET",
     287              :                                                                                   "EUROPEANSC2STANDARD",
     288              :                                                                                   "EUROPEANSC2NOMINALWET",
     289              :                                                                                   "EUROPEANSC3STANDARD",
     290              :                                                                                   "EUROPEANSC3NOMINALWET",
     291              :                                                                                   "EUROPEANSC4STANDARD",
     292              :                                                                                   "EUROPEANSC4NOMINALWET",
     293              :                                                                                   "EUROPEANSC5STANDARD",
     294              :                                                                                   "EUROPEANSC5NOMINALWET",
     295              :                                                                                   "UNITLOADFACTORSENSIBLEONLY"};
     296              : 
     297              : constexpr std::array<std::string_view, (int)SHRCorrectionType::Num> shrCorrectionTypeNames = {
     298              :     "LinearSHR60", "QuadraticSHR", "European", "TabularRHxDT1xTRoom"};
     299              : constexpr std::array<std::string_view, (int)SHRCorrectionType::Num> shrCorrectionTypeNamesUC = {
     300              :     "LINEARSHR60", "QUADRATICSHR", "EUROPEAN", "TABULARRHXDT1XTROOM"};
     301              : 
     302              : constexpr std::array<std::string_view, (int)VerticalLoc::Num> verticalLocNames = {"Ceiling", "Middle", "Floor"};
     303              : constexpr std::array<std::string_view, (int)VerticalLoc::Num> verticalLocNamesUC = {"CEILING", "MIDDLE", "FLOOR"};
     304              : 
     305              : constexpr std::array<std::string_view, (int)DefrostType::Num> defrostTypeNames = {"HotFluid", "Electric", "None", "OffCycle"};
     306              : constexpr std::array<std::string_view, (int)DefrostType::Num> defrostTypeNamesUC = {"HOTFLUID", "ELECTRIC", "NONE", "OFFCYCLE"};
     307              : 
     308              : constexpr std::array<std::string_view, (int)CriticalType::Num> criticalTypeNames = {"Subcritical", "Transcritical"};
     309              : constexpr std::array<std::string_view, (int)CriticalType::Num> criticalTypeNamesUC = {"SUBCRITICAL", "TRANSCRITICAL"};
     310              : 
     311              : constexpr std::array<std::string_view, (int)IntercoolerType::Num> intercoolerTypeNames = {"None", "Flash Intercooler", "Shell-and-Coil Intercooler"};
     312              : constexpr std::array<std::string_view, (int)IntercoolerType::Num> intercoolerTypeNamesUC = {
     313              :     "NONE", "FLASH INTERCOOLER", "SHELL-AND-COIL INTERCOOLER"};
     314              : 
     315              : constexpr std::array<std::string_view, (int)IntercoolerType::Num> transSysTypeNames = {"SingleStage", "TwoStage"};
     316              : constexpr std::array<std::string_view, (int)IntercoolerType::Num> transSysTypeNamesUC = {"SINGLESTAGE", "TWOSTAGE"};
     317              : 
     318      3184668 : void ManageRefrigeratedCaseRacks(EnergyPlusData &state)
     319              : {
     320              : 
     321              :     // SUBROUTINE INFORMATION:
     322              :     //       AUTHOR         Richard Raustad, FSEC
     323              :     //       DATE WRITTEN   Oct/Nov 2004
     324              :     //       MODIFIED       Shirey, FSEC Dec 2004, Stovall, ORNL, May 2008
     325              :     //       RE-ENGINEERED  na
     326              : 
     327              :     // PURPOSE OF THIS SUBROUTINE:
     328              :     // This subroutine is called from HVACManager.cc, subroutine ManageHVAC to
     329              :     // manage refrigerated cases and associated compressor racks on zone time step
     330              :     // OR from SimAirChillerSet in this module on sys time step (Stovall 2011)
     331              : 
     332              :     // METHODOLOGY EMPLOYED:
     333              :     // Each compressor rack is modeled by first simulating the attached refrigeration loads. The
     334              :     // loads can include refrigerated cases, walk-in coolers, and secondary fluid chillers.  The sum
     335              :     // of the total heat transfer for all attached loads determines the load on the compressor rack.
     336              :     // For the refrigeration rack approach, a simple model for variation of COP with
     337              :     // condensing temperature is used to determine rack power and energy consumption.
     338              :     // For the detailed system approach, the compressors and condensers are modeled individually
     339              :     // using manufacturer's data and rated performance curves.
     340              :     // Inter-system heat transfer via subcoolers and cascade condensers can be accommodated.
     341              :     // Secondary refrigeration cycles are also available.
     342              : 
     343      3184668 :     auto &RefrigRack = state.dataRefrigCase->RefrigRack;
     344              : 
     345      3184668 :     if (!state.dataRefrigCase->ManageRefrigeration) {
     346      2716169 :         return;
     347              :     }
     348              : 
     349       468499 :     CheckRefrigerationInput(state);
     350              : 
     351       468499 :     InitRefrigeration(state);
     352              : 
     353              :     // ManageRefrigeratedCaseRacks is called on each zone time step.
     354              :     //  However, if have chillers, ManageRefrigeration will be .TRUE. and will
     355              :     //  need to bounce back. (InitRefrig has to be called anyway to zero values at zone time step.)
     356              :     //  Therefore...
     357       468499 :     if ((!state.dataRefrigCase->HaveCasesOrWalkins) && (!state.dataRefrigCase->UseSysTimeStep)) {
     358              :         // Zero requests for cooling water from plant or tank
     359         2891 :         ZeroHVACValues(state);
     360         2891 :         return;
     361              :     }
     362              :     // Following case should never occur, but just for completeness:
     363       465608 :     if ((!state.dataRefrigCase->HaveChillers) && (state.dataRefrigCase->UseSysTimeStep)) {
     364            0 :         return;
     365              :     }
     366              : 
     367              :     // Refrigerated cases are not simulated the first time through, replicate this on beginning of next environment
     368       465608 :     if (state.dataGlobal->BeginEnvrnFlag && state.dataRefrigCase->MyEnvrnFlag) {
     369          321 :         state.dataRefrigCase->MyEnvrnFlag = false;
     370          321 :         return;
     371              :     }
     372       465287 :     if (!state.dataGlobal->BeginEnvrnFlag) {
     373       464512 :         state.dataRefrigCase->MyEnvrnFlag = true;
     374              :     }
     375              : 
     376       465287 :     if (state.dataRefrigCase->HaveRefrigRacks) {
     377       256304 :         for (int RackNum = 1; RackNum <= state.dataRefrigCase->NumRefrigeratedRacks; ++RackNum) {
     378       170642 :             RefrigRack(RackNum).CalcRackSystem(state);
     379       170642 :             RefrigRack(RackNum).ReportRackSystem(state, RackNum);
     380              :         }
     381              :     }
     382              : 
     383       465287 :     if (state.dataRefrigCase->HaveDetailedRefrig) {
     384       395801 :         SimulateDetailedRefrigerationSystems(state);
     385              :     }
     386       465287 :     if (state.dataRefrigCase->HaveDetailedTransRefrig) {
     387         2022 :         SimulateDetailedTransRefrigSystems(state);
     388              :     }
     389              : }
     390              : 
     391          801 : void GetRefrigerationInput(EnergyPlusData &state)
     392              : {
     393              : 
     394              :     // SUBROUTINE INFORMATION:
     395              :     //       AUTHOR         Richard Raustad, FSEC
     396              :     //       DATE WRITTEN   Oct/Nov 2004
     397              :     //       MODIFIED       Shirey, FSEC Dec 2004; Hudson, ORNL Feb 2007, July 2007
     398              :     //       MODIFIED       Stovall, ORNL April 2008, Assisted by Hugh Henderson
     399              :     //       RE-ENGINEERED  na
     400              : 
     401              :     // PURPOSE OF THIS SUBROUTINE:
     402              :     // GetObjectItem is called to read refrigerated case, rack, compressor, and condenser information
     403              :     // Lists of cases and compressors are then correlated to the appropriate system.
     404              :     // The nominal ratings of all components are then compared and a warning is printed if the system is not balanced
     405              : 
     406              :     // METHODOLOGY EMPLOYED:
     407              :     // GetObjectItem is called to read refrigerated case information
     408              : 
     409              :     static constexpr std::string_view TrackMessage("from refrigerated case");
     410              :     static constexpr std::string_view RoutineName("GetRefrigerationInput: ");
     411              :     static constexpr std::string_view routineName = "GetRefrigerationInput";
     412              :     static constexpr std::string_view TrackMessageAlt("GetInput in RefrigeratedCase");
     413              : 
     414              :     //     input in both watts and flow rate
     415          801 :     int constexpr NumWIAlphaFieldsBeforeZoneInput(9);   // Used to cycle through zones on input for walk in coolers
     416          801 :     int constexpr NumWIAlphaFieldsPerZone(4);           // Used to cycle through zones on input for walk in coolers
     417          801 :     int constexpr NumWINumberFieldsBeforeZoneInput(12); // Used to cycle through zones on input for walk in coolers
     418          801 :     int constexpr NumWINumberFieldsPerZone(8);          // Used to cycle through zones on input for walk in coolers
     419          801 :     Real64 constexpr CondARI460DelT(16.7);              // Rated sat cond temp - dry bulb air T for air-cooled Condensers, ARI460
     420          801 :     Real64 constexpr CondARI460Tcond(51.7);             // Rated sat cond temp for air-cooled cond, ARI 460
     421          801 :     Real64 constexpr CondARI490DelT(15.0);              // Rated sat cond temp - wet bulb air T for evap-cooled Cond w R22, ARI490
     422          801 :     Real64 constexpr CondARI490Tcond(40.6);             // Rated sat cond temp for evap-cooled cond with R22, ARI 490
     423          801 :     Real64 constexpr DelEvapTDefault(5.0);              // default difference between case T and evap T (C)
     424          801 :     Real64 constexpr DefaultCascadeCondApproach(3.0);   // Cascade condenser approach temperature difference (deltaC)
     425          801 :     Real64 constexpr DefaultCircRate(2.5);              // Phase change liquid overfeed circulating rate (ASHRAE definition)
     426          801 :     Real64 constexpr DefaultWISurfaceUValue(0.3154);    // equiv R18 in Archaic American units (W/m2-delta T)
     427          801 :     Real64 constexpr DefaultWIUValueGlassDr(1.136);     // equiv R5 in Archaic American units (W/m2-delta T)
     428          801 :     Real64 constexpr DefaultWIUValueStockDr(0.3785);    // equiv R15 in Archaic American units (W/m2-delta T)
     429          801 :     Real64 constexpr DefaultWIHeightGlassDr(1.5);       // glass door height in walk-in cooler (m)
     430          801 :     Real64 constexpr DefaultWIHeightStockDr(3.0);       // stock door height in walk-in cooler (m)
     431          801 :     Real64 constexpr PumpImpellerEfficiency(0.78);      // same as used in pump auto-sizing, dimensionless
     432          801 :     Real64 constexpr PumpMotorEfficiency(0.85);         // suggested as average value in ITT/Gould pump references,
     433              : 
     434          801 :     Array1D_string Alphas;             // Alpha items for object
     435          801 :     Array1D_string cAlphaFieldNames;   // Alpha field names (from input processor)
     436          801 :     Array1D_string cNumericFieldNames; // Numeric field names (from input processor)
     437          801 :     std::string CurrentModuleObject;   // Object type for getting and error messages
     438              : 
     439          801 :     Array1D_bool lAlphaBlanks;   // Logic array, alpha input blank = .TRUE.
     440          801 :     Array1D_bool lNumericBlanks; // Logic array, numeric input blank = .TRUE.
     441          801 :     bool ErrorsFound(false);     // Set to true if errors in input, fatal at end of routine
     442              : 
     443          801 :     int AlphaNum(0);                       // Used to cycle through input
     444          801 :     int IOStatus(0);                       // Used in GetObjectItem
     445          801 :     int MaxNumAlphasRack(0);               // Maximum number of alphas for rack object
     446          801 :     int MaxNumAlphasAirChiller(0);         // Maximum number of alphas for air chiller
     447          801 :     int MaxNumAlphasAll(0);                // Maximum number of alphas for all objects
     448          801 :     int MaxNumAlphasSys(0);                // Maximum number of alphas for system object
     449          801 :     int MaxNumAlphasTransSys(0);           // Maximum number of alphas for transcritical system object
     450          801 :     int MaxNumAlphasChillerSet(0);         // Maximum number of alphas for chiller set
     451          801 :     int MaxNumAlphasConda(0);              // Maximum number of alphas for air-cooled condenser object
     452          801 :     int MaxNumAlphasConde(0);              // Maximum number of alphas for evap-cooled condenser object
     453          801 :     int MaxNumAlphasCondw(0);              // Maximum number of alphas for water-cooled condenser object
     454          801 :     int MaxNumAlphasGasCoolera(0);         // Maximum number of alphas for air-cooled gas cooler object
     455          801 :     int MaxNumAlphasComp(0);               // Maximum number of alphas for compressor object
     456          801 :     int MaxNumAlphasCompressorList(0);     // Maximum number of alphas for compressor list objects
     457          801 :     int MaxNumAlphasCase(0);               // Maximum number of alphas for case object
     458          801 :     int MaxNumAlphasCaseAndWalkInList(0);  // Maximum number of alphas in CaseAndWalkInList
     459          801 :     int MaxNumAlphasWalkIn(0);             // Maximum number of alphas for walkin object
     460          801 :     int MaxNumAlphasSecond(0);             // Maximum number of alphas for air chiller object
     461          801 :     int MaxNumNumbersAirChiller(0);        // Maximum number of numbers for air chiller object
     462          801 :     int MaxNumNumbersSecond(0);            // Maximum number of numbers for secondary system object
     463          801 :     int MaxNumNumbersWalkIn(0);            // Maximum number of numbers for walkin object
     464          801 :     int MaxNumNumbersCase(0);              // Maximum number of numbers for case object
     465          801 :     int MaxNumNumbersCaseAndWalkInList(0); // Maximum number of numbers in CaseAndWalkInList
     466          801 :     int MaxNumNumbersRack(0);              // Maximum number of numbers for rack object
     467          801 :     int MaxNumNumbersAll(0);               // Maximum number of numeric inputs for all objects
     468          801 :     int MaxNumNumbersSys(0);               // Maximum number of numbers for system object
     469          801 :     int MaxNumNumbersTransSys(0);          // Maximum number of numbers for transcritical system object
     470          801 :     int MaxNumNumbersChillerSet(0);        // Maximum number of numbers for chiller set object
     471          801 :     int MaxNumNumbersConda(0);             // Maximum number of numbers for air-cooled condenser object
     472          801 :     int MaxNumNumbersConde(0);             // Maximum number of numbers for evap-cooled condenser object
     473          801 :     int MaxNumNumbersCondw(0);             // Maximum number of numbers for water-cooled condenser object
     474          801 :     int MaxNumNumbersGasCoolera(0);        // Maximum number of numbers for air-cooled gas cooler object
     475          801 :     int MaxNumNumbersComp(0);              // Maximum number of numbers for compressor object
     476          801 :     int MaxNumNumbersCompressorList(0);    // Maximum number of numbers
     477          801 :     int MaxNumArgs(0);                     // Max number of alphas and numbers (arguments) for rack object
     478          801 :     int NumAlphas(0);                      // Number of Alphas for each GetObjectItem call
     479          801 :     int NumCases(0);                       // Number of refrigerated cases for single system
     480          801 :     int NumNum(0);                         // Used to cycle through input
     481          801 :     int NumNumbers(0);                     // Number of Numbers for each GetObjectItem call
     482          801 :     int NumDisplayCases(0);                // Counter for refrigerated cases in GetInput do loop
     483          801 :     int NumWalkIns(0);                     // Number of walk ins
     484          801 :     int RefrigSysNum(0);
     485          801 :     int RefrigIndex(0);                // Index used in fluid property routines
     486          801 :     Real64 DeltaHPhaseChange(0.0);     // Secondary loop enthalpy change in condenser w overfeed system (J/g)
     487          801 :     Real64 DelTempMin(0.0);            // min temperature for heat rej curve for air cooled condenser (C)
     488          801 :     Real64 DelTempMax(0.0);            // max temperature for heat rej curve for air cooled condenser (C)
     489          801 :     Real64 DensityBrineRated(0.0);     // density of circ fluid in secondary loop
     490          801 :     Real64 DensityPhaseChange(0.0);    // Secondary loop density at condensing temperature w overfeed system (g/m3)
     491          801 :     Real64 NominalTotalCompCapLP(0.0); // Total of nominal low pressure compressor capacities, used for rough input check (W) (Transcritical CO2)
     492          801 :     Real64 NominalTotalCompCapHP(0.0);
     493          801 :     Array1D<Real64> Numbers;   // Numeric items for object
     494          801 :     Array2D<Real64> DayValues; // Array of schedule values
     495              : 
     496          801 :     auto &RefrigCase = state.dataRefrigCase->RefrigCase;
     497          801 :     auto &RefrigRack = state.dataRefrigCase->RefrigRack;
     498          801 :     auto &CaseRAFraction = state.dataRefrigCase->CaseRAFraction;
     499          801 :     auto &System = state.dataRefrigCase->System;
     500          801 :     auto &TransSystem = state.dataRefrigCase->TransSystem;
     501          801 :     auto &Condenser = state.dataRefrigCase->Condenser;
     502          801 :     auto &Compressor = state.dataRefrigCase->Compressor;
     503          801 :     auto &GasCooler = state.dataRefrigCase->GasCooler;
     504          801 :     auto &Subcooler = state.dataRefrigCase->Subcooler;
     505          801 :     auto &CaseAndWalkInList = state.dataRefrigCase->CaseAndWalkInList;
     506          801 :     auto &CompressorLists = state.dataRefrigCase->CompressorLists;
     507          801 :     auto &Secondary = state.dataRefrigCase->Secondary;
     508          801 :     auto &TransferLoadList = state.dataRefrigCase->TransferLoadList;
     509          801 :     auto &WalkIn = state.dataRefrigCase->WalkIn;
     510          801 :     auto &WarehouseCoil = state.dataRefrigCase->WarehouseCoil;
     511          801 :     auto &AirChillerSet = state.dataRefrigCase->AirChillerSet;
     512          801 :     auto &CoilSysCredit = state.dataRefrigCase->CoilSysCredit;
     513          801 :     auto &CaseWIZoneReport = state.dataRefrigCase->CaseWIZoneReport;
     514              : 
     515         1602 :     state.dataRefrigCase->NumSimulationCascadeCondensers =
     516          801 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:Condenser:Cascade");
     517          801 :     state.dataRefrigCase->NumSimulationCases = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:Case");
     518         1602 :     state.dataRefrigCase->NumSimulationCaseAndWalkInLists =
     519          801 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:CaseAndWalkInList");
     520          801 :     state.dataRefrigCase->NumRefrigeratedRacks = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:CompressorRack");
     521         1602 :     state.dataRefrigCase->NumSimulationSecondarySystems =
     522          801 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:SecondarySystem");
     523         1602 :     state.dataRefrigCase->NumSimulationTransferLoadLists =
     524          801 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:TransferLoadList");
     525          801 :     state.dataRefrigCase->NumSimulationWalkIns = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:WalkIn");
     526          801 :     state.dataRefrigCase->NumRefrigSystems = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:System");
     527         1602 :     state.dataRefrigCase->NumTransRefrigSystems =
     528          801 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:TranscriticalSystem");
     529         1602 :     state.dataRefrigCase->NumSimulationCondAir =
     530          801 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:Condenser:AirCooled");
     531         1602 :     state.dataRefrigCase->NumSimulationCondEvap =
     532          801 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:Condenser:EvaporativeCooled");
     533         1602 :     state.dataRefrigCase->NumSimulationCondWater =
     534          801 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:Condenser:WaterCooled");
     535         1602 :     state.dataRefrigCase->NumSimulationGasCooler =
     536          801 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:GasCooler:AirCooled");
     537          801 :     state.dataRefrigCase->NumRefrigCondensers = state.dataRefrigCase->NumSimulationCondAir + state.dataRefrigCase->NumSimulationCondEvap +
     538          801 :                                                 state.dataRefrigCase->NumSimulationCondWater + state.dataRefrigCase->NumSimulationCascadeCondensers;
     539          801 :     state.dataRefrigCase->NumSimulationCompressors = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:Compressor");
     540          801 :     state.dataRefrigCase->NumSimulationSubcoolers = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:Subcooler");
     541          801 :     int NumCompressorLists = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:CompressorList");
     542         1602 :     state.dataRefrigCase->NumRefrigChillerSets =
     543          801 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "ZoneHVAC:RefrigerationChillerSet");
     544         1602 :     state.dataRefrigCase->NumSimulationRefrigAirChillers =
     545          801 :         state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Refrigeration:AirChiller");
     546              : 
     547              :     // Set flags used later to avoid unnecessary steps.
     548          801 :     if (state.dataRefrigCase->NumRefrigeratedRacks == 0) {
     549          770 :         state.dataRefrigCase->HaveRefrigRacks = false;
     550              :     }
     551          801 :     if (state.dataRefrigCase->NumRefrigSystems == 0) {
     552          786 :         state.dataRefrigCase->HaveDetailedRefrig = false;
     553              :     }
     554          801 :     if (state.dataRefrigCase->NumTransRefrigSystems == 0) {
     555          800 :         state.dataRefrigCase->HaveDetailedTransRefrig = false;
     556              :     }
     557          801 :     if (state.dataRefrigCase->NumSimulationCases == 0 && state.dataRefrigCase->NumSimulationWalkIns == 0) {
     558          764 :         state.dataRefrigCase->HaveCasesOrWalkins = false;
     559              :     }
     560          801 :     if (state.dataRefrigCase->NumSimulationRefrigAirChillers == 0) {
     561          800 :         state.dataRefrigCase->HaveChillers = false;
     562              :     }
     563              : 
     564          801 :     if (state.dataRefrigCase->NumRefrigeratedRacks > 0) {
     565           31 :         RefrigRack.allocate(state.dataRefrigCase->NumRefrigeratedRacks);
     566           31 :         state.dataHeatBal->HeatReclaimRefrigeratedRack.allocate(state.dataRefrigCase->NumRefrigeratedRacks);
     567              :     }
     568          801 :     if (state.dataRefrigCase->NumRefrigSystems > 0) {
     569           15 :         System.allocate(state.dataRefrigCase->NumRefrigSystems);
     570           15 :         state.dataRefrigCase->ShowUnmetEnergyWarning.allocate(state.dataRefrigCase->NumRefrigSystems);
     571           15 :         state.dataRefrigCase->ShowHiStageUnmetEnergyWarning.allocate(state.dataRefrigCase->NumRefrigSystems);
     572           15 :         state.dataRefrigCase->ShowUnmetEnergyWarning = true;
     573           15 :         state.dataRefrigCase->ShowHiStageUnmetEnergyWarning = true;
     574              :     }
     575          801 :     if (state.dataRefrigCase->NumTransRefrigSystems > 0) {
     576            1 :         TransSystem.allocate(state.dataRefrigCase->NumTransRefrigSystems);
     577            1 :         state.dataRefrigCase->ShowUnmetEnergyWarningTrans.dimension(state.dataRefrigCase->NumTransRefrigSystems, true);
     578              :     }
     579          801 :     if (state.dataRefrigCase->NumRefrigChillerSets > 0) {
     580            1 :         AirChillerSet.allocate(state.dataRefrigCase->NumRefrigChillerSets);
     581              :     }
     582          801 :     if (state.dataRefrigCase->NumRefrigCondensers > 0) {
     583           15 :         state.dataHeatBal->HeatReclaimRefrigCondenser.allocate(state.dataRefrigCase->NumRefrigCondensers);
     584           15 :         Condenser.allocate(state.dataRefrigCase->NumRefrigCondensers);
     585           15 :         state.dataRefrigCase->UniqueCondenserNames.reserve(static_cast<unsigned>(state.dataRefrigCase->NumRefrigCondensers));
     586              :     }
     587          801 :     if (state.dataRefrigCase->NumSimulationGasCooler > 0) {
     588            1 :         GasCooler.allocate(state.dataRefrigCase->NumSimulationGasCooler);
     589              :     }
     590          801 :     if (state.dataRefrigCase->NumSimulationCases > 0) {
     591           37 :         CaseRAFraction.allocate(state.dataGlobal->NumOfZones);
     592           37 :         RefrigCase.allocate(state.dataRefrigCase->NumSimulationCases);
     593              :     }
     594          801 :     if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
     595           14 :         WalkIn.allocate(state.dataRefrigCase->NumSimulationWalkIns);
     596              :     }
     597          801 :     if ((state.dataRefrigCase->NumSimulationWalkIns > 0) || (state.dataRefrigCase->NumSimulationCases > 0)) {
     598           37 :         CaseWIZoneReport.allocate(state.dataGlobal->NumOfZones);
     599              :     } else {
     600          764 :         state.dataRefrigCase->UseSysTimeStep = true;
     601              :         // needed to avoid accessing unallocated caseWIZoneReport on early call to SumZones
     602              :     }
     603          801 :     if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
     604            1 :         Secondary.allocate(state.dataRefrigCase->NumSimulationSecondarySystems);
     605            1 :         state.dataRefrigCase->ShowUnmetSecondEnergyWarning.dimension(state.dataRefrigCase->NumSimulationSecondarySystems, true);
     606              :     }
     607          801 :     if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0) {
     608            1 :         WarehouseCoil.allocate(state.dataRefrigCase->NumSimulationRefrigAirChillers);
     609            1 :         CoilSysCredit.allocate(state.dataGlobal->NumOfZones);
     610              :     }
     611          801 :     if (state.dataRefrigCase->NumSimulationCompressors > 0) {
     612           16 :         Compressor.allocate(state.dataRefrigCase->NumSimulationCompressors);
     613              :     }
     614          801 :     if (state.dataRefrigCase->NumSimulationSubcoolers > 0) {
     615            1 :         Subcooler.allocate(state.dataRefrigCase->NumSimulationSubcoolers);
     616              :     }
     617          801 :     if (state.dataRefrigCase->NumSimulationCaseAndWalkInLists > 0) {
     618           28 :         CaseAndWalkInList.allocate(state.dataRefrigCase->NumSimulationCaseAndWalkInLists);
     619              :     }
     620          801 :     if (NumCompressorLists > 0) {
     621           16 :         CompressorLists.allocate(NumCompressorLists);
     622              :     }
     623          801 :     if (state.dataRefrigCase->NumSimulationTransferLoadLists > 0) {
     624            1 :         TransferLoadList.allocate(state.dataRefrigCase->NumSimulationTransferLoadLists);
     625              :     }
     626              : 
     627          801 :     DayValues.allocate(state.dataGlobal->TimeStepsInHour, Constant::iHoursInDay);
     628          801 :     state.dataRefrigCase->RefrigPresentInZone.dimension(state.dataGlobal->NumOfZones, false);
     629              : 
     630          801 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, "Refrigeration:Case", MaxNumArgs, MaxNumAlphasCase, MaxNumNumbersCase);
     631          801 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     632              :         state, "Refrigeration:CaseAndWalkInList", MaxNumArgs, MaxNumAlphasCaseAndWalkInList, MaxNumNumbersCaseAndWalkInList);
     633          801 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     634              :         state, "Refrigeration:CompressorRack", MaxNumArgs, MaxNumAlphasRack, MaxNumNumbersRack);
     635          801 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, "Refrigeration:System", MaxNumArgs, MaxNumAlphasSys, MaxNumNumbersSys);
     636          801 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     637              :         state, "Refrigeration:TranscriticalSystem", MaxNumArgs, MaxNumAlphasTransSys, MaxNumNumbersTransSys);
     638          801 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     639              :         state, "Refrigeration:Condenser:AirCooled", MaxNumArgs, MaxNumAlphasConda, MaxNumNumbersConda);
     640          801 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     641              :         state, "Refrigeration:Condenser:EvaporativeCooled", MaxNumArgs, MaxNumAlphasConde, MaxNumNumbersConde);
     642          801 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     643              :         state, "Refrigeration:Condenser:WaterCooled", MaxNumArgs, MaxNumAlphasCondw, MaxNumNumbersCondw);
     644          801 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     645              :         state, "Refrigeration:GasCooler:AirCooled", MaxNumArgs, MaxNumAlphasGasCoolera, MaxNumNumbersGasCoolera);
     646          801 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     647              :         state, "Refrigeration:Compressor", MaxNumArgs, MaxNumAlphasComp, MaxNumNumbersComp);
     648          801 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     649              :         state, "Refrigeration:CompressorList", MaxNumArgs, MaxNumAlphasCompressorList, MaxNumNumbersCompressorList);
     650          801 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     651              :         state, "Refrigeration:WalkIn", MaxNumArgs, MaxNumAlphasWalkIn, MaxNumNumbersWalkIn);
     652          801 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     653              :         state, "Refrigeration:SecondarySystem", MaxNumArgs, MaxNumAlphasSecond, MaxNumNumbersSecond);
     654          801 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     655              :         state, "ZoneHVAC:RefrigerationChillerSet", MaxNumArgs, MaxNumAlphasChillerSet, MaxNumNumbersChillerSet);
     656          801 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(
     657              :         state, "Refrigeration:AirChiller", MaxNumArgs, MaxNumAlphasAirChiller, MaxNumNumbersAirChiller);
     658              : 
     659          801 :     MaxNumAlphasAll = max(MaxNumAlphasCase,
     660              :                           MaxNumAlphasCaseAndWalkInList,
     661              :                           MaxNumAlphasRack,
     662              :                           MaxNumAlphasSys,
     663              :                           MaxNumAlphasTransSys,
     664              :                           MaxNumAlphasConda,
     665              :                           MaxNumAlphasConde,
     666              :                           MaxNumAlphasCondw,
     667              :                           MaxNumAlphasGasCoolera,
     668              :                           MaxNumAlphasComp,
     669              :                           MaxNumAlphasCompressorList,
     670              :                           MaxNumAlphasSecond,
     671              :                           MaxNumAlphasWalkIn,
     672              :                           MaxNumAlphasChillerSet,
     673              :                           MaxNumAlphasAirChiller);
     674          801 :     MaxNumNumbersAll = max(MaxNumNumbersCase,
     675              :                            MaxNumNumbersCaseAndWalkInList,
     676              :                            MaxNumNumbersRack,
     677              :                            MaxNumNumbersSys,
     678              :                            MaxNumNumbersTransSys,
     679              :                            MaxNumNumbersConda,
     680              :                            MaxNumNumbersConde,
     681              :                            MaxNumNumbersCondw,
     682              :                            MaxNumNumbersGasCoolera,
     683              :                            MaxNumNumbersComp,
     684              :                            MaxNumNumbersCompressorList,
     685              :                            MaxNumNumbersSecond,
     686              :                            MaxNumNumbersWalkIn,
     687              :                            MaxNumNumbersChillerSet,
     688              :                            MaxNumNumbersAirChiller);
     689              : 
     690          801 :     Alphas.allocate(MaxNumAlphasAll);
     691          801 :     Numbers.dimension(MaxNumNumbersAll, 0.0);
     692          801 :     cAlphaFieldNames.allocate(MaxNumAlphasAll);
     693          801 :     cNumericFieldNames.allocate(MaxNumNumbersAll);
     694          801 :     lAlphaBlanks.dimension(MaxNumAlphasAll, true);
     695          801 :     lNumericBlanks.dimension(MaxNumNumbersAll, true);
     696              :     // bbb stovall note for future - for all curve entries, see if need fail on type or if can allow table input
     697          801 :     if (state.dataRefrigCase->NumSimulationCases > 0) {
     698           37 :         CurrentModuleObject = "Refrigeration:Case";
     699          227 :         for (int CaseNum = 1; CaseNum <= state.dataRefrigCase->NumSimulationCases; ++CaseNum) {
     700          190 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
     701              :                                                                      CurrentModuleObject,
     702              :                                                                      CaseNum,
     703              :                                                                      Alphas,
     704              :                                                                      NumAlphas,
     705              :                                                                      Numbers,
     706              :                                                                      NumNumbers,
     707              :                                                                      IOStatus,
     708              :                                                                      lNumericBlanks,
     709              :                                                                      lAlphaBlanks,
     710              :                                                                      cAlphaFieldNames,
     711              :                                                                      cNumericFieldNames);
     712              : 
     713          190 :             ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
     714              : 
     715          190 :             ++NumDisplayCases;
     716              : 
     717          190 :             AlphaNum = 1;
     718          190 :             Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
     719          190 :             RefrigCase(CaseNum).Name = Alphas(AlphaNum);
     720              : 
     721          190 :             AlphaNum = 2;
     722          190 :             if (lAlphaBlanks(AlphaNum)) {
     723            0 :                 RefrigCase(CaseNum).availSched = Sched::GetScheduleAlwaysOn(state);
     724          190 :             } else if ((RefrigCase(CaseNum).availSched = Sched::GetSchedule(state, Alphas(AlphaNum))) == nullptr) {
     725            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
     726            0 :                 ErrorsFound = true;
     727          190 :             } else if (!RefrigCase(CaseNum).availSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) {
     728            0 :                 Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum), Clusive::In, 0.0, Clusive::In, 1.0);
     729            0 :                 ErrorsFound = true;
     730              :             }
     731              : 
     732              :             // Get the Zone node number from the zone name entered by the user
     733          190 :             RefrigCase(CaseNum).ZoneName = Alphas(3);
     734          190 :             RefrigCase(CaseNum).ActualZoneNum = Util::FindItemInList(Alphas(3), state.dataHeatBal->Zone);
     735              : 
     736          190 :             if (RefrigCase(CaseNum).ActualZoneNum == 0) {
     737            0 :                 ShowSevereError(state,
     738            0 :                                 format("{}{}=\"{}\", invalid  {} not valid: {}",
     739              :                                        RoutineName,
     740              :                                        CurrentModuleObject,
     741            0 :                                        RefrigCase(CaseNum).Name,
     742              :                                        cAlphaFieldNames(3),
     743              :                                        Alphas(3)));
     744            0 :                 ErrorsFound = true;
     745              :             } else {
     746          190 :                 state.dataRefrigCase->RefrigPresentInZone(RefrigCase(CaseNum).ActualZoneNum) = true;
     747              :             }
     748              : 
     749          190 :             RefrigCase(CaseNum).ZoneNodeNum = DataZoneEquipment::GetSystemNodeNumberForZone(state, RefrigCase(CaseNum).ActualZoneNum);
     750              : 
     751          190 :             RefrigCase(CaseNum).RatedAmbientTemp = Numbers(1);
     752          190 :             if (Numbers(1) <= 0.0) {
     753            0 :                 ShowSevereError(state,
     754            0 :                                 format("{}{}=\"{}\", {} must be greater than 0 C",
     755              :                                        RoutineName,
     756              :                                        CurrentModuleObject,
     757            0 :                                        RefrigCase(CaseNum).Name,
     758              :                                        cNumericFieldNames(1)));
     759            0 :                 ErrorsFound = true;
     760              :             }
     761              : 
     762          190 :             RefrigCase(CaseNum).RatedAmbientRH = Numbers(2);
     763          190 :             if (Numbers(2) <= 0.0 || Numbers(2) >= 100.0) {
     764            0 :                 ShowSevereError(state,
     765            0 :                                 format("{}{}=\"{}\", {} must be greater than 0% and less than 100%",
     766              :                                        RoutineName,
     767              :                                        CurrentModuleObject,
     768            0 :                                        RefrigCase(CaseNum).Name,
     769              :                                        cNumericFieldNames(2)));
     770            0 :                 ErrorsFound = true;
     771              :             }
     772          380 :             RefrigCase(CaseNum).RatedAmbientDewPoint = Psychrometrics::PsyTdpFnWPb(
     773              :                 state,
     774          190 :                 Psychrometrics::PsyWFnTdbRhPb(
     775          190 :                     state, RefrigCase(CaseNum).RatedAmbientTemp, (RefrigCase(CaseNum).RatedAmbientRH / 100.0), state.dataEnvrn->StdBaroPress),
     776          190 :                 state.dataEnvrn->StdBaroPress);
     777              : 
     778          190 :             RefrigCase(CaseNum).RateTotCapPerLength = Numbers(3);
     779          190 :             if (Numbers(3) <= 0.0) {
     780            0 :                 ShowSevereError(state,
     781            0 :                                 format("{}{}=\"{}\", {} must be greater than 0 W/m",
     782              :                                        RoutineName,
     783              :                                        CurrentModuleObject,
     784            0 :                                        RefrigCase(CaseNum).Name,
     785              :                                        cNumericFieldNames(3)));
     786            0 :                 ErrorsFound = true;
     787              :             }
     788              : 
     789          190 :             RefrigCase(CaseNum).RatedLHR = Numbers(4);
     790          190 :             if (Numbers(4) < 0.0 || Numbers(4) > 1.0) {
     791            0 :                 ShowSevereError(
     792              :                     state,
     793            0 :                     format(
     794            0 :                         "{}{}=\"{}\", {} must be >= 0 and <= 1", RoutineName, CurrentModuleObject, RefrigCase(CaseNum).Name, cNumericFieldNames(4)));
     795            0 :                 ErrorsFound = true;
     796              :             }
     797              : 
     798          190 :             RefrigCase(CaseNum).RatedRTF = Numbers(5);
     799          190 :             if (Numbers(5) <= 0.0 || Numbers(5) > 1.0) {
     800            0 :                 ShowSevereError(state,
     801            0 :                                 format("{}{}=\"{}\", {} must be > 0 and <= to 1",
     802              :                                        RoutineName,
     803              :                                        CurrentModuleObject,
     804            0 :                                        RefrigCase(CaseNum).Name,
     805              :                                        cNumericFieldNames(5)));
     806            0 :                 ErrorsFound = true;
     807              :             }
     808              : 
     809          190 :             RefrigCase(CaseNum).Length = Numbers(6);
     810          190 :             if (Numbers(6) <= 0.0) {
     811            0 :                 ShowSevereError(state,
     812            0 :                                 format("{}{}=\"{}\", {} must be greater than 0 m",
     813              :                                        RoutineName,
     814              :                                        CurrentModuleObject,
     815            0 :                                        RefrigCase(CaseNum).Name,
     816              :                                        cNumericFieldNames(6)));
     817            0 :                 ErrorsFound = true;
     818              :             }
     819              : 
     820          190 :             RefrigCase(CaseNum).Temperature = Numbers(7);
     821          190 :             if (RefrigCase(CaseNum).Temperature >= RefrigCase(CaseNum).RatedAmbientTemp) {
     822            0 :                 ShowSevereError(state,
     823            0 :                                 format("{}{}=\"{}\", {} must be below {}",
     824              :                                        RoutineName,
     825              :                                        CurrentModuleObject,
     826            0 :                                        RefrigCase(CaseNum).Name,
     827              :                                        cNumericFieldNames(7),
     828              :                                        cNumericFieldNames(1)));
     829            0 :                 ErrorsFound = true;
     830              :             }
     831              : 
     832          190 :             RefrigCase(CaseNum).LatentEnergyCurveType = static_cast<EnergyEqnForm>(getEnumValue(energyEqnFormNamesUC, Alphas(4)));
     833          190 :             if (RefrigCase(CaseNum).LatentEnergyCurveType == EnergyEqnForm::Invalid) {
     834            0 :                 ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(4), Alphas(4));
     835            0 :                 ErrorsFound = true;
     836              :             }
     837              : 
     838          190 :             RefrigCase(CaseNum).LatCapCurvePtr = Curve::GetCurveIndex(state, Alphas(5)); // convert curve name to number
     839          190 :             if (RefrigCase(CaseNum).LatCapCurvePtr == 0) {
     840            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(5), Alphas(5));
     841            0 :                 ErrorsFound = true;
     842              :             }
     843              : 
     844          570 :             ErrorsFound |= Curve::CheckCurveDims(state,
     845          190 :                                                  RefrigCase(CaseNum).LatCapCurvePtr, // Curve index
     846              :                                                  {1},                                // Valid dimensions
     847              :                                                  RoutineName,                        // Routine name
     848              :                                                  CurrentModuleObject,                // Object Type
     849          190 :                                                  RefrigCase(CaseNum).Name,           // Object Name
     850          190 :                                                  cAlphaFieldNames(5));               // Field Name
     851              : 
     852          190 :             NumNum = 8;
     853          190 :             if (!lNumericBlanks(NumNum)) {
     854          190 :                 RefrigCase(CaseNum).STDFanPower = Numbers(NumNum);
     855          190 :                 if (Numbers(NumNum) < 0.0) {
     856            0 :                     ShowSevereError(state,
     857            0 :                                     format("{}{}=\"{}\", {} must be greater than or equal to 0 W/m",
     858              :                                            RoutineName,
     859              :                                            CurrentModuleObject,
     860            0 :                                            RefrigCase(CaseNum).Name,
     861              :                                            cNumericFieldNames(NumNum)));
     862            0 :                     ErrorsFound = true;
     863              :                 }
     864              :             } else { // blank use default of 75 W/m
     865            0 :                 RefrigCase(CaseNum).STDFanPower = 75.0;
     866              :             } // blank input
     867              : 
     868          190 :             NumNum = 9;
     869          190 :             if (!lNumericBlanks(NumNum)) {
     870          190 :                 RefrigCase(CaseNum).OperatingFanPower = Numbers(NumNum);
     871          190 :                 if (Numbers(NumNum) < 0.0) {
     872            0 :                     ShowSevereError(state,
     873            0 :                                     format("{}{}=\"{}\", {} must be greater than or equal to 0 W/m",
     874              :                                            RoutineName,
     875              :                                            CurrentModuleObject,
     876            0 :                                            RefrigCase(CaseNum).Name,
     877              :                                            cNumericFieldNames(NumNum)));
     878            0 :                     ErrorsFound = true;
     879              :                 }
     880              :             } else { // if blank set = to std fan power
     881            0 :                 RefrigCase(CaseNum).OperatingFanPower = RefrigCase(CaseNum).STDFanPower;
     882              :             } // if blank
     883              : 
     884          190 :             NumNum = 10;
     885          190 :             if (!lNumericBlanks(NumNum)) {
     886          190 :                 RefrigCase(CaseNum).RatedLightingPower = Numbers(NumNum);
     887          190 :                 if (Numbers(NumNum) < 0.0) {
     888            0 :                     ShowSevereError(state,
     889            0 :                                     format("{}{}=\"{}\", {} must be greater than or equal to 0 W/m",
     890              :                                            RoutineName,
     891              :                                            CurrentModuleObject,
     892            0 :                                            RefrigCase(CaseNum).Name,
     893              :                                            cNumericFieldNames(NumNum)));
     894            0 :                     ErrorsFound = true;
     895              :                 }
     896              :             } else { // blank input - use default of 90 W/m
     897            0 :                 RefrigCase(CaseNum).RatedLightingPower = 90.0;
     898              :             } // blank input
     899              : 
     900          190 :             NumNum = 11;
     901          190 :             if (!lNumericBlanks(NumNum)) {
     902           12 :                 RefrigCase(CaseNum).LightingPower = Numbers(NumNum);
     903           12 :                 if (Numbers(NumNum) < 0.0) {
     904            0 :                     ShowSevereError(state,
     905            0 :                                     format("{}{}=\"{}\", {} must be greater than or equal to 0 W/m",
     906              :                                            RoutineName,
     907              :                                            CurrentModuleObject,
     908            0 :                                            RefrigCase(CaseNum).Name,
     909              :                                            cNumericFieldNames(NumNum)));
     910            0 :                     ErrorsFound = true;
     911              :                 }
     912              :             } else { // blank input so set lighting power equal to rated/std lighting power
     913          178 :                 RefrigCase(CaseNum).LightingPower = RefrigCase(CaseNum).RatedLightingPower;
     914              :             } // blank input
     915              : 
     916          190 :             if (lAlphaBlanks(6)) {
     917            0 :                 RefrigCase(CaseNum).lightingSched = Sched::GetScheduleAlwaysOn(state); // Not an availability schedule, but defaults to constant-1.0
     918          190 :             } else if ((RefrigCase(CaseNum).lightingSched = Sched::GetSchedule(state, Alphas(6))) == nullptr) {
     919            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(6), Alphas(6));
     920            0 :                 ErrorsFound = true;
     921          190 :             } else if (!RefrigCase(CaseNum).lightingSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) {
     922            0 :                 Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(6), Alphas(6), Clusive::In, 0.0, Clusive::In, 1.0);
     923            0 :                 ErrorsFound = true;
     924              :             }
     925              : 
     926          190 :             NumNum = 12;
     927          190 :             RefrigCase(CaseNum).LightingFractionToCase = 1.0; // default value
     928          190 :             if (!lNumericBlanks(NumNum)) {
     929          190 :                 RefrigCase(CaseNum).LightingFractionToCase = Numbers(NumNum);
     930              :             } // blank input lighting fraction to case
     931              :             //   check lighting fraction to case input
     932          190 :             if (RefrigCase(CaseNum).LightingFractionToCase < 0.0 || RefrigCase(CaseNum).LightingFractionToCase > 1.0) {
     933            0 :                 ShowSevereError(state,
     934            0 :                                 format("{}{}=\"{}\", {} has a value outside the valid range",
     935              :                                        RoutineName,
     936              :                                        CurrentModuleObject,
     937            0 :                                        RefrigCase(CaseNum).Name,
     938              :                                        cNumericFieldNames(NumNum)));
     939            0 :                 ShowContinueError(state, "  Minimum should be >= 0.0 and Maximum should be <= 1.0");
     940            0 :                 ErrorsFound = true;
     941              :             }
     942              : 
     943          190 :             NumNum = 13;
     944          190 :             RefrigCase(CaseNum).AntiSweatPower = Numbers(NumNum);
     945          190 :             if (Numbers(NumNum) < 0.0) {
     946            0 :                 ShowSevereError(state,
     947            0 :                                 format("{}{}=\"{}\", {} must be greater than or equal to 0 W/m",
     948              :                                        RoutineName,
     949              :                                        CurrentModuleObject,
     950            0 :                                        RefrigCase(CaseNum).Name,
     951              :                                        cNumericFieldNames(NumNum)));
     952            0 :                 ErrorsFound = true;
     953              :             }
     954              : 
     955          190 :             NumNum = 14;
     956          190 :             RefrigCase(CaseNum).MinimumASPower = Numbers(NumNum);
     957          190 :             if (Numbers(NumNum) < 0.0) {
     958            0 :                 ShowSevereError(state,
     959            0 :                                 format("{}{}=\"{}\", {} must be greater than or equal to 0 W/m",
     960              :                                        RoutineName,
     961              :                                        CurrentModuleObject,
     962            0 :                                        RefrigCase(CaseNum).Name,
     963              :                                        cNumericFieldNames(NumNum)));
     964            0 :                 ErrorsFound = true;
     965              :             }
     966              : 
     967          190 :             RefrigCase(CaseNum).AntiSweatControlType = static_cast<ASHtrCtrlType>(getEnumValue(asHtrCtrlTypeNamesUC, Alphas(7)));
     968          190 :             if (RefrigCase(CaseNum).AntiSweatControlType == ASHtrCtrlType::Invalid) {
     969            0 :                 ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(7), Alphas(7));
     970            0 :                 ErrorsFound = true;
     971          190 :             } else if (RefrigCase(CaseNum).AntiSweatControlType == ASHtrCtrlType::None) {
     972          111 :                 RefrigCase(CaseNum).AntiSweatPower = 0.0;
     973              :             }
     974              : 
     975              :             //   Assure that case temperature is below the rated dew point when anti-sweat heater control type is dew point method
     976          190 :             if (RefrigCase(CaseNum).Temperature >= RefrigCase(CaseNum).RatedAmbientDewPoint &&
     977            0 :                 RefrigCase(CaseNum).AntiSweatControlType == ASHtrCtrlType::DewPoint) {
     978            0 :                 ShowSevereError(state,
     979            0 :                                 format("{}{}=\"{}\", {} must be below the Rated Ambient Dew Point when {} is Dew Point Method",
     980              :                                        RoutineName,
     981              :                                        CurrentModuleObject,
     982            0 :                                        RefrigCase(CaseNum).Name,
     983              :                                        cNumericFieldNames(7),
     984              :                                        cAlphaFieldNames(7)));
     985            0 :                 ErrorsFound = true;
     986              :             }
     987              : 
     988          190 :             NumNum = 15;
     989              :             //  negative values for minimum humidity are allowed
     990          190 :             RefrigCase(CaseNum).HumAtZeroAS = Numbers(NumNum);
     991              : 
     992              :             //   check minimum humidity when linear AS control type is used
     993          190 :             if (RefrigCase(CaseNum).HumAtZeroAS >= RefrigCase(CaseNum).RatedAmbientRH &&
     994            0 :                 RefrigCase(CaseNum).AntiSweatControlType == ASHtrCtrlType::Linear) {
     995            0 :                 ShowSevereError(state,
     996            0 :                                 format("{}{}=\"{}\", {} must be less than {}",
     997              :                                        RoutineName,
     998              :                                        CurrentModuleObject,
     999            0 :                                        RefrigCase(CaseNum).Name,
    1000              :                                        cNumericFieldNames(NumNum),
    1001              :                                        cNumericFieldNames(2)));
    1002            0 :                 ShowContinueError(state, format(" for Linear {}.", cAlphaFieldNames(7)));
    1003            0 :                 ErrorsFound = true;
    1004              :             }
    1005              : 
    1006          190 :             NumNum = 16;
    1007          190 :             RefrigCase(CaseNum).Height = Numbers(NumNum);
    1008          190 :             if (Numbers(NumNum) < 0.0) {
    1009            0 :                 ShowSevereError(state,
    1010            0 :                                 format("{}{}=\"{}\", {} must be greater than or equal to 0 m",
    1011              :                                        RoutineName,
    1012              :                                        CurrentModuleObject,
    1013            0 :                                        RefrigCase(CaseNum).Name,
    1014              :                                        cNumericFieldNames(NumNum)));
    1015            0 :                 ErrorsFound = true;
    1016              :             }
    1017              : 
    1018          190 :             if (RefrigCase(CaseNum).Height <= 0.0 && RefrigCase(CaseNum).AntiSweatControlType == ASHtrCtrlType::HeatBalance) {
    1019            0 :                 ShowSevereError(state,
    1020            0 :                                 format("{}{}=\"{}\", {} must be greater than 0 when {} is Heat Balance Method.",
    1021              :                                        RoutineName,
    1022              :                                        CurrentModuleObject,
    1023            0 :                                        RefrigCase(CaseNum).Name,
    1024              :                                        cNumericFieldNames(NumNum),
    1025              :                                        cAlphaFieldNames(7)));
    1026            0 :                 ShowContinueError(state, format("..given {} was: {:.3R}", cNumericFieldNames(NumNum), RefrigCase(CaseNum).Height));
    1027            0 :                 ErrorsFound = true;
    1028              :             }
    1029              : 
    1030              :             //   initialize case resistance for anti-sweat heater control type = Heat Balance Method
    1031          190 :             if (RefrigCase(CaseNum).AntiSweatControlType == ASHtrCtrlType::HeatBalance) {
    1032           41 :                 Real64 Rcase(0.0);      // Case thermal resistance used with anti-sweat heater control
    1033           41 :                 Real64 RcaseDenom(0.0); // Denominator of case thermal resistance calculation for anti-sweat
    1034              : 
    1035           41 :                 if (RefrigCase(CaseNum).Height == 0.0) {
    1036            0 :                     Rcase = 0.0;
    1037              :                 } else {
    1038           41 :                     RcaseDenom = ((RefrigCase(CaseNum).AntiSweatPower / RefrigCase(CaseNum).Height) -
    1039           41 :                                   (RefrigCase(CaseNum).RatedAmbientDewPoint - RefrigCase(CaseNum).RatedAmbientTemp) / Rair);
    1040           41 :                     Rcase = (RefrigCase(CaseNum).RatedAmbientDewPoint - RefrigCase(CaseNum).Temperature) / RcaseDenom;
    1041              :                 }
    1042           41 :                 RefrigCase(CaseNum).Rcase = max(0.0, Rcase);
    1043           41 :                 if (RefrigCase(CaseNum).Rcase == 0.0) {
    1044            0 :                     ShowWarningError(state,
    1045            0 :                                      format("{}=\"{}\" A case thermal resistance of 0 was calculated for anti-sweat heater performance using the",
    1046              :                                             CurrentModuleObject,
    1047            0 :                                             RefrigCase(CaseNum).Name));
    1048            0 :                     ShowContinueError(state,
    1049            0 :                                       format(" Heat Balance Method control type. Anti-sweat heater performance cannot be calculated and {} will be "
    1050              :                                              "set to None and simulation continues.",
    1051              :                                              cAlphaFieldNames(7)));
    1052            0 :                     ShowContinueError(state, " See Engineering Documentation for anti-sweat heater control of refrigerated cases.");
    1053              :                 }
    1054              :             }
    1055              : 
    1056          190 :             NumNum = 17;
    1057          190 :             RefrigCase(CaseNum).ASHeaterFractionToCase = Numbers(NumNum);
    1058          190 :             if (Numbers(NumNum) < 0.0 || Numbers(NumNum) > 1.0) {
    1059            0 :                 ShowSevereError(state,
    1060            0 :                                 format("{}{}=\"{}\", {} must be >= 0 and <= 1",
    1061              :                                        RoutineName,
    1062              :                                        CurrentModuleObject,
    1063            0 :                                        RefrigCase(CaseNum).Name,
    1064              :                                        cNumericFieldNames(NumNum)));
    1065            0 :                 ErrorsFound = true;
    1066              :             }
    1067              : 
    1068              :             // Multiple strings mapping to the same enum is not good
    1069          190 :             if (Alphas(8) == "HOTGAS") {
    1070           18 :                 Alphas(8) = "HOTFLUID";
    1071          172 :             } else if (Alphas(8) == "HOTGASWITHTEMPERATURETERMINATION") {
    1072           40 :                 Alphas(8) = "HOTFLUIDWITHTEMPERATURETERMINATION";
    1073              :             }
    1074              : 
    1075          190 :             RefrigCase(CaseNum).defrostType = static_cast<RefCaseDefrostType>(getEnumValue(refCaseDefrostTypeNamesUC, Alphas(8)));
    1076          190 :             if (RefrigCase(CaseNum).defrostType == RefCaseDefrostType::Invalid) {
    1077            0 :                 ShowWarningInvalidKey(state, eoh, cAlphaFieldNames(8), Alphas(8), "None");
    1078            0 :                 RefrigCase(CaseNum).defrostType = RefCaseDefrostType::None;
    1079              :             }
    1080              : 
    1081          190 :             RefCaseDefrostType DefType = RefrigCase(CaseNum).defrostType;
    1082          190 :             NumNum = 18;
    1083          190 :             if (!lNumericBlanks(NumNum)) {
    1084          190 :                 RefrigCase(CaseNum).DefrostPower = Numbers(NumNum);
    1085          190 :                 if (Numbers(NumNum) < 0.0) {
    1086            0 :                     ShowSevereError(state,
    1087            0 :                                     format("{}{}=\"{}\", {} must be greater than or equal to 0 W/m",
    1088              :                                            RoutineName,
    1089              :                                            CurrentModuleObject,
    1090            0 :                                            RefrigCase(CaseNum).Name,
    1091              :                                            cNumericFieldNames(NumNum)));
    1092            0 :                     ErrorsFound = true;
    1093              :                 }
    1094              :                 //   disregard defrost power for Off-Cycle or None defrost types
    1095          190 :                 if ((DefType == RefCaseDefrostType::OffCycle || DefType == RefCaseDefrostType::None) && (RefrigCase(CaseNum).DefrostPower > 0.0)) {
    1096            0 :                     RefrigCase(CaseNum).DefrostPower = 0.0;
    1097            0 :                     ShowWarningError(state,
    1098            0 :                                      format("{}=\"{}\", {} for {} None or Off-Cycle will be set to 0 and simulation continues.",
    1099              :                                             CurrentModuleObject,
    1100            0 :                                             RefrigCase(CaseNum).Name,
    1101              :                                             cNumericFieldNames(NumNum),
    1102              :                                             cAlphaFieldNames(8)));
    1103              :                 }
    1104              :             } else {
    1105            0 :                 RefrigCase(CaseNum).DefrostPower = 0.0;
    1106              :             }
    1107              : 
    1108              :             // defrost power needed to calculate heat gain to case even if not needed for electric consumption
    1109          172 :             if ((DefType == RefCaseDefrostType::HotFluid || DefType == RefCaseDefrostType::HotFluidTerm || DefType == RefCaseDefrostType::Electric ||
    1110          380 :                  DefType == RefCaseDefrostType::ElectricTerm) &&
    1111          104 :                 RefrigCase(CaseNum).DefrostPower <= 0.0) {
    1112            0 :                 ShowSevereError(state,
    1113            0 :                                 format("{}{}=\"{}\", {} must be greater than 0 W/m for {} {}",
    1114              :                                        RoutineName,
    1115              :                                        CurrentModuleObject,
    1116            0 :                                        RefrigCase(CaseNum).Name,
    1117              :                                        cNumericFieldNames(NumNum),
    1118              :                                        cAlphaFieldNames(8),
    1119              :                                        Alphas(8)));
    1120            0 :                 ErrorsFound = true;
    1121              :             }
    1122              : 
    1123          190 :             if (RefrigCase(CaseNum).defrostType == RefCaseDefrostType::None) {
    1124          155 :             } else if (lAlphaBlanks(9)) {
    1125            0 :                 ShowSevereEmptyField(state, eoh, cAlphaFieldNames(9));
    1126            0 :                 ErrorsFound = true;
    1127          155 :             } else if ((RefrigCase(CaseNum).defrostSched = Sched::GetSchedule(state, Alphas(9))) == nullptr) {
    1128            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(9), Alphas(9));
    1129            0 :                 ErrorsFound = true;
    1130          155 :             } else if (!RefrigCase(CaseNum).defrostSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) {
    1131            0 :                 Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(9), Alphas(9), Clusive::In, 0.0, Clusive::In, 1.0);
    1132            0 :                 ErrorsFound = true;
    1133              :             }
    1134              : 
    1135              :             //   Note that next section counting number cycles and setting maxkgfrost not used now, but may be in the future.
    1136              :             //   count the number of defrost cycles
    1137              : 
    1138              :             // Flag for counting defrost cycles
    1139          190 :             int NumDefCycles = 0;
    1140              : 
    1141          190 :             if (RefrigCase(CaseNum).defrostSched != nullptr) {
    1142          155 :                 bool StartCycle = false;
    1143          155 :                 std::vector<Real64> const &dayVals = RefrigCase(CaseNum).defrostSched->getDayVals(state, 1);
    1144        21203 :                 for (int i = 0; i < Constant::iHoursInDay * state.dataGlobal->TimeStepsInHour; ++i) {
    1145        21048 :                     if (dayVals[i] == 0.0) {
    1146        20478 :                         StartCycle = false;
    1147          570 :                     } else if (!StartCycle) {
    1148          286 :                         ++NumDefCycles;
    1149          286 :                         StartCycle = true;
    1150              :                     }
    1151              :                 }
    1152              :             }
    1153              : 
    1154          190 :             if (NumDefCycles > 0) {
    1155              :                 //     calculate maximum frost formation based on defrost schedule, heat of vaporization+fusion for water = 2833.0 kJ/kg
    1156          143 :                 RefrigCase(CaseNum).MaxKgFrost =
    1157          143 :                     (RefrigCase(CaseNum).RateTotCapPerLength * RefrigCase(CaseNum).RatedLHR * RefrigCase(CaseNum).RatedRTF * Constant::rSecsInHour *
    1158          143 :                      Constant::rHoursInDay / 1000.0 / 2833.0) / // Parenthesize!!!
    1159              :                     (NumDefCycles);
    1160              :             } else {
    1161           47 :                 RefrigCase(CaseNum).MaxKgFrost = 9999999.9;
    1162              :             }
    1163              : 
    1164              :             //   some defrost types do not use drip-down schedules, use same defrost schedule pointer in that case
    1165          190 :             if (lAlphaBlanks(10)) {
    1166           33 :                 RefrigCase(CaseNum).defrostDripDownSched = RefrigCase(CaseNum).defrostSched;
    1167          157 :             } else if ((RefrigCase(CaseNum).defrostDripDownSched = Sched::GetSchedule(state, Alphas(10))) == nullptr) {
    1168            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(10), Alphas(10));
    1169            0 :                 ErrorsFound = true;
    1170          157 :             } else if (!RefrigCase(CaseNum).defrostDripDownSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) {
    1171            0 :                 Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(10), Alphas(10), Clusive::In, 0.0, Clusive::In, 1.0);
    1172            0 :                 ErrorsFound = true;
    1173              :             }
    1174              : 
    1175          190 :             RefrigCase(CaseNum).DefrostEnergyCurveType = static_cast<EnergyEqnForm>(getEnumValue(energyEqnFormNamesUC, Alphas(11)));
    1176          190 :             if (RefrigCase(CaseNum).DefrostEnergyCurveType == EnergyEqnForm::Invalid) {
    1177            0 :                 ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(11), Alphas(11));
    1178            0 :                 ErrorsFound = true;
    1179              :             }
    1180              : 
    1181          190 :             RefrigCase(CaseNum).DefCapCurvePtr = Curve::GetCurveIndex(state, Alphas(12)); // convert curve name to number
    1182          190 :             if ((RefrigCase(CaseNum).defrostType == RefCaseDefrostType::ElectricTerm ||
    1183          248 :                  RefrigCase(CaseNum).defrostType == RefCaseDefrostType::HotFluidTerm) &&
    1184           58 :                 (RefrigCase(CaseNum).DefCapCurvePtr == 0)) {
    1185            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(12), Alphas(12));
    1186            0 :                 ErrorsFound = true;
    1187              :             }
    1188              : 
    1189          190 :             if (RefrigCase(CaseNum).DefCapCurvePtr > 0) {
    1190          232 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    1191           58 :                                                      RefrigCase(CaseNum).DefCapCurvePtr, // Curve index
    1192              :                                                      {1},                                // Valid dimensions
    1193              :                                                      RoutineName,                        // Routine name
    1194              :                                                      CurrentModuleObject,                // Object Type
    1195           58 :                                                      RefrigCase(CaseNum).Name,           // Object Name
    1196           58 :                                                      cAlphaFieldNames(12));              // Field Name
    1197              :             }
    1198              : 
    1199              :             //  warn user if defrost energy curve is entered that it is only used for temperature termination types
    1200          190 :             if (RefrigCase(CaseNum).DefCapCurvePtr > 0) {
    1201           98 :                 if (RefrigCase(CaseNum).defrostType != RefCaseDefrostType::ElectricTerm &&
    1202           40 :                     RefrigCase(CaseNum).defrostType != RefCaseDefrostType::HotFluidTerm) {
    1203            0 :                     ShowWarningError(state,
    1204            0 :                                      format("{}=\"{}\", invalid  {} is only applicable to Defrost Temperature Termination types.",
    1205              :                                             CurrentModuleObject,
    1206            0 :                                             RefrigCase(CaseNum).Name,
    1207              :                                             cAlphaFieldNames(12)));
    1208            0 :                     ShowContinueError(state, format("{} will be disregarded and simulation continues.", cAlphaFieldNames(12)));
    1209              :                 }
    1210              :             }
    1211              : 
    1212          190 :             NumNum = 19;
    1213          190 :             RefrigCase(CaseNum).RAFrac = Numbers(NumNum);
    1214          190 :             if (Numbers(NumNum) < 0.0 || Numbers(NumNum) > 1.0) {
    1215            0 :                 ShowSevereError(state,
    1216            0 :                                 format("{}{}=\"{}\", {} must be >= 0 or <= 1 ",
    1217              :                                        RoutineName,
    1218              :                                        CurrentModuleObject,
    1219            0 :                                        RefrigCase(CaseNum).Name,
    1220              :                                        cNumericFieldNames(NumNum)));
    1221            0 :                 ErrorsFound = true;
    1222              :             }
    1223              : 
    1224              :             // Set return air node number
    1225          190 :             RefrigCase(CaseNum).ZoneRANode = 0;
    1226          190 :             std::string retNodeName;
    1227          190 :             if (!lAlphaBlanks(15)) {
    1228            0 :                 retNodeName = Alphas(15);
    1229              :             }
    1230          190 :             if (RefrigCase(CaseNum).RAFrac > 0.0) {
    1231          122 :                 std::string callDescription = CurrentModuleObject + "=" + RefrigCase(CaseNum).Name;
    1232          244 :                 RefrigCase(CaseNum).ZoneRANode =
    1233          122 :                     DataZoneEquipment::GetReturnAirNodeForZone(state, RefrigCase(CaseNum).ActualZoneNum, retNodeName, callDescription);
    1234          122 :             }
    1235              : 
    1236          190 :             if (RefrigCase(CaseNum).ActualZoneNum >= 0) {
    1237          190 :                 if (RefrigCase(CaseNum).ZoneNodeNum == 0) {
    1238            0 :                     ShowSevereError(state,
    1239            0 :                                     format("{}{}=\"{}\", System Node Number not found for {} = {}",
    1240              :                                            RoutineName,
    1241              :                                            CurrentModuleObject,
    1242            0 :                                            RefrigCase(CaseNum).Name,
    1243              :                                            cAlphaFieldNames(3),
    1244              :                                            Alphas(3)));
    1245            0 :                     ShowContinueError(state,
    1246              :                                       "..Refrigerated cases must reference a controlled Zone (appear in a ZoneHVAC:EquipmentConnections object).");
    1247            0 :                     ErrorsFound = true;
    1248              :                 }
    1249          190 :                 if ((RefrigCase(CaseNum).RAFrac > 0.0) && (RefrigCase(CaseNum).ZoneRANode == 0)) {
    1250            0 :                     ShowSevereError(state,
    1251            0 :                                     format("{}{}=\"{}\", Under Case HVAC Return Air Node number not found for {} = {}",
    1252              :                                            RoutineName,
    1253              :                                            CurrentModuleObject,
    1254            0 :                                            RefrigCase(CaseNum).Name,
    1255              :                                            cAlphaFieldNames(3),
    1256              :                                            Alphas(3)));
    1257            0 :                     ShowContinueError(state,
    1258              :                                       "..Refrigerated cases must reference a controlled Zone (appear in a ZoneHVAC:EquipmentConnections object) "
    1259              :                                       "with at least one return air node.");
    1260            0 :                     ErrorsFound = true;
    1261              :                 }
    1262              :             }
    1263              : 
    1264              :             // set flag in Zone Data if RAFrac > 0
    1265          190 :             if (RefrigCase(CaseNum).RAFrac > 0.0) {
    1266          122 :                 state.dataHeatBal->Zone(RefrigCase(CaseNum).ActualZoneNum).RefrigCaseRA = true;
    1267              :             }
    1268              : 
    1269              :             //   Make sure RA node exists for display cases with under case HVAC returns
    1270          190 :             if (RefrigCase(CaseNum).ZoneRANode == 0 && RefrigCase(CaseNum).RAFrac > 0.0) {
    1271            0 :                 ShowSevereError(state,
    1272            0 :                                 format("{}{}=\"{}\", {} not applicable to zones without return air systems.",
    1273              :                                        RoutineName,
    1274              :                                        CurrentModuleObject,
    1275            0 :                                        RefrigCase(CaseNum).Name,
    1276              :                                        cNumericFieldNames(19)));
    1277            0 :                 ErrorsFound = true;
    1278              :             }
    1279              : 
    1280          190 :             if (RefrigCase(CaseNum).ActualZoneNum != 0) {
    1281          190 :                 CaseRAFraction(RefrigCase(CaseNum).ActualZoneNum).TotalCaseRAFraction += RefrigCase(CaseNum).RAFrac;
    1282          190 :                 CaseRAFraction(RefrigCase(CaseNum).ActualZoneNum).ZoneName = RefrigCase(CaseNum).ZoneName;
    1283              :             }
    1284              : 
    1285          190 :             if (lAlphaBlanks(13)) {
    1286          190 :             } else if ((RefrigCase(CaseNum).stockingSched = Sched::GetSchedule(state, Alphas(13))) == nullptr) {
    1287            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(13), Alphas(13));
    1288            0 :                 ErrorsFound = true;
    1289              :             }
    1290              : 
    1291              :             //   calculate sensible case load at design conditions
    1292              :             // Case sensible capacity used for error messages
    1293          190 :             Real64 DesignSensibleCap = RefrigCase(CaseNum).RateTotCapPerLength * (1.0 - RefrigCase(CaseNum).RatedLHR) * RefrigCase(CaseNum).RatedRTF *
    1294          190 :                                        RefrigCase(CaseNum).Length;
    1295              : 
    1296              :             //   calculate case heat gain = lights + fans + anti-sweat
    1297              :             Real64 CaseHeatGain =
    1298          190 :                 ((RefrigCase(CaseNum).RatedLightingPower * RefrigCase(CaseNum).LightingFractionToCase) +
    1299          190 :                  (RefrigCase(CaseNum).AntiSweatPower * RefrigCase(CaseNum).ASHeaterFractionToCase) + RefrigCase(CaseNum).STDFanPower) *
    1300          190 :                 RefrigCase(CaseNum).Length;
    1301              : 
    1302              :             //   sensible case credits are calculated as the difference between the design sensible capacity and the case heat gain
    1303          190 :             RefrigCase(CaseNum).DesignSensCaseCredit = DesignSensibleCap - CaseHeatGain;
    1304              : 
    1305              :             //   compare case loads to design capacity
    1306          190 :             if (DesignSensibleCap < CaseHeatGain) {
    1307            0 :                 ShowSevereError(
    1308              :                     state,
    1309            0 :                     format("{}{}=\"{}\", the sum of lighting, fan, and anti-sweat heater energy is greater than refrigerated case sensible capacity",
    1310              :                            RoutineName,
    1311              :                            CurrentModuleObject,
    1312            0 :                            RefrigCase(CaseNum).Name));
    1313            0 :                 ErrorsFound = true;
    1314              :             }
    1315              : 
    1316          190 :             if (lAlphaBlanks(14)) {
    1317          120 :             } else if ((RefrigCase(CaseNum).caseCreditFracSched = Sched::GetSchedule(state, Alphas(14))) == nullptr) {
    1318            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(14), Alphas(14));
    1319            0 :                 ErrorsFound = true;
    1320          120 :             } else if (!RefrigCase(CaseNum).caseCreditFracSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) {
    1321            0 :                 Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(14), Alphas(14), Clusive::In, 0.0, Clusive::In, 1.0);
    1322            0 :                 ErrorsFound = true;
    1323              :             }
    1324              : 
    1325          190 :             RefrigCase(CaseNum).DesignRatedCap = RefrigCase(CaseNum).RateTotCapPerLength * RefrigCase(CaseNum).Length;
    1326          190 :             RefrigCase(CaseNum).DesignLatentCap = RefrigCase(CaseNum).DesignRatedCap * RefrigCase(CaseNum).RatedLHR * RefrigCase(CaseNum).RatedRTF;
    1327          190 :             RefrigCase(CaseNum).DesignDefrostCap = RefrigCase(CaseNum).DefrostPower * RefrigCase(CaseNum).Length;
    1328          190 :             RefrigCase(CaseNum).DesignLighting = RefrigCase(CaseNum).LightingPower * RefrigCase(CaseNum).Length;
    1329          190 :             RefrigCase(CaseNum).DesignFanPower = RefrigCase(CaseNum).OperatingFanPower * RefrigCase(CaseNum).Length;
    1330              : 
    1331              :             // Design evaporating temperature:  for a DX system, saturated temperature for pressure leaving case
    1332              :             //                              :  for a liquid system, liquid temperature entering case
    1333          190 :             NumNum = 20;
    1334          190 :             if (!lNumericBlanks(NumNum)) {
    1335           89 :                 RefrigCase(CaseNum).EvapTempDesign = Numbers(NumNum);
    1336           89 :                 if (RefrigCase(CaseNum).EvapTempDesign >= RefrigCase(CaseNum).Temperature) {
    1337            0 :                     ShowSevereError(state,
    1338            0 :                                     format("{}{}=\"{}\" {} must be below {}",
    1339              :                                            RoutineName,
    1340              :                                            CurrentModuleObject,
    1341            0 :                                            RefrigCase(CaseNum).Name,
    1342              :                                            cNumericFieldNames(NumNum),
    1343              :                                            cNumericFieldNames(7)));
    1344            0 :                     ErrorsFound = true;
    1345              :                 }
    1346              :             } else {
    1347          101 :                 RefrigCase(CaseNum).EvapTempDesign = RefrigCase(CaseNum).Temperature - DelEvapTDefault;
    1348              :                 //    default 5C less than case operating temperature
    1349              :             }
    1350              : 
    1351          190 :             NumNum = 21;
    1352          190 :             if (!lNumericBlanks(NumNum)) {
    1353           12 :                 RefrigCase(CaseNum).RefrigInventory = Numbers(NumNum);
    1354           12 :                 RefrigCase(CaseNum).DesignRefrigInventory = RefrigCase(CaseNum).RefrigInventory * RefrigCase(CaseNum).Length;
    1355           12 :                 if (RefrigCase(CaseNum).RefrigInventory < 0.0) {
    1356            0 :                     ShowSevereError(state,
    1357            0 :                                     format("{}{}=\"{}\" {} must be a positive number.",
    1358              :                                            RoutineName,
    1359              :                                            CurrentModuleObject,
    1360            0 :                                            RefrigCase(CaseNum).Name,
    1361              :                                            cNumericFieldNames(NumNum)));
    1362            0 :                     ErrorsFound = true;
    1363              :                 }
    1364              :             } else {
    1365          178 :                 RefrigCase(CaseNum).RefrigInventory = 0.0;
    1366              :             }
    1367              : 
    1368          190 :         } // Individual refrigerated cases
    1369              :     } //(NumSimulationCases > 0 )
    1370              : 
    1371              :     //************ START WALK IN COOLER INPUT **************
    1372              : 
    1373          801 :     if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
    1374           14 :         CurrentModuleObject = "Refrigeration:WalkIn";
    1375           31 :         for (int WalkInID = 1; WalkInID <= state.dataRefrigCase->NumSimulationWalkIns; ++WalkInID) {
    1376           17 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
    1377              :                                                                      CurrentModuleObject,
    1378              :                                                                      WalkInID,
    1379              :                                                                      Alphas,
    1380              :                                                                      NumAlphas,
    1381              :                                                                      Numbers,
    1382              :                                                                      NumNumbers,
    1383              :                                                                      IOStatus,
    1384              :                                                                      lNumericBlanks,
    1385              :                                                                      lAlphaBlanks,
    1386              :                                                                      cAlphaFieldNames,
    1387              :                                                                      cNumericFieldNames);
    1388              : 
    1389           17 :             ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
    1390              : 
    1391           17 :             WalkIn(WalkInID).Name = Alphas(1);
    1392              : 
    1393           17 :             if (lAlphaBlanks(2)) {
    1394            0 :                 WalkIn(WalkInID).availSched = Sched::GetScheduleAlwaysOn(state);
    1395           17 :             } else if ((WalkIn(WalkInID).availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) {
    1396            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(2), Alphas(2));
    1397            0 :                 ErrorsFound = true;
    1398           17 :             } else if (!WalkIn(WalkInID).availSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) {
    1399            0 :                 Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(2), Alphas(2), Clusive::In, 0.0, Clusive::In, 1.0);
    1400            0 :                 ErrorsFound = true;
    1401              :             }
    1402              : 
    1403           17 :             WalkIn(WalkInID).DesignRatedCap = Numbers(1);
    1404           17 :             if (Numbers(1) <= 0.0) {
    1405            0 :                 ShowSevereError(
    1406              :                     state,
    1407            0 :                     format(
    1408            0 :                         "{}{}=\"{}\", {} must be greater than 0 W", RoutineName, CurrentModuleObject, WalkIn(WalkInID).Name, cNumericFieldNames(1)));
    1409            0 :                 ErrorsFound = true;
    1410              :             }
    1411              : 
    1412           17 :             if (!lNumericBlanks(2)) {
    1413           17 :                 WalkIn(WalkInID).Temperature = Numbers(2);
    1414              :             } else {
    1415            0 :                 ShowSevereEmptyField(state, eoh, cNumericFieldNames(2));
    1416            0 :                 ErrorsFound = true;
    1417              :             }
    1418              : 
    1419           17 :             if (!lNumericBlanks(3)) {
    1420           17 :                 WalkIn(WalkInID).TEvapDesign = Numbers(3);
    1421              :             } else {
    1422            0 :                 ShowSevereEmptyField(state, eoh, cNumericFieldNames(3));
    1423            0 :                 ErrorsFound = true;
    1424              :             }
    1425              : 
    1426           17 :             if (!lNumericBlanks(4)) {
    1427           17 :                 WalkIn(WalkInID).HeaterPower = Numbers(4);
    1428              :             } else {
    1429            0 :                 ShowSevereEmptyField(state, eoh, cNumericFieldNames(4));
    1430            0 :                 ErrorsFound = true;
    1431              :             }
    1432              : 
    1433           17 :             AlphaNum = 3;
    1434           17 :             if (lAlphaBlanks(AlphaNum)) {
    1435            0 :                 WalkIn(WalkInID).heaterSched = Sched::GetScheduleAlwaysOn(state); // Not an availability schedule, but defaults to constant-1.0
    1436           17 :             } else if ((WalkIn(WalkInID).heaterSched = Sched::GetSchedule(state, Alphas(AlphaNum))) == nullptr) {
    1437            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    1438            0 :                 ErrorsFound = true;
    1439           17 :             } else if (!WalkIn(WalkInID).heaterSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) {
    1440            0 :                 Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum), Clusive::In, 0.0, Clusive::In, 1.0);
    1441            0 :                 ErrorsFound = true;
    1442              :             }
    1443              : 
    1444           17 :             if (!lNumericBlanks(5) && Numbers(5) > 0.0) {
    1445           17 :                 WalkIn(WalkInID).CoilFanPower = Numbers(5);
    1446              :             } else {
    1447            0 :                 ShowWarningError(state,
    1448            0 :                                  format("{}{}=\"{}\", {} was not input or was less than 0 and default of 375.0 W will be used ",
    1449              :                                         RoutineName,
    1450              :                                         CurrentModuleObject,
    1451            0 :                                         WalkIn(WalkInID).Name,
    1452              :                                         cNumericFieldNames(5)));
    1453            0 :                 WalkIn(WalkInID).CoilFanPower = 375.0; // default value = 1/2 hp
    1454              :             }
    1455              : 
    1456           17 :             if (lNumericBlanks(6)) {
    1457            0 :                 WalkIn(WalkInID).CircFanPower = 0.0;
    1458              :             } else {
    1459           17 :                 WalkIn(WalkInID).CircFanPower = Numbers(6);
    1460           17 :                 if (Numbers(7) < 0.0) {
    1461            0 :                     ShowSevereError(state,
    1462            0 :                                     format("{}{}=\"{}\", {} must be greater than >= 0 W",
    1463              :                                            RoutineName,
    1464              :                                            CurrentModuleObject,
    1465            0 :                                            WalkIn(WalkInID).Name,
    1466              :                                            cNumericFieldNames(6)));
    1467            0 :                     ErrorsFound = true;
    1468              :                 }
    1469              :             }
    1470              : 
    1471           17 :             if (!lNumericBlanks(7)) {
    1472           17 :                 WalkIn(WalkInID).DesignLighting = Numbers(7);
    1473              :             } else {
    1474            0 :                 ShowSevereEmptyField(state, eoh, cNumericFieldNames(7));
    1475            0 :                 ErrorsFound = true;
    1476              :             }
    1477              : 
    1478           17 :             AlphaNum = 4;
    1479           17 :             if (lAlphaBlanks(AlphaNum)) {
    1480            0 :                 WalkIn(WalkInID).lightingSched = Sched::GetScheduleAlwaysOn(state); // Not an availability schedule, but defaults to constant-1.0
    1481           17 :             } else if ((WalkIn(WalkInID).lightingSched = Sched::GetSchedule(state, Alphas(AlphaNum))) == nullptr) {
    1482            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    1483            0 :                 ErrorsFound = true;
    1484           17 :             } else if (!WalkIn(WalkInID).lightingSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) {
    1485            0 :                 Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum), Clusive::In, 0.0, Clusive::In, 1.0);
    1486            0 :                 ErrorsFound = true;
    1487              :             }
    1488              : 
    1489              :             // Input walk-in cooler defrost information
    1490           17 :             AlphaNum = 5;
    1491           17 :             if (lAlphaBlanks(AlphaNum)) {
    1492            0 :                 WalkIn(WalkInID).defrostType = DefrostType::Elec;
    1493           17 :             } else if ((WalkIn(WalkInID).defrostType = static_cast<DefrostType>(getEnumValue(defrostTypeNamesUC, Alphas(AlphaNum)))) ==
    1494              :                        DefrostType::Invalid) {
    1495            0 :                 ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    1496            0 :                 ErrorsFound = true;
    1497              :             }
    1498              : 
    1499           17 :             AlphaNum = 6;
    1500           17 :             if (lAlphaBlanks(AlphaNum)) {
    1501            0 :                 WalkIn(WalkInID).DefrostControlType = DefrostCtrlType::Sched;
    1502           17 :             } else if ((WalkIn(WalkInID).DefrostControlType = static_cast<DefrostCtrlType>(getEnumValue(defrostCtrlTypeNamesUC, Alphas(AlphaNum)))) ==
    1503              :                        DefrostCtrlType::Invalid) {
    1504            0 :                 ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    1505            0 :                 ErrorsFound = true;
    1506              :             } // defrost control type
    1507              : 
    1508              :             // convert defrost schedule name to pointer
    1509           17 :             AlphaNum = 7;
    1510              : 
    1511           17 :             if (lAlphaBlanks(AlphaNum)) {
    1512            0 :                 ShowSevereEmptyField(state, eoh, cAlphaFieldNames(AlphaNum));
    1513            0 :                 ErrorsFound = true;
    1514           17 :             } else if ((WalkIn(WalkInID).defrostSched = Sched::GetSchedule(state, Alphas(AlphaNum))) == nullptr) {
    1515            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    1516            0 :                 ErrorsFound = true;
    1517           17 :             } else if (!WalkIn(WalkInID).defrostSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) {
    1518            0 :                 Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum), Clusive::In, 0.0, Clusive::In, 1.0);
    1519            0 :                 ErrorsFound = true;
    1520              :             }
    1521              : 
    1522              :             // convert defrost drip-down schedule name to pointer
    1523              :             // some defrost types do not use drip-down schedules, use same defrost schedule pointer in that case
    1524           17 :             AlphaNum = 8;
    1525           17 :             if (lAlphaBlanks(AlphaNum)) { // blank input so use drip down schedule for defrost
    1526            1 :                 WalkIn(WalkInID).defrostDripDownSched = WalkIn(WalkInID).defrostSched;
    1527           16 :             } else if ((WalkIn(WalkInID).defrostDripDownSched = Sched::GetSchedule(state, Alphas(AlphaNum))) == nullptr) {
    1528            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    1529            0 :                 ErrorsFound = true;
    1530           16 :             } else if (!WalkIn(WalkInID).defrostDripDownSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) {
    1531            0 :                 Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum), Clusive::In, 0.0, Clusive::In, 1.0);
    1532            0 :                 ErrorsFound = true;
    1533              :             }
    1534              : 
    1535           17 :             if (WalkIn(WalkInID).defrostType == DefrostType::OffCycle || WalkIn(WalkInID).defrostType == DefrostType::None) {
    1536            0 :                 WalkIn(WalkInID).DefrostCapacity = 0.0;
    1537              :                 // Don't even need to read N8 or N9 for those two defrost types.
    1538              :             } else { // have electric or hot gas/brine defrost
    1539           17 :                 if ((lNumericBlanks(8)) || (Numbers(8) <= 0.0)) {
    1540            0 :                     ShowSevereError(state,
    1541            0 :                                     format("{}{}=\"{}\", {} must be input and greater than or equal to 0 W for {} {}",
    1542              :                                            RoutineName,
    1543              :                                            CurrentModuleObject,
    1544            0 :                                            WalkIn(WalkInID).Name,
    1545              :                                            cNumericFieldNames(8),
    1546              :                                            cAlphaFieldNames(5),
    1547              :                                            Alphas(5)));
    1548            0 :                     ErrorsFound = true;
    1549              :                 } else {
    1550           17 :                     WalkIn(WalkInID).DefrostCapacity = Numbers(8);
    1551              :                 } // Blank  or negative N8
    1552              : 
    1553              :                 // defaults for defrost energy fraction are 0.7 for elec defrost and 0.3 for warm fluid
    1554              :                 // note this value is only used for temperature terminated defrost control type
    1555           17 :                 if (WalkIn(WalkInID).defrostType == DefrostType::Elec) {
    1556           14 :                     WalkIn(WalkInID).DefEnergyFraction = 0.7;
    1557              :                 }
    1558           17 :                 if (WalkIn(WalkInID).defrostType == DefrostType::Fluid) {
    1559            3 :                     WalkIn(WalkInID).DefEnergyFraction = 0.3;
    1560              :                 }
    1561           17 :                 if (!lNumericBlanks(9)) {
    1562            6 :                     if ((Numbers(9) > 1.0) || (Numbers(9) < 0.0)) {
    1563            0 :                         ShowWarningError(state,
    1564            0 :                                          format("{}{}=\"{}\", {} must be between 0 and 1, default values will be used.",
    1565              :                                                 RoutineName,
    1566              :                                                 CurrentModuleObject,
    1567            0 :                                                 WalkIn(WalkInID).Name,
    1568              :                                                 cNumericFieldNames(9)));
    1569              :                     } else {
    1570            6 :                         WalkIn(WalkInID).DefEnergyFraction = Numbers(9);
    1571              :                     } // number out of range
    1572              :                 } // lnumericblanks
    1573              :             } // defrost type
    1574              : 
    1575              :             // convert restocking schedule name to pointer, default of 0.1 is assigned inside walkin subroutine if blank
    1576           17 :             AlphaNum = 9;
    1577           17 :             if (lAlphaBlanks(AlphaNum)) {
    1578           17 :             } else if ((WalkIn(WalkInID).stockingSched = Sched::GetSchedule(state, Alphas(AlphaNum))) == nullptr) {
    1579            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    1580            0 :                 ErrorsFound = true;
    1581              :             }
    1582              : 
    1583           17 :             WalkIn(WalkInID).DesignRefrigInventory = 0.0;
    1584           17 :             if (!lNumericBlanks(10)) {
    1585            6 :                 WalkIn(WalkInID).DesignRefrigInventory = Numbers(10);
    1586              :             }
    1587              : 
    1588           17 :             if (!lNumericBlanks(11)) {
    1589           17 :                 WalkIn(WalkInID).FloorArea = Numbers(11);
    1590              :             } else {
    1591            0 :                 ShowSevereError(
    1592            0 :                     state, format("{}{}=\"{}\", {} must be input", RoutineName, CurrentModuleObject, WalkIn(WalkInID).Name, cNumericFieldNames(11)));
    1593            0 :                 ErrorsFound = true;
    1594              :             }
    1595              : 
    1596           17 :             if (lNumericBlanks(12)) {
    1597            0 :                 WalkIn(WalkInID).FloorUValue = DefaultWISurfaceUValue;
    1598              :             } else {
    1599           17 :                 WalkIn(WalkInID).FloorUValue = Numbers(12);
    1600           17 :                 if (Numbers(12) <= 0.0) {
    1601            0 :                     ShowSevereError(
    1602              :                         state,
    1603            0 :                         format("{}{}=\"{}\", {} must be > 0.", RoutineName, CurrentModuleObject, WalkIn(WalkInID).Name, cNumericFieldNames(12)));
    1604            0 :                     ErrorsFound = true;
    1605              :                 }
    1606              :             }
    1607              : 
    1608              :             // Calculate the number of zones exposed to walk-in based on number of input fields, all integer math,
    1609              :             // This approach used because last zone could have less than NumWIFieldsPerZone due to optional values
    1610           17 :             int NumWIFieldsPerZone = NumWIAlphaFieldsPerZone + NumWINumberFieldsPerZone;
    1611           17 :             int NumWIFieldsTotal = NumNumbers + NumAlphas - NumWIAlphaFieldsBeforeZoneInput - NumWINumberFieldsBeforeZoneInput;
    1612           17 :             int NumZones = 1;
    1613           17 :             if (NumWIFieldsTotal > NumWIFieldsPerZone) {
    1614            0 :                 NumZones = 2;
    1615              :             }
    1616           17 :             if (NumWIFieldsTotal > (2 * NumWIFieldsPerZone)) {
    1617            0 :                 NumZones = 3;
    1618              :             }
    1619           17 :             if (NumWIFieldsTotal > (3 * NumWIFieldsPerZone)) {
    1620            0 :                 NumZones = 4;
    1621              :             }
    1622           17 :             if (NumWIFieldsTotal > (4 * NumWIFieldsPerZone)) {
    1623            0 :                 NumZones = 5;
    1624              :             }
    1625           17 :             if (NumWIFieldsTotal > (5 * NumWIFieldsPerZone)) {
    1626            0 :                 NumZones = 6;
    1627              :             }
    1628           17 :             WalkIn(WalkInID).NumZones = NumZones;
    1629              : 
    1630              :             // All variables for walk-in/zone interactions need to be allocated after know number of zones
    1631              :             // Autodesk Missing initialization added below: At least SensZoneCreditRate was used uninitialized
    1632           17 :             if (!allocated(WalkIn(WalkInID).ZoneName)) {
    1633           17 :                 WalkIn(WalkInID).ZoneName.allocate(NumZones);
    1634              :             }
    1635           17 :             if (!allocated(WalkIn(WalkInID).ZoneNum)) {
    1636           17 :                 WalkIn(WalkInID).ZoneNum.allocate(NumZones) = 0;
    1637              :             }
    1638           17 :             if (!allocated(WalkIn(WalkInID).ZoneNodeNum)) {
    1639           17 :                 WalkIn(WalkInID).ZoneNodeNum.allocate(NumZones) = 0;
    1640              :             }
    1641           17 :             if (!allocated(WalkIn(WalkInID).SurfaceArea)) {
    1642           17 :                 WalkIn(WalkInID).SurfaceArea.allocate(NumZones) = 0.0;
    1643              :             }
    1644           17 :             if (!allocated(WalkIn(WalkInID).UValue)) {
    1645           17 :                 WalkIn(WalkInID).UValue.allocate(NumZones) = 0.0;
    1646              :             }
    1647           17 :             if (!allocated(WalkIn(WalkInID).UValueGlassDr)) {
    1648           17 :                 WalkIn(WalkInID).UValueGlassDr.allocate(NumZones) = 0.0;
    1649              :             }
    1650           17 :             if (!allocated(WalkIn(WalkInID).glassDoorOpenScheds)) {
    1651           17 :                 WalkIn(WalkInID).glassDoorOpenScheds.allocate(NumZones) = nullptr; // What is this?
    1652              :             }
    1653           17 :             if (!allocated(WalkIn(WalkInID).AreaGlassDr)) {
    1654           17 :                 WalkIn(WalkInID).AreaGlassDr.allocate(NumZones) = 0.0;
    1655              :             }
    1656           17 :             if (!allocated(WalkIn(WalkInID).HeightGlassDr)) {
    1657           17 :                 WalkIn(WalkInID).HeightGlassDr.allocate(NumZones) = 0.0;
    1658              :             }
    1659           17 :             if (!allocated(WalkIn(WalkInID).UValueStockDr)) {
    1660           17 :                 WalkIn(WalkInID).UValueStockDr.allocate(NumZones) = 0.0;
    1661              :             }
    1662           17 :             if (!allocated(WalkIn(WalkInID).stockDoorOpenScheds)) {
    1663           17 :                 WalkIn(WalkInID).stockDoorOpenScheds.allocate(NumZones) = nullptr; // What is this?
    1664              :             }
    1665           17 :             if (!allocated(WalkIn(WalkInID).StockDoorProtectType)) {
    1666           17 :                 WalkIn(WalkInID).StockDoorProtectType.allocate(NumZones) = WIStockDoor::Invalid;
    1667              :             }
    1668           17 :             if (!allocated(WalkIn(WalkInID).AreaStockDr)) {
    1669           17 :                 WalkIn(WalkInID).AreaStockDr.allocate(NumZones) = 0.0;
    1670              :             }
    1671           17 :             if (!allocated(WalkIn(WalkInID).HeightStockDr)) {
    1672           17 :                 WalkIn(WalkInID).HeightStockDr.allocate(NumZones) = 0.0;
    1673              :             }
    1674           17 :             if (!allocated(WalkIn(WalkInID).SensZoneCreditRate)) {
    1675           17 :                 WalkIn(WalkInID).SensZoneCreditRate.allocate(NumZones) = 0.0;
    1676              :             }
    1677           17 :             if (!allocated(WalkIn(WalkInID).SensZoneCreditCoolRate)) {
    1678           17 :                 WalkIn(WalkInID).SensZoneCreditCoolRate.allocate(NumZones) = 0.0;
    1679              :             }
    1680           17 :             if (!allocated(WalkIn(WalkInID).SensZoneCreditCool)) {
    1681           17 :                 WalkIn(WalkInID).SensZoneCreditCool.allocate(NumZones) = 0.0;
    1682              :             }
    1683           17 :             if (!allocated(WalkIn(WalkInID).SensZoneCreditHeatRate)) {
    1684           17 :                 WalkIn(WalkInID).SensZoneCreditHeatRate.allocate(NumZones) = 0.0;
    1685              :             }
    1686           17 :             if (!allocated(WalkIn(WalkInID).SensZoneCreditHeat)) {
    1687           17 :                 WalkIn(WalkInID).SensZoneCreditHeat.allocate(NumZones) = 0.0;
    1688              :             }
    1689           17 :             if (!allocated(WalkIn(WalkInID).LatZoneCreditRate)) {
    1690           17 :                 WalkIn(WalkInID).LatZoneCreditRate.allocate(NumZones) = 0.0;
    1691              :             }
    1692           17 :             if (!allocated(WalkIn(WalkInID).LatZoneCredit)) {
    1693           17 :                 WalkIn(WalkInID).LatZoneCredit.allocate(NumZones) = 0.0;
    1694              :             }
    1695              : 
    1696           17 :             int AStart = NumWIAlphaFieldsBeforeZoneInput + 1;
    1697           17 :             int NStart = NumWINumberFieldsBeforeZoneInput + 1;
    1698           34 :             for (int ZoneID = 1; ZoneID <= NumZones; ++ZoneID) {
    1699              :                 // Get the Zone node number from the zone name
    1700              :                 // The Zone Node is needed to get the zone's ambient conditions, DataGlobals::NumOfZones from dataglobals
    1701           17 :                 WalkIn(WalkInID).ZoneName(ZoneID) = Alphas(AStart);
    1702           17 :                 WalkIn(WalkInID).ZoneNum(ZoneID) = Util::FindItemInList(Alphas(AStart), state.dataHeatBal->Zone);
    1703              : 
    1704           17 :                 if (WalkIn(WalkInID).ZoneNum(ZoneID) == 0) {
    1705            0 :                     ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AStart), Alphas(AStart));
    1706            0 :                     ErrorsFound = true;
    1707              :                 } else {
    1708           17 :                     state.dataRefrigCase->RefrigPresentInZone(WalkIn(WalkInID).ZoneNum(ZoneID)) = true;
    1709              :                 }
    1710           17 :                 WalkIn(WalkInID).ZoneNodeNum(ZoneID) = DataZoneEquipment::GetSystemNodeNumberForZone(state, WalkIn(WalkInID).ZoneNum(ZoneID));
    1711           17 :                 if (WalkIn(WalkInID).ZoneNum(ZoneID) >= 0) {
    1712           17 :                     if (WalkIn(WalkInID).ZoneNodeNum(ZoneID) == 0) {
    1713            0 :                         ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AStart), Alphas(AStart));
    1714            0 :                         ShowContinueError(state, ".. Walk Ins must reference a controlled Zone (appear in a ZoneHVAC:EquipmentConnections object.");
    1715            0 :                         ErrorsFound = true;
    1716              :                     }
    1717              :                 }
    1718              : 
    1719           17 :                 if (!lNumericBlanks(NStart)) {
    1720           17 :                     WalkIn(WalkInID).SurfaceArea(ZoneID) = Numbers(NStart);
    1721              :                 } else {
    1722            0 :                     ShowSevereError(state,
    1723            0 :                                     format("{}{}=\"{}\", {} must be input for Zone: {}",
    1724              :                                            RoutineName,
    1725              :                                            CurrentModuleObject,
    1726            0 :                                            WalkIn(WalkInID).Name,
    1727              :                                            cNumericFieldNames(NStart),
    1728            0 :                                            WalkIn(WalkInID).ZoneName(ZoneID)));
    1729            0 :                     ErrorsFound = true;
    1730              :                 }
    1731              : 
    1732           17 :                 if (lNumericBlanks(NStart + 1)) {
    1733            0 :                     WalkIn(WalkInID).UValue(ZoneID) = DefaultWISurfaceUValue;
    1734              :                 } else {
    1735           17 :                     WalkIn(WalkInID).UValue(ZoneID) = Numbers(NStart + 1);
    1736           17 :                     if (Numbers(NStart + 1) <= 0.0) {
    1737            0 :                         ShowSevereError(state,
    1738            0 :                                         format(R"({}{}="{}", Zone="{}", {} must be > 0.)",
    1739              :                                                RoutineName,
    1740              :                                                CurrentModuleObject,
    1741            0 :                                                WalkIn(WalkInID).Name,
    1742            0 :                                                WalkIn(WalkInID).ZoneName(ZoneID),
    1743              :                                                cNumericFieldNames(NStart + 1)));
    1744            0 :                         ErrorsFound = true;
    1745              :                     }
    1746              :                 }
    1747              : 
    1748              :                 // start IF set for glass doors in this zone
    1749           17 :                 WalkIn(WalkInID).AreaGlassDr(ZoneID) = 0.0;
    1750           17 :                 WalkIn(WalkInID).HeightGlassDr(ZoneID) = 0.0;
    1751           17 :                 WalkIn(WalkInID).UValueGlassDr(ZoneID) = 0.0;
    1752           17 :                 if (!lNumericBlanks(NStart + 2)) {
    1753            6 :                     WalkIn(WalkInID).AreaGlassDr(ZoneID) = Numbers(NStart + 2);
    1754              : 
    1755            6 :                     WalkIn(WalkInID).HeightGlassDr(ZoneID) = DefaultWIHeightGlassDr;
    1756            6 :                     if (!lNumericBlanks(NStart + 3)) {
    1757            6 :                         WalkIn(WalkInID).HeightGlassDr(ZoneID) = Numbers(NStart + 3);
    1758              :                     }
    1759              : 
    1760            6 :                     WalkIn(WalkInID).UValueGlassDr(ZoneID) = DefaultWIUValueGlassDr;
    1761            6 :                     if (!lNumericBlanks(NStart + 4)) {
    1762            6 :                         WalkIn(WalkInID).UValueGlassDr(ZoneID) = Numbers(NStart + 4);
    1763              :                     }
    1764              : 
    1765              :                     // convert door opening schedule name to pointer, default of 0.1 is assigned inside walkin subroutine if blank
    1766            6 :                     if (lAlphaBlanks(AStart + 1)) {
    1767            6 :                     } else if ((WalkIn(WalkInID).glassDoorOpenScheds(ZoneID) = Sched::GetSchedule(state, Alphas(AStart + 1))) == nullptr) {
    1768            0 :                         ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AStart + 1), Alphas(AStart + 1));
    1769            0 :                         ErrorsFound = true;
    1770            6 :                     } else if (!WalkIn(WalkInID).glassDoorOpenScheds(ZoneID)->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) {
    1771            0 :                         Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(AStart + 1), Alphas(AStart + 1), Clusive::In, 0.0, Clusive::In, 1.0);
    1772            0 :                         ErrorsFound = true;
    1773              :                     } // blank on door opening schedule (AStart + 1)
    1774              :                 } // have glassdoor area facing zone (blank on lNumericBlanks(NStart+2))
    1775              : 
    1776              :                 // start IF set for stock doors in this zone
    1777           17 :                 WalkIn(WalkInID).AreaStockDr(ZoneID) = 0.0;
    1778           17 :                 WalkIn(WalkInID).HeightStockDr(ZoneID) = 0.0;
    1779           17 :                 WalkIn(WalkInID).UValueStockDr(ZoneID) = 0.0;
    1780           17 :                 if (!lNumericBlanks(NStart + 5)) {
    1781           17 :                     WalkIn(WalkInID).AreaStockDr(ZoneID) = Numbers(NStart + 5);
    1782              : 
    1783           17 :                     WalkIn(WalkInID).HeightStockDr(ZoneID) = DefaultWIHeightStockDr;
    1784           17 :                     if (!lNumericBlanks(NStart + 6)) {
    1785           17 :                         WalkIn(WalkInID).HeightStockDr(ZoneID) = Numbers(NStart + 6);
    1786              :                     }
    1787              : 
    1788           17 :                     WalkIn(WalkInID).UValueStockDr(ZoneID) = DefaultWIUValueStockDr;
    1789           17 :                     if (!lNumericBlanks(NStart + 7)) {
    1790            6 :                         WalkIn(WalkInID).UValueStockDr(ZoneID) = Numbers(NStart + 7);
    1791              :                     }
    1792              : 
    1793              :                     // convert door opening schedule name to pointer, default of 0.1 is assigned inside walkin subroutine if blank
    1794           17 :                     if (lAlphaBlanks(AStart + 2)) {
    1795           17 :                     } else if ((WalkIn(WalkInID).stockDoorOpenScheds(ZoneID) = Sched::GetSchedule(state, Alphas(AStart + 2))) == nullptr) {
    1796            0 :                         ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AStart + 2), Alphas(AStart + 2));
    1797            0 :                         ErrorsFound = true;
    1798           17 :                     } else if (!WalkIn(WalkInID).stockDoorOpenScheds(ZoneID)->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) {
    1799            0 :                         Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(AStart + 2), Alphas(AStart + 2), Clusive::In, 0.0, Clusive::In, 1.0);
    1800            0 :                         ErrorsFound = true;
    1801              :                     } // blank on door opening schedule (AStart + 2)
    1802              : 
    1803           17 :                     if (lAlphaBlanks(AStart + 3)) {
    1804              :                         // default air curtain
    1805            0 :                         WalkIn(WalkInID).StockDoorProtectType(ZoneID) = WIStockDoor::AirCurtain;
    1806           17 :                     } else if ((WalkIn(WalkInID).StockDoorProtectType(ZoneID) =
    1807           34 :                                     static_cast<WIStockDoor>(getEnumValue(wiStockDoorNamesUC, Alphas(AStart + 3)))) == WIStockDoor::Invalid) {
    1808            0 :                         ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(AStart + 3), Alphas(AStart + 3));
    1809            0 :                         ErrorsFound = true;
    1810              :                     } // stock door protection (AStart + 3) blank
    1811              :                 } // have Stockdoor area facing zone
    1812              : 
    1813           17 :                 AStart += NumWIAlphaFieldsPerZone;
    1814           17 :                 NStart += NumWINumberFieldsPerZone;
    1815              :             } // Zones for Walk Ins
    1816              :         } // Individual Walk Ins
    1817              :     } //(NumSimulationWalkIns > 0 )
    1818              : 
    1819              :     //************* Start Indiv Refrig Air Chillers
    1820              : 
    1821          801 :     if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0) {
    1822            1 :         CurrentModuleObject = "Refrigeration:AirChiller";
    1823           84 :         for (int CoilID = 1; CoilID <= state.dataRefrigCase->NumSimulationRefrigAirChillers; ++CoilID) {
    1824              :             // A1
    1825           83 :             AlphaNum = 1;
    1826           83 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
    1827              :                                                                      CurrentModuleObject,
    1828              :                                                                      CoilID,
    1829              :                                                                      Alphas,
    1830              :                                                                      NumAlphas,
    1831              :                                                                      Numbers,
    1832              :                                                                      NumNumbers,
    1833              :                                                                      IOStatus,
    1834              :                                                                      lNumericBlanks,
    1835              :                                                                      lAlphaBlanks,
    1836              :                                                                      cAlphaFieldNames,
    1837              :                                                                      cNumericFieldNames);
    1838              : 
    1839           83 :             ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
    1840              : 
    1841           83 :             Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    1842              : 
    1843           83 :             WarehouseCoil(CoilID).Name = Alphas(AlphaNum);
    1844              : 
    1845              :             // A2
    1846           83 :             ++AlphaNum;
    1847           83 :             if (lAlphaBlanks(AlphaNum)) {
    1848            0 :                 WarehouseCoil(CoilID).availSched = Sched::GetScheduleAlwaysOn(state);
    1849           83 :             } else if ((WarehouseCoil(CoilID).availSched = Sched::GetSchedule(state, Alphas(AlphaNum))) == nullptr) {
    1850            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    1851            0 :                 ErrorsFound = true;
    1852           83 :             } else if (!WarehouseCoil(CoilID).availSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) {
    1853            0 :                 Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum), Clusive::In, 0.0, Clusive::In, 1.0);
    1854            0 :                 ErrorsFound = true;
    1855              :             }
    1856              : 
    1857              :             // Input capacity rating type
    1858              :             // bbbbb input values (DT1 or DTM type)translate DT1 to DTm here because node will give avg temp?
    1859              :             //      ask whether ceiling or floor mounted? - effects translation from DT1 to DTM
    1860              :             //      input coil condition, wet or dry OR input rating basis, European SC1, SC2 etc., have to combine with refrigerant factor)
    1861              :             //      rated capacity, BAC give W/C, European gives W
    1862              :             //      fin material factor, default 1
    1863              :             //      refrigerant factor (factor of both refrigerant and Tevap)
    1864              : 
    1865              :             // A3
    1866           83 :             ++AlphaNum;
    1867           83 :             if (lAlphaBlanks(AlphaNum)) {
    1868            0 :                 ShowSevereEmptyField(state, eoh, cAlphaFieldNames(AlphaNum));
    1869            0 :                 ErrorsFound = true;
    1870           83 :             } else if ((WarehouseCoil(CoilID).ratingType = static_cast<RatingType>(getEnumValue(ratingTypeNamesUC, Alphas(AlphaNum)))) ==
    1871              :                        RatingType::Invalid) {
    1872              : 
    1873            0 :                 ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    1874            0 :                 ErrorsFound = true;
    1875              :             }
    1876              : 
    1877              :             // Here have to do select case with one numeric field with units of W and the second with units of W/deltaC,
    1878              :             //  (RatedRH field only used for RatedCapacityTotal type)
    1879              :             { // Why is this a new scope
    1880           83 :                 switch (WarehouseCoil(CoilID).ratingType) {
    1881           81 :                 case RatingType::UnitLoadFactorSens: {
    1882              :                     // N1
    1883           81 :                     NumNum = 1;
    1884           81 :                     if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    1885           81 :                         WarehouseCoil(CoilID).UnitLoadFactorSens = Numbers(NumNum);
    1886              :                     } else {
    1887            0 :                         ShowSevereError(state,
    1888            0 :                                         format("{}{}=\"{}\", {} must be input and be greater than 0 W/C",
    1889              :                                                RoutineName,
    1890              :                                                CurrentModuleObject,
    1891            0 :                                                WarehouseCoil(CoilID).Name,
    1892              :                                                cNumericFieldNames(NumNum)));
    1893            0 :                         ErrorsFound = true;
    1894              :                     }
    1895           81 :                 } break;
    1896              : 
    1897            1 :                 case RatingType::RatedCapacityTotal: {
    1898              :                     // N2
    1899            1 :                     NumNum = 2; // advance past rating in W/C to N2 with rating in W
    1900            1 :                     if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    1901            1 :                         WarehouseCoil(CoilID).RatedCapTotal = Numbers(NumNum);
    1902              :                         // N3
    1903            1 :                         NumNum = 3; // read rated RH only for this type of rating at N3
    1904            1 :                         if (lNumericBlanks(NumNum)) {
    1905            0 :                             WarehouseCoil(CoilID).RatedRH = 0.85;
    1906              :                         } else {
    1907            1 :                             if (Numbers(NumNum) <= 0.0 || Numbers(NumNum) >= 100.0) {
    1908            0 :                                 ShowSevereError(state,
    1909            0 :                                                 format("{}{}=\"{}\", {} must be greater than 0% and less than 100%",
    1910              :                                                        RoutineName,
    1911              :                                                        CurrentModuleObject,
    1912            0 :                                                        WarehouseCoil(CoilID).Name,
    1913              :                                                        cNumericFieldNames(NumNum)));
    1914            0 :                                 ErrorsFound = true;
    1915              :                             }
    1916            1 :                             WarehouseCoil(CoilID).RatedRH = Numbers(NumNum) / 100.0;
    1917              :                         }
    1918              :                     } else {
    1919            0 :                         ShowSevereError(state,
    1920            0 :                                         format("{}{}=\"{}\", {} must be input and be greater than 0 W",
    1921              :                                                RoutineName,
    1922              :                                                CurrentModuleObject,
    1923            0 :                                                WarehouseCoil(CoilID).Name,
    1924              :                                                cNumericFieldNames(NumNum)));
    1925            0 :                         ErrorsFound = true;
    1926              :                     }
    1927            1 :                 } break;
    1928              : 
    1929            0 :                 case RatingType::EuropeanSC1Std: {
    1930              :                     // N2
    1931            0 :                     NumNum = 2; // advance past rating in W/C to rating in W at N2
    1932            0 :                     if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    1933            0 :                         WarehouseCoil(CoilID).RatedSensibleCap = Numbers(NumNum);
    1934            0 :                         WarehouseCoil(CoilID).SCIndex = 1;
    1935              :                     } else {
    1936            0 :                         ShowSevereError(state,
    1937            0 :                                         format("{}{}=\"{}\", {} must be input and be greater than 0 W",
    1938              :                                                RoutineName,
    1939              :                                                CurrentModuleObject,
    1940            0 :                                                WarehouseCoil(CoilID).Name,
    1941              :                                                cNumericFieldNames(NumNum)));
    1942            0 :                         ErrorsFound = true;
    1943              :                     }
    1944            0 :                 } break;
    1945              : 
    1946            0 :                 case RatingType::EuropeanSC1Nom: {
    1947              :                     // N2
    1948            0 :                     NumNum = 2; // advance past rating in W/C to rating in W at N2
    1949            0 :                     if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    1950            0 :                         WarehouseCoil(CoilID).RatedCapTotal = Numbers(NumNum);
    1951            0 :                         WarehouseCoil(CoilID).RatedSensibleCap = Numbers(NumNum) / EuropeanWetCoilFactor[0];
    1952            0 :                         WarehouseCoil(CoilID).SCIndex = 1;
    1953              :                     } else {
    1954            0 :                         ShowSevereError(state,
    1955            0 :                                         format("{}{}=\"{}\", {} must be input and be greater than 0 W",
    1956              :                                                RoutineName,
    1957              :                                                CurrentModuleObject,
    1958            0 :                                                WarehouseCoil(CoilID).Name,
    1959              :                                                cNumericFieldNames(NumNum)));
    1960            0 :                         ErrorsFound = true;
    1961              :                     }
    1962            0 :                 } break;
    1963              : 
    1964            0 :                 case RatingType::EuropeanSC2Std: {
    1965              :                     // N2
    1966            0 :                     NumNum = 2; // advance past rating in W/C to rating in W at N2
    1967            0 :                     if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    1968            0 :                         WarehouseCoil(CoilID).RatedSensibleCap = Numbers(NumNum);
    1969            0 :                         WarehouseCoil(CoilID).SCIndex = 2;
    1970              :                     } else {
    1971            0 :                         ShowSevereError(state,
    1972            0 :                                         format("{}{}=\"{}\", {} must be input and be greater than 0 W",
    1973              :                                                RoutineName,
    1974              :                                                CurrentModuleObject,
    1975            0 :                                                WarehouseCoil(CoilID).Name,
    1976              :                                                cNumericFieldNames(NumNum)));
    1977            0 :                         ErrorsFound = true;
    1978              :                     }
    1979            0 :                 } break;
    1980              : 
    1981            0 :                 case RatingType::EuropeanSC2Nom: {
    1982              :                     // N2
    1983            0 :                     NumNum = 2; // advance past rating in W/C to rating in W at N2
    1984            0 :                     if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    1985            0 :                         WarehouseCoil(CoilID).RatedCapTotal = Numbers(NumNum);
    1986            0 :                         WarehouseCoil(CoilID).RatedSensibleCap = Numbers(NumNum) / EuropeanWetCoilFactor[1];
    1987            0 :                         WarehouseCoil(CoilID).SCIndex = 2;
    1988              :                     } else {
    1989            0 :                         ShowSevereError(state,
    1990            0 :                                         format("{}{}=\"{}\", {} must be input and be greater than 0 W",
    1991              :                                                RoutineName,
    1992              :                                                CurrentModuleObject,
    1993            0 :                                                WarehouseCoil(CoilID).Name,
    1994              :                                                cNumericFieldNames(NumNum)));
    1995            0 :                         ErrorsFound = true;
    1996              :                     }
    1997            0 :                 } break;
    1998              : 
    1999            1 :                 case RatingType::EuropeanSC3Std: {
    2000              :                     // N2
    2001            1 :                     NumNum = 2; // advance past rating in W/C to rating in W at N2
    2002            1 :                     if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    2003            1 :                         WarehouseCoil(CoilID).RatedSensibleCap = Numbers(NumNum);
    2004            1 :                         WarehouseCoil(CoilID).SCIndex = 3;
    2005              :                     } else {
    2006            0 :                         ShowSevereError(state,
    2007            0 :                                         format("{}{}=\"{}\", {} must be input and be greater than 0 W",
    2008              :                                                RoutineName,
    2009              :                                                CurrentModuleObject,
    2010            0 :                                                WarehouseCoil(CoilID).Name,
    2011              :                                                cNumericFieldNames(NumNum)));
    2012            0 :                         ErrorsFound = true;
    2013              :                     }
    2014            1 :                 } break;
    2015              : 
    2016            0 :                 case RatingType::EuropeanSC3Nom: {
    2017              :                     // N2
    2018            0 :                     NumNum = 2; // advance past rating in W/C to rating in W at N2
    2019            0 :                     if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    2020            0 :                         WarehouseCoil(CoilID).RatedCapTotal = Numbers(NumNum);
    2021            0 :                         WarehouseCoil(CoilID).RatedSensibleCap = Numbers(NumNum) / EuropeanWetCoilFactor[2];
    2022            0 :                         WarehouseCoil(CoilID).SCIndex = 3;
    2023              :                     } else {
    2024            0 :                         ShowSevereError(state,
    2025            0 :                                         format("{}{}=\"{}\", {} must be input and be greater than 0 W",
    2026              :                                                RoutineName,
    2027              :                                                CurrentModuleObject,
    2028            0 :                                                WarehouseCoil(CoilID).Name,
    2029              :                                                cNumericFieldNames(NumNum)));
    2030            0 :                         ErrorsFound = true;
    2031              :                     }
    2032            0 :                 } break;
    2033              : 
    2034            0 :                 case RatingType::EuropeanSC4Std: {
    2035              :                     // N2
    2036            0 :                     NumNum = 2; // advance past rating in W/C to rating in W at N2
    2037            0 :                     if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    2038            0 :                         WarehouseCoil(CoilID).RatedSensibleCap = Numbers(NumNum);
    2039            0 :                         WarehouseCoil(CoilID).SCIndex = 4;
    2040              :                     } else {
    2041            0 :                         ShowSevereError(state,
    2042            0 :                                         format("{}{}=\"{}\", {} must be input and be greater than 0 W",
    2043              :                                                RoutineName,
    2044              :                                                CurrentModuleObject,
    2045            0 :                                                WarehouseCoil(CoilID).Name,
    2046              :                                                cNumericFieldNames(NumNum)));
    2047            0 :                         ErrorsFound = true;
    2048              :                     }
    2049            0 :                 } break;
    2050              : 
    2051            0 :                 case RatingType::EuropeanSC4Nom: {
    2052              :                     // N2
    2053            0 :                     NumNum = 2; // advance past rating in W/C to rating in W at N2
    2054            0 :                     if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    2055            0 :                         WarehouseCoil(CoilID).RatedCapTotal = Numbers(NumNum);
    2056            0 :                         WarehouseCoil(CoilID).RatedSensibleCap = Numbers(NumNum) / EuropeanWetCoilFactor[3];
    2057            0 :                         WarehouseCoil(CoilID).SCIndex = 4;
    2058              :                     } else {
    2059            0 :                         ShowSevereError(state,
    2060            0 :                                         format("{}{}=\"{}\", {} must be input and be greater than 0 W",
    2061              :                                                RoutineName,
    2062              :                                                CurrentModuleObject,
    2063            0 :                                                WarehouseCoil(CoilID).Name,
    2064              :                                                cNumericFieldNames(NumNum)));
    2065            0 :                         ErrorsFound = true;
    2066              :                     }
    2067            0 :                 } break;
    2068              : 
    2069            0 :                 case RatingType::EuropeanSC5Std: {
    2070              :                     // N2
    2071            0 :                     NumNum = 2; // advance past rating in W/C to rating in W at N2
    2072            0 :                     if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    2073            0 :                         WarehouseCoil(CoilID).RatedSensibleCap = Numbers(NumNum);
    2074            0 :                         WarehouseCoil(CoilID).SCIndex = 5;
    2075              :                     } else {
    2076            0 :                         ShowSevereError(state,
    2077            0 :                                         format("{}{}=\"{}\", {} must be input and be greater than 0 W",
    2078              :                                                RoutineName,
    2079              :                                                CurrentModuleObject,
    2080            0 :                                                WarehouseCoil(CoilID).Name,
    2081              :                                                cNumericFieldNames(NumNum)));
    2082            0 :                         ErrorsFound = true;
    2083              :                     }
    2084            0 :                 } break;
    2085              : 
    2086            0 :                 case RatingType::EuropeanSC5Nom: {
    2087              :                     // N2
    2088            0 :                     NumNum = 2; // advance past rating in W/C to rating in W at N2
    2089            0 :                     if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    2090            0 :                         WarehouseCoil(CoilID).RatedCapTotal = Numbers(NumNum);
    2091            0 :                         WarehouseCoil(CoilID).RatedSensibleCap = Numbers(NumNum) / EuropeanWetCoilFactor[4];
    2092            0 :                         WarehouseCoil(CoilID).SCIndex = 5;
    2093              :                     } else {
    2094            0 :                         ShowSevereError(state,
    2095            0 :                                         format("{}{}=\"{}\", {} must be input and be greater than 0 W",
    2096              :                                                RoutineName,
    2097              :                                                CurrentModuleObject,
    2098            0 :                                                WarehouseCoil(CoilID).Name,
    2099              :                                                cNumericFieldNames(NumNum)));
    2100            0 :                         ErrorsFound = true;
    2101              :                     }
    2102            0 :                 } break;
    2103              : 
    2104            0 :                 default: {
    2105            0 :                 } break;
    2106              :                 }
    2107              :             } // WarehouseCoil(CoilID)%RatingType
    2108              : 
    2109              :             // N4
    2110           83 :             NumNum = 4;
    2111           83 :             if (!lNumericBlanks(NumNum)) {
    2112           83 :                 WarehouseCoil(CoilID).TEvapDesign = Numbers(NumNum); // also used to rep inlet brine T later when add that option
    2113              :             } else {
    2114            0 :                 ShowSevereError(
    2115              :                     state,
    2116            0 :                     format(
    2117            0 :                         "{}{}=\"{}\", {} must be input", RoutineName, CurrentModuleObject, WarehouseCoil(CoilID).Name, cNumericFieldNames(NumNum)));
    2118            0 :                 ErrorsFound = true;
    2119              :             }
    2120              : 
    2121           83 :             ++NumNum; // N5
    2122           83 :             if (!lNumericBlanks(NumNum)) {
    2123           83 :                 WarehouseCoil(CoilID).RatedTemperatureDif = Numbers(NumNum);
    2124              :                 // INLET temperature - evaporating temperature, NOT room temp - evap temp
    2125              :             } else {
    2126            0 :                 ShowSevereError(
    2127              :                     state,
    2128            0 :                     format(
    2129            0 :                         "{}{}=\"{}\", {} must be input", RoutineName, CurrentModuleObject, WarehouseCoil(CoilID).Name, cNumericFieldNames(NumNum)));
    2130            0 :                 ErrorsFound = true;
    2131              :             }
    2132              : 
    2133           83 :             ++NumNum; // N6
    2134           83 :             if (!lNumericBlanks(NumNum)) {
    2135           83 :                 WarehouseCoil(CoilID).MaxTemperatureDif = Numbers(NumNum);
    2136              :                 // Maximum difference between INLET temperature - evaporating temperature, NOT room temp - evap temp
    2137              :                 // Important when cooling down space at start of environment or if large stocking loads imposed.
    2138              :             } else {
    2139            0 :                 WarehouseCoil(CoilID).MaxTemperatureDif = 1.3 * WarehouseCoil(CoilID).RatedTemperatureDif;
    2140            0 :                 ShowWarningError(state,
    2141            0 :                                  format("{}{}=\"{}\", {} not entered, default 1.3 times rated temperature difference will be used.",
    2142              :                                         RoutineName,
    2143              :                                         CurrentModuleObject,
    2144            0 :                                         WarehouseCoil(CoilID).Name,
    2145              :                                         cNumericFieldNames(NumNum)));
    2146              :             }
    2147              : 
    2148              :             // Correction factor from manufacturer's rating for coil material, default 1.0
    2149           83 :             ++NumNum;                                 // N7
    2150           83 :             WarehouseCoil(CoilID).CorrMaterial = 1.0; // default value
    2151           83 :             if (!lNumericBlanks(NumNum)) {
    2152            0 :                 WarehouseCoil(CoilID).CorrMaterial = Numbers(NumNum);
    2153              :             }
    2154              : 
    2155              :             // Correction factor from manufacturer's rating for refrigerant, default 1.0
    2156           83 :             ++NumNum;                                    // N8
    2157           83 :             WarehouseCoil(CoilID).CorrRefrigerant = 1.0; // default value
    2158           83 :             if (!lNumericBlanks(NumNum)) {
    2159            1 :                 WarehouseCoil(CoilID).CorrRefrigerant = Numbers(NumNum);
    2160              :             }
    2161              :             // ONLY used if the Capacity Rating Type is CapacityTotalSpecificConditions
    2162              : 
    2163              :             // Convert all European sensible capacities to sensible load factors
    2164           85 :             if ((WarehouseCoil(CoilID).ratingType != RatingType::UnitLoadFactorSens) &&
    2165            2 :                 (WarehouseCoil(CoilID).ratingType != RatingType::RatedCapacityTotal)) {
    2166            1 :                 WarehouseCoil(CoilID).UnitLoadFactorSens = WarehouseCoil(CoilID).RatedSensibleCap / WarehouseCoil(CoilID).RatedTemperatureDif;
    2167              :             }
    2168              :             // Now have UnitLoadFactorSens for all except RatingType == RatedCapacityTotal
    2169              : 
    2170              :             // Apply material and refrigerant correction factors to sensible load factors
    2171           83 :             if ((WarehouseCoil(CoilID).ratingType != RatingType::RatedCapacityTotal)) {
    2172           82 :                 WarehouseCoil(CoilID).UnitLoadFactorSens *= WarehouseCoil(CoilID).CorrMaterial * WarehouseCoil(CoilID).CorrRefrigerant;
    2173              :             }
    2174              :             // First calc of ratedsensiblecap for type type unitloadfactorsens
    2175           83 :             WarehouseCoil(CoilID).RatedSensibleCap = WarehouseCoil(CoilID).UnitLoadFactorSens * WarehouseCoil(CoilID).RatedTemperatureDif;
    2176              :             // A4    Enter capacity correction curve type
    2177           83 :             AlphaNum = 4;
    2178           83 :             if ((lAlphaBlanks(AlphaNum)) && (WarehouseCoil(CoilID).ratingType != RatingType::RatedCapacityTotal)) {
    2179              :                 // For all except RatedCapacityTotal - default to linear capacity factor approximating Nelson August 2010 ASHRAE journal
    2180            0 :                 WarehouseCoil(CoilID).SHRCorrType = SHRCorrectionType::SHR60;
    2181           83 :             } else if (WarehouseCoil(CoilID).ratingType == RatingType::RatedCapacityTotal) {
    2182              :                 // For RatedCapacityTotal, the manufacturer's coil performance map is required
    2183              :                 // Specify the performance map with TabularRHxDT1xTRoom
    2184            1 :                 WarehouseCoil(CoilID).SHRCorrType = SHRCorrectionType::TabularRH_DT1_TRoom;
    2185            1 :                 if (!(Util::SameString(Alphas(AlphaNum), "TabularRHxDT1xTRoom"))) {
    2186            0 :                     ShowWarningError(state,
    2187            0 :                                      format(R"({}{}="{}", invalid {}="{}".)",
    2188              :                                             RoutineName,
    2189              :                                             CurrentModuleObject,
    2190            0 :                                             WarehouseCoil(CoilID).Name,
    2191              :                                             cAlphaFieldNames(AlphaNum),
    2192              :                                             Alphas(AlphaNum)));
    2193            0 :                     ShowContinueError(state,
    2194              :                                       "The \"CapacityTotalSpecificConditions\" Capacity Rating Type has been specified for this air chiller.  "
    2195              :                                       "This rating type requires ");
    2196            0 :                     ShowContinueError(
    2197              :                         state,
    2198            0 :                         format(
    2199              :                             R"(the "TabularRHxDT1xTRoom" correction curve.  Verify that a valid "TabularRHxDT1xTRoom" curve is specified in "{}".)",
    2200              :                             cAlphaFieldNames(AlphaNum + 1)));
    2201              :                 }
    2202          164 :             } else if ((WarehouseCoil(CoilID).SHRCorrType =
    2203           82 :                             static_cast<SHRCorrectionType>(getEnumValue(shrCorrectionTypeNamesUC, Alphas(AlphaNum)))) == SHRCorrectionType::Invalid) {
    2204            0 :                 ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    2205            0 :                 ErrorsFound = true;
    2206              :             }
    2207              : 
    2208           83 :             ++AlphaNum; // A5
    2209           83 :             ++NumNum;   // N9
    2210           83 :             switch (WarehouseCoil(CoilID).SHRCorrType) {
    2211           81 :             case SHRCorrectionType::SHR60: {
    2212           81 :                 WarehouseCoil(CoilID).SHRCorrection60 = 1.48; // reference Nelson, ASHRAE journal August 2010 Fig 2
    2213           81 :                 if (!lNumericBlanks(NumNum)) {
    2214           81 :                     WarehouseCoil(CoilID).SHRCorrection60 = Numbers(NumNum);
    2215              :                 }
    2216              :                 //(1.66667 would be a perfect effectiveness, 1.0 would be artificial coil that does only sensible)
    2217           81 :                 if (WarehouseCoil(CoilID).SHRCorrection60 > 1.67) {
    2218            0 :                     WarehouseCoil(CoilID).SHRCorrection60 = 1.67;
    2219            0 :                     ShowWarningError(state,
    2220            0 :                                      format("{}{}=\"{}\", {} must be between 1 and 1.67, 1.67 will be used.",
    2221              :                                             RoutineName,
    2222              :                                             CurrentModuleObject,
    2223            0 :                                             WarehouseCoil(CoilID).Name,
    2224              :                                             cNumericFieldNames(NumNum)));
    2225              :                 }
    2226           81 :                 if (WarehouseCoil(CoilID).SHRCorrection60 < 1.0) {
    2227            0 :                     WarehouseCoil(CoilID).SHRCorrection60 = 1.0;
    2228            0 :                     ShowWarningError(state,
    2229            0 :                                      format("{}{}=\"{}\", {} must be between 1 and 1.67, 1.00 will be used.",
    2230              :                                             RoutineName,
    2231              :                                             CurrentModuleObject,
    2232            0 :                                             WarehouseCoil(CoilID).Name,
    2233              :                                             cNumericFieldNames(NumNum)));
    2234              :                 }
    2235           81 :             } break;
    2236            1 :             case SHRCorrectionType::European: {
    2237              :                 // WarehouseCoil(CoilID)%SHRCorrectionCurvePtr = CurveManager::GetCurveIndex(state, 'ChillerEuropeanWetCoilFactor')
    2238              :                 // This is a place holder, currently use embedded constants for European ratings, future may want a curve
    2239            1 :             } break;
    2240            0 :             case SHRCorrectionType::QuadraticSHR: {
    2241            0 :                 if (lAlphaBlanks(AlphaNum)) {
    2242            0 :                     ShowSevereEmptyField(state, eoh, cAlphaFieldNames(AlphaNum));
    2243            0 :                     ErrorsFound = true;
    2244            0 :                 } else if ((WarehouseCoil(CoilID).SHRCorrectionCurvePtr = Curve::GetCurveIndex(state, Alphas(AlphaNum))) == 0) {
    2245            0 :                     ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    2246            0 :                     ErrorsFound = true;
    2247              :                 }
    2248              :                 // error checks for curve type entered and curve name
    2249            0 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    2250            0 :                                                      WarehouseCoil(CoilID).SHRCorrectionCurvePtr, // Curve index
    2251              :                                                      {1},                                         // Valid dimensions
    2252              :                                                      RoutineName,                                 // Routine name
    2253              :                                                      CurrentModuleObject,                         // Object Type
    2254            0 :                                                      WarehouseCoil(CoilID).Name,                  // Object Name
    2255            0 :                                                      cAlphaFieldNames(AlphaNum));                 // Field Name
    2256            0 :             } break;
    2257            1 :             case SHRCorrectionType::TabularRH_DT1_TRoom: {
    2258            1 :                 WarehouseCoil(CoilID).SHRCorrectionCurvePtr = Curve::GetCurveIndex(state, Alphas(AlphaNum)); // convert curve name to number
    2259            1 :                 if (lAlphaBlanks(AlphaNum)) {
    2260            0 :                     ShowSevereError(state,
    2261            0 :                                     format("{}{}=\"{}\", invalid  {} is blank, required.",
    2262              :                                            RoutineName,
    2263              :                                            CurrentModuleObject,
    2264            0 :                                            WarehouseCoil(CoilID).Name,
    2265              :                                            cAlphaFieldNames(AlphaNum)));
    2266            0 :                     ErrorsFound = true;
    2267            1 :                 } else if (WarehouseCoil(CoilID).SHRCorrectionCurvePtr == 0) {
    2268            0 :                     ShowSevereError(state, format("{}{}=\"{}\", invalid  ", RoutineName, CurrentModuleObject, WarehouseCoil(CoilID).Name));
    2269            0 :                     ShowContinueError(state, format("...invalid curve {}=\"{}\".", cAlphaFieldNames(AlphaNum), Alphas(AlphaNum)));
    2270            0 :                     ErrorsFound = true;
    2271              :                 }
    2272            3 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    2273            1 :                                                      WarehouseCoil(CoilID).SHRCorrectionCurvePtr, // Curve index
    2274              :                                                      {3},                                         // Valid dimensions
    2275              :                                                      RoutineName,                                 // Routine name
    2276              :                                                      CurrentModuleObject,                         // Object Type
    2277            1 :                                                      WarehouseCoil(CoilID).Name,                  // Object Name
    2278            1 :                                                      cAlphaFieldNames(AlphaNum));                 // Field Name
    2279              :                 //        IF(WarehouseCoil(CoilID)%SHRCorrectionCurvePtr == 0) THEN
    2280              :                 //          CALL ShowSevereError(state, RoutineName//TRIM(CurrentModuleObject)//'="'//TRIM(WarehouseCoil(CoilID)%Name)//&
    2281              :                 //                           '", not found  '//TRIM(cAlphaFieldNames(AlphaNum)))
    2282              :                 //          ErrorsFound = .TRUE.
    2283              :                 //        END IF !valid table name
    2284            1 :             } break;
    2285            0 :             default:
    2286            0 :                 break;
    2287              :             } // SHRCorrectionType
    2288              : 
    2289           83 :             ++NumNum; // N10
    2290           83 :             if (!lNumericBlanks(NumNum)) {
    2291           83 :                 WarehouseCoil(CoilID).HeaterPower = Numbers(NumNum);
    2292              :             } else {
    2293            0 :                 ShowSevereEmptyField(state, eoh, cNumericFieldNames(NumNum));
    2294            0 :                 ErrorsFound = true;
    2295              :             }
    2296              : 
    2297           83 :             ++AlphaNum; // A6
    2298           83 :             if (lAlphaBlanks(AlphaNum)) {
    2299            0 :                 WarehouseCoil(CoilID).heaterAvailSched = Sched::GetScheduleAlwaysOn(state);
    2300           83 :             } else if ((WarehouseCoil(CoilID).heaterAvailSched = Sched::GetSchedule(state, Alphas(AlphaNum))) == nullptr) {
    2301            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    2302            0 :                 ErrorsFound = true;
    2303           83 :             } else if (!WarehouseCoil(CoilID).heaterAvailSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) {
    2304            0 :                 Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum), Clusive::In, 0.0, Clusive::In, 1.0);
    2305            0 :                 ErrorsFound = true;
    2306              :             }
    2307              : 
    2308              :             // Input fan control type
    2309           83 :             ++AlphaNum; // A7
    2310           83 :             if (lAlphaBlanks(AlphaNum)) {
    2311           83 :                 WarehouseCoil(CoilID).FanType = FanSpeedCtrlType::ConstantSpeed;
    2312            0 :             } else if ((WarehouseCoil(CoilID).FanType = static_cast<FanSpeedCtrlType>(getEnumValue(fanSpeedCtrlTypeNamesUC, Alphas(AlphaNum)))) ==
    2313              :                        FanSpeedCtrlType::Invalid) {
    2314            0 :                 ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    2315            0 :                 ErrorsFound = true;
    2316              :             } // fan control type
    2317              : 
    2318           83 :             ++NumNum; // N11
    2319           83 :             if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    2320           83 :                 WarehouseCoil(CoilID).RatedFanPower = Numbers(NumNum);
    2321              :             } else {
    2322            0 :                 ShowSevereError(state,
    2323            0 :                                 format("{}{}=\"{}\", {} was not input or was less than 0 ",
    2324              :                                        RoutineName,
    2325              :                                        CurrentModuleObject,
    2326            0 :                                        WarehouseCoil(CoilID).Name,
    2327              :                                        cNumericFieldNames(NumNum)));
    2328            0 :                 ErrorsFound = true;
    2329              :             } // coil fan power
    2330              : 
    2331           83 :             ++NumNum; // N12
    2332           83 :             if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    2333           83 :                 WarehouseCoil(CoilID).RatedAirVolumeFlow = Numbers(NumNum);
    2334              :             } else {
    2335            0 :                 ShowSevereError(state,
    2336            0 :                                 format("{}{}=\"{}\", {} is required and was not input or was less than 0  ",
    2337              :                                        RoutineName,
    2338              :                                        CurrentModuleObject,
    2339            0 :                                        WarehouseCoil(CoilID).Name,
    2340              :                                        cNumericFieldNames(NumNum)));
    2341              :             } // air volume flow
    2342              : 
    2343           83 :             ++NumNum;                                       // N13
    2344           83 :             WarehouseCoil(CoilID).FanMinAirFlowRatio = 0.2; // default value
    2345           83 :             if (!lNumericBlanks(NumNum) && Numbers(NumNum) > 0.0) {
    2346            0 :                 WarehouseCoil(CoilID).FanMinAirFlowRatio = Numbers(NumNum);
    2347              :             }
    2348              : 
    2349              :             // Input defrost type
    2350           83 :             ++AlphaNum; // A8
    2351           83 :             if (lAlphaBlanks(AlphaNum)) {
    2352            0 :                 WarehouseCoil(CoilID).defrostType = DefrostType::Elec;
    2353           83 :             } else if ((WarehouseCoil(CoilID).defrostType = static_cast<DefrostType>(getEnumValue(defrostTypeNamesUC, Alphas(AlphaNum)))) ==
    2354              :                        DefrostType::Invalid) {
    2355            0 :                 ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    2356            0 :                 ErrorsFound = true;
    2357              :             } // defrost type
    2358              : 
    2359           83 :             ++AlphaNum; // A9
    2360           83 :             if (lAlphaBlanks(AlphaNum)) {
    2361           16 :                 WarehouseCoil(CoilID).DefrostControlType = DefrostCtrlType::Sched;
    2362          134 :             } else if ((WarehouseCoil(CoilID).DefrostControlType =
    2363           67 :                             static_cast<DefrostCtrlType>(getEnumValue(defrostCtrlTypeNamesUC, Alphas(AlphaNum)))) == DefrostCtrlType::Invalid) {
    2364            0 :                 ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    2365            0 :                 ErrorsFound = true;
    2366              :             } // defrost control type
    2367              : 
    2368              :             // convert defrost schedule name to pointer
    2369           83 :             ++AlphaNum; // A10
    2370           83 :             if (lAlphaBlanks(AlphaNum)) {
    2371            0 :                 ShowSevereEmptyField(state, eoh, cAlphaFieldNames(AlphaNum));
    2372            0 :                 ErrorsFound = true;
    2373           83 :             } else if ((WarehouseCoil(CoilID).defrostSched = Sched::GetSchedule(state, Alphas(AlphaNum))) == nullptr) {
    2374            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    2375            0 :                 ErrorsFound = true;
    2376           83 :             } else if (!WarehouseCoil(CoilID).defrostSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) {
    2377            0 :                 Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum), Clusive::In, 0.0, Clusive::In, 1.0);
    2378            0 :                 ErrorsFound = true;
    2379              :             } // check for valid schedule name
    2380              : 
    2381              :             // convert defrost drip-down schedule name to pointer
    2382              :             // some defrost types do not use drip-down schedules, use same defrost schedule pointer in that case
    2383           83 :             ++AlphaNum; // A11
    2384           83 :             if (lAlphaBlanks(AlphaNum)) {
    2385            0 :                 WarehouseCoil(CoilID).defrostDripDownSched = WarehouseCoil(CoilID).defrostSched;
    2386           83 :             } else if ((WarehouseCoil(CoilID).defrostDripDownSched = Sched::GetSchedule(state, Alphas(AlphaNum))) == nullptr) {
    2387            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    2388            0 :                 ErrorsFound = true;
    2389           83 :             } else if (!WarehouseCoil(CoilID).defrostDripDownSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) {
    2390            0 :                 Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum), Clusive::In, 0.0, Clusive::In, 1.0);
    2391            0 :                 ErrorsFound = true;
    2392              :             } // check for valid schedule name
    2393              : 
    2394           83 :             ++NumNum; // N14
    2395           83 :             if (WarehouseCoil(CoilID).defrostType == DefrostType::OffCycle || WarehouseCoil(CoilID).defrostType == DefrostType::None) {
    2396            0 :                 WarehouseCoil(CoilID).DefrostCapacity = 0.0;
    2397              :                 // Don't even need to read Defrost capacity for those two defrost types.
    2398              :             } else { // have electric or hot gas/brine defrost
    2399           83 :                 if ((lNumericBlanks(NumNum)) || (Numbers(NumNum) <= 0.0)) {
    2400            0 :                     ShowSevereError(state,
    2401            0 :                                     format("{}{}=\"{}\", {} must be input and greater than or equal to 0 W for {} {}",
    2402              :                                            RoutineName,
    2403              :                                            CurrentModuleObject,
    2404            0 :                                            WarehouseCoil(CoilID).Name,
    2405              :                                            cNumericFieldNames(NumNum),
    2406              :                                            cAlphaFieldNames(AlphaNum),
    2407              :                                            Alphas(AlphaNum)));
    2408            0 :                     ErrorsFound = true;
    2409              :                 } else {
    2410           83 :                     WarehouseCoil(CoilID).DefrostCapacity = Numbers(NumNum);
    2411              :                 } // Blank  or negative Defrost Capacity
    2412              : 
    2413              :                 // defaults for defrost energy fraction are 0.7 for elec defrost and 0.3 for warm fluid
    2414              :                 // note this value is only used for temperature terminated defrost control type
    2415           83 :                 if (WarehouseCoil(CoilID).defrostType == DefrostType::Elec) {
    2416           82 :                     WarehouseCoil(CoilID).DefEnergyFraction = 0.7;
    2417              :                 }
    2418           83 :                 if (WarehouseCoil(CoilID).defrostType == DefrostType::Fluid) {
    2419            1 :                     WarehouseCoil(CoilID).DefEnergyFraction = 0.3;
    2420              :                 }
    2421              : 
    2422           83 :                 ++NumNum; // N15
    2423           83 :                 if (!lNumericBlanks(NumNum)) {
    2424            1 :                     if ((Numbers(NumNum) > 1.0) || (Numbers(NumNum) < 0.0)) {
    2425            0 :                         ShowWarningError(state,
    2426            0 :                                          format("{}{}=\"{}\", {} must be between 0 and 1, default values will be used.",
    2427              :                                                 RoutineName,
    2428              :                                                 CurrentModuleObject,
    2429            0 :                                                 WarehouseCoil(CoilID).Name,
    2430              :                                                 cNumericFieldNames(NumNum)));
    2431              :                     } else {
    2432            1 :                         WarehouseCoil(CoilID).DefEnergyFraction = Numbers(NumNum);
    2433              :                     } // number out of range
    2434              :                 } // lnumericblanks
    2435              :             } // defrost type
    2436              : 
    2437           83 :             ++AlphaNum; // A12
    2438           83 :             if (lAlphaBlanks(AlphaNum)) {
    2439           83 :                 WarehouseCoil(CoilID).VerticalLocation = VerticalLoc::Middle; // default position
    2440            0 :             } else if ((WarehouseCoil(CoilID).VerticalLocation = static_cast<VerticalLoc>(getEnumValue(verticalLocNamesUC, Alphas(AlphaNum)))) ==
    2441              :                        VerticalLoc::Invalid) {
    2442            0 :                 ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    2443            0 :                 ErrorsFound = true;
    2444              :             } // Vertical location class
    2445              : 
    2446           83 :             ++NumNum; // N16
    2447           83 :             WarehouseCoil(CoilID).DesignRefrigInventory = 0.0;
    2448           83 :             if (!lNumericBlanks(NumNum)) {
    2449            0 :                 WarehouseCoil(CoilID).DesignRefrigInventory = Numbers(NumNum);
    2450              :             }
    2451              :         } // NumRefrigAirChillers
    2452              :     } // NumRefrigerationAirChillers > 0
    2453              : 
    2454              :     //************ START Warehouse Coil SET INPUT **************
    2455              :     // One Set allowed per zone, but indiv coils within zone can be served by different compressor/condenser systems
    2456              : 
    2457          801 :     if (state.dataRefrigCase->NumRefrigChillerSets > 0) {
    2458              : 
    2459            1 :         state.dataRefrigCase->CheckChillerSetName.dimension(state.dataRefrigCase->NumRefrigChillerSets, true);
    2460              : 
    2461            1 :         CurrentModuleObject = "ZoneHVAC:RefrigerationChillerSet";
    2462           11 :         for (int SetID = 1; SetID <= state.dataRefrigCase->NumRefrigChillerSets; ++SetID) {
    2463           10 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
    2464              :                                                                      CurrentModuleObject,
    2465              :                                                                      SetID,
    2466              :                                                                      Alphas,
    2467              :                                                                      NumAlphas,
    2468              :                                                                      Numbers,
    2469              :                                                                      NumNumbers,
    2470              :                                                                      IOStatus,
    2471              :                                                                      lNumericBlanks,
    2472              :                                                                      lAlphaBlanks,
    2473              :                                                                      cAlphaFieldNames,
    2474              :                                                                      cNumericFieldNames);
    2475              : 
    2476           10 :             ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
    2477              : 
    2478           10 :             AlphaNum = 1;
    2479           10 :             Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    2480              : 
    2481           10 :             AirChillerSet(SetID).Name = Alphas(AlphaNum);
    2482              : 
    2483           10 :             AlphaNum = 2;
    2484           10 :             if (lAlphaBlanks(AlphaNum)) {
    2485           10 :                 AirChillerSet(SetID).availSched = Sched::GetScheduleAlwaysOn(state);
    2486            0 :             } else if ((AirChillerSet(SetID).availSched = Sched::GetSchedule(state, Alphas(AlphaNum))) == nullptr) {
    2487            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    2488            0 :                 ErrorsFound = true;
    2489            0 :             } else if (!AirChillerSet(SetID).availSched->checkMinMaxVals(state, Clusive::In, 0.0, Clusive::In, 1.0)) {
    2490            0 :                 Sched::ShowSevereBadMinMax(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum), Clusive::In, 0.0, Clusive::In, 1.0);
    2491            0 :                 ErrorsFound = true;
    2492              :             }
    2493              : 
    2494           10 :             ++AlphaNum;
    2495           10 :             AirChillerSet(SetID).ZoneName = Alphas(AlphaNum);
    2496           10 :             AirChillerSet(SetID).ZoneNum = Util::FindItemInList(Alphas(AlphaNum), state.dataHeatBal->Zone);
    2497              : 
    2498           10 :             if (AirChillerSet(SetID).ZoneNum == 0) {
    2499            0 :                 ShowSevereError(state,
    2500            0 :                                 format("{}{}=\"{}\", invalid  {} not valid: {}",
    2501              :                                        RoutineName,
    2502              :                                        CurrentModuleObject,
    2503            0 :                                        AirChillerSet(SetID).Name,
    2504              :                                        cAlphaFieldNames(AlphaNum),
    2505              :                                        Alphas(AlphaNum)));
    2506            0 :                 ErrorsFound = true;
    2507              :             }
    2508           10 :             AirChillerSet(SetID).ZoneNodeNum = DataZoneEquipment::GetSystemNodeNumberForZone(state, AirChillerSet(SetID).ZoneNum);
    2509           10 :             if (AirChillerSet(SetID).ZoneNodeNum == 0) {
    2510            0 :                 ShowSevereError(state,
    2511            0 :                                 format("{}{}=\"{}\" System Node Number not found for {} = {}",
    2512              :                                        RoutineName,
    2513              :                                        CurrentModuleObject,
    2514            0 :                                        AirChillerSet(SetID).Name,
    2515              :                                        cAlphaFieldNames(AlphaNum),
    2516              :                                        Alphas(AlphaNum)));
    2517            0 :                 ShowContinueError(state,
    2518              :                                   ".. Refrigeration chillers must reference a controlled Zone (appear in a ZoneHVAC:EquipmentConnections object.");
    2519            0 :                 ErrorsFound = true;
    2520              :             }
    2521           10 :             state.dataRefrigCase->RefrigPresentInZone(AirChillerSet(SetID).ZoneNum) = true;
    2522              : 
    2523           10 :             ++AlphaNum;
    2524           10 :             if (!lAlphaBlanks(AlphaNum)) {
    2525            0 :                 ShowMessage(state,
    2526            0 :                             format("{}{}=\"{}\" {} is not used. This is not an error.  Energy is exchanged directly with the zone independent of "
    2527              :                                    "any air system. ",
    2528              :                                    RoutineName,
    2529              :                                    CurrentModuleObject,
    2530            0 :                                    AirChillerSet(SetID).Name,
    2531              :                                    cAlphaFieldNames(AlphaNum)));
    2532              :                 // Node identification reserved for future use.  Currently exchange energy directly with zone outside any air system
    2533              :                 // AirChillerSet(SetID)%NodeNumInlet = &
    2534              :                 //       NodeInputManager::GetOnlySingleNode(state, Alphas(AlphaNum),ErrorsFound,TRIM(CurrentModuleObject), &
    2535              :                 //                    AirChillerSet(SetID)%Name,DataLoopNode::NodeFluidType::Air,DataLoopNode::NodeConnectionType::Inlet,1,DataLoopNode::ObjectIsNotParent)
    2536              :             }
    2537              : 
    2538           10 :             ++AlphaNum;
    2539           10 :             if (!lAlphaBlanks(AlphaNum)) {
    2540            0 :                 ShowMessage(state,
    2541            0 :                             format("{}{}=\"{}\" {} is not used. This is not an error.  Energy is exchanged directly with the zone independent of "
    2542              :                                    "any air system. ",
    2543              :                                    RoutineName,
    2544              :                                    CurrentModuleObject,
    2545            0 :                                    AirChillerSet(SetID).Name,
    2546              :                                    cAlphaFieldNames(AlphaNum)));
    2547              :                 // Node identification reserved for future use.  Currently exchange energy directly with zone outside any air system
    2548              :                 // AirChillerSet(SetID)%NodeNumOutlet = &
    2549              :                 //         NodeInputManager::GetOnlySingleNode(state, Alphas(AlphaNum),ErrorsFound,TRIM(CurrentModuleObject), &
    2550              :                 //                      AirChillerSet(SetID)%Name,DataLoopNode::NodeFluidType::Air,DataLoopNode::NodeConnectionType::Outlet,1,DataLoopNode::ObjectIsNotParent)
    2551              :             }
    2552              : 
    2553              :             // An extensible list is used to enter the individual names of each chiller in the set.
    2554              :             // These chillers will be dispatched in this list order to meet the required zone load
    2555           10 :             int NumChillersInSet = NumAlphas - AlphaNum;
    2556           10 :             int AlphaStartList = AlphaNum; //+ 1
    2557           10 :             AirChillerSet(SetID).NumCoils = NumChillersInSet;
    2558           10 :             if (!allocated(AirChillerSet(SetID).CoilNum)) {
    2559           10 :                 AirChillerSet(SetID).CoilNum.allocate(NumChillersInSet);
    2560              :             }
    2561           93 :             for (int ChillerIndex = 1; ChillerIndex <= NumChillersInSet; ++ChillerIndex) {
    2562           83 :                 int AlphaListNum = AlphaStartList + ChillerIndex;
    2563           83 :                 if (!lAlphaBlanks(AlphaListNum)) {
    2564           83 :                     int CoilNum = Util::FindItemInList(Alphas(AlphaListNum), WarehouseCoil);
    2565           83 :                     if (CoilNum == 0) {
    2566            0 :                         ShowSevereError(state,
    2567            0 :                                         format("{}{}=\"{}\", has an invalid {} defined as {}",
    2568              :                                                RoutineName,
    2569              :                                                CurrentModuleObject,
    2570            0 :                                                AirChillerSet(SetID).Name,
    2571              :                                                cAlphaFieldNames(AlphaListNum),
    2572              :                                                Alphas(AlphaListNum)));
    2573            0 :                         ErrorsFound = true;
    2574              :                     } // == 0
    2575           83 :                     AirChillerSet(SetID).CoilNum(ChillerIndex) = CoilNum;
    2576           83 :                     WarehouseCoil(CoilNum).ZoneName = AirChillerSet(SetID).ZoneName;
    2577           83 :                     WarehouseCoil(CoilNum).ZoneNum = AirChillerSet(SetID).ZoneNum;
    2578           83 :                     WarehouseCoil(CoilNum).ZoneNodeNum = AirChillerSet(SetID).ZoneNodeNum;
    2579              :                 } // ! = alphablanks
    2580              :             } // CoilID over NumChillersInSet
    2581              :         } // NumChillerSets
    2582              :     } // NumChillerSets > 0
    2583              :     //************* End Air Chiller Sets
    2584              : 
    2585              :     //**** Read CaseAndWalkIn Lists **********************************************************
    2586          801 :     if (state.dataRefrigCase->NumSimulationCaseAndWalkInLists > 0) {
    2587           28 :         CurrentModuleObject = "Refrigeration:CaseAndWalkInList";
    2588           92 :         for (int ListNum = 1; ListNum <= state.dataRefrigCase->NumSimulationCaseAndWalkInLists; ++ListNum) {
    2589           64 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
    2590              :                                                                      CurrentModuleObject,
    2591              :                                                                      ListNum,
    2592              :                                                                      Alphas,
    2593              :                                                                      NumAlphas,
    2594              :                                                                      Numbers,
    2595              :                                                                      NumNumbers,
    2596              :                                                                      IOStatus,
    2597              :                                                                      lNumericBlanks,
    2598              :                                                                      lAlphaBlanks,
    2599              :                                                                      cAlphaFieldNames,
    2600              :                                                                      cNumericFieldNames);
    2601           64 :             Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    2602           64 :             CaseAndWalkInList(ListNum).Name = Alphas(1);
    2603              : 
    2604              :             // CaseAndWalkInList alphas include CaseAndWalkInList name and one name for each Case or WalkIn in list
    2605              :             // below allocates larger than needed (each allocated to sum of both), but avoids two loops through input fields
    2606           64 :             int NumTotalLoadsOnList = NumAlphas - 1;
    2607           64 :             if (!allocated(CaseAndWalkInList(ListNum).WalkInItemNum)) {
    2608           64 :                 CaseAndWalkInList(ListNum).WalkInItemNum.allocate(NumTotalLoadsOnList);
    2609              :             }
    2610           64 :             if (!allocated(CaseAndWalkInList(ListNum).CaseItemNum)) {
    2611           64 :                 CaseAndWalkInList(ListNum).CaseItemNum.allocate(NumTotalLoadsOnList);
    2612              :             }
    2613           64 :             if (!allocated(CaseAndWalkInList(ListNum).CoilItemNum)) {
    2614           64 :                 CaseAndWalkInList(ListNum).CoilItemNum.allocate(NumTotalLoadsOnList);
    2615              :             }
    2616              : 
    2617           64 :             int NumCasesOnList = 0;
    2618           64 :             int NumCoilsOnList = 0;
    2619           64 :             int NumWalkInsOnList = 0;
    2620           64 :             int LoadCount = 0;
    2621          315 :             for (int NumLoad = 1; NumLoad <= NumTotalLoadsOnList; ++NumLoad) {
    2622          251 :                 int AlphaListNum = 1 + NumLoad;
    2623          251 :                 if (!lAlphaBlanks(AlphaListNum)) {
    2624          251 :                     ++LoadCount;
    2625          251 :                     int LoadWalkInNum = 0;
    2626          251 :                     int LoadCaseNum = 0;
    2627          251 :                     int LoadCoilNum = 0;
    2628          251 :                     if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
    2629          106 :                         LoadWalkInNum = Util::FindItemInList(Alphas(AlphaListNum), WalkIn);
    2630              :                     }
    2631          251 :                     if (state.dataRefrigCase->NumSimulationCases > 0) {
    2632          168 :                         LoadCaseNum = Util::FindItemInList(Alphas(AlphaListNum), RefrigCase);
    2633              :                     }
    2634          251 :                     if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0) {
    2635           83 :                         LoadCoilNum = Util::FindItemInList(Alphas(AlphaListNum), WarehouseCoil);
    2636              :                     }
    2637          251 :                     if ((LoadWalkInNum == 0) && (LoadCaseNum == 0) && (LoadCoilNum == 0)) {
    2638            0 :                         ShowSevereError(state,
    2639            0 :                                         format("{}{}=\"{}\", has an invalid value of {}",
    2640              :                                                RoutineName,
    2641              :                                                CurrentModuleObject,
    2642              :                                                cAlphaFieldNames(AlphaListNum),
    2643              :                                                Alphas(AlphaListNum)));
    2644            0 :                         ErrorsFound = true;
    2645          251 :                     } else if ((LoadWalkInNum != 0) && (LoadCaseNum != 0) && (LoadCoilNum != 0)) {
    2646            0 :                         ShowSevereError(state,
    2647            0 :                                         format("{}{}=\"{}\", {} Case and WalkIns and Refrigerated Coils cannot have the same name.",
    2648              :                                                RoutineName,
    2649              :                                                CurrentModuleObject,
    2650              :                                                cAlphaFieldNames(AlphaListNum),
    2651              :                                                Alphas(AlphaListNum)));
    2652            0 :                         ErrorsFound = true;
    2653          251 :                     } else if (LoadWalkInNum != 0) {
    2654           17 :                         ++NumWalkInsOnList;
    2655           17 :                         CaseAndWalkInList(ListNum).WalkInItemNum(NumWalkInsOnList) = LoadWalkInNum;
    2656          234 :                     } else if (LoadCaseNum != 0) {
    2657          151 :                         ++NumCasesOnList;
    2658          151 :                         CaseAndWalkInList(ListNum).CaseItemNum(NumCasesOnList) = LoadCaseNum;
    2659           83 :                     } else if (LoadCoilNum != 0) {
    2660           83 :                         ++NumCoilsOnList;
    2661           83 :                         CaseAndWalkInList(ListNum).CoilItemNum(NumCoilsOnList) = LoadCoilNum;
    2662              :                     }
    2663              :                 } // lAlphaBlanks
    2664              :             } // Num Total Loads on List
    2665           64 :             if (LoadCount == 0) {
    2666            0 :                 ShowSevereError(
    2667              :                     state,
    2668            0 :                     format(
    2669            0 :                         "{}{}, \"{}\" : degenerate list All entries were blank.", RoutineName, CurrentModuleObject, CaseAndWalkInList(ListNum).Name));
    2670            0 :                 ErrorsFound = true;
    2671              :             } // loadcount == 0
    2672           64 :             CaseAndWalkInList(ListNum).NumCases = NumCasesOnList;
    2673           64 :             CaseAndWalkInList(ListNum).NumCoils = NumCoilsOnList;
    2674           64 :             CaseAndWalkInList(ListNum).NumWalkIns = NumWalkInsOnList;
    2675              :         } // ListNum=1,NumSimulationCaseAndWalkInLists
    2676              :     } //(NumSimulationCaseAndWalkInLists > 0)
    2677              : 
    2678              :     //**** End read CaseAndWalkIn Lists **********************************************************
    2679              : 
    2680              :     //************** Start RefrigerationRacks
    2681              : 
    2682          801 :     if (state.dataRefrigCase->NumRefrigeratedRacks > 0) {
    2683              : 
    2684           31 :         CurrentModuleObject = "Refrigeration:CompressorRack";
    2685              : 
    2686           92 :         for (int RackNum = 1; RackNum <= state.dataRefrigCase->NumRefrigeratedRacks; ++RackNum) {
    2687              : 
    2688           61 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
    2689              :                                                                      CurrentModuleObject,
    2690              :                                                                      RackNum,
    2691              :                                                                      Alphas,
    2692              :                                                                      NumAlphas,
    2693              :                                                                      Numbers,
    2694              :                                                                      NumNumbers,
    2695              :                                                                      IOStatus,
    2696              :                                                                      lNumericBlanks,
    2697              :                                                                      lAlphaBlanks,
    2698              :                                                                      cAlphaFieldNames,
    2699              :                                                                      cNumericFieldNames);
    2700              : 
    2701           61 :             ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
    2702           61 :             Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    2703              : 
    2704           61 :             RefrigRack(RackNum).Name = Alphas(1);
    2705           61 :             RefrigRack(RackNum).MyIdx = RackNum;
    2706           61 :             state.dataHeatBal->HeatReclaimRefrigeratedRack(RackNum).Name = Alphas(1);
    2707           61 :             state.dataHeatBal->HeatReclaimRefrigeratedRack(RackNum).SourceType = CurrentModuleObject;
    2708              : 
    2709           61 :             if (lAlphaBlanks(2)) {
    2710            0 :                 RefrigRack(RackNum).HeatRejectionLocation = HeatRejLocation::Outdoors;
    2711           61 :             } else if ((RefrigRack(RackNum).HeatRejectionLocation = static_cast<HeatRejLocation>(getEnumValue(heatRejLocationNamesUC, Alphas(2)))) ==
    2712              :                        HeatRejLocation::Invalid) {
    2713            0 :                 RefrigRack(RackNum).HeatRejectionLocation = HeatRejLocation::Outdoors;
    2714            0 :                 ShowWarningInvalidKey(state, eoh, cAlphaFieldNames(2), Alphas(2), "Outdoors");
    2715              :             }
    2716              : 
    2717           61 :             RefrigRack(RackNum).RatedCOP = Numbers(1);
    2718              : 
    2719           61 :             if (RefrigRack(RackNum).RatedCOP <= 0.0) {
    2720            0 :                 ShowSevereError(state,
    2721            0 :                                 format("{}{}=\"{}\" {} must be greater than 0.0",
    2722              :                                        RoutineName,
    2723              :                                        CurrentModuleObject,
    2724            0 :                                        RefrigRack(RackNum).Name,
    2725              :                                        cNumericFieldNames(1)));
    2726            0 :                 ErrorsFound = true;
    2727              :             }
    2728              : 
    2729           61 :             RefrigRack(RackNum).COPFTempPtr = Curve::GetCurveIndex(state, Alphas(3)); // convert curve name to number
    2730           61 :             if (RefrigRack(RackNum).COPFTempPtr == 0) {
    2731            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(3), Alphas(3));
    2732            0 :                 ErrorsFound = true;
    2733              :             }
    2734              : 
    2735          183 :             ErrorsFound |= Curve::CheckCurveDims(state,
    2736           61 :                                                  RefrigRack(RackNum).COPFTempPtr, // Curve index
    2737              :                                                  {1},                             // Valid dimensions
    2738              :                                                  RoutineName,                     // Routine name
    2739              :                                                  CurrentModuleObject,             // Object Type
    2740           61 :                                                  RefrigRack(RackNum).Name,        // Object Name
    2741           61 :                                                  cAlphaFieldNames(3));            // Field Name
    2742              : 
    2743           61 :             RefrigRack(RackNum).CondenserFanPower = Numbers(2);
    2744           61 :             if (Numbers(2) < 0.0) {
    2745            0 :                 ShowSevereError(state,
    2746            0 :                                 format("{}{}=\"{}\" {} must be greater than or equal to 0 Watts.",
    2747              :                                        RoutineName,
    2748              :                                        CurrentModuleObject,
    2749            0 :                                        RefrigRack(RackNum).Name,
    2750              :                                        cNumericFieldNames(2)));
    2751            0 :                 ErrorsFound = true;
    2752              :             }
    2753              : 
    2754           61 :             RefrigRack(RackNum).TotCondFTempPtr = Curve::GetCurveIndex(state, Alphas(4)); // convert curve name to number
    2755           61 :             if ((!lAlphaBlanks(4)) && RefrigRack(RackNum).TotCondFTempPtr == 0) {
    2756            0 :                 ShowSevereError(state,
    2757            0 :                                 format("{}{}=\"{}\", invalid  {} not found:{}",
    2758              :                                        RoutineName,
    2759              :                                        CurrentModuleObject,
    2760            0 :                                        RefrigRack(RackNum).Name,
    2761              :                                        cAlphaFieldNames(4),
    2762              :                                        Alphas(4)));
    2763            0 :                 ErrorsFound = true;
    2764              :             }
    2765              : 
    2766           61 :             if (!lAlphaBlanks(4)) {
    2767          124 :                 ErrorsFound |= Curve::CheckCurveDims(state,
    2768           31 :                                                      RefrigRack(RackNum).TotCondFTempPtr, // Curve index
    2769              :                                                      {1},                                 // Valid dimensions
    2770              :                                                      RoutineName,                         // Routine name
    2771              :                                                      CurrentModuleObject,                 // Object Type
    2772           31 :                                                      RefrigRack(RackNum).Name,            // Object Name
    2773           31 :                                                      cAlphaFieldNames(4));                // Field Name
    2774              :             }
    2775              : 
    2776           61 :             if (lAlphaBlanks(5)) {
    2777            0 :                 RefrigRack(RackNum).CondenserType = DataHeatBalance::RefrigCondenserType::Air;
    2778          122 :             } else if ((RefrigRack(RackNum).CondenserType = static_cast<DataHeatBalance::RefrigCondenserType>(
    2779           61 :                             getEnumValue(DataHeatBalance::refrigCondenserTypeNamesUC, Alphas(5)))) == DataHeatBalance::RefrigCondenserType::Invalid) {
    2780            0 :                 ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(5), Alphas(5));
    2781            0 :                 ErrorsFound = true;
    2782          120 :             } else if (RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::Evap ||
    2783           59 :                        RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
    2784            3 :                 if (RefrigRack(RackNum).HeatRejectionLocation == HeatRejLocation::Zone) {
    2785            0 :                     ShowWarningError(state,
    2786            0 :                                      format("{}=\"{}\" {}=\"{}\" not available with {} = Zone.",
    2787              :                                             CurrentModuleObject,
    2788            0 :                                             RefrigRack(RackNum).Name,
    2789              :                                             cAlphaFieldNames(5),
    2790              :                                             Alphas(5),
    2791              :                                             cAlphaFieldNames(2)));
    2792            0 :                     ShowContinueError(state, format("{} reset to Air Cooled and simulation continues.", cAlphaFieldNames(5)));
    2793            0 :                     RefrigRack(RackNum).CondenserType = DataHeatBalance::RefrigCondenserType::Air;
    2794              :                 }
    2795          116 :             } else if (RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::Cascade ||
    2796           58 :                        RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::WaterHeater) {
    2797            0 :                 ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(5), Alphas(5));
    2798            0 :                 ErrorsFound = true;
    2799              :             }
    2800              :             // Get water-cooled condenser input, if applicable
    2801           61 :             if (RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
    2802            2 :                 RefrigRack(RackNum).InletNode = NodeInputManager::GetOnlySingleNode(state,
    2803            1 :                                                                                     Alphas(6),
    2804              :                                                                                     ErrorsFound,
    2805              :                                                                                     DataLoopNode::ConnectionObjectType::RefrigerationCompressorRack,
    2806            1 :                                                                                     Alphas(1),
    2807              :                                                                                     DataLoopNode::NodeFluidType::Water,
    2808              :                                                                                     DataLoopNode::ConnectionType::Inlet,
    2809              :                                                                                     NodeInputManager::CompFluidStream::Primary,
    2810              :                                                                                     DataLoopNode::ObjectIsNotParent);
    2811            2 :                 RefrigRack(RackNum).OutletNode = NodeInputManager::GetOnlySingleNode(state,
    2812            1 :                                                                                      Alphas(7),
    2813              :                                                                                      ErrorsFound,
    2814              :                                                                                      DataLoopNode::ConnectionObjectType::RefrigerationCompressorRack,
    2815            1 :                                                                                      Alphas(1),
    2816              :                                                                                      DataLoopNode::NodeFluidType::Water,
    2817              :                                                                                      DataLoopNode::ConnectionType::Outlet,
    2818              :                                                                                      NodeInputManager::CompFluidStream::Primary,
    2819              :                                                                                      DataLoopNode::ObjectIsNotParent);
    2820              :                 // Check node connections
    2821            1 :                 BranchNodeConnections::TestCompSet(state, CurrentModuleObject, Alphas(1), Alphas(6), Alphas(7), "RefrigRack Nodes");
    2822              :                 // Get loop flow type
    2823            1 :                 if ((RefrigRack(RackNum).FlowType = static_cast<CndsrFlowType>(getEnumValue(cndsrFlowTypeNamesUC, Alphas(8)))) ==
    2824              :                     CndsrFlowType::Invalid) {
    2825            0 :                     ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(8), Alphas(8));
    2826            0 :                     ErrorsFound = true;
    2827              :                 }
    2828              :                 // Get outlet temperature schedule for variable flow case
    2829            1 :                 if (RefrigRack(RackNum).FlowType == CndsrFlowType::Variable) {
    2830            1 :                     if (lAlphaBlanks(9)) {
    2831            1 :                     } else if ((RefrigRack(RackNum).outletTempSched = Sched::GetSchedule(state, Alphas(9))) == nullptr) {
    2832            0 :                         ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(9), Alphas(9));
    2833            0 :                         ErrorsFound = true;
    2834              :                     }
    2835              :                 }
    2836              : 
    2837              :                 // Get volumetric flow rate if applicable
    2838            1 :                 if (RefrigRack(RackNum).FlowType == CndsrFlowType::Constant) {
    2839            0 :                     RefrigRack(RackNum).DesVolFlowRate = Numbers(3);
    2840            0 :                     RefrigRack(RackNum).VolFlowRate = Numbers(3);
    2841              :                 }
    2842              :                 // Get maximum flow rates
    2843            1 :                 RefrigRack(RackNum).VolFlowRateMax = Numbers(4);
    2844              : 
    2845              :                 // Check constant flow for max violation, if applicable
    2846            1 :                 if (RefrigRack(RackNum).FlowType == CndsrFlowType::Constant && RefrigRack(RackNum).VolFlowRate > Numbers(4)) {
    2847            0 :                     ShowSevereError(state,
    2848            0 :                                     format("{}{}=\"{}\" {} > {}.",
    2849              :                                            RoutineName,
    2850              :                                            CurrentModuleObject,
    2851            0 :                                            RefrigRack(RackNum).Name,
    2852              :                                            cNumericFieldNames(3),
    2853              :                                            cNumericFieldNames(4)));
    2854            0 :                     ShowContinueError(state, "Revise flow rates.");
    2855            0 :                     ErrorsFound = true;
    2856              :                 }
    2857              :                 // Get max/min allowed water temps
    2858            1 :                 RefrigRack(RackNum).OutletTempMax = Numbers(5);
    2859            1 :                 RefrigRack(RackNum).InletTempMin = Numbers(6);
    2860              :                 // set flow request for plant sizing.
    2861            1 :                 PlantUtilities::RegisterPlantCompDesignFlow(state, RefrigRack(RackNum).InletNode, RefrigRack(RackNum).VolFlowRateMax);
    2862              :             } // Water cooled condenser data
    2863              : 
    2864              :             // Get evaporative cooled condenser input
    2865           61 :             if (lAlphaBlanks(10)) {
    2866            1 :             } else if ((RefrigRack(RackNum).evapAvailSched = Sched::GetSchedule(state, Alphas(10))) == nullptr) {
    2867            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(10), Alphas(10));
    2868            0 :                 ErrorsFound = true;
    2869            1 :             } else if (!RefrigRack(RackNum).evapAvailSched->checkMinVal(state, Clusive::In, 0.0)) {
    2870            0 :                 Sched::ShowSevereBadMin(state, eoh, cAlphaFieldNames(10), Alphas(10), Clusive::In, 0.0);
    2871            0 :                 ErrorsFound = true;
    2872              :             }
    2873              : 
    2874           61 :             RefrigRack(RackNum).EvapEffect = Numbers(7);
    2875           61 :             if (RefrigRack(RackNum).EvapEffect < 0.0 || RefrigRack(RackNum).EvapEffect > 1.0) {
    2876            0 :                 ShowSevereError(state,
    2877            0 :                                 format("{}{}=\"{}\" {} cannot be less than zero or greater than 1.0.",
    2878              :                                        RoutineName,
    2879              :                                        CurrentModuleObject,
    2880            0 :                                        RefrigRack(RackNum).Name,
    2881              :                                        cNumericFieldNames(7)));
    2882            0 :                 ErrorsFound = true;
    2883              :             }
    2884              : 
    2885           61 :             RefrigRack(RackNum).CondenserAirFlowRate = Numbers(8);
    2886           63 :             if (RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::Evap && RefrigRack(RackNum).CondenserAirFlowRate <= 0.0 &&
    2887            2 :                 RefrigRack(RackNum).CondenserAirFlowRate != Constant::AutoCalculate) {
    2888            0 :                 ShowSevereError(state,
    2889            0 :                                 format("{}{}=\"{}\", {} cannot be less than or equal to zero.",
    2890              :                                        RoutineName,
    2891              :                                        CurrentModuleObject,
    2892            0 :                                        RefrigRack(RackNum).Name,
    2893              :                                        cNumericFieldNames(8)));
    2894            0 :                 ErrorsFound = true;
    2895              :             }
    2896              : 
    2897              :             //   Basin heater power as a function of temperature must be greater than or equal to 0
    2898           61 :             RefrigRack(RackNum).BasinHeaterPowerFTempDiff = Numbers(9);
    2899           61 :             if (RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::Evap && Numbers(9) < 0.0) {
    2900            0 :                 ShowSevereError(
    2901            0 :                     state, format("{}{}=\"{}\", {} must be >= 0", RoutineName, CurrentModuleObject, RefrigRack(RackNum).Name, cNumericFieldNames(9)));
    2902            0 :                 ErrorsFound = true;
    2903              :             }
    2904              : 
    2905           61 :             RefrigRack(RackNum).BasinHeaterSetPointTemp = Numbers(10);
    2906           63 :             if (RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::Evap &&
    2907            2 :                 RefrigRack(RackNum).BasinHeaterSetPointTemp < 2.0) {
    2908            0 :                 ShowWarningError(state,
    2909            0 :                                  format("{}=\"{}\", {} is less than 2 deg C. Freezing could occur.",
    2910              :                                         CurrentModuleObject,
    2911            0 :                                         RefrigRack(RackNum).Name,
    2912              :                                         cNumericFieldNames(10)));
    2913              :             }
    2914              : 
    2915           61 :             RefrigRack(RackNum).EvapPumpPower = Numbers(11);
    2916           63 :             if (RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::Evap && RefrigRack(RackNum).EvapPumpPower < 0.0 &&
    2917            2 :                 RefrigRack(RackNum).EvapPumpPower != Constant::AutoCalculate) {
    2918            0 :                 ShowSevereError(state,
    2919            0 :                                 format("{}{}=\"{}\", {} cannot be less than zero.",
    2920              :                                        RoutineName,
    2921              :                                        CurrentModuleObject,
    2922            0 :                                        RefrigRack(RackNum).Name,
    2923              :                                        cNumericFieldNames(11)));
    2924            0 :                 ErrorsFound = true;
    2925              :             }
    2926              : 
    2927              :             // Get Water System tank connections
    2928           61 :             RefrigRack(RackNum).SupplyTankName = Alphas(11);
    2929           61 :             if (lAlphaBlanks(11)) {
    2930           60 :                 RefrigRack(RackNum).EvapWaterSupplyMode = WaterSupply::FromMains;
    2931              :             } else {
    2932            1 :                 RefrigRack(RackNum).EvapWaterSupplyMode = WaterSupply::FromTank;
    2933            2 :                 WaterManager::SetupTankDemandComponent(state,
    2934            1 :                                                        RefrigRack(RackNum).Name,
    2935              :                                                        CurrentModuleObject,
    2936            1 :                                                        RefrigRack(RackNum).SupplyTankName,
    2937              :                                                        ErrorsFound,
    2938            1 :                                                        RefrigRack(RackNum).EvapWaterSupTankID,
    2939            1 :                                                        RefrigRack(RackNum).EvapWaterTankDemandARRID);
    2940              :             }
    2941              : 
    2942              :             // Check condenser air inlet node connection
    2943           61 :             if (lAlphaBlanks(12)) {
    2944           16 :                 RefrigRack(RackNum).OutsideAirNodeNum = 0;
    2945              :             } else {
    2946           90 :                 RefrigRack(RackNum).OutsideAirNodeNum =
    2947           90 :                     NodeInputManager::GetOnlySingleNode(state,
    2948           45 :                                                         Alphas(12),
    2949              :                                                         ErrorsFound,
    2950              :                                                         DataLoopNode::ConnectionObjectType::RefrigerationCompressorRack,
    2951           45 :                                                         Alphas(1),
    2952              :                                                         DataLoopNode::NodeFluidType::Air,
    2953              :                                                         DataLoopNode::ConnectionType::OutsideAirReference,
    2954              :                                                         NodeInputManager::CompFluidStream::Primary,
    2955              :                                                         DataLoopNode::ObjectIsParent);
    2956           45 :                 if (!OutAirNodeManager::CheckOutAirNodeNumber(state, RefrigRack(RackNum).OutsideAirNodeNum)) {
    2957            0 :                     ShowSevereError(state,
    2958            0 :                                     format("{}{}=\"{}\", {} not found: {}",
    2959              :                                            RoutineName,
    2960              :                                            CurrentModuleObject,
    2961            0 :                                            RefrigRack(RackNum).Name,
    2962              :                                            cAlphaFieldNames(12),
    2963              :                                            Alphas(12)));
    2964            0 :                     ShowContinueError(state, "...does not appear in an OutdoorAir:NodeList or as an OutdoorAir:Node.");
    2965            0 :                     ErrorsFound = true;
    2966              :                 }
    2967              :             }
    2968              : 
    2969           61 :             if (!lAlphaBlanks(13)) {
    2970           36 :                 RefrigRack(RackNum).EndUseSubcategory = Alphas(13);
    2971              :             }
    2972              : 
    2973              :             // Read all loads on this rack: cases and walk-ins and coils
    2974           61 :             NumCases = 0;
    2975           61 :             int NumCoils = 0;
    2976           61 :             NumWalkIns = 0;
    2977           61 :             RefrigRack(RackNum).NumCases = 0;
    2978           61 :             RefrigRack(RackNum).NumCoils = 0;
    2979           61 :             RefrigRack(RackNum).NumWalkIns = 0;
    2980           61 :             RefrigRack(RackNum).TotalRackLoad = 0.0;
    2981              : 
    2982              :             //   Read display case and walkin assignments for this rack
    2983           61 :             AlphaNum = 14;
    2984           61 :             if (lAlphaBlanks(AlphaNum)) {
    2985              :                 // No cases or walkins or coils specified, ie, rack has no load
    2986            0 :                 ShowSevereError(state,
    2987            0 :                                 format("{}{}=\"{}\" : has no loads, must have at least one of: {}",
    2988              :                                        RoutineName,
    2989              :                                        CurrentModuleObject,
    2990            0 :                                        RefrigRack(RackNum).Name,
    2991              :                                        cAlphaFieldNames(14)));
    2992            0 :                 ErrorsFound = true;
    2993              :             } else { // (.NOT. lAlphaBlanks(AlphaNum))
    2994              :                 // Entry for Alphas(AlphaNum) can be either a Case, WalkIn, Coil, or CaseAndWalkInList name
    2995           61 :                 int CaseAndWalkInListNum = 0;
    2996           61 :                 int CaseNum = 0;
    2997           61 :                 int WalkInNum = 0;
    2998           61 :                 int CoilNum = 0;
    2999           61 :                 if (state.dataRefrigCase->NumSimulationCaseAndWalkInLists > 0) {
    3000           41 :                     CaseAndWalkInListNum = Util::FindItemInList(Alphas(AlphaNum), CaseAndWalkInList);
    3001              :                 }
    3002           61 :                 if (state.dataRefrigCase->NumSimulationCases > 0) {
    3003           61 :                     CaseNum = Util::FindItemInList(Alphas(AlphaNum), RefrigCase);
    3004              :                 }
    3005           61 :                 if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
    3006            8 :                     WalkInNum = Util::FindItemInList(Alphas(AlphaNum), WalkIn);
    3007              :                 }
    3008           61 :                 if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0) {
    3009            0 :                     CoilNum = Util::FindItemInList(Alphas(AlphaNum), WarehouseCoil);
    3010              :                 }
    3011           61 :                 int NumNameMatches = 0;
    3012           61 :                 if (CaseAndWalkInListNum != 0) {
    3013           25 :                     ++NumNameMatches;
    3014              :                 }
    3015           61 :                 if (CaseNum != 0) {
    3016           36 :                     ++NumNameMatches;
    3017              :                 }
    3018           61 :                 if (WalkInNum != 0) {
    3019            0 :                     ++NumNameMatches;
    3020              :                 }
    3021           61 :                 if (CoilNum != 0) {
    3022            0 :                     ++NumNameMatches;
    3023              :                 }
    3024              : 
    3025           61 :                 if (NumNameMatches != 1) { // name must uniquely point to a list or a single case or walkin
    3026            0 :                     ErrorsFound = true;
    3027            0 :                     if (NumNameMatches == 0) {
    3028            0 :                         ShowSevereError(state,
    3029            0 :                                         format("{}{}=\"{}\" : has an invalid {}: {}",
    3030              :                                                RoutineName,
    3031              :                                                CurrentModuleObject,
    3032            0 :                                                RefrigRack(RackNum).Name,
    3033              :                                                cAlphaFieldNames(AlphaNum),
    3034              :                                                Alphas(AlphaNum)));
    3035            0 :                     } else if (NumNameMatches > 1) {
    3036            0 :                         ShowSevereError(state,
    3037            0 :                                         format("{}{}=\"{}\" : has a non-unique name that could be either a {}: {}",
    3038              :                                                RoutineName,
    3039              :                                                CurrentModuleObject,
    3040            0 :                                                RefrigRack(RackNum).Name,
    3041              :                                                cAlphaFieldNames(AlphaNum),
    3042              :                                                Alphas(AlphaNum)));
    3043              :                     } // num matches = 0 or > 1
    3044           61 :                 } else if (CaseAndWalkInListNum != 0) { // Name points to a CaseAndWalkInList
    3045           25 :                     NumCoils = CaseAndWalkInList(CaseAndWalkInListNum).NumCoils;
    3046           25 :                     NumCases = CaseAndWalkInList(CaseAndWalkInListNum).NumCases;
    3047           25 :                     NumWalkIns = CaseAndWalkInList(CaseAndWalkInListNum).NumWalkIns;
    3048           25 :                     RefrigRack(RackNum).NumCoils = NumCoils;
    3049           25 :                     RefrigRack(RackNum).NumCases = NumCases;
    3050           25 :                     RefrigRack(RackNum).NumWalkIns = NumWalkIns;
    3051           25 :                     if (!allocated(RefrigRack(RackNum).CoilNum)) {
    3052           25 :                         RefrigRack(RackNum).CoilNum.allocate(NumCoils);
    3053              :                     }
    3054           25 :                     RefrigRack(RackNum).CoilNum({1, NumCoils}) = CaseAndWalkInList(CaseAndWalkInListNum).CoilItemNum({1, NumCoils});
    3055           25 :                     if (!allocated(RefrigRack(RackNum).CaseNum)) {
    3056           25 :                         RefrigRack(RackNum).CaseNum.allocate(NumCases);
    3057              :                     }
    3058           25 :                     RefrigRack(RackNum).CaseNum({1, NumCases}) = CaseAndWalkInList(CaseAndWalkInListNum).CaseItemNum({1, NumCases});
    3059           25 :                     if (!allocated(RefrigRack(RackNum).WalkInNum)) {
    3060           25 :                         RefrigRack(RackNum).WalkInNum.allocate(NumWalkIns);
    3061              :                     }
    3062           25 :                     RefrigRack(RackNum).WalkInNum({1, NumWalkIns}) = CaseAndWalkInList(CaseAndWalkInListNum).WalkInItemNum({1, NumWalkIns});
    3063           36 :                 } else if (CoilNum != 0) { // Name points to a coil
    3064            0 :                     NumCoils = 1;
    3065            0 :                     RefrigRack(RackNum).NumCoils = 1;
    3066            0 :                     if (!allocated(RefrigRack(RackNum).CoilNum)) {
    3067            0 :                         RefrigRack(RackNum).CoilNum.allocate(NumCoils);
    3068              :                     }
    3069            0 :                     RefrigRack(RackNum).CoilNum(NumCoils) = CoilNum;
    3070           36 :                 } else if (CaseNum != 0) { // Name points to a case
    3071           36 :                     NumCases = 1;
    3072           36 :                     RefrigRack(RackNum).NumCases = 1;
    3073           36 :                     if (!allocated(RefrigRack(RackNum).CaseNum)) {
    3074           36 :                         RefrigRack(RackNum).CaseNum.allocate(NumCases);
    3075              :                     }
    3076           36 :                     RefrigRack(RackNum).CaseNum(NumCases) = CaseNum;
    3077            0 :                 } else if (WalkInNum != 0) { // Name points to a walkin
    3078            0 :                     NumWalkIns = 1;
    3079            0 :                     RefrigRack(RackNum).NumWalkIns = 1;
    3080            0 :                     if (!allocated(RefrigRack(RackNum).WalkInNum)) {
    3081            0 :                         RefrigRack(RackNum).WalkInNum.allocate(NumWalkIns);
    3082              :                     }
    3083            0 :                     RefrigRack(RackNum).WalkInNum(NumWalkIns) = WalkInNum;
    3084              :                 } // NumNameMatches /= 1
    3085              :             } // blank input for loads on rack
    3086              : 
    3087           61 :             if (NumCases > 0) {
    3088          153 :                 for (int caseIndex = 1; caseIndex <= NumCases; ++caseIndex) {
    3089           92 :                     int caseID = RefrigRack(RackNum).CaseNum(caseIndex);
    3090              :                     // mark all cases on rack as used by this system (checking for unused or non-unique cases)
    3091           92 :                     ++RefrigCase(caseID).NumSysAttach;
    3092              :                     // determine total capacity on rack
    3093           92 :                     RefrigRack(RackNum).TotalRackLoad += RefrigCase(caseID).DesignRatedCap;
    3094              :                 } // CaseIndex=1,NumCases
    3095              :                 //     check that all refrigerated cases attached to a rack are to the same zone if heat rejection location is "Zone"
    3096              :                 //     however, won't matter if walk-in specified
    3097           88 :                 if (RefrigRack(RackNum).HeatRejectionLocation == HeatRejLocation::Zone && RefrigRack(RackNum).NumCases > 1 &&
    3098           88 :                     RefrigCase(RefrigRack(RackNum).CaseNum(1)).ActualZoneNum != 0 && NumWalkIns < 1 && NumCoils < 1) {
    3099            0 :                     int ZoneNum = RefrigCase(RefrigRack(RackNum).CaseNum(1)).ActualZoneNum;
    3100            0 :                     for (int caseIndex = 2; caseIndex <= RefrigRack(RackNum).NumCases; ++caseIndex) {
    3101            0 :                         if (RefrigCase(RefrigRack(RackNum).CaseNum(caseIndex)).ActualZoneNum == ZoneNum) {
    3102            0 :                             continue;
    3103              :                         }
    3104            0 :                         ShowSevereError(state,
    3105            0 :                                         format(R"({}{}="{}" : All cases attached to a rack must be in the same zone when {} equals "Zone".)",
    3106              :                                                RoutineName,
    3107              :                                                CurrentModuleObject,
    3108            0 :                                                RefrigRack(RackNum).Name,
    3109              :                                                cAlphaFieldNames(2)));
    3110            0 :                         ErrorsFound = true;
    3111            0 :                         break;
    3112              :                     }
    3113              :                 } // heat rejection location is zone
    3114              :             } // numcases > 0
    3115              : 
    3116           61 :             if (NumCoils > 0) {
    3117            0 :                 RefrigRack(RackNum).CoilFlag = true;
    3118            0 :                 for (int CoilIndex = 1; CoilIndex <= NumCoils; ++CoilIndex) {
    3119            0 :                     int CoilNum = RefrigRack(RackNum).CoilNum(CoilIndex);
    3120              :                     // mark all Coils on rack as used by this system (checking for unused or non-unique Coils)
    3121            0 :                     ++WarehouseCoil(CoilNum).NumSysAttach;
    3122              :                     // determine total capacity on rack
    3123            0 :                     RefrigRack(RackNum).TotalRackLoad += WarehouseCoil(CoilNum).RatedSensibleCap;
    3124              :                 } // CoilIndex=1,NumCoils
    3125              :             } // numcoils > 0
    3126              : 
    3127           61 :             if (NumWalkIns > 0) {
    3128            0 :                 for (int WalkInIndex = 1; WalkInIndex <= NumWalkIns; ++WalkInIndex) {
    3129            0 :                     int WalkInID = RefrigRack(RackNum).WalkInNum(WalkInIndex);
    3130              :                     // mark all WalkIns on rack as used by this system (checking for unused or non-unique WalkIns)
    3131            0 :                     ++WalkIn(WalkInID).NumSysAttach;
    3132              :                     // determine total capacity on rack
    3133            0 :                     RefrigRack(RackNum).TotalRackLoad += WalkIn(WalkInID).DesignRatedCap;
    3134              :                 } // WalkInIndex=1,NumWalkIns
    3135              :             } // NumWalkins
    3136              : 
    3137           61 :             if (NumWalkIns > 0 || NumCoils > 0) {
    3138              :                 // Get the heat rejection Zone node number from the zone name entered by the user (if heatrej location = zone)
    3139            0 :                 if (RefrigRack(RackNum).HeatRejectionLocation == HeatRejLocation::Zone) {
    3140            0 :                     if (lAlphaBlanks(15)) {
    3141            0 :                         ShowSevereError(
    3142              :                             state,
    3143            0 :                             format("{}{}=\"{}{} must be input if walkins or AirChillers connected to rack and heat rejection location = zone.",
    3144              :                                    RoutineName,
    3145              :                                    CurrentModuleObject,
    3146            0 :                                    RefrigRack(RackNum).Name,
    3147              :                                    cAlphaFieldNames(15)));
    3148            0 :                         ErrorsFound = true;
    3149              :                     } else { // alpha (15) not blank
    3150            0 :                         RefrigRack(RackNum).HeatRejectionZoneNum = Util::FindItemInList(Alphas(15), state.dataHeatBal->Zone);
    3151            0 :                         RefrigRack(RackNum).HeatRejectionZoneNodeNum =
    3152            0 :                             DataZoneEquipment::GetSystemNodeNumberForZone(state, RefrigRack(RackNum).HeatRejectionZoneNum);
    3153            0 :                         if (RefrigRack(RackNum).HeatRejectionZoneNum == 0) {
    3154            0 :                             ShowSevereError(state,
    3155            0 :                                             format("{}{}=\"{}\", invalid  {} not valid: {}",
    3156              :                                                    RoutineName,
    3157              :                                                    CurrentModuleObject,
    3158            0 :                                                    RefrigRack(RackNum).Name,
    3159              :                                                    cAlphaFieldNames(15),
    3160              :                                                    Alphas(15)));
    3161            0 :                             ErrorsFound = true;
    3162              :                         } else {
    3163            0 :                             state.dataRefrigCase->RefrigPresentInZone(RefrigRack(RackNum).HeatRejectionZoneNum) = true;
    3164              :                         } // zonenum == 0
    3165              :                     } // alpha 15 blank
    3166              :                 } // zone heat rej and walk-ins or coils present, must input heat rejection zone
    3167              :             } // numwalkins or coils > 0
    3168              : 
    3169              :             // set condenser air flow and evap water pump power if autocalculated
    3170              :             // autocalculate condenser evap water pump if needed
    3171           63 :             if (RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::Evap &&
    3172            2 :                 RefrigRack(RackNum).EvapPumpPower == Constant::AutoCalculate) {
    3173            2 :                 RefrigRack(RackNum).EvapPumpPower = CondPumpRatePower * RefrigRack(RackNum).TotalRackLoad;
    3174              :             }
    3175              :             // autocalculate evap condenser air volume flow rate if needed
    3176           63 :             if (RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::Evap &&
    3177            2 :                 RefrigRack(RackNum).CondenserAirFlowRate == Constant::AutoCalculate) {
    3178            2 :                 RefrigRack(RackNum).CondenserAirFlowRate = AirVolRateEvapCond * RefrigRack(RackNum).TotalRackLoad;
    3179              :             }
    3180              : 
    3181              :         } // RackNum=1,NumRefrigeratedRacks
    3182              : 
    3183           31 :         state.dataRefrigCase->CheckEquipNameRackWaterCondenser.dimension(state.dataRefrigCase->NumRefrigeratedRacks, true);
    3184              :     } //(NumRefrigeratedRacks > 0)
    3185              : 
    3186          801 :     if (state.dataRefrigCase->NumRefrigSystems > 0 || state.dataRefrigCase->NumTransRefrigSystems > 0) {
    3187              : 
    3188           16 :         if (state.dataRefrigCase->NumRefrigSystems > 0 && state.dataRefrigCase->NumRefrigCondensers == 0) {
    3189            0 :             ShowSevereError(state,
    3190              :                             "Refrigeration:System objects were found during input processing, however no Refrigeration condenser objects (which "
    3191              :                             "may be either: ");
    3192            0 :             ShowContinueError(state,
    3193              :                               " Refrigeration:Condenser:AirCooled, Refrigeration:Condenser:WaterCooled, "
    3194              :                               "Refrigeration:Condenser:EvaporativeCooled,or Refrigeration:Condenser:CascadeCooled) were found.");
    3195            0 :             ErrorsFound = true;
    3196              :         }
    3197           16 :         if (state.dataRefrigCase->NumTransRefrigSystems > 0 && state.dataRefrigCase->NumSimulationGasCooler == 0) {
    3198            0 :             ShowSevereError(state,
    3199              :                             "Refrigeration:TranscriticalSystem objects were found during input processing, however no Refrigeration gas cooler "
    3200              :                             "objects (Refrigeration:GasCooler:AirCooled) were found.");
    3201            0 :             ErrorsFound = true;
    3202              :         }
    3203           16 :         if (state.dataRefrigCase->NumSimulationCompressors == 0) {
    3204            0 :             ShowSevereError(
    3205              :                 state, "Refrigeration:System objects were found during input processing, however no Refrigeration:Compressor objects were found.");
    3206            0 :             ErrorsFound = true;
    3207              :         }
    3208              : 
    3209              :         //************ START CONDENSER INPUT  **************
    3210              : 
    3211           16 :         if (state.dataRefrigCase->NumSimulationCondAir > 0) {
    3212           13 :             CurrentModuleObject = "Refrigeration:Condenser:AirCooled";
    3213           47 :             for (int CondNum = 1; CondNum <= state.dataRefrigCase->NumSimulationCondAir; ++CondNum) {
    3214           34 :                 state.dataInputProcessing->inputProcessor->getObjectItem(state,
    3215              :                                                                          CurrentModuleObject,
    3216              :                                                                          CondNum,
    3217              :                                                                          Alphas,
    3218              :                                                                          NumAlphas,
    3219              :                                                                          Numbers,
    3220              :                                                                          NumNumbers,
    3221              :                                                                          IOStatus,
    3222              :                                                                          lNumericBlanks,
    3223              :                                                                          lAlphaBlanks,
    3224              :                                                                          cAlphaFieldNames,
    3225              :                                                                          cNumericFieldNames);
    3226              : 
    3227           34 :                 ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
    3228              : 
    3229           34 :                 GlobalNames::VerifyUniqueInterObjectName(
    3230           68 :                     state, state.dataRefrigCase->UniqueCondenserNames, Alphas(1), CurrentModuleObject, cAlphaFieldNames(1), ErrorsFound);
    3231           34 :                 Condenser(CondNum).Name = Alphas(1);
    3232           34 :                 state.dataHeatBal->HeatReclaimRefrigCondenser(CondNum).Name = Alphas(1);
    3233           34 :                 Condenser(CondNum).CapCurvePtr = Curve::GetCurveIndex(state, Alphas(2)); // convert curve name to number
    3234           34 :                 if (Condenser(CondNum).CapCurvePtr == 0) {
    3235            0 :                     ShowSevereError(state,
    3236            0 :                                     format("{}{}=\"{}\", invalid  {} not found:{}",
    3237              :                                            RoutineName,
    3238              :                                            CurrentModuleObject,
    3239            0 :                                            Condenser(CondNum).Name,
    3240              :                                            cAlphaFieldNames(2),
    3241              :                                            Alphas(2)));
    3242            0 :                     ErrorsFound = true;
    3243              :                 }
    3244              : 
    3245              :                 // set start of count for number of systems attached to this condenser
    3246           34 :                 Condenser(CondNum).NumSysAttach = 0;
    3247           34 :                 if (!allocated(Condenser(CondNum).SysNum)) {
    3248           34 :                     Condenser(CondNum).SysNum.allocate(state.dataRefrigCase->NumRefrigSystems);
    3249              :                 }
    3250              : 
    3251              :                 // set CondenserType and rated temperature difference (51.7 - 35)C per ARI 460
    3252           34 :                 Condenser(CondNum).CondenserType = DataHeatBalance::RefrigCondenserType::Air;
    3253           34 :                 state.dataHeatBal->HeatReclaimRefrigCondenser(CondNum).SourceType = CurrentModuleObject;
    3254           34 :                 Condenser(CondNum).RatedDelT = CondARI460DelT; //= 16.7d0 ,Rated sat cond temp - dry bulb air T for air-cooled Condensers, ARI460
    3255           34 :                 Condenser(CondNum).RatedTCondense = CondARI460Tcond;
    3256           34 :                 if (Condenser(CondNum).CapCurvePtr > 0) {
    3257           34 :                     Condenser(CondNum).RatedCapacity = Curve::CurveValue(state, Condenser(CondNum).CapCurvePtr, CondARI460DelT);
    3258              :                 }
    3259              :                 // elevation capacity correction on air-cooled condensers, Carrier correlation more conservative than Trane
    3260           34 :                 Condenser(CondNum).RatedCapacity *= (1.0 - 7.17e-5 * state.dataEnvrn->Elevation);
    3261           34 :                 if (Condenser(CondNum).RatedCapacity > 0.0) {
    3262           34 :                     Curve::GetCurveMinMaxValues(state, Condenser(CondNum).CapCurvePtr, DelTempMin, DelTempMax);
    3263           34 :                     Real64 Capmin = Curve::CurveValue(state, Condenser(CondNum).CapCurvePtr, DelTempMin) *
    3264           34 :                                     (1.0 - 7.17e-5 * state.dataEnvrn->Elevation); // Mar 2011 bug fix
    3265           34 :                     Real64 Capmax = Curve::CurveValue(state, Condenser(CondNum).CapCurvePtr, DelTempMax) *
    3266           34 :                                     (1.0 - 7.17e-5 * state.dataEnvrn->Elevation); // Mar 2011 bug
    3267           68 :                     Condenser(CondNum).TempSlope =
    3268           34 :                         (DelTempMax - DelTempMin) / ((Capmax - Capmin)); // * ( 1.0 - 7.17e-5 * Elevation ) ) //Mar 2011 bug fix
    3269           34 :                     Condenser(CondNum).MinCondLoad = Capmax - DelTempMax / Condenser(CondNum).TempSlope;
    3270              :                 } else {
    3271            0 :                     ShowSevereError(state,
    3272            0 :                                     format("{}{}=\"{}\" Condenser capacity curve per ARI 460 must be input and must be greater than 0 Watts at "
    3273              :                                            "16.7C temperature difference.",
    3274              :                                            RoutineName,
    3275              :                                            CurrentModuleObject,
    3276            0 :                                            Condenser(CondNum).Name));
    3277            0 :                     ErrorsFound = true;
    3278              :                 }
    3279              : 
    3280           34 :                 Condenser(CondNum).RatedSubcool = 0.0; // default value
    3281           34 :                 if (!lNumericBlanks(1)) {
    3282           34 :                     Condenser(CondNum).RatedSubcool = Numbers(1);
    3283              :                 }
    3284              : 
    3285              :                 // Get fan control type
    3286           34 :                 if (lAlphaBlanks(3)) {
    3287            0 :                     Condenser(CondNum).FanSpeedControlType = FanSpeedCtrlType::ConstantSpeed; // default
    3288           68 :                 } else if ((Condenser(CondNum).FanSpeedControlType =
    3289           34 :                                 static_cast<FanSpeedCtrlType>(getEnumValue(fanSpeedCtrlTypeNamesUC, Alphas(3)))) == FanSpeedCtrlType::Invalid) {
    3290            0 :                     ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(3), Alphas(3));
    3291            0 :                     ErrorsFound = true;
    3292              :                 } // Set fan control type
    3293              : 
    3294           34 :                 if (!lNumericBlanks(2)) {
    3295           34 :                     Condenser(CondNum).RatedFanPower = Numbers(2);
    3296              :                 }
    3297           34 :                 if ((lNumericBlanks(2)) || (Numbers(2) < 0.0)) {
    3298            0 :                     ShowSevereError(state,
    3299            0 :                                     format("{}{}=\"{}\" {} must be input greater than or equal to 0 Watts.",
    3300              :                                            RoutineName,
    3301              :                                            CurrentModuleObject,
    3302            0 :                                            Condenser(CondNum).Name,
    3303              :                                            cNumericFieldNames(2)));
    3304            0 :                     ErrorsFound = true;
    3305              :                 }
    3306              : 
    3307           34 :                 Condenser(CondNum).FanMinAirFlowRatio = 0.2; // default value
    3308           34 :                 if (!lNumericBlanks(3)) {
    3309           24 :                     Condenser(CondNum).FanMinAirFlowRatio = Numbers(3);
    3310              :                 }
    3311              : 
    3312              :                 // Check condenser air inlet node connection
    3313              :                 // Jan 2011 - added ability to reject heat to a zone from air-cooled condenser
    3314           34 :                 Condenser(CondNum).CondenserRejectHeatToZone = false;
    3315           34 :                 if (lAlphaBlanks(4)) {
    3316            0 :                     Condenser(CondNum).InletAirNodeNum = 0;
    3317              :                 } else { // see if it's an outside air node name or an indoor zone name,
    3318              :                     // have to check inside first because outside check automatically generates an error message
    3319           34 :                     Condenser(CondNum).InletAirZoneNum = Util::FindItemInList(Alphas(4), state.dataHeatBal->Zone);
    3320              :                     // need to clearly id node number for air inlet conditions and zone number for casecredit assignment
    3321           34 :                     if (Condenser(CondNum).InletAirZoneNum != 0) {
    3322              :                         // set condenser flag (later used to set system flag) and zone flag
    3323            3 :                         Condenser(CondNum).InletAirNodeNum = DataZoneEquipment::GetSystemNodeNumberForZone(state, Condenser(CondNum).InletAirZoneNum);
    3324            3 :                         Condenser(CondNum).CondenserRejectHeatToZone = true;
    3325            3 :                         state.dataRefrigCase->RefrigPresentInZone(Condenser(CondNum).InletAirZoneNum) = true;
    3326              :                     } else { // not in a conditioned zone, so see if it's outside
    3327           62 :                         Condenser(CondNum).InletAirNodeNum =
    3328           62 :                             NodeInputManager::GetOnlySingleNode(state,
    3329           31 :                                                                 Alphas(4),
    3330              :                                                                 ErrorsFound,
    3331              :                                                                 DataLoopNode::ConnectionObjectType::RefrigerationCondenserAirCooled,
    3332           31 :                                                                 Alphas(1),
    3333              :                                                                 DataLoopNode::NodeFluidType::Air,
    3334              :                                                                 DataLoopNode::ConnectionType::OutsideAirReference,
    3335              :                                                                 NodeInputManager::CompFluidStream::Primary,
    3336              :                                                                 DataLoopNode::ObjectIsParent);
    3337           31 :                         if (!OutAirNodeManager::CheckOutAirNodeNumber(state, Condenser(CondNum).InletAirNodeNum)) {
    3338              :                             // not outside and not a zone
    3339            0 :                             ShowSevereError(state,
    3340            0 :                                             format("{}{}=\"{}\", {} not found: {}",
    3341              :                                                    RoutineName,
    3342              :                                                    CurrentModuleObject,
    3343            0 :                                                    Condenser(CondNum).Name,
    3344              :                                                    cAlphaFieldNames(4),
    3345              :                                                    Alphas(4)));
    3346            0 :                             ShowContinueError(state, "...does not appear in an OutdoorAir:NodeList or as an OutdoorAir:Node or as a Zone.");
    3347            0 :                             ErrorsFound = true;
    3348              :                         } // checkoutairnodenumber
    3349              :                     } // InletAirZoneNum \=0
    3350              :                 } // Condenser air inlet node connection
    3351              : 
    3352           34 :                 Condenser(CondNum).EndUseSubcategory = "";
    3353           34 :                 if (!lAlphaBlanks(5)) {
    3354           28 :                     Condenser(CondNum).EndUseSubcategory = Alphas(5);
    3355              :                 }
    3356              : 
    3357           34 :                 Condenser(CondNum).RefOpCharge = 0.0;
    3358           34 :                 Condenser(CondNum).RefReceiverInventory = 0.0;
    3359           34 :                 Condenser(CondNum).RefPipingInventory = 0.0;
    3360           34 :                 if (!lNumericBlanks(4)) {
    3361            0 :                     Condenser(CondNum).RefOpCharge = Numbers(4);
    3362              :                 }
    3363           34 :                 if (!lNumericBlanks(5)) {
    3364            0 :                     Condenser(CondNum).RefReceiverInventory = Numbers(5);
    3365              :                 }
    3366           34 :                 if (!lNumericBlanks(6)) {
    3367            0 :                     Condenser(CondNum).RefPipingInventory = Numbers(6);
    3368              :                 }
    3369              : 
    3370              :             } // Read input for REFRIGERATION:Condenser:AirCooled
    3371              :         } // NumSimulationCondAir > 0
    3372              : 
    3373           16 :         if (state.dataRefrigCase->NumSimulationCondEvap > 0) {
    3374            2 :             CurrentModuleObject = "Refrigeration:Condenser:EvaporativeCooled";
    3375            5 :             for (int CondIndex = 1; CondIndex <= state.dataRefrigCase->NumSimulationCondEvap; ++CondIndex) {
    3376            3 :                 int CondNum = CondIndex + state.dataRefrigCase->NumSimulationCondAir;
    3377            3 :                 state.dataInputProcessing->inputProcessor->getObjectItem(state,
    3378              :                                                                          CurrentModuleObject,
    3379              :                                                                          CondIndex,
    3380              :                                                                          Alphas,
    3381              :                                                                          NumAlphas,
    3382              :                                                                          Numbers,
    3383              :                                                                          NumNumbers,
    3384              :                                                                          IOStatus,
    3385              :                                                                          lNumericBlanks,
    3386              :                                                                          lAlphaBlanks,
    3387              :                                                                          cAlphaFieldNames,
    3388              :                                                                          cNumericFieldNames);
    3389              : 
    3390            3 :                 ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
    3391              : 
    3392            3 :                 GlobalNames::VerifyUniqueInterObjectName(
    3393            6 :                     state, state.dataRefrigCase->UniqueCondenserNames, Alphas(1), CurrentModuleObject, cAlphaFieldNames(1), ErrorsFound);
    3394            3 :                 Condenser(CondNum).Name = Alphas(1);
    3395            3 :                 state.dataHeatBal->HeatReclaimRefrigCondenser(CondNum).Name = Alphas(1);
    3396              : 
    3397              :                 // set start of count for number of systems attached to this condenser
    3398            3 :                 Condenser(CondNum).NumSysAttach = 0;
    3399            3 :                 if (!allocated(Condenser(CondNum).SysNum)) {
    3400            3 :                     Condenser(CondNum).SysNum.allocate(state.dataRefrigCase->NumRefrigSystems);
    3401              :                 }
    3402              : 
    3403              :                 // set CondenserType and rated Heat Rejection per ARI 490 rating
    3404            3 :                 Condenser(CondNum).CondenserType = DataHeatBalance::RefrigCondenserType::Evap;
    3405            3 :                 state.dataHeatBal->HeatReclaimRefrigCondenser(CondNum).SourceType = CurrentModuleObject;
    3406            3 :                 Condenser(CondNum).RatedTCondense = CondARI490Tcond;
    3407            3 :                 Condenser(CondNum).RatedDelT = CondARI490DelT;
    3408              : 
    3409            3 :                 if ((!lNumericBlanks(1)) && (Numbers(1) > 0.0)) {
    3410            3 :                     Condenser(CondNum).RatedCapacity = Numbers(1);
    3411              :                 } else {
    3412            0 :                     ShowSevereError(state,
    3413            0 :                                     format("{}{}=\"{}\" {} per ARI 490 must be input and must be greater than 0 Watts.",
    3414              :                                            RoutineName,
    3415              :                                            CurrentModuleObject,
    3416            0 :                                            Condenser(CondNum).Name,
    3417              :                                            cNumericFieldNames(1)));
    3418            0 :                     ErrorsFound = true;
    3419              :                 }
    3420              :                 // Calculate capacity elevation derate factor per ARI 490 barometric pressure correction factor
    3421            3 :                 Condenser(CondNum).EvapElevFact = 1.0 - 3.074e-5 * state.dataEnvrn->Elevation;
    3422              : 
    3423            3 :                 Condenser(CondNum).RatedSubcool = 0.0; // default value
    3424            3 :                 if ((!lNumericBlanks(2)) && (Numbers(2) > 0.0)) {
    3425            0 :                     Condenser(CondNum).RatedSubcool = Numbers(2);
    3426              :                 }
    3427              : 
    3428              :                 // Get fan control type
    3429            3 :                 if (lAlphaBlanks(2)) {
    3430            0 :                     Condenser(CondNum).FanSpeedControlType = FanSpeedCtrlType::ConstantSpeed; // default
    3431            6 :                 } else if ((Condenser(CondNum).FanSpeedControlType =
    3432            3 :                                 static_cast<FanSpeedCtrlType>(getEnumValue(fanSpeedCtrlTypeNamesUC, Alphas(2)))) == FanSpeedCtrlType::Invalid) {
    3433            0 :                     ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(2), Alphas(2));
    3434            0 :                     ErrorsFound = true;
    3435              :                 } // Set fan control type
    3436              : 
    3437            3 :                 Condenser(CondNum).RatedFanPower = Numbers(3);
    3438            3 :                 if (Numbers(3) < 0.0) {
    3439            0 :                     ShowSevereError(state,
    3440            0 :                                     format("{}{}=\"{}\" {} must be greater than or equal to 0 Watts.",
    3441              :                                            RoutineName,
    3442              :                                            CurrentModuleObject,
    3443            0 :                                            Condenser(CondNum).Name,
    3444              :                                            cNumericFieldNames(3)));
    3445            0 :                     ErrorsFound = true;
    3446              :                 }
    3447              : 
    3448            3 :                 Condenser(CondNum).FanMinAirFlowRatio = 0.2; // default value
    3449            3 :                 if (!lNumericBlanks(4)) {
    3450            0 :                     Condenser(CondNum).FanMinAirFlowRatio = Numbers(4);
    3451              :                 }
    3452              : 
    3453              :                 // Enter min and max and default coefficients for evap condenser HRCF correlation
    3454              :                 // Defaults taken from 2008 BAC equipment for R22, R134a, series CXV
    3455              :                 // Correlation coefficients for other manufacturers are very similar per Hugh Henderson's work
    3456            3 :                 Condenser(CondNum).EvapCoeff1 = 6.63;
    3457            3 :                 Condenser(CondNum).EvapCoeff2 = 0.468;
    3458            3 :                 Condenser(CondNum).EvapCoeff3 = 17.93;
    3459            3 :                 Condenser(CondNum).EvapCoeff4 = -0.322;
    3460            3 :                 Condenser(CondNum).MinCapFacEvap = 0.5;
    3461            3 :                 Condenser(CondNum).MaxCapFacEvap = 5.0;
    3462            3 :                 NumNum = 5; // added warnings if below not blank but unused due to limits
    3463            3 :                 if (!lNumericBlanks(NumNum)) {
    3464            3 :                     if (Numbers(NumNum) >= 0.0) {
    3465            3 :                         Condenser(CondNum).EvapCoeff1 = Numbers(NumNum);
    3466              :                     } else {
    3467            0 :                         ShowWarningError(state,
    3468            0 :                                          format("{}=\"{}\", {} is less than 0 and was not used. Default was used.",
    3469              :                                                 CurrentModuleObject,
    3470            0 :                                                 Condenser(CondNum).Name,
    3471              :                                                 cNumericFieldNames(NumNum)));
    3472              :                     }
    3473              :                 }
    3474            3 :                 NumNum = 6; // EvapCoeff2 can't be equal to 0 because used in a denominator
    3475            3 :                 if (!lNumericBlanks(NumNum)) {
    3476            3 :                     if (Numbers(NumNum) > 0.0) {
    3477            3 :                         Condenser(CondNum).EvapCoeff2 = Numbers(NumNum);
    3478              :                     } else {
    3479            0 :                         ShowWarningError(state,
    3480            0 :                                          format("{}=\"{}\", {} is less than or equal to 0 and was not used. Default was used.",
    3481              :                                                 CurrentModuleObject,
    3482            0 :                                                 Condenser(CondNum).Name,
    3483              :                                                 cNumericFieldNames(NumNum)));
    3484              :                     }
    3485              :                 }
    3486            3 :                 NumNum = 7;
    3487            3 :                 if (!lNumericBlanks(NumNum)) {
    3488            3 :                     if (Numbers(NumNum) >= 0.0) {
    3489            3 :                         Condenser(CondNum).EvapCoeff3 = Numbers(NumNum);
    3490              :                     } else {
    3491            0 :                         ShowWarningError(state,
    3492            0 :                                          format("{}=\"{}\", {} is less than 0 and was not used. Default was used.",
    3493              :                                                 CurrentModuleObject,
    3494            0 :                                                 Condenser(CondNum).Name,
    3495              :                                                 cNumericFieldNames(NumNum)));
    3496              :                     }
    3497              :                 }
    3498            3 :                 NumNum = 8;
    3499            3 :                 if (!lNumericBlanks(NumNum)) {
    3500            3 :                     if (Numbers(NumNum) >= -20.0) {
    3501            3 :                         Condenser(CondNum).EvapCoeff4 = Numbers(NumNum);
    3502              :                     } else {
    3503            0 :                         ShowWarningError(state,
    3504            0 :                                          format("{}=\"{}\", {} is less than -20 and was not used. Default was used.",
    3505              :                                                 CurrentModuleObject,
    3506            0 :                                                 Condenser(CondNum).Name,
    3507              :                                                 cNumericFieldNames(NumNum)));
    3508              :                     }
    3509              :                 }
    3510            3 :                 NumNum = 9;
    3511            3 :                 if (!lNumericBlanks(NumNum)) {
    3512            3 :                     if (Numbers(NumNum) >= 0.0) {
    3513            3 :                         Condenser(CondNum).MinCapFacEvap = Numbers(NumNum);
    3514              :                     } else {
    3515            0 :                         ShowWarningError(state,
    3516            0 :                                          format("{}=\"{}\", {} is less than 0 and was not used. Default was used.",
    3517              :                                                 CurrentModuleObject,
    3518            0 :                                                 Condenser(CondNum).Name,
    3519              :                                                 cNumericFieldNames(NumNum)));
    3520              :                     }
    3521              :                 }
    3522            3 :                 NumNum = 10;
    3523            3 :                 if (!lNumericBlanks(NumNum)) {
    3524            3 :                     if (Numbers(NumNum) >= 0.0) {
    3525            3 :                         Condenser(CondNum).MaxCapFacEvap = Numbers(NumNum);
    3526              :                     } else {
    3527            0 :                         ShowWarningError(state,
    3528            0 :                                          format("{}=\"{}\", {} is less than 0 and was not used. Default was used.",
    3529              :                                                 CurrentModuleObject,
    3530            0 :                                                 Condenser(CondNum).Name,
    3531              :                                                 cNumericFieldNames(NumNum)));
    3532              :                     }
    3533              :                 }
    3534              : 
    3535              :                 // Check condenser air inlet node connection
    3536            3 :                 if (lAlphaBlanks(3)) {
    3537            0 :                     Condenser(CondNum).InletAirNodeNum = 0;
    3538              :                 } else {
    3539            6 :                     Condenser(CondNum).InletAirNodeNum =
    3540            6 :                         NodeInputManager::GetOnlySingleNode(state,
    3541            3 :                                                             Alphas(3),
    3542              :                                                             ErrorsFound,
    3543              :                                                             DataLoopNode::ConnectionObjectType::RefrigerationCondenserEvaporativeCooled,
    3544            3 :                                                             Alphas(1),
    3545              :                                                             DataLoopNode::NodeFluidType::Air,
    3546              :                                                             DataLoopNode::ConnectionType::OutsideAirReference,
    3547              :                                                             NodeInputManager::CompFluidStream::Primary,
    3548              :                                                             DataLoopNode::ObjectIsParent);
    3549            3 :                     if (!OutAirNodeManager::CheckOutAirNodeNumber(state, Condenser(CondNum).InletAirNodeNum)) {
    3550            0 :                         ShowSevereError(state,
    3551            0 :                                         format("{}{}=\"{}\", {} not found: {}",
    3552              :                                                RoutineName,
    3553              :                                                CurrentModuleObject,
    3554            0 :                                                Condenser(CondNum).Name,
    3555              :                                                cAlphaFieldNames(3),
    3556              :                                                Alphas(3)));
    3557            0 :                         ShowContinueError(state, "...does not appear in an OutdoorAir:NodeList or as an OutdoorAir:Node.");
    3558            0 :                         ErrorsFound = true;
    3559              :                     }
    3560              :                 } // Condenser air inlet node connection
    3561              : 
    3562            3 :                 NumNum = 11;
    3563            3 :                 Condenser(CondNum).RatedAirFlowRate = Numbers(NumNum);
    3564              :                 // Note the autocalculate feature for this value takes place in the system section because
    3565              :                 //  it is a function of the total cooling capacity of the cases served by the condenser
    3566              : 
    3567              :                 // Evaporative condensers basin heater power as a function of temperature must be greater than or equal to 0
    3568            3 :                 NumNum = 12;
    3569            3 :                 Condenser(CondNum).BasinHeaterPowerFTempDiff = Numbers(NumNum);
    3570            3 :                 if (Numbers(NumNum) < 0.0) {
    3571            0 :                     ShowSevereError(
    3572              :                         state,
    3573            0 :                         format(
    3574            0 :                             "{}{}=\"{}\", {} must be >= 0", RoutineName, CurrentModuleObject, Condenser(CondNum).Name, cNumericFieldNames(NumNum)));
    3575            0 :                     ErrorsFound = true;
    3576              :                 }
    3577              : 
    3578            3 :                 NumNum = 13;
    3579            3 :                 Condenser(CondNum).BasinHeaterSetPointTemp = 2.0; // default
    3580            3 :                 if (!lNumericBlanks(NumNum)) {
    3581            3 :                     Condenser(CondNum).BasinHeaterSetPointTemp = Numbers(NumNum);
    3582              :                 }
    3583            3 :                 if (Condenser(CondNum).BasinHeaterSetPointTemp < 2.0) {
    3584            0 :                     ShowWarningError(state,
    3585            0 :                                      format("{}=\"{}\", {} is less than 2 deg C. Freezing could occur.",
    3586              :                                             CurrentModuleObject,
    3587            0 :                                             Condenser(CondNum).Name,
    3588              :                                             cNumericFieldNames(NumNum)));
    3589              :                 }
    3590              : 
    3591            3 :                 NumNum = 14;
    3592            3 :                 Condenser(CondNum).EvapPumpPower = 1000.0; // default
    3593            3 :                 if (!lNumericBlanks(NumNum)) {
    3594            3 :                     Condenser(CondNum).EvapPumpPower = Numbers(NumNum);
    3595              :                 }
    3596              :                 // Note the autocalculate feature for this value takes place in the system section because
    3597              :                 //  it is a function of the total cooling capacity of the cases served by the condenser
    3598              : 
    3599              :                 // Get Evaporative Water System tank connections
    3600            3 :                 Condenser(CondNum).SupplyTankName = Alphas(4);
    3601            3 :                 if (lAlphaBlanks(4)) {
    3602            0 :                     Condenser(CondNum).EvapWaterSupplyMode = WaterSupply::FromMains;
    3603              :                 } else {
    3604            3 :                     Condenser(CondNum).EvapWaterSupplyMode = WaterSupply::FromTank;
    3605            6 :                     WaterManager::SetupTankDemandComponent(state,
    3606            3 :                                                            Condenser(CondNum).Name,
    3607              :                                                            CurrentModuleObject,
    3608            3 :                                                            Condenser(CondNum).SupplyTankName,
    3609              :                                                            ErrorsFound,
    3610            3 :                                                            Condenser(CondNum).EvapWaterSupTankID,
    3611            3 :                                                            Condenser(CondNum).EvapWaterTankDemandARRID);
    3612              :                 }
    3613              : 
    3614            3 :                 if (lAlphaBlanks(5)) {
    3615            3 :                 } else if ((Condenser(CondNum).evapAvailSched = Sched::GetSchedule(state, Alphas(5))) == nullptr) {
    3616            0 :                     ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(5), Alphas(5));
    3617            0 :                     ErrorsFound = true;
    3618            3 :                 } else if (!Condenser(CondNum).evapAvailSched->checkMinVal(state, Clusive::In, 0.0)) {
    3619            0 :                     Sched::ShowSevereBadMin(state, eoh, cAlphaFieldNames(5), Alphas(5), Clusive::In, 0.0);
    3620            0 :                     ErrorsFound = true;
    3621              :                 }
    3622              : 
    3623            3 :                 Condenser(CondNum).EndUseSubcategory = "";
    3624            3 :                 if (!lAlphaBlanks(6)) {
    3625            0 :                     Condenser(CondNum).EndUseSubcategory = Alphas(6);
    3626              :                 }
    3627              : 
    3628            3 :                 Condenser(CondNum).RefOpCharge = 0.0;
    3629            3 :                 Condenser(CondNum).RefReceiverInventory = 0.0;
    3630            3 :                 Condenser(CondNum).RefPipingInventory = 0.0;
    3631            3 :                 NumNum = 15;
    3632            3 :                 if (!lNumericBlanks(NumNum)) {
    3633            3 :                     Condenser(CondNum).RefOpCharge = Numbers(NumNum);
    3634              :                 }
    3635            3 :                 NumNum = 16;
    3636            3 :                 if (!lNumericBlanks(NumNum)) {
    3637            3 :                     Condenser(CondNum).RefReceiverInventory = Numbers(NumNum);
    3638              :                 }
    3639            3 :                 NumNum = 17;
    3640            3 :                 if (!lNumericBlanks(NumNum)) {
    3641            3 :                     Condenser(CondNum).RefPipingInventory = Numbers(NumNum);
    3642              :                 }
    3643              :             } // Read input for CONDENSER:REFRIGERATION:EVAPorativeCooled
    3644              :         } // If NumSimulationCondEvap > 0
    3645              : 
    3646           16 :         if (state.dataRefrigCase->NumSimulationCondWater > 0) {
    3647            1 :             CurrentModuleObject = "Refrigeration:Condenser:WaterCooled";
    3648            2 :             for (int CondIndex = 1; CondIndex <= state.dataRefrigCase->NumSimulationCondWater; ++CondIndex) {
    3649            1 :                 int CondNum = CondIndex + state.dataRefrigCase->NumSimulationCondAir + state.dataRefrigCase->NumSimulationCondEvap;
    3650            1 :                 state.dataInputProcessing->inputProcessor->getObjectItem(state,
    3651              :                                                                          CurrentModuleObject,
    3652              :                                                                          CondIndex,
    3653              :                                                                          Alphas,
    3654              :                                                                          NumAlphas,
    3655              :                                                                          Numbers,
    3656              :                                                                          NumNumbers,
    3657              :                                                                          IOStatus,
    3658              :                                                                          lNumericBlanks,
    3659              :                                                                          lAlphaBlanks,
    3660              :                                                                          cAlphaFieldNames,
    3661              :                                                                          cNumericFieldNames);
    3662              : 
    3663            1 :                 ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
    3664              : 
    3665            1 :                 GlobalNames::VerifyUniqueInterObjectName(
    3666            2 :                     state, state.dataRefrigCase->UniqueCondenserNames, Alphas(1), CurrentModuleObject, cAlphaFieldNames(1), ErrorsFound);
    3667            1 :                 Condenser(CondNum).Name = Alphas(1);
    3668            1 :                 state.dataHeatBal->HeatReclaimRefrigCondenser(CondNum).Name = Alphas(1);
    3669              : 
    3670              :                 // set start of count for number of systems attached to this condenser
    3671            1 :                 Condenser(CondNum).NumSysAttach = 0;
    3672            1 :                 if (!allocated(Condenser(CondNum).SysNum)) {
    3673            1 :                     Condenser(CondNum).SysNum.allocate(state.dataRefrigCase->NumRefrigSystems);
    3674              :                 }
    3675              : 
    3676              :                 // set CondenserType and rated Heat Rejection per ARI 450 rating
    3677            1 :                 Condenser(CondNum).CondenserType = DataHeatBalance::RefrigCondenserType::Water;
    3678            1 :                 state.dataHeatBal->HeatReclaimRefrigCondenser(CondNum).SourceType = CurrentModuleObject;
    3679            1 :                 if ((!lNumericBlanks(1)) && (Numbers(1) > 0.0)) {
    3680            1 :                     Condenser(CondNum).RatedCapacity = Numbers(1);
    3681              :                 } else {
    3682            0 :                     ShowSevereError(state,
    3683            0 :                                     format("{}{}=\"{}\" {} per ARI 450 must be input and must be greater than 0 Watts.",
    3684              :                                            RoutineName,
    3685              :                                            CurrentModuleObject,
    3686            0 :                                            Condenser(CondNum).Name,
    3687              :                                            cNumericFieldNames(1)));
    3688            0 :                     ErrorsFound = true;
    3689              :                 }
    3690              : 
    3691            1 :                 if ((!lNumericBlanks(2)) && (Numbers(2) > 0.0)) {
    3692            1 :                     Condenser(CondNum).RatedTCondense = Numbers(2);
    3693              :                 } else {
    3694            0 :                     ShowSevereError(state,
    3695            0 :                                     format("{}{}=\"{}\" {} per ARI 450 must be input and must be greater than 0 C.",
    3696              :                                            RoutineName,
    3697              :                                            CurrentModuleObject,
    3698            0 :                                            Condenser(CondNum).Name,
    3699              :                                            cNumericFieldNames(2)));
    3700            0 :                     ErrorsFound = true;
    3701              :                 }
    3702              : 
    3703            1 :                 if (!lNumericBlanks(3)) {
    3704            1 :                     if (Numbers(3) >= 0.0) {
    3705            1 :                         Condenser(CondNum).RatedSubcool = Numbers(3);
    3706              :                     } else {
    3707            0 :                         ShowSevereError(state,
    3708            0 :                                         format("{}{}=\"{}\" {} must be greater than or equal to zero.",
    3709              :                                                RoutineName,
    3710              :                                                CurrentModuleObject,
    3711            0 :                                                Condenser(CondNum).Name,
    3712              :                                                cNumericFieldNames(3)));
    3713            0 :                         ErrorsFound = true;
    3714              :                     }
    3715              :                 } else {
    3716            0 :                     Condenser(CondNum).RatedSubcool = 0.0; // default value
    3717              :                 }
    3718              : 
    3719            1 :                 if ((!lNumericBlanks(4)) && (Numbers(4) > 0.0)) {
    3720            1 :                     Condenser(CondNum).RatedWaterInletT = Numbers(4);
    3721            1 :                     Condenser(CondNum).RatedApproachT = Condenser(CondNum).RatedTCondense - Numbers(4);
    3722              :                 } else {
    3723            0 :                     ShowSevereError(state,
    3724            0 :                                     format("{}{}=\"{}\" {} must be input and greater than zero.",
    3725              :                                            RoutineName,
    3726              :                                            CurrentModuleObject,
    3727            0 :                                            Condenser(CondNum).Name,
    3728              :                                            cNumericFieldNames(4)));
    3729            0 :                     ErrorsFound = true;
    3730              :                 }
    3731              : 
    3732            2 :                 Condenser(CondNum).InletNode =
    3733            2 :                     NodeInputManager::GetOnlySingleNode(state,
    3734            1 :                                                         Alphas(2),
    3735              :                                                         ErrorsFound,
    3736              :                                                         DataLoopNode::ConnectionObjectType::RefrigerationCondenserWaterCooled,
    3737            1 :                                                         Alphas(1),
    3738              :                                                         DataLoopNode::NodeFluidType::Water,
    3739              :                                                         DataLoopNode::ConnectionType::Inlet,
    3740              :                                                         NodeInputManager::CompFluidStream::Primary,
    3741              :                                                         DataLoopNode::ObjectIsNotParent);
    3742            2 :                 Condenser(CondNum).OutletNode =
    3743            2 :                     NodeInputManager::GetOnlySingleNode(state,
    3744            1 :                                                         Alphas(3),
    3745              :                                                         ErrorsFound,
    3746              :                                                         DataLoopNode::ConnectionObjectType::RefrigerationCondenserWaterCooled,
    3747            1 :                                                         Alphas(1),
    3748              :                                                         DataLoopNode::NodeFluidType::Water,
    3749              :                                                         DataLoopNode::ConnectionType::Outlet,
    3750              :                                                         NodeInputManager::CompFluidStream::Primary,
    3751              :                                                         DataLoopNode::ObjectIsNotParent);
    3752              :                 // Check node connections
    3753            1 :                 BranchNodeConnections::TestCompSet(state, CurrentModuleObject, Alphas(1), Alphas(2), Alphas(3), "Water Cooled Condenser Nodes");
    3754              :                 // Get loop flow type
    3755            1 :                 if ((Condenser(CondNum).FlowType = static_cast<CndsrFlowType>(getEnumValue(cndsrFlowTypeNamesUC, Alphas(4)))) ==
    3756              :                     CndsrFlowType::Invalid) {
    3757              : 
    3758            0 :                     ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(4), Alphas(4));
    3759            0 :                     ErrorsFound = true;
    3760              :                 } // Set FlowType
    3761              : 
    3762              :                 // Get outlet temperature schedule for variable flow case
    3763            1 :                 if (Condenser(CondNum).FlowType == CndsrFlowType::Variable) {
    3764            1 :                     if (lAlphaBlanks(5)) {
    3765            1 :                     } else if ((Condenser(CondNum).outletTempSched = Sched::GetSchedule(state, Alphas(5))) == nullptr) {
    3766            0 :                         ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(5), Alphas(5));
    3767            0 :                         ErrorsFound = true;
    3768              :                     }
    3769              :                 } // Outlet temperature schedule
    3770              : 
    3771              :                 // Get volumetric flow rate if applicable
    3772            0 :                 else if (Condenser(CondNum).FlowType == CndsrFlowType::Constant) {
    3773            0 :                     if ((!lNumericBlanks(5)) && (Numbers(5) > 0.0)) {
    3774            0 :                         Condenser(CondNum).DesVolFlowRate = Numbers(5);
    3775            0 :                         Condenser(CondNum).VolFlowRate = Numbers(5);
    3776              :                     } else {
    3777            0 :                         ShowSevereError(state,
    3778            0 :                                         format("{}{}=\"{}\" {} must be greater than zero.",
    3779              :                                                RoutineName,
    3780              :                                                CurrentModuleObject,
    3781            0 :                                                Condenser(CondNum).Name,
    3782              :                                                cNumericFieldNames(5)));
    3783            0 :                         ShowContinueError(state, "Revise flow rates.");
    3784            0 :                         ErrorsFound = true;
    3785              :                     }
    3786            0 :                     PlantUtilities::RegisterPlantCompDesignFlow(state, Condenser(CondNum).InletNode, Condenser(CondNum).DesVolFlowRate);
    3787              :                 }
    3788              : 
    3789              :                 // Get maximum flow rates
    3790            1 :                 if (Numbers(6) > 0.0) {
    3791            1 :                     Condenser(CondNum).VolFlowRateMax = Numbers(6);
    3792              :                     // Check constant flow for max violation, if applicable
    3793            1 :                     if (Condenser(CondNum).FlowType == CndsrFlowType::Constant && Condenser(CondNum).VolFlowRate > Numbers(6)) {
    3794            0 :                         ShowSevereError(state,
    3795            0 :                                         format("{}{}=\"{}\" {} > {} .",
    3796              :                                                RoutineName,
    3797              :                                                CurrentModuleObject,
    3798            0 :                                                Condenser(CondNum).Name,
    3799              :                                                cNumericFieldNames(5),
    3800              :                                                cNumericFieldNames(6)));
    3801            0 :                         ShowContinueError(state, "Revise flow rates.");
    3802            0 :                         ErrorsFound = true;
    3803              :                     } // Error check on max flow rate
    3804              :                 } else {
    3805            0 :                     ShowSevereError(state,
    3806            0 :                                     format("{}{}=\"{}\" {} must be greater than zero.",
    3807              :                                            RoutineName,
    3808              :                                            CurrentModuleObject,
    3809            0 :                                            Condenser(CondNum).Name,
    3810              :                                            cNumericFieldNames(6)));
    3811            0 :                     ErrorsFound = true;
    3812              :                 }
    3813              : 
    3814              :                 // Get max/min allowed water temps
    3815            1 :                 Condenser(CondNum).OutletTempMax = Numbers(7);
    3816            1 :                 Condenser(CondNum).InletTempMin = Numbers(8);
    3817              : 
    3818            1 :                 Condenser(CondNum).EndUseSubcategory = "";
    3819            1 :                 if (!lAlphaBlanks(6)) {
    3820            0 :                     Condenser(CondNum).EndUseSubcategory = Alphas(6);
    3821              :                 }
    3822              : 
    3823            1 :                 Condenser(CondNum).RefOpCharge = 0.0;
    3824            1 :                 Condenser(CondNum).RefReceiverInventory = 0.0;
    3825            1 :                 Condenser(CondNum).RefPipingInventory = 0.0;
    3826            1 :                 if (!lNumericBlanks(9)) {
    3827            1 :                     Condenser(CondNum).RefOpCharge = Numbers(9);
    3828              :                 }
    3829            1 :                 if (!lNumericBlanks(10)) {
    3830            1 :                     Condenser(CondNum).RefReceiverInventory = Numbers(10);
    3831              :                 }
    3832            1 :                 if (!lNumericBlanks(11)) {
    3833            1 :                     Condenser(CondNum).RefPipingInventory = Numbers(11);
    3834              :                 }
    3835              : 
    3836              :             } // Read input for CONDENSER:REFRIGERATION:WaterCooled
    3837              : 
    3838            1 :             state.dataRefrigCase->CheckEquipNameWaterCondenser.dimension(state.dataRefrigCase->NumRefrigCondensers, true);
    3839              :         } // NumSimulationCondWater > 0
    3840              : 
    3841              :         // cascade condensers assumed to provide zero subcooling
    3842           16 :         if (state.dataRefrigCase->NumSimulationCascadeCondensers > 0) {
    3843            1 :             CurrentModuleObject = "Refrigeration:Condenser:Cascade";
    3844            2 :             for (int CondIndex = 1; CondIndex <= state.dataRefrigCase->NumSimulationCascadeCondensers; ++CondIndex) {
    3845            1 :                 int CondNum = CondIndex + state.dataRefrigCase->NumSimulationCondAir + state.dataRefrigCase->NumSimulationCondEvap +
    3846            1 :                               state.dataRefrigCase->NumSimulationCondWater;
    3847            1 :                 state.dataInputProcessing->inputProcessor->getObjectItem(state,
    3848              :                                                                          CurrentModuleObject,
    3849              :                                                                          CondIndex,
    3850              :                                                                          Alphas,
    3851              :                                                                          NumAlphas,
    3852              :                                                                          Numbers,
    3853              :                                                                          NumNumbers,
    3854              :                                                                          IOStatus,
    3855              :                                                                          lNumericBlanks,
    3856              :                                                                          lAlphaBlanks,
    3857              :                                                                          cAlphaFieldNames,
    3858              :                                                                          cNumericFieldNames);
    3859              : 
    3860            1 :                 ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
    3861              : 
    3862            1 :                 GlobalNames::VerifyUniqueInterObjectName(
    3863            2 :                     state, state.dataRefrigCase->UniqueCondenserNames, Alphas(1), CurrentModuleObject, cAlphaFieldNames(1), ErrorsFound);
    3864            1 :                 Condenser(CondNum).Name = Alphas(1);
    3865            1 :                 state.dataHeatBal->HeatReclaimRefrigCondenser(CondNum).Name = Alphas(1);
    3866              : 
    3867              :                 // set start of count for number of systems attached to this condenser
    3868            1 :                 Condenser(CondNum).NumSysAttach = 0;
    3869            1 :                 if (!allocated(Condenser(CondNum).SysNum)) {
    3870            1 :                     Condenser(CondNum).SysNum.allocate(state.dataRefrigCase->NumRefrigSystems);
    3871              :                 }
    3872              : 
    3873              :                 // set CondenserType
    3874            1 :                 Condenser(CondNum).CondenserType = DataHeatBalance::RefrigCondenserType::Cascade;
    3875              : 
    3876            1 :                 if (!lNumericBlanks(1)) {
    3877            1 :                     Condenser(CondNum).RatedTCondense = Numbers(1);
    3878              :                 } else {
    3879            0 :                     ShowSevereError(
    3880              :                         state,
    3881            0 :                         format("{}{}=\"{}\" {} must be input.", RoutineName, CurrentModuleObject, Condenser(CondNum).Name, cNumericFieldNames(1)));
    3882            0 :                     ErrorsFound = true;
    3883              :                 }
    3884              : 
    3885            1 :                 if (!lNumericBlanks(2)) {
    3886            1 :                     if (Numbers(2) >= 0.0) {
    3887            1 :                         Condenser(CondNum).RatedApproachT = Numbers(2);
    3888              :                     } else {
    3889            0 :                         ShowSevereError(state,
    3890            0 :                                         format("{}{}=\"{}\" {} must be greater than or equal to zero.",
    3891              :                                                RoutineName,
    3892              :                                                CurrentModuleObject,
    3893            0 :                                                Condenser(CondNum).Name,
    3894              :                                                cNumericFieldNames(2)));
    3895            0 :                         ErrorsFound = true;
    3896              :                     }
    3897              :                 } else {
    3898            0 :                     Condenser(CondNum).RatedApproachT = DefaultCascadeCondApproach;
    3899              :                 }
    3900              : 
    3901            1 :                 if ((!lNumericBlanks(3)) && (Numbers(3) > 0.0)) {
    3902            1 :                     Condenser(CondNum).RatedCapacity = Numbers(3);
    3903              :                 } else {
    3904            0 :                     ShowSevereError(state,
    3905            0 :                                     format("{}{}=\"{}\" {} must be in put and must be greater than or equal to zero.",
    3906              :                                            RoutineName,
    3907              :                                            CurrentModuleObject,
    3908            0 :                                            Condenser(CondNum).Name,
    3909              :                                            cNumericFieldNames(3)));
    3910            0 :                     ErrorsFound = true;
    3911              :                 }
    3912              : 
    3913              :                 // Get condensing temperature type, either fixed by design or allowed to float to match other loads on supply system
    3914            1 :                 if (lAlphaBlanks(2)) {
    3915            0 :                     Condenser(CondNum).CascadeTempControl = CascadeCndsrTempCtrlType::TempSet;
    3916            2 :                 } else if ((Condenser(CondNum).CascadeTempControl = static_cast<CascadeCndsrTempCtrlType>(
    3917            1 :                                 getEnumValue(cascaseCndsrTempCtrlTypeNamesUC, Alphas(2)))) == CascadeCndsrTempCtrlType::Invalid) {
    3918            0 :                     ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(2), Alphas(2));
    3919            0 :                     ErrorsFound = true;
    3920              :                 } // string comparison to key choices
    3921              : 
    3922            1 :                 Condenser(CondNum).CascadeRatedEvapTemp = Condenser(CondNum).RatedTCondense - Condenser(CondNum).RatedApproachT;
    3923              : 
    3924              :                 // future - add refrigerant inventory on system side accepting reject heat (as was done for secondary)
    3925            1 :                 Condenser(CondNum).RefOpCharge = 0.0;
    3926            1 :                 Condenser(CondNum).RefReceiverInventory = 0.0;
    3927            1 :                 Condenser(CondNum).RefPipingInventory = 0.0;
    3928            1 :                 if (!lNumericBlanks(4)) {
    3929            0 :                     Condenser(CondNum).RefOpCharge = Numbers(4);
    3930              :                 }
    3931            1 :                 if (!lNumericBlanks(5)) {
    3932            0 :                     Condenser(CondNum).RefReceiverInventory = Numbers(5);
    3933              :                 }
    3934            1 :                 if (!lNumericBlanks(6)) {
    3935            0 :                     Condenser(CondNum).RefPipingInventory = Numbers(6);
    3936              :                 }
    3937              : 
    3938              :             } // Read input for CONDENSER:REFRIGERATION:Cascade
    3939              :         } // NumSimulationCascadeCondensers > 0
    3940              : 
    3941              :         //************ END CONDENSER INPUT   **************
    3942              : 
    3943              :         //**********  START GAS COOLER INPUT  **********
    3944              : 
    3945           16 :         if (state.dataRefrigCase->NumSimulationGasCooler > 0) {
    3946            1 :             CurrentModuleObject = "Refrigeration:GasCooler:AirCooled";
    3947            2 :             for (int GCNum = 1; GCNum <= state.dataRefrigCase->NumSimulationGasCooler; ++GCNum) {
    3948            1 :                 state.dataInputProcessing->inputProcessor->getObjectItem(state,
    3949              :                                                                          CurrentModuleObject,
    3950              :                                                                          GCNum,
    3951              :                                                                          Alphas,
    3952              :                                                                          NumAlphas,
    3953              :                                                                          Numbers,
    3954              :                                                                          NumNumbers,
    3955              :                                                                          IOStatus,
    3956              :                                                                          lNumericBlanks,
    3957              :                                                                          lAlphaBlanks,
    3958              :                                                                          cAlphaFieldNames,
    3959              :                                                                          cNumericFieldNames);
    3960            1 :                 ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
    3961              : 
    3962            1 :                 GasCooler(GCNum).Name = Alphas(1);
    3963              : 
    3964            1 :                 GasCooler(GCNum).CapCurvePtr = Curve::GetCurveIndex(state, Alphas(2)); // convert curve name to number
    3965            1 :                 if (GasCooler(GCNum).CapCurvePtr == 0) {
    3966            0 :                     ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(2), Alphas(2));
    3967            0 :                     ErrorsFound = true;
    3968              :                 }
    3969              : 
    3970              :                 // set start of count for number of systems attached to this gas cooler
    3971            1 :                 GasCooler(GCNum).NumSysAttach = 0;
    3972            1 :                 if (!allocated(GasCooler(GCNum).SysNum)) {
    3973            1 :                     GasCooler(GCNum).SysNum.allocate(state.dataRefrigCase->NumTransRefrigSystems);
    3974              :                 }
    3975              : 
    3976            1 :                 GasCooler(GCNum).RatedApproachT = 3.0; // rated CO2 gas cooler approach temperature
    3977            1 :                 if (GasCooler(GCNum).CapCurvePtr > 0) {
    3978            1 :                     GasCooler(GCNum).RatedCapacity = Curve::CurveValue(state, GasCooler(GCNum).CapCurvePtr, GasCooler(GCNum).RatedApproachT);
    3979              :                 }
    3980              :                 // elevation capacity correction on air-cooled condensers, Carrier correlation more conservative than Trane
    3981            1 :                 GasCooler(GCNum).RatedCapacity *= (1.0 - 7.17e-5 * state.dataEnvrn->Elevation);
    3982            1 :                 if (GasCooler(GCNum).RatedCapacity > 0.0) {
    3983            1 :                     Curve::GetCurveMinMaxValues(state, GasCooler(GCNum).CapCurvePtr, DelTempMin, DelTempMax);
    3984            1 :                     Real64 Capmin = Curve::CurveValue(state, GasCooler(GCNum).CapCurvePtr, DelTempMin) * (1.0 - 7.17e-5 * state.dataEnvrn->Elevation);
    3985            1 :                     Real64 Capmax = Curve::CurveValue(state, GasCooler(GCNum).CapCurvePtr, DelTempMax) * (1.0 - 7.17e-5 * state.dataEnvrn->Elevation);
    3986            1 :                     GasCooler(GCNum).TempSlope = (DelTempMax - DelTempMin) / ((Capmax - Capmin));
    3987            1 :                     GasCooler(GCNum).MinCondLoad = Capmax - DelTempMax / GasCooler(GCNum).TempSlope;
    3988              :                 } else {
    3989            0 :                     ShowSevereError(
    3990              :                         state,
    3991            0 :                         format("{}{}=\"{}\" Gas Cooler capacity curve must be input and must be greater than 0 Watts at 3C temperature difference.",
    3992              :                                RoutineName,
    3993              :                                CurrentModuleObject,
    3994            0 :                                GasCooler(GCNum).Name));
    3995            0 :                     ErrorsFound = true;
    3996              :                 }
    3997              : 
    3998              :                 // Get fan control type
    3999            1 :                 if (lAlphaBlanks(3)) {
    4000            0 :                     GasCooler(GCNum).FanSpeedControlType = FanSpeedCtrlType::ConstantSpeed; // default
    4001            1 :                 } else if ((GasCooler(GCNum).FanSpeedControlType = static_cast<FanSpeedCtrlType>(getEnumValue(fanSpeedCtrlTypeNamesUC, Alphas(3)))) ==
    4002              :                            FanSpeedCtrlType::Invalid) {
    4003            0 :                     ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(3), Alphas(3));
    4004            0 :                     ErrorsFound = true;
    4005              :                 }
    4006              : 
    4007              :                 // Gas cooler fan power
    4008            1 :                 GasCooler(GCNum).RatedFanPower = 5000.0; // default value
    4009            1 :                 if (!lNumericBlanks(1)) {
    4010            1 :                     GasCooler(GCNum).RatedFanPower = Numbers(1);
    4011              :                 }
    4012            1 :                 if (Numbers(1) < 0.0) {
    4013            0 :                     ShowSevereError(state,
    4014            0 :                                     format("{}{}=\"{}\" {} must be input greater than or equal to 0 Watts.",
    4015              :                                            RoutineName,
    4016              :                                            CurrentModuleObject,
    4017            0 :                                            GasCooler(GCNum).Name,
    4018              :                                            cNumericFieldNames(1)));
    4019            0 :                     ErrorsFound = true;
    4020              :                 }
    4021              : 
    4022              :                 // Gas cooler minimum fan air flow ratio
    4023            1 :                 GasCooler(GCNum).FanMinAirFlowRatio = 0.2; // default value
    4024            1 :                 if (!lNumericBlanks(2)) {
    4025            1 :                     GasCooler(GCNum).FanMinAirFlowRatio = Numbers(2);
    4026              :                 }
    4027            1 :                 if ((GasCooler(GCNum).FanMinAirFlowRatio < 0.0) || (GasCooler(GCNum).FanMinAirFlowRatio > 1.0)) {
    4028            0 :                     ShowSevereError(state,
    4029            0 :                                     format("{}{}=\"{}\" {} must be a value between zero and one.  The default value (0.2) will be used.",
    4030              :                                            RoutineName,
    4031              :                                            CurrentModuleObject,
    4032            0 :                                            GasCooler(GCNum).Name,
    4033              :                                            cNumericFieldNames(2)));
    4034            0 :                     GasCooler(GCNum).FanMinAirFlowRatio = 0.2;
    4035              :                 }
    4036              : 
    4037              :                 // Gas cooler transition temperature
    4038            1 :                 GasCooler(GCNum).TransitionTemperature = 2.7e1; // default value
    4039            1 :                 if (!lNumericBlanks(3)) {
    4040            1 :                     GasCooler(GCNum).TransitionTemperature = Numbers(3);
    4041              :                 }
    4042            1 :                 if (GasCooler(GCNum).TransitionTemperature < 2.5e1) {
    4043            0 :                     ShowWarningError(state,
    4044            0 :                                      format("{}{}=\"{}\" {} is low (less than 25C).  Consider raising the transition temperature to operate for "
    4045              :                                             "longer periods of time in the subcritical region.",
    4046              :                                             RoutineName,
    4047              :                                             CurrentModuleObject,
    4048            0 :                                             GasCooler(GCNum).Name,
    4049              :                                             cNumericFieldNames(3)));
    4050              :                 }
    4051            1 :                 if (GasCooler(GCNum).TransitionTemperature > 30.978) {
    4052            0 :                     ShowWarningError(
    4053              :                         state,
    4054            0 :                         format("{}{}=\"{}\" {} is greater than the critical temperature of carbon dioxide.  The default value (27C) will be used.",
    4055              :                                RoutineName,
    4056              :                                CurrentModuleObject,
    4057            0 :                                GasCooler(GCNum).Name,
    4058              :                                cNumericFieldNames(3)));
    4059            0 :                     GasCooler(GCNum).TransitionTemperature = 2.7e1;
    4060              :                 }
    4061              : 
    4062              :                 // Gas cooler approach temperature for transcritical operation
    4063            1 :                 GasCooler(GCNum).GasCoolerApproachT = 3.0; // default value
    4064            1 :                 if (!lNumericBlanks(4)) {
    4065            1 :                     GasCooler(GCNum).GasCoolerApproachT = Numbers(4);
    4066              :                 }
    4067            1 :                 if (GasCooler(GCNum).GasCoolerApproachT < 0.0) {
    4068            0 :                     ShowSevereError(state,
    4069            0 :                                     format("{}{}=\"{}\" {} must be greater than 0C.",
    4070              :                                            RoutineName,
    4071              :                                            CurrentModuleObject,
    4072            0 :                                            GasCooler(GCNum).Name,
    4073              :                                            cNumericFieldNames(4)));
    4074            0 :                     ErrorsFound = true;
    4075              :                 }
    4076              : 
    4077              :                 // Gas cooler temperature difference for subcritical operation
    4078            1 :                 GasCooler(GCNum).SubcriticalTempDiff = 1.0e1; // default value
    4079            1 :                 if (!lNumericBlanks(5)) {
    4080            1 :                     GasCooler(GCNum).SubcriticalTempDiff = Numbers(5);
    4081              :                 }
    4082            1 :                 if (GasCooler(GCNum).SubcriticalTempDiff < 0.0) {
    4083            0 :                     ShowSevereError(state,
    4084            0 :                                     format("{}{}=\"{}\" {} must be greater than 0C.",
    4085              :                                            RoutineName,
    4086              :                                            CurrentModuleObject,
    4087            0 :                                            GasCooler(GCNum).Name,
    4088              :                                            cNumericFieldNames(5)));
    4089            0 :                     ErrorsFound = true;
    4090              :                 }
    4091              : 
    4092              :                 // Gas cooler minimum condensing temperature for subcritical operation
    4093            1 :                 GasCooler(GCNum).MinCondTemp = 1.0e1; // default value
    4094            1 :                 if (!lNumericBlanks(6)) {
    4095            1 :                     GasCooler(GCNum).MinCondTemp = Numbers(6);
    4096              :                 }
    4097            1 :                 if (GasCooler(GCNum).MinCondTemp > 30.9) {
    4098            0 :                     ShowSevereError(state,
    4099            0 :                                     format("{}{}=\"{}\" {} must be less than the critical temperature of carbon dioxide (31C).",
    4100              :                                            RoutineName,
    4101              :                                            CurrentModuleObject,
    4102            0 :                                            GasCooler(GCNum).Name,
    4103              :                                            cNumericFieldNames(6)));
    4104            0 :                     ErrorsFound = true;
    4105              :                 }
    4106              : 
    4107              :                 // Check GasCooler air inlet node connection
    4108            1 :                 GasCooler(GCNum).GasCoolerRejectHeatToZone = false;
    4109            1 :                 if (lAlphaBlanks(4)) {
    4110            1 :                     GasCooler(GCNum).InletAirNodeNum = 0;
    4111              :                 } else { // see if it's an outside air node name or an indoor zone name,
    4112              :                     // have to check inside first because outside check automatically generates an error message
    4113            0 :                     GasCooler(GCNum).InletAirZoneNum = Util::FindItemInList(Alphas(4), state.dataHeatBal->Zone);
    4114              :                     // need to clearly id node number for air inlet conditions and zone number for casecredit assignment
    4115            0 :                     if (GasCooler(GCNum).InletAirZoneNum != 0) {
    4116              :                         // set condenser flag (later used to set system flag) and zone flag
    4117            0 :                         GasCooler(GCNum).InletAirNodeNum = DataZoneEquipment::GetSystemNodeNumberForZone(state, GasCooler(GCNum).InletAirZoneNum);
    4118            0 :                         GasCooler(GCNum).GasCoolerRejectHeatToZone = true;
    4119            0 :                         state.dataRefrigCase->RefrigPresentInZone(GasCooler(GCNum).InletAirZoneNum) = true;
    4120              :                     } else { // not in a conditioned zone, so see if it's outside
    4121            0 :                         GasCooler(GCNum).InletAirNodeNum =
    4122            0 :                             NodeInputManager::GetOnlySingleNode(state,
    4123            0 :                                                                 Alphas(4),
    4124              :                                                                 ErrorsFound,
    4125              :                                                                 DataLoopNode::ConnectionObjectType::RefrigerationGasCoolerAirCooled,
    4126            0 :                                                                 Alphas(1),
    4127              :                                                                 DataLoopNode::NodeFluidType::Air,
    4128              :                                                                 DataLoopNode::ConnectionType::OutsideAirReference,
    4129              :                                                                 NodeInputManager::CompFluidStream::Primary,
    4130              :                                                                 DataLoopNode::ObjectIsParent);
    4131            0 :                         if (!OutAirNodeManager::CheckOutAirNodeNumber(state, GasCooler(GCNum).InletAirNodeNum)) {
    4132              :                             // not outside and not a zone
    4133            0 :                             ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(4), Alphas(4));
    4134            0 :                             ShowContinueError(state, "...does not appear in an OutdoorAir:NodeList or as an OutdoorAir:Node or as a Zone.");
    4135            0 :                             ErrorsFound = true;
    4136              :                         } // checkoutairnodenumber
    4137              :                     } // InletAirZoneNum \=0
    4138              :                 } // Gas cooler air inlet node connection
    4139              : 
    4140            1 :                 GasCooler(GCNum).EndUseSubcategory = "";
    4141            1 :                 if (!lAlphaBlanks(5)) {
    4142            1 :                     GasCooler(GCNum).EndUseSubcategory = Alphas(5);
    4143              :                 }
    4144              : 
    4145            1 :                 GasCooler(GCNum).RefOpCharge = 0.0;
    4146            1 :                 GasCooler(GCNum).RefReceiverInventory = 0.0;
    4147            1 :                 GasCooler(GCNum).RefPipingInventory = 0.0;
    4148            1 :                 if (!lNumericBlanks(7)) {
    4149            0 :                     GasCooler(GCNum).RefOpCharge = Numbers(7);
    4150              :                 }
    4151            1 :                 if (!lNumericBlanks(8)) {
    4152            0 :                     GasCooler(GCNum).RefReceiverInventory = Numbers(8);
    4153              :                 }
    4154            1 :                 if (!lNumericBlanks(9)) {
    4155            0 :                     GasCooler(GCNum).RefPipingInventory = Numbers(9);
    4156              :                 }
    4157              : 
    4158              :             } // Read input for REFRIGERATION:GasCooler:AirCooled
    4159              :         } // NumSimulationGasCooler > 0
    4160              : 
    4161              :         //**********  END GAS COOLER INPUT  **********
    4162              : 
    4163              :         //************ START SECONDARY LOOP INPUT (before system input) **************
    4164           16 :         if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
    4165            1 :             CurrentModuleObject = "Refrigeration:SecondarySystem";
    4166            3 :             for (int SecondaryNum = 1; SecondaryNum <= state.dataRefrigCase->NumSimulationSecondarySystems; ++SecondaryNum) {
    4167            2 :                 state.dataInputProcessing->inputProcessor->getObjectItem(state,
    4168              :                                                                          CurrentModuleObject,
    4169              :                                                                          SecondaryNum,
    4170              :                                                                          Alphas,
    4171              :                                                                          NumAlphas,
    4172              :                                                                          Numbers,
    4173              :                                                                          NumNumbers,
    4174              :                                                                          IOStatus,
    4175              :                                                                          lNumericBlanks,
    4176              :                                                                          lAlphaBlanks,
    4177              :                                                                          cAlphaFieldNames,
    4178              :                                                                          cNumericFieldNames);
    4179              : 
    4180            2 :                 ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
    4181            2 :                 Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    4182              : 
    4183            2 :                 Secondary(SecondaryNum).Name = Alphas(1);
    4184              : 
    4185              :                 //   Find the loads on the secondary loop: can be input in form of case or walkin or CaseAndWalkInList names
    4186            2 :                 Real64 NominalTotalCaseCap = 0.0;
    4187            2 :                 NumCases = 0;
    4188            2 :                 Real64 NominalTotalCoilCap = 0.0;
    4189            2 :                 int NumCoils = 0;
    4190            2 :                 NumWalkIns = 0;
    4191            2 :                 Real64 NominalTotalWalkInCap = 0.0;
    4192            2 :                 Secondary(SecondaryNum).RefInventory = 0.0;
    4193              : 
    4194              :                 //   Read display case and walkin assignments for this secondary
    4195            2 :                 AlphaNum = 2;
    4196            2 :                 if (lAlphaBlanks(AlphaNum)) {
    4197              :                     // No cases or walkins specified, ie, secondary has no load
    4198            0 :                     ShowSevereError(state,
    4199            0 :                                     format("{}{}=\"{}\", has no loads, must have at least one of: {}",
    4200              :                                            RoutineName,
    4201              :                                            CurrentModuleObject,
    4202            0 :                                            Secondary(SecondaryNum).Name,
    4203              :                                            cAlphaFieldNames(AlphaNum)));
    4204            0 :                     ErrorsFound = true;
    4205              :                 } else { // (.NOT. lAlphaBlanks(AlphaNum))
    4206              : 
    4207              :                     // Entry for Alphas(AlphaNum) can be either a Case, WalkIn Coil, or CaseAndWalkInList name
    4208            2 :                     int CaseAndWalkInListNum = 0;
    4209            2 :                     int CaseNum = 0;
    4210            2 :                     int WalkInNum = 0;
    4211            2 :                     int CoilNum = 0;
    4212            2 :                     if (state.dataRefrigCase->NumSimulationCaseAndWalkInLists > 0) {
    4213            2 :                         CaseAndWalkInListNum = Util::FindItemInList(Alphas(AlphaNum), CaseAndWalkInList);
    4214              :                     }
    4215            2 :                     if (state.dataRefrigCase->NumSimulationCases > 0) {
    4216            2 :                         CaseNum = Util::FindItemInList(Alphas(AlphaNum), RefrigCase);
    4217              :                     }
    4218            2 :                     if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
    4219            2 :                         WalkInNum = Util::FindItemInList(Alphas(AlphaNum), WalkIn);
    4220              :                     }
    4221            2 :                     if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0) {
    4222            0 :                         CoilNum = Util::FindItemInList(Alphas(AlphaNum), WarehouseCoil);
    4223              :                     }
    4224            2 :                     int NumNameMatches = 0;
    4225            2 :                     if (CaseAndWalkInListNum != 0) {
    4226            2 :                         ++NumNameMatches;
    4227              :                     }
    4228            2 :                     if (CaseNum != 0) {
    4229            0 :                         ++NumNameMatches;
    4230              :                     }
    4231            2 :                     if (WalkInNum != 0) {
    4232            0 :                         ++NumNameMatches;
    4233              :                     }
    4234            2 :                     if (CoilNum != 0) {
    4235            0 :                         ++NumNameMatches;
    4236              :                     }
    4237              : 
    4238            2 :                     if (NumNameMatches != 1) { // name must uniquely point to a list or a single case or walkin or coil
    4239            0 :                         ErrorsFound = true;
    4240            0 :                         if (NumNameMatches == 0) {
    4241            0 :                             ShowSevereError(state,
    4242            0 :                                             format("{}{}=\"{}\", has an invalid {}: {}",
    4243              :                                                    RoutineName,
    4244              :                                                    CurrentModuleObject,
    4245            0 :                                                    Secondary(SecondaryNum).Name,
    4246              :                                                    cAlphaFieldNames(AlphaNum),
    4247              :                                                    Alphas(AlphaNum)));
    4248            0 :                         } else if (NumNameMatches > 1) {
    4249            0 :                             ShowSevereError(state,
    4250            0 :                                             format("{}{}=\"{}\", has a non-unique name that could be either a {}: {}",
    4251              :                                                    RoutineName,
    4252              :                                                    CurrentModuleObject,
    4253            0 :                                                    Secondary(SecondaryNum).Name,
    4254              :                                                    cAlphaFieldNames(AlphaNum),
    4255              :                                                    Alphas(AlphaNum)));
    4256              :                         } // num matches = 0 or > 1
    4257            2 :                     } else if (CaseAndWalkInListNum != 0) { // Name points to a CaseAndWalkInList
    4258            2 :                         NumCoils = CaseAndWalkInList(CaseAndWalkInListNum).NumCoils;
    4259            2 :                         NumCases = CaseAndWalkInList(CaseAndWalkInListNum).NumCases;
    4260            2 :                         NumWalkIns = CaseAndWalkInList(CaseAndWalkInListNum).NumWalkIns;
    4261            2 :                         Secondary(SecondaryNum).NumCases = NumCases;
    4262            2 :                         Secondary(SecondaryNum).NumCoils = NumCoils;
    4263            2 :                         Secondary(SecondaryNum).NumWalkIns = NumWalkIns;
    4264            2 :                         if (!allocated(Secondary(SecondaryNum).CaseNum)) {
    4265            2 :                             Secondary(SecondaryNum).CaseNum.allocate(NumCases);
    4266              :                         }
    4267            2 :                         Secondary(SecondaryNum).CaseNum({1, NumCases}) = CaseAndWalkInList(CaseAndWalkInListNum).CaseItemNum({1, NumCases});
    4268            2 :                         if (!allocated(Secondary(SecondaryNum).CoilNum)) {
    4269            2 :                             Secondary(SecondaryNum).CoilNum.allocate(NumCoils);
    4270              :                         }
    4271            2 :                         Secondary(SecondaryNum).CoilNum({1, NumCoils}) = CaseAndWalkInList(CaseAndWalkInListNum).CoilItemNum({1, NumCoils});
    4272            2 :                         if (!allocated(Secondary(SecondaryNum).WalkInNum)) {
    4273            2 :                             Secondary(SecondaryNum).WalkInNum.allocate(NumWalkIns);
    4274              :                         }
    4275            2 :                         Secondary(SecondaryNum).WalkInNum({1, NumWalkIns}) = CaseAndWalkInList(CaseAndWalkInListNum).WalkInItemNum({1, NumWalkIns});
    4276            0 :                     } else if (CaseNum != 0) { // Name points to a case
    4277            0 :                         NumCases = 1;
    4278            0 :                         Secondary(SecondaryNum).NumCases = 1;
    4279            0 :                         if (!allocated(Secondary(SecondaryNum).CaseNum)) {
    4280            0 :                             Secondary(SecondaryNum).CaseNum.allocate(NumCases);
    4281              :                         }
    4282            0 :                         Secondary(SecondaryNum).CaseNum(NumCases) = CaseNum;
    4283            0 :                     } else if (CoilNum != 0) { // Name points to a coil
    4284            0 :                         NumCoils = 1;
    4285            0 :                         Secondary(SecondaryNum).NumCoils = 1;
    4286            0 :                         if (!allocated(Secondary(SecondaryNum).CoilNum)) {
    4287            0 :                             Secondary(SecondaryNum).CoilNum.allocate(NumCoils);
    4288              :                         }
    4289            0 :                         Secondary(SecondaryNum).CoilNum(NumCoils) = CoilNum;
    4290            0 :                     } else if (WalkInNum != 0) { // Name points to a walkin
    4291            0 :                         NumWalkIns = 1;
    4292            0 :                         Secondary(SecondaryNum).NumWalkIns = 1;
    4293            0 :                         if (!allocated(Secondary(SecondaryNum).WalkInNum)) {
    4294            0 :                             Secondary(SecondaryNum).WalkInNum.allocate(NumWalkIns);
    4295              :                         }
    4296            0 :                         Secondary(SecondaryNum).WalkInNum(NumWalkIns) = WalkInNum;
    4297              :                     } // NumNameMatches /= 1
    4298              :                 } // blank input for loads on secondary
    4299              : 
    4300            2 :                 if (NumCases > 0) {
    4301              :                     // Find lowest design T loop fluid out of secondary chiller
    4302              :                     // Sum rated capacity of all cases on Secondary
    4303            9 :                     for (int caseIndex = 1; caseIndex <= NumCases; ++caseIndex) {
    4304              :                         // mark all cases on Secondary as used by this Secondary - checking for unused or non-unique cases
    4305            7 :                         int CaseNum = Secondary(SecondaryNum).CaseNum(caseIndex);
    4306            7 :                         ++RefrigCase(CaseNum).NumSysAttach;
    4307            7 :                         NominalTotalCaseCap += RefrigCase(CaseNum).DesignRatedCap * RefrigCase(CaseNum).RatedRTF;
    4308            7 :                         Secondary(SecondaryNum).RefInventory += RefrigCase(CaseNum).DesignRefrigInventory;
    4309            7 :                         if (caseIndex == 1) { // look for lowest case design evap T for Secondary
    4310            2 :                             Secondary(SecondaryNum).TMinNeeded = RefrigCase(CaseNum).EvapTempDesign;
    4311              :                         } else {
    4312            5 :                             Secondary(SecondaryNum).TMinNeeded = min(RefrigCase(CaseNum).EvapTempDesign, Secondary(SecondaryNum).TMinNeeded);
    4313              :                         }
    4314              :                     } // CaseIndex=1,NumCases
    4315              :                 } // Numcases > 0
    4316              : 
    4317            2 :                 if (NumCoils > 0) {
    4318              :                     // Find lowest design T loop fluid out of secondary chiller
    4319              :                     // Sum rated capacity of all Coils on Secondary
    4320            0 :                     for (int CoilIndex = 1; CoilIndex <= NumCoils; ++CoilIndex) {
    4321              :                         // mark all Coils on Secondary as used by this Secondary - checking for unused or non-unique Coils
    4322            0 :                         int CoilNum = Secondary(SecondaryNum).CoilNum(CoilIndex);
    4323            0 :                         ++WarehouseCoil(CoilNum).NumSysAttach;
    4324            0 :                         NominalTotalCoilCap += WarehouseCoil(CoilNum).RatedSensibleCap;
    4325            0 :                         Secondary(SecondaryNum).RefInventory += WarehouseCoil(CoilNum).DesignRefrigInventory;
    4326            0 :                         if ((CoilIndex == 1) && (NumCases == 0)) { // look for lowest Coil design evap T for Secondary
    4327            0 :                             Secondary(SecondaryNum).TMinNeeded = WarehouseCoil(CoilNum).TEvapDesign;
    4328              :                         } else {
    4329            0 :                             Secondary(SecondaryNum).TMinNeeded = min(WarehouseCoil(CoilNum).TEvapDesign, Secondary(SecondaryNum).TMinNeeded);
    4330              :                         }
    4331              :                     } // CoilIndex=1,NumCoils
    4332              :                 } // NumCoils > 0
    4333              : 
    4334            2 :                 if (NumWalkIns > 0) {
    4335              :                     // Find lowest design T loop fluid out of secondary chiller
    4336              :                     // Sum rated capacity of all WalkIns on Secondary
    4337            2 :                     for (int WalkInIndex = 1; WalkInIndex <= NumWalkIns; ++WalkInIndex) {
    4338              :                         // mark all WalkIns on Secondary as used by this Secondary - checking for unused or non-unique WalkIns
    4339            1 :                         int WalkInID = Secondary(SecondaryNum).WalkInNum(WalkInIndex);
    4340            1 :                         ++WalkIn(WalkInID).NumSysAttach;
    4341            1 :                         NominalTotalWalkInCap += WalkIn(WalkInID).DesignRatedCap;
    4342            1 :                         Secondary(SecondaryNum).RefInventory += WalkIn(WalkInID).DesignRefrigInventory;
    4343            1 :                         if ((WalkInIndex == 1) && (NumCases == 0) && (NumCoils == 0)) { // look for lowest load design evap T for Secondary
    4344            0 :                             Secondary(SecondaryNum).TMinNeeded = WalkIn(WalkInID).TEvapDesign;
    4345              :                         } else {
    4346            1 :                             Secondary(SecondaryNum).TMinNeeded = min(Secondary(SecondaryNum).TMinNeeded, WalkIn(WalkInID).TEvapDesign);
    4347              :                         }
    4348              :                     } // WalkInIndex=1,NumWalkIns
    4349              :                 } // Numwalkins > 0
    4350              : 
    4351              :                 // Get circulating fluid type
    4352            2 :                 AlphaNum = 3;
    4353            2 :                 if (lAlphaBlanks(AlphaNum)) {
    4354            0 :                     ShowSevereEmptyField(state, eoh, cAlphaFieldNames(AlphaNum));
    4355            0 :                     ErrorsFound = true;
    4356            2 :                 } else if ((Secondary(SecondaryNum).FluidType = static_cast<SecFluidType>(getEnumValue(secFluidTypeNamesUC, Alphas(AlphaNum)))) ==
    4357              :                            SecFluidType::Invalid) {
    4358            0 :                     ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    4359            0 :                     ErrorsFound = true;
    4360              :                 } // Set FluidType
    4361              : 
    4362            2 :                 AlphaNum = 4;
    4363            2 :                 Secondary(SecondaryNum).FluidName = Alphas(AlphaNum);
    4364            2 :                 if (Secondary(SecondaryNum).FluidName.empty()) {
    4365            0 :                     ShowSevereEmptyField(state, eoh, cAlphaFieldNames(AlphaNum));
    4366            0 :                     ErrorsFound = true;
    4367            2 :                 } else if ((Secondary(SecondaryNum).glycol = Fluid::GetGlycol(state, Secondary(SecondaryNum).FluidName)) != nullptr) {
    4368            1 :                 } else if ((Secondary(SecondaryNum).refrig = Fluid::GetRefrig(state, Secondary(SecondaryNum).FluidName)) != nullptr) {
    4369              :                 } else {
    4370            0 :                     ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    4371            0 :                     ErrorsFound = true;
    4372              :                 }
    4373              : 
    4374              :                 // Error messages for refrigerants and glycols already found in fluidproperties
    4375              : 
    4376              :                 // Note remainder of inputs for secondary don't follow IDD input order because of different interpretations
    4377              :                 //   and intermediate calculations used to assign default values for brine type vs. liquid overfeed/phase change loops
    4378              : 
    4379            2 :                 if (!lNumericBlanks(3)) {
    4380            2 :                     Secondary(SecondaryNum).TEvapDesign = Numbers(3);
    4381              :                 } else {
    4382            0 :                     ShowSevereError(state,
    4383            0 :                                     format("{}{}=\"{}\" {} must be specified.",
    4384              :                                            RoutineName,
    4385              :                                            CurrentModuleObject,
    4386            0 :                                            Secondary(SecondaryNum).Name,
    4387              :                                            cNumericFieldNames(3)));
    4388            0 :                     ErrorsFound = true;
    4389              :                 } // blank on N3
    4390              : 
    4391            2 :                 if (!lNumericBlanks(4)) {
    4392            2 :                     Secondary(SecondaryNum).TApproachDifRated = Numbers(4);
    4393              :                 } else {
    4394            0 :                     ShowSevereError(state,
    4395            0 :                                     format("{}{}=\"{}\" {} must be specified.",
    4396              :                                            RoutineName,
    4397              :                                            CurrentModuleObject,
    4398            0 :                                            Secondary(SecondaryNum).Name,
    4399              :                                            cNumericFieldNames(4)));
    4400            0 :                     ErrorsFound = true;
    4401              :                 } // blank on N4
    4402              : 
    4403              :                 //^^^^^^^Now look at input and once-only calculations required only for liquid/brine secondary loops^^^^^^^^^^^^^^^^^^^^^^
    4404              :                 //   Ensure that required input data is not missing prior to performing the following once-only calculations
    4405            2 :                 if (ErrorsFound) {
    4406            0 :                     ShowFatalError(state,
    4407            0 :                                    format("{}{}=\"{}\", Program terminated due to previous condition(s).",
    4408              :                                           RoutineName,
    4409              :                                           CurrentModuleObject,
    4410            0 :                                           Secondary(SecondaryNum).Name));
    4411              :                 } // ErrorsFound
    4412              : 
    4413            2 :                 Real64 CpBrineRated = 0.0;
    4414            2 :                 Real64 PumpTotRatedFlowVol(0.0);   // Rated flow from input pump data, m3/s
    4415            2 :                 Real64 SecondaryFlowVolRated(0.0); // Rated flow of secondary fluid, used to calculate capacity (m3/s)
    4416            2 :                 Real64 TBrineOutRated(0.0);        // Rated temperature of circ fluid LEAVING heat exchanger,C
    4417            2 :                 Real64 TBrineInRated(0.0);         // Rated temperature of circ fluid going INTO heat exchanger, C
    4418              : 
    4419            2 :                 if (Secondary(SecondaryNum).FluidType == SecFluidType::AlwaysLiquid) {
    4420            1 :                     if (!lNumericBlanks(5)) {
    4421            1 :                         Secondary(SecondaryNum).TRangeDifRated = Numbers(5);
    4422              :                     } else {
    4423            0 :                         ShowSevereError(state,
    4424            0 :                                         format("{}{}=\"{}\", {} must be specified.",
    4425              :                                                RoutineName,
    4426              :                                                CurrentModuleObject,
    4427            0 :                                                Secondary(SecondaryNum).Name,
    4428              :                                                cNumericFieldNames(5)));
    4429            0 :                         ShowContinueError(state, format("...when {}=\"FluidAlwaysLiquid\".", cAlphaFieldNames(3)));
    4430            0 :                         ErrorsFound = true;
    4431              :                     } // blank on N5
    4432              : 
    4433              :                     // Get fluid properties at rated conditions, will be used to calculate ht exchgr effectiveness
    4434            1 :                     TBrineOutRated = Secondary(SecondaryNum).TEvapDesign + Secondary(SecondaryNum).TApproachDifRated;
    4435            1 :                     TBrineInRated = TBrineOutRated + Secondary(SecondaryNum).TRangeDifRated;
    4436            1 :                     Real64 TBrineAverage = (TBrineOutRated + TBrineInRated) / 2.0;
    4437            1 :                     Secondary(SecondaryNum).TBrineAverage = TBrineAverage;
    4438            1 :                     DensityBrineRated = Secondary(SecondaryNum).glycol->getDensity(state, TBrineAverage, TrackMessage);
    4439            1 :                     Secondary(SecondaryNum).DensityBrineRated = DensityBrineRated;
    4440            1 :                     CpBrineRated = Secondary(SecondaryNum).glycol->getSpecificHeat(state, TBrineAverage, TrackMessage);
    4441            1 :                     Secondary(SecondaryNum).CpBrineRated = CpBrineRated;
    4442              : 
    4443              :                     // Users can input either design brine flow (m3/s), or capacity in W, or both.  Now have
    4444              :                     //  temperatures needed to calculate either the loop cooling capacity or fluid flow rate, if one was not input
    4445              :                     //  Don't need to save as a flow vol as a permanent var because calc whichever is missing here
    4446            1 :                     Real64 FlowMassRated(0.0); // Design mass flow rate of circ fluid in secondary loop(kg/s)
    4447            1 :                     if ((!lNumericBlanks(1)) && (!lNumericBlanks(2))) {
    4448              :                         // Both values input, check for approximate agreement
    4449            1 :                         Secondary(SecondaryNum).CoolingLoadRated = Numbers(1);
    4450            1 :                         SecondaryFlowVolRated = Numbers(2);
    4451            1 :                         FlowMassRated = SecondaryFlowVolRated * DensityBrineRated;
    4452            1 :                         Real64 NominalSecondaryCapacity = FlowMassRated * CpBrineRated * Secondary(SecondaryNum).TRangeDifRated;
    4453            1 :                         Real64 TestDelta = (NominalSecondaryCapacity - Secondary(SecondaryNum).CoolingLoadRated) / NominalSecondaryCapacity;
    4454            1 :                         if (std::abs(TestDelta) > 0.2) {
    4455            0 :                             ShowWarningError(state,
    4456            0 :                                              format("{}=\"{} You may wish to check the system definition. Based upon the design flow rate and "
    4457              :                                                     "range temperature difference,  The nominal secondary loop heat exchanger capacity is, "
    4458              :                                                     "{:.0R} but the specified design capacity is,  {:.0R}",
    4459              :                                                     CurrentModuleObject,
    4460            0 :                                                     Secondary(SecondaryNum).Name,
    4461              :                                                     NominalSecondaryCapacity,
    4462            0 :                                                     Secondary(SecondaryNum).CoolingLoadRated));
    4463              :                         }
    4464            0 :                     } else if (!lNumericBlanks(1)) {
    4465            0 :                         Secondary(SecondaryNum).CoolingLoadRated = Numbers(1);
    4466              :                         // Calc flow vol rated
    4467            0 :                         FlowMassRated = Secondary(SecondaryNum).CoolingLoadRated / (CpBrineRated * Secondary(SecondaryNum).TRangeDifRated);
    4468            0 :                         SecondaryFlowVolRated = FlowMassRated / DensityBrineRated;
    4469            0 :                     } else if (!lNumericBlanks(2)) {
    4470            0 :                         SecondaryFlowVolRated = Numbers(2);
    4471              :                         // Calc rated load
    4472            0 :                         FlowMassRated = SecondaryFlowVolRated * DensityBrineRated;
    4473            0 :                         Secondary(SecondaryNum).CoolingLoadRated = FlowMassRated * CpBrineRated * Secondary(SecondaryNum).TRangeDifRated;
    4474              :                     } else {
    4475            0 :                         ShowSevereError(state,
    4476            0 :                                         format(R"({}{}="{}", Either "{}" OR "{}" must be input.)",
    4477              :                                                RoutineName,
    4478              :                                                CurrentModuleObject,
    4479            0 :                                                Secondary(SecondaryNum).Name,
    4480              :                                                cNumericFieldNames(1),
    4481              :                                                cNumericFieldNames(2)));
    4482            0 :                         ErrorsFound = true;
    4483              :                     } // Capacity Input via either or both options
    4484              : 
    4485            1 :                     if (!ErrorsFound) {
    4486              :                         // Calculate heat exchanger effectiveness based on rated flow and temperature differences
    4487            2 :                         Secondary(SecondaryNum).HeatExchangeEta =
    4488            1 :                             Secondary(SecondaryNum).CoolingLoadRated /
    4489            1 :                             (FlowMassRated * CpBrineRated * (TBrineInRated - Secondary(SecondaryNum).TEvapDesign));
    4490            1 :                         Secondary(SecondaryNum).TBrineInRated = TBrineInRated;
    4491            1 :                         if (Secondary(SecondaryNum).HeatExchangeEta > 0.99) {
    4492            0 :                             ShowWarningError(
    4493              :                                 state,
    4494            0 :                                 format("{}=\"{} You may wish to check the system definition.  The heat exchanger effectiveness is, {:.2R}",
    4495              :                                        CurrentModuleObject,
    4496            0 :                                        Secondary(SecondaryNum).Name,
    4497            0 :                                        Secondary(SecondaryNum).HeatExchangeEta));
    4498            0 :                             Secondary(SecondaryNum).HeatExchangeEta = 0.99;
    4499              :                         }
    4500              :                     } else {
    4501            0 :                         ShowContinueError(state, "...remainder of this object input skipped due to previous errors");
    4502            0 :                         continue;
    4503              :                     }
    4504              : 
    4505            1 :                     PumpTotRatedFlowVol = SecondaryFlowVolRated;
    4506            1 :                     if (!lNumericBlanks(7)) {
    4507            1 :                         PumpTotRatedFlowVol = Numbers(7);
    4508              :                     }
    4509              : 
    4510              :                 } else { // FluidType = FluidTypePhaseChange     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    4511            1 :                     if (!lNumericBlanks(1)) {
    4512            0 :                         Secondary(SecondaryNum).CoolingLoadRated = Numbers(1);
    4513              :                     } else {
    4514            1 :                         Secondary(SecondaryNum).CoolingLoadRated = NominalTotalCaseCap + NominalTotalWalkInCap;
    4515              :                         // first estimate, will later be adjusted to include pump power
    4516              :                     } // input capacity
    4517              : 
    4518            1 :                     Secondary(SecondaryNum).TCondense = Secondary(SecondaryNum).TEvapDesign + Secondary(SecondaryNum).TApproachDifRated;
    4519            1 :                     Secondary(SecondaryNum).CircRate = DefaultCircRate;
    4520            1 :                     if (!lNumericBlanks(10)) {
    4521            1 :                         Secondary(SecondaryNum).CircRate = Numbers(10);
    4522              :                     }
    4523              : 
    4524              :                     DensityPhaseChange =
    4525            1 :                         Secondary(SecondaryNum).refrig->getSatDensity(state, Secondary(SecondaryNum).TCondense, 0.0, TrackMessageAlt);
    4526            1 :                     DeltaHPhaseChange =
    4527            1 :                         Secondary(SecondaryNum).refrig->getSatEnthalpy(state, Secondary(SecondaryNum).TCondense, 1.0, TrackMessageAlt) -
    4528            1 :                         Secondary(SecondaryNum).refrig->getSatEnthalpy(state, Secondary(SecondaryNum).TCondense, 0.0, TrackMessageAlt);
    4529              : 
    4530              :                     // TotRatedFlowVol= capacity*circrate/deltahphasechange/density
    4531              :                     Real64 CalcTotFlowVol =
    4532            1 :                         Secondary(SecondaryNum).CoolingLoadRated * Secondary(SecondaryNum).CircRate / (DensityPhaseChange * DeltaHPhaseChange);
    4533            1 :                     PumpTotRatedFlowVol = CalcTotFlowVol;
    4534            1 :                     if (!lNumericBlanks(7)) {
    4535            0 :                         PumpTotRatedFlowVol = Numbers(7);
    4536            0 :                         Real64 CalcCircRate = DensityPhaseChange * DeltaHPhaseChange * PumpTotRatedFlowVol / Secondary(SecondaryNum).CoolingLoadRated;
    4537            0 :                         Real64 DiffCircRates = (CalcCircRate - Secondary(SecondaryNum).CircRate) / Secondary(SecondaryNum).CircRate;
    4538            0 :                         if (std::abs(DiffCircRates) > 0.3) {
    4539            0 :                             ShowWarningError(state,
    4540            0 :                                              format("{}=\"{} {} Produces a circulating rate of {:.2R} ;  A circulating rate of {:.2R} would need "
    4541              :                                                     "a {} of {:.2R} m3/s",
    4542              :                                                     CurrentModuleObject,
    4543            0 :                                                     Secondary(SecondaryNum).Name,
    4544              :                                                     cNumericFieldNames(7),
    4545              :                                                     CalcCircRate,
    4546            0 :                                                     Secondary(SecondaryNum).CircRate,
    4547              :                                                     cNumericFieldNames(7),
    4548              :                                                     CalcTotFlowVol));
    4549              :                         } // warning check on pump flow rate vs circ rate input
    4550              :                     } // blank pump flow rate
    4551            1 :                     SecondaryFlowVolRated = PumpTotRatedFlowVol;
    4552              : 
    4553              :                 } // fluid type AlwaysLiquid or PhaseChange ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    4554              : 
    4555              :                 // Read number of pumps (or pump stages) in secondary loop
    4556            2 :                 int NumPumps = 1; // default value
    4557            2 :                 if ((!lNumericBlanks(6)) && (Numbers(6) >= 1)) {
    4558            2 :                     NumPumps = Numbers(6);
    4559              :                 }
    4560            2 :                 Secondary(SecondaryNum).NumPumps = NumPumps;
    4561              :                 // Get pump power (users can input either power in W or head in Pa or both)
    4562              :                 // Assume pump impeller efficiency is 0.78 (consistent with E+ Pump auto-sizing assumption)
    4563              :                 // Assume pump motor efficiency is 0.85 (Goulds Pumps motor data sheet)
    4564              :                 // It is important that tot rated head must be for specific fluid
    4565            2 :                 Real64 PumpTotRatedHead(0.0); // Total pump rated head on secondary loop (Pa)
    4566              : 
    4567            2 :                 if ((!lNumericBlanks(8)) && (!lNumericBlanks(9))) {
    4568            0 :                     Secondary(SecondaryNum).PumpTotRatedPower = Numbers(8);
    4569            0 :                     PumpTotRatedHead = Numbers(9);
    4570            0 :                     Real64 ErrSecondPumpPower = (Secondary(SecondaryNum).PumpTotRatedPower -
    4571            0 :                                                  PumpTotRatedFlowVol * PumpTotRatedHead / (PumpImpellerEfficiency * PumpMotorEfficiency)) /
    4572            0 :                                                 Secondary(SecondaryNum).PumpTotRatedPower;
    4573            0 :                     if (std::abs(ErrSecondPumpPower) > 0.35) {
    4574            0 :                         ShowWarningError(
    4575              :                             state,
    4576            0 :                             format("{}=\"{} Input value for {} not consistent with input value for {}. {} will be used",
    4577              :                                    CurrentModuleObject,
    4578            0 :                                    Secondary(SecondaryNum).Name,
    4579              :                                    cNumericFieldNames(9),
    4580              :                                    cNumericFieldNames(8),
    4581              :                                    cNumericFieldNames(8))); // generous diff allowed because comparing to my assumed impeller and motor effs
    4582              :                     }
    4583            2 :                 } else if (!lNumericBlanks(8)) {
    4584            0 :                     Secondary(SecondaryNum).PumpTotRatedPower = Numbers(8);
    4585            2 :                 } else if (!lNumericBlanks(9)) {
    4586            2 :                     PumpTotRatedHead = Numbers(9);
    4587            2 :                     Secondary(SecondaryNum).PumpTotRatedPower =
    4588            2 :                         PumpTotRatedFlowVol * PumpTotRatedHead / (PumpImpellerEfficiency * PumpMotorEfficiency);
    4589              :                 } else {
    4590            0 :                     ShowSevereError(state,
    4591            0 :                                     format(R"({}{}="{}", Either "{}" OR "{}" must be input.)",
    4592              :                                            RoutineName,
    4593              :                                            CurrentModuleObject,
    4594            0 :                                            Secondary(SecondaryNum).Name,
    4595              :                                            cNumericFieldNames(8),
    4596              :                                            cNumericFieldNames(9)));
    4597            0 :                     ErrorsFound = true;
    4598              :                 } // Either or pump power Input variations (head or power)
    4599              : 
    4600              :                 // Get pump drive type
    4601            2 :                 AlphaNum = 5;
    4602            2 :                 if (lAlphaBlanks(AlphaNum)) {
    4603            1 :                     Secondary(SecondaryNum).PumpControlType = SecPumpCtrl::Constant; // default
    4604            1 :                 } else if ((Secondary(SecondaryNum).PumpControlType = static_cast<SecPumpCtrl>(getEnumValue(secPumpCtrlNamesUC, Alphas(AlphaNum)))) ==
    4605              :                            SecPumpCtrl::Invalid) {
    4606            0 :                     ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    4607            0 :                     ErrorsFound = true;
    4608              :                 }
    4609              : 
    4610              :                 //  Print warning if Pump Control = Constant and Variable Speed Curve is specified.
    4611            2 :                 if ((Secondary(SecondaryNum).PumpControlType == SecPumpCtrl::Constant) && (!lAlphaBlanks(AlphaNum + 1))) {
    4612            0 :                     ShowWarningError(state,
    4613            0 :                                      format(R"({}{}="{}", A {} is specified even though {} is "CONSTANT".)",
    4614              :                                             RoutineName,
    4615              :                                             CurrentModuleObject,
    4616            0 :                                             Secondary(SecondaryNum).Name,
    4617              :                                             cAlphaFieldNames(AlphaNum + 1),
    4618              :                                             cAlphaFieldNames(AlphaNum)));
    4619            0 :                     ShowContinueError(state,
    4620            0 :                                       format("The secondary loop pump(s) will be modeled as constant speed and the {} will be ignored.",
    4621              :                                              cAlphaFieldNames(AlphaNum + 1)));
    4622              :                 }
    4623              : 
    4624            2 :                 if (Secondary(SecondaryNum).PumpControlType == SecPumpCtrl::Constant) {
    4625              :                     // Set incremental flow and power amounts for pump dispatch
    4626            1 :                     Secondary(SecondaryNum).PumpIncrementFlowVol = PumpTotRatedFlowVol / NumPumps;
    4627            1 :                     Secondary(SecondaryNum).PumpIncrementPower = Secondary(SecondaryNum).PumpTotRatedPower / NumPumps;
    4628              :                 } else { // Variable speed drive need to read in power curve
    4629            1 :                     AlphaNum = 6;
    4630            1 :                     Secondary(SecondaryNum).VarSpeedCurvePtr = Curve::GetCurveIndex(state, Alphas(AlphaNum)); // convert curve name to number
    4631            1 :                     if (Secondary(SecondaryNum).VarSpeedCurvePtr == 0) {
    4632            0 :                         ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    4633            0 :                         ErrorsFound = true;
    4634              :                     }
    4635            4 :                     ErrorsFound |= Curve::CheckCurveDims(state,
    4636            1 :                                                          Secondary(SecondaryNum).VarSpeedCurvePtr, // Curve index
    4637              :                                                          {1},                                      // Valid dimensions
    4638              :                                                          RoutineName,                              // Routine name
    4639              :                                                          CurrentModuleObject,                      // Object Type
    4640            1 :                                                          Secondary(SecondaryNum).Name,             // Object Name
    4641            1 :                                                          cAlphaFieldNames(AlphaNum));              // Field Name
    4642              :                 } // input power conditions/levels for constant or variable speed pump drives
    4643              : 
    4644              :                 // Default non-hermetic motor eff at 85% and all shaft power goes to heat in fluid
    4645              :                 // In a semi-hermetic motor, assume all power to motor goes to heat in fluid
    4646            2 :                 Secondary(SecondaryNum).PumpPowerToHeat = PumpMotorEfficiency;
    4647            2 :                 NumNum = 11;
    4648            2 :                 if (!lNumericBlanks(NumNum)) {
    4649            2 :                     if ((0.5 <= Numbers(NumNum)) && (1.0 >= Numbers(NumNum))) {
    4650            2 :                         Secondary(SecondaryNum).PumpPowerToHeat = Numbers(NumNum);
    4651              :                     } else {
    4652            0 :                         ShowWarningError(state,
    4653            0 :                                          format("{}{}=\"{}\" {} must be between 0.5 and 1.0. Default value of : {:.3R} will be used",
    4654              :                                                 RoutineName,
    4655              :                                                 CurrentModuleObject,
    4656            0 :                                                 Secondary(SecondaryNum).Name,
    4657              :                                                 cNumericFieldNames(NumNum),
    4658              :                                                 PumpMotorEfficiency));
    4659              :                     } // range of pump moter heat to fluid
    4660              :                 } // blank input for pumppowertoheat
    4661              : 
    4662              :                 // Distribution piping heat gain - optional
    4663              :                 //  Input UA and Zone containing the bulk of the secondary coolant distribution piping
    4664              :                 //  This Zone ID will be used to determine the temperature used for distribution piping heat gain.
    4665              :                 //  Zone Id is only required if Sum UA Distribution Piping >0.0
    4666              :                 //  Get the Zone node number from the zone name entered by the user
    4667            2 :                 Secondary(SecondaryNum).SumUADistPiping = 0.0;
    4668            2 :                 AlphaNum = 7;
    4669            2 :                 NumNum = 12;
    4670            2 :                 if (!lNumericBlanks(NumNum) && !lAlphaBlanks(AlphaNum)) {
    4671            2 :                     Secondary(SecondaryNum).SumUADistPiping = Numbers(NumNum);
    4672            2 :                     Secondary(SecondaryNum).DistPipeZoneNum = Util::FindItemInList(Alphas(AlphaNum), state.dataHeatBal->Zone);
    4673            4 :                     Secondary(SecondaryNum).DistPipeZoneNodeNum =
    4674            2 :                         DataZoneEquipment::GetSystemNodeNumberForZone(state, Secondary(SecondaryNum).DistPipeZoneNum);
    4675              : 
    4676            2 :                     if (Secondary(SecondaryNum).DistPipeZoneNum == 0) {
    4677            0 :                         ShowSevereError(state,
    4678            0 :                                         format("{}{}=\"{}\", invalid  {} not valid: {}",
    4679              :                                                RoutineName,
    4680              :                                                CurrentModuleObject,
    4681            0 :                                                Secondary(SecondaryNum).Name,
    4682              :                                                cAlphaFieldNames(AlphaNum),
    4683              :                                                Alphas(AlphaNum)));
    4684            0 :                         ErrorsFound = true;
    4685              :                     } else {
    4686            2 :                         state.dataRefrigCase->RefrigPresentInZone(Secondary(SecondaryNum).DistPipeZoneNum) = true;
    4687              :                     }
    4688              : 
    4689            2 :                     if (Secondary(SecondaryNum).DistPipeZoneNodeNum == 0) {
    4690            0 :                         ShowSevereError(
    4691              :                             state,
    4692            0 :                             format("{}{}=\"{}\" System Node Number not found for {} = {} even though {} is greater than zero. Distribution "
    4693              :                                    "piping heat gain cannot be calculated unless a controlled Zone (appear in a ZoneHVAC:EquipmentConnections "
    4694              :                                    "object.) is defined to determine the environmental temperature surrounding the piping.",
    4695              :                                    RoutineName,
    4696              :                                    CurrentModuleObject,
    4697            0 :                                    Secondary(SecondaryNum).Name,
    4698              :                                    cAlphaFieldNames(AlphaNum),
    4699              :                                    Alphas(AlphaNum),
    4700              :                                    cNumericFieldNames(NumNum)));
    4701            0 :                         ErrorsFound = true;
    4702              :                     }
    4703            0 :                 } else if (!lNumericBlanks(NumNum) && lAlphaBlanks(AlphaNum)) {
    4704            0 :                     ShowWarningError(
    4705              :                         state,
    4706            0 :                         format("{}{}=\"{}\", {} not found even though {} is greater than zero. Distribution piping heat gain will not be "
    4707              :                                "calculated unless a Zone is defined to determine the environmental temperature surrounding the piping.",
    4708              :                                RoutineName,
    4709              :                                CurrentModuleObject,
    4710            0 :                                Secondary(SecondaryNum).Name,
    4711              :                                cAlphaFieldNames(AlphaNum),
    4712              :                                cNumericFieldNames(NumNum)));
    4713            0 :                 } else if (lNumericBlanks(NumNum) && !lAlphaBlanks(AlphaNum)) {
    4714            0 :                     ShowWarningError(
    4715              :                         state,
    4716            0 :                         format("{}{}=\"{}\", {} will not be used and distribution piping heat gain will not be calculated because {} was blank.",
    4717              :                                RoutineName,
    4718              :                                CurrentModuleObject,
    4719            0 :                                Secondary(SecondaryNum).Name,
    4720              :                                cAlphaFieldNames(AlphaNum),
    4721              :                                cNumericFieldNames(NumNum)));
    4722              :                 } // distribution piping
    4723              : 
    4724              :                 // Separator/receiver heat gain - optional
    4725              :                 //  Input UA and Zone containing the Separator/receiver
    4726              :                 //  This Zone ID will be used to determine the temperature used for Separator/receiver heat gain.
    4727              :                 //  Zone Id is only required if Sum UA Separator/receiver >0.0
    4728              :                 //  Get the Zone node number from the zone name entered by the user
    4729            2 :                 Secondary(SecondaryNum).SumUAReceiver = 0.0;
    4730            2 :                 AlphaNum = 8;
    4731            2 :                 NumNum = 13;
    4732            2 :                 if (!lNumericBlanks(NumNum) && !lAlphaBlanks(AlphaNum)) {
    4733            1 :                     Secondary(SecondaryNum).SumUAReceiver = Numbers(NumNum);
    4734            1 :                     Secondary(SecondaryNum).ReceiverZoneNum = Util::FindItemInList(Alphas(AlphaNum), state.dataHeatBal->Zone);
    4735            2 :                     Secondary(SecondaryNum).ReceiverZoneNodeNum =
    4736            1 :                         DataZoneEquipment::GetSystemNodeNumberForZone(state, Secondary(SecondaryNum).ReceiverZoneNum);
    4737              : 
    4738            1 :                     if (Secondary(SecondaryNum).ReceiverZoneNum == 0) {
    4739            0 :                         ShowSevereError(state,
    4740            0 :                                         format("{}{}=\"{}\", invalid  {} not valid: {}",
    4741              :                                                RoutineName,
    4742              :                                                CurrentModuleObject,
    4743            0 :                                                Secondary(SecondaryNum).Name,
    4744              :                                                cAlphaFieldNames(AlphaNum),
    4745              :                                                Alphas(AlphaNum)));
    4746            0 :                         ErrorsFound = true;
    4747              :                     } else {
    4748            1 :                         state.dataRefrigCase->RefrigPresentInZone(Secondary(SecondaryNum).ReceiverZoneNum) = true;
    4749              :                     }
    4750            1 :                     if (Secondary(SecondaryNum).ReceiverZoneNodeNum == 0) {
    4751            0 :                         ShowSevereError(
    4752              :                             state,
    4753            0 :                             format("{}{}=\"{}\" System Node Number not found for {} = {} even though {} is greater than zero. Receiver heat gain "
    4754              :                                    "cannot be calculated unless a controlled Zone (appear in a ZoneHVAC:EquipmentConnections object.) is defined "
    4755              :                                    "to determine the environmental temperature surrounding the Receiver.",
    4756              :                                    RoutineName,
    4757              :                                    CurrentModuleObject,
    4758            0 :                                    Secondary(SecondaryNum).Name,
    4759              :                                    cAlphaFieldNames(AlphaNum),
    4760              :                                    Alphas(AlphaNum),
    4761              :                                    cNumericFieldNames(NumNum)));
    4762            0 :                         ErrorsFound = true;
    4763              :                     }
    4764            1 :                 } else if (!lNumericBlanks(NumNum) && lAlphaBlanks(AlphaNum)) {
    4765            0 :                     ShowWarningError(
    4766              :                         state,
    4767            0 :                         format("{}{}=\"{}\", {} not found even though {} is greater than zero. Receiver heat gain will not be calculated unless "
    4768              :                                "a Zone is defined to determine the environmental temperature surrounding the Receiver.",
    4769              :                                RoutineName,
    4770              :                                CurrentModuleObject,
    4771            0 :                                Secondary(SecondaryNum).Name,
    4772              :                                cAlphaFieldNames(AlphaNum),
    4773              :                                cNumericFieldNames(NumNum)));
    4774            1 :                 } else if (lNumericBlanks(NumNum) && !lAlphaBlanks(AlphaNum)) {
    4775            0 :                     ShowWarningError(state,
    4776            0 :                                      format("{}{}=\"{}\", {} will not be used and Receiver heat gain will not be calculated because {} was blank.",
    4777              :                                             RoutineName,
    4778              :                                             CurrentModuleObject,
    4779            0 :                                             Secondary(SecondaryNum).Name,
    4780              :                                             cAlphaFieldNames(AlphaNum),
    4781              :                                             cNumericFieldNames(NumNum)));
    4782              :                 } // Receiver
    4783              : 
    4784            2 :                 NumNum = 14;
    4785            2 :                 Secondary(SecondaryNum).ChillerRefInventory = 0.0;
    4786            2 :                 if (!lNumericBlanks(NumNum)) {
    4787            0 :                     Secondary(SecondaryNum).ChillerRefInventory = Numbers(NumNum);
    4788              :                 }
    4789            2 :                 if (Secondary(SecondaryNum).ChillerRefInventory < 0.0) {
    4790            0 :                     Secondary(SecondaryNum).ChillerRefInventory = 0.0;
    4791            0 :                     ShowWarningError(state,
    4792            0 :                                      format("{}{}=\"{}\", The value specified for {} is less than zero. The default value of zero will be used.",
    4793              :                                             RoutineName,
    4794              :                                             CurrentModuleObject,
    4795            0 :                                             Secondary(SecondaryNum).Name,
    4796              :                                             cNumericFieldNames(NumNum)));
    4797              :                 }
    4798              : 
    4799            2 :                 AlphaNum = 9;
    4800            2 :                 if (!lAlphaBlanks(AlphaNum)) {
    4801            0 :                     Secondary(SecondaryNum).EndUseSubcategory = Alphas(AlphaNum);
    4802              :                 }
    4803              : 
    4804              :                 // Error checks on secondary loop:
    4805              :                 // Note, rated capacities can be far off from operating capacities, but rough checks here
    4806              :                 //       (don't include dist piping or receiver heat gains).
    4807              :                 // Load limit logic here (maxvolflow and maxload used in calcs later)
    4808            2 :                 Secondary(SecondaryNum).MaxVolFlow = min(SecondaryFlowVolRated, PumpTotRatedFlowVol);
    4809            2 :                 Real64 NominalSecondaryRefLoad = NominalTotalCaseCap + NominalTotalWalkInCap + Secondary(SecondaryNum).PumpTotRatedPower;
    4810              : 
    4811            2 :                 if (Secondary(SecondaryNum).FluidType == SecFluidType::AlwaysLiquid) {
    4812            1 :                     if (TBrineOutRated > (Secondary(SecondaryNum).TMinNeeded + 0.5)) {
    4813            0 :                         ShowWarningError(state,
    4814            0 :                                          format("{}=\"{} The design brine temperature to the refrigeration loads: {:.1R} ;",
    4815              :                                                 CurrentModuleObject,
    4816            0 :                                                 Secondary(SecondaryNum).Name,
    4817              :                                                 TBrineOutRated));
    4818            0 :                         ShowContinueError(state,
    4819            0 :                                           format(" is greater than the design inlet temperature for at least one of the cases or walkins: {:.1R}",
    4820            0 :                                                  Secondary(SecondaryNum).TMinNeeded));
    4821            0 :                         ShowContinueError(
    4822              :                             state, " Compare your Approach and Evaporating Temperature to the design inlet temperatures needed for the loads.");
    4823              :                         // ErrorsFound = .TRUE.
    4824              :                     } // Tbrine out warning
    4825            1 :                     Real64 CapacityAtMaxVolFlow = Secondary(SecondaryNum).MaxVolFlow * Secondary(SecondaryNum).HeatExchangeEta *
    4826            1 :                                                   (CpBrineRated * DensityBrineRated) * (TBrineInRated - Secondary(SecondaryNum).TEvapDesign);
    4827            1 :                     Secondary(SecondaryNum).MaxLoad = min(Secondary(SecondaryNum).CoolingLoadRated, CapacityAtMaxVolFlow);
    4828              :                     Real64 DeltaCap1 =
    4829            1 :                         std::abs((Secondary(SecondaryNum).CoolingLoadRated - CapacityAtMaxVolFlow) / Secondary(SecondaryNum).CoolingLoadRated);
    4830            1 :                     if (DeltaCap1 > (0.3)) { // diff between chiller rating and capacity at max flow > 30%
    4831            0 :                         ShowWarningError(state,
    4832            0 :                                          format("{}=\"{}\" You may wish to check the system sizing.  The nominal secondary loop heat exchanger "
    4833              :                                                 "capacity is {:.0R} But the capacity based upon the maximum flow rate is {:.0R}",
    4834              :                                                 CurrentModuleObject,
    4835            0 :                                                 Secondary(SecondaryNum).Name,
    4836            0 :                                                 Secondary(SecondaryNum).CoolingLoadRated,
    4837              :                                                 CapacityAtMaxVolFlow));
    4838              :                     } // DeltaCap1 > .3
    4839              :                 } else {                         // Fluid type phase change                !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    4840            1 :                     if (lNumericBlanks(1)) {     // Chiller/evaporator capacity was not specified
    4841            1 :                         if (lNumericBlanks(7)) { // Pump power was not input, calc based on flow and head
    4842              :                             // need to refine because capacity calculated, but needs to include pump power (which was prev
    4843              :                             //   estimated based upon capacity which had been estimated as sum of case and walk-in capacities)
    4844            1 :                             PumpTotRatedFlowVol =
    4845            1 :                                 NominalSecondaryRefLoad * Secondary(SecondaryNum).CircRate / (DensityPhaseChange * DeltaHPhaseChange);
    4846            2 :                             Secondary(SecondaryNum).PumpTotRatedPower =
    4847            1 :                                 PumpTotRatedFlowVol * PumpTotRatedHead / (PumpImpellerEfficiency * PumpMotorEfficiency);
    4848              :                             // need to recalc nominal load with new pump power value
    4849            1 :                             NominalSecondaryRefLoad = NominalTotalCaseCap + NominalTotalWalkInCap + Secondary(SecondaryNum).PumpTotRatedPower;
    4850            1 :                             if (Secondary(SecondaryNum).PumpControlType == SecPumpCtrl::Constant) {
    4851              :                                 // Set incremental flow and power amounts for pump dispatch
    4852            0 :                                 Secondary(SecondaryNum).PumpIncrementFlowVol = PumpTotRatedFlowVol / NumPumps;
    4853            0 :                                 Secondary(SecondaryNum).PumpIncrementPower = Secondary(SecondaryNum).PumpTotRatedPower / NumPumps;
    4854              :                             } // constant speed pump
    4855              :                         } // Pump power was not specified
    4856            1 :                         Secondary(SecondaryNum).CoolingLoadRated = NominalSecondaryRefLoad;
    4857              :                     } // Chiller/evap capacity was not specified
    4858            1 :                     Secondary(SecondaryNum).MaxLoad = Secondary(SecondaryNum).CoolingLoadRated;
    4859              :                 } // SecFluidType
    4860              : 
    4861              :                 Real64 DeltaCap2 =
    4862            2 :                     std::abs((Secondary(SecondaryNum).CoolingLoadRated - NominalSecondaryRefLoad) / Secondary(SecondaryNum).CoolingLoadRated);
    4863            2 :                 if (DeltaCap2 > (0.3)) { // diff between chiller rating and sum of nominal loads > 30%
    4864            0 :                     ShowWarningError(
    4865              :                         state,
    4866            0 :                         format("{}=\"{}\" You may wish to check the system sizing. Total nominal refrigerating load is {:.0R} (Including cases, "
    4867              :                                "walk-ins, and pump heat).  The nominal secondary loop heat exchanger capacity is {:.0R}",
    4868              :                                CurrentModuleObject,
    4869            0 :                                Secondary(SecondaryNum).Name,
    4870              :                                NominalSecondaryRefLoad,
    4871            0 :                                Secondary(SecondaryNum).CoolingLoadRated));
    4872              :                 }
    4873              :                 // compare rated xt xchanger brine flow to the total rated pump flow
    4874            2 :                 if (SecondaryFlowVolRated > (1.1 * PumpTotRatedFlowVol)) {
    4875            0 :                     ShowWarningError(state,
    4876            0 :                                      format("{}=\"{}\" You may wish to check the pump sizing. Total nominal brine flow is {:.0R} m3/s, but the "
    4877              :                                             "total nominal pump flow rate is:  {:.0R} m3/s. ",
    4878              :                                             CurrentModuleObject,
    4879            0 :                                             Secondary(SecondaryNum).Name,
    4880              :                                             SecondaryFlowVolRated,
    4881              :                                             PumpTotRatedFlowVol));
    4882              :                 }
    4883              : 
    4884              :             } // Secondary Loops
    4885              :         } //(  IF (NumSimulationSecondarySystems > 0)
    4886              : 
    4887              :         //************ END SECONDARY SYSTEM INPUT  **************
    4888              : 
    4889              :         //************ START Compressor INPUT  **************
    4890              : 
    4891           16 :         CurrentModuleObject = "Refrigeration:Compressor";
    4892          198 :         for (int CompNum = 1; CompNum <= state.dataRefrigCase->NumSimulationCompressors; ++CompNum) {
    4893          182 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
    4894              :                                                                      CurrentModuleObject,
    4895              :                                                                      CompNum,
    4896              :                                                                      Alphas,
    4897              :                                                                      NumAlphas,
    4898              :                                                                      Numbers,
    4899              :                                                                      NumNumbers,
    4900              :                                                                      IOStatus,
    4901              :                                                                      lNumericBlanks,
    4902              :                                                                      lAlphaBlanks,
    4903              :                                                                      cAlphaFieldNames,
    4904              :                                                                      cNumericFieldNames);
    4905          182 :             ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
    4906              : 
    4907          182 :             Compressor(CompNum).Name = Alphas(1);
    4908              : 
    4909          182 :             Compressor(CompNum).ElecPowerCurvePtr = Curve::GetCurveIndex(state, Alphas(2)); // convert curve name to number
    4910          182 :             if ((!lAlphaBlanks(2)) && Compressor(CompNum).ElecPowerCurvePtr == 0) {
    4911            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(2), Alphas(2));
    4912            0 :                 ErrorsFound = true;
    4913              :             }
    4914              : 
    4915          182 :             Compressor(CompNum).CapacityCurvePtr = Curve::GetCurveIndex(state, Alphas(3)); // convert curve name to number
    4916          182 :             if ((!lAlphaBlanks(3)) && Compressor(CompNum).CapacityCurvePtr == 0) {
    4917            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(3), Alphas(3));
    4918            0 :                 ErrorsFound = true;
    4919              :             }
    4920              : 
    4921              :             // Get superheat rating type (Either N1 or N2 Must be input)
    4922          182 :             if (((!lNumericBlanks(1)) && (!lNumericBlanks(2))) || (lNumericBlanks(1) && lNumericBlanks(2))) {
    4923            0 :                 ShowSevereError(state,
    4924            0 :                                 format("{}{}=\"{}\"One, and Only One of {} or {}",
    4925              :                                        RoutineName,
    4926              :                                        CurrentModuleObject,
    4927            0 :                                        Compressor(CompNum).Name,
    4928              :                                        cNumericFieldNames(1),
    4929              :                                        cNumericFieldNames(2)));
    4930            0 :                 ShowContinueError(state, "Must Be Entered. Check input value choices.");
    4931            0 :                 ErrorsFound = true;
    4932          182 :             } else if (!lNumericBlanks(1)) {
    4933           83 :                 Compressor(CompNum).SuperheatRatingType = CompRatingType::Superheat;
    4934           83 :                 Compressor(CompNum).RatedSuperheat = Numbers(1);
    4935           99 :             } else if (!lNumericBlanks(2)) {
    4936           99 :                 Compressor(CompNum).SuperheatRatingType = CompRatingType::ReturnGasTemperature;
    4937           99 :                 Compressor(CompNum).RatedSuperheat = Numbers(2);
    4938              :             } // Set SuperheatRatingType
    4939              : 
    4940              :             // Get subcool rating type (Either N3 or N4 Must be input)
    4941          182 :             if (((!lNumericBlanks(3)) && (!lNumericBlanks(4))) || (lNumericBlanks(3) && lNumericBlanks(4))) {
    4942            0 :                 ShowSevereError(state,
    4943            0 :                                 format("{}{}=\"{}\" One, and Only One of {} or {}",
    4944              :                                        RoutineName,
    4945              :                                        CurrentModuleObject,
    4946            0 :                                        Compressor(CompNum).Name,
    4947              :                                        cNumericFieldNames(3),
    4948              :                                        cNumericFieldNames(4)));
    4949            0 :                 ShowContinueError(state, "Must Be Entered. Check input value choices.");
    4950            0 :                 ErrorsFound = true;
    4951          182 :             } else if (!lNumericBlanks(3)) {
    4952           19 :                 Compressor(CompNum).SubcoolRatingType = CompRatingType::LiquidTemperature;
    4953           19 :                 Compressor(CompNum).RatedSubcool = Numbers(3);
    4954          163 :             } else if (!lNumericBlanks(4)) {
    4955          163 :                 Compressor(CompNum).SubcoolRatingType = CompRatingType::Subcooling;
    4956          163 :                 Compressor(CompNum).RatedSubcool = Numbers(4);
    4957              :             } // Set SubcoolRatingType
    4958              : 
    4959          182 :             Compressor(CompNum).EndUseSubcategory = "General";
    4960          182 :             if (!lAlphaBlanks(4)) {
    4961           22 :                 Compressor(CompNum).EndUseSubcategory = Alphas(4);
    4962              :             }
    4963              : 
    4964              :             //  If the compressor is a transcritical CO compressor, get transcritical power and capacity curves
    4965          182 :             if (lAlphaBlanks(5)) {
    4966          176 :                 Compressor(CompNum).TransFlag = false;
    4967              :                 // For some reason, Alkphas(5) is not uppercased?
    4968            6 :             } else if (CriticalType crit = static_cast<CriticalType>(getEnumValue(criticalTypeNamesUC, Util::makeUPPER(Alphas(5))));
    4969              :                        crit != CriticalType::Invalid) {
    4970            6 :                 Compressor(CompNum).TransFlag = static_cast<bool>(crit);
    4971              :             } else {
    4972            0 :                 ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(5), Alphas(5));
    4973            0 :                 ErrorsFound = true;
    4974              :             }
    4975              : 
    4976          182 :             if (Compressor(CompNum).TransFlag) {
    4977            3 :                 if (lAlphaBlanks(6)) {
    4978            0 :                     ShowSevereEmptyField(state, eoh, cAlphaFieldNames(6));
    4979            0 :                     ErrorsFound = true;
    4980            3 :                 } else if ((Compressor(CompNum).TransElecPowerCurvePtr = Curve::GetCurveIndex(state, Alphas(6))) == 0) {
    4981            0 :                     ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(6), Alphas(6));
    4982            0 :                     ErrorsFound = true;
    4983              :                 }
    4984              : 
    4985            3 :                 if (lAlphaBlanks(7)) {
    4986            0 :                     ShowSevereEmptyField(state, eoh, cAlphaFieldNames(7));
    4987            0 :                     ErrorsFound = true;
    4988            3 :                 } else if ((Compressor(CompNum).TransCapacityCurvePtr = Curve::GetCurveIndex(state, Alphas(7))) == 0) {
    4989            0 :                     ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(7), Alphas(7));
    4990            0 :                     ErrorsFound = true;
    4991              :                 }
    4992              :             } else {
    4993          179 :                 if (!lAlphaBlanks(6)) {
    4994            0 :                     ShowWarningNonEmptyField(state, eoh, cAlphaFieldNames(6), cAlphaFieldNames(5), Alphas(5));
    4995              :                 }
    4996          179 :                 if (!lAlphaBlanks(7)) {
    4997            0 :                     ShowWarningNonEmptyField(state, eoh, cAlphaFieldNames(7), cAlphaFieldNames(5), Alphas(5));
    4998              :                 }
    4999              :             }
    5000              : 
    5001              :         } // RefrigCompressor
    5002              : 
    5003              :         //************ END Compressor INPUT         **************
    5004              : 
    5005              :         //************ START Subcooler INPUT        **************
    5006           16 :         if (state.dataRefrigCase->NumSimulationSubcoolers > 0) {
    5007            1 :             CurrentModuleObject = "Refrigeration:Subcooler";
    5008            1 :             state.dataRefrigCase->NumSimulationMechSubcoolers = 0;
    5009            3 :             for (int SubcoolerNum = 1; SubcoolerNum <= state.dataRefrigCase->NumSimulationSubcoolers; ++SubcoolerNum) {
    5010            2 :                 state.dataInputProcessing->inputProcessor->getObjectItem(state,
    5011              :                                                                          CurrentModuleObject,
    5012              :                                                                          SubcoolerNum,
    5013              :                                                                          Alphas,
    5014              :                                                                          NumAlphas,
    5015              :                                                                          Numbers,
    5016              :                                                                          NumNumbers,
    5017              :                                                                          IOStatus,
    5018              :                                                                          lNumericBlanks,
    5019              :                                                                          lAlphaBlanks,
    5020              :                                                                          cAlphaFieldNames,
    5021              :                                                                          cNumericFieldNames);
    5022            2 :                 ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
    5023            2 :                 Subcooler(SubcoolerNum).Name = Alphas(1);
    5024              : 
    5025              :                 // Get subcooler type
    5026            2 :                 if ((Subcooler(SubcoolerNum).subcoolerType = static_cast<SubcoolerType>(getEnumValue(subcoolerTypeNamesUC, Alphas(2)))) ==
    5027              :                     SubcoolerType::Invalid) {
    5028            0 :                     ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(2), Alphas(2));
    5029            0 :                     ErrorsFound = true;
    5030            2 :                 } else if (Subcooler(SubcoolerNum).subcoolerType == SubcoolerType::Mechanical) {
    5031            1 :                     ++state.dataRefrigCase->NumSimulationMechSubcoolers;
    5032              :                 }
    5033              : 
    5034            2 :                 switch (Subcooler(SubcoolerNum).subcoolerType) {
    5035            1 :                 case SubcoolerType::LiquidSuction: {
    5036            1 :                     Subcooler(SubcoolerNum).LiqSuctDesignDelT = 10.0; // default value
    5037            1 :                     if (!lNumericBlanks(1)) {
    5038            1 :                         Subcooler(SubcoolerNum).LiqSuctDesignDelT = Numbers(1);
    5039              :                     }
    5040            1 :                     if (Subcooler(SubcoolerNum).LiqSuctDesignDelT < 0.0) {
    5041            0 :                         ShowSevereError(state,
    5042            0 :                                         format("{}{}=\"{}\" {} cannot be less than zero.",
    5043              :                                                RoutineName,
    5044              :                                                CurrentModuleObject,
    5045            0 :                                                Subcooler(SubcoolerNum).Name,
    5046              :                                                cNumericFieldNames(1)));
    5047            0 :                         ErrorsFound = true;
    5048              :                     }
    5049              : 
    5050            1 :                     if (!lNumericBlanks(2)) {
    5051            1 :                         Subcooler(SubcoolerNum).LiqSuctDesignTliqIn = Numbers(2);
    5052              :                     } else {
    5053            0 :                         ShowSevereError(state,
    5054            0 :                                         format("{}{}=\"{}\" {} must be specified.",
    5055              :                                                RoutineName,
    5056              :                                                CurrentModuleObject,
    5057            0 :                                                Subcooler(SubcoolerNum).Name,
    5058              :                                                cNumericFieldNames(2)));
    5059            0 :                         ErrorsFound = true;
    5060              :                     }
    5061              : 
    5062            1 :                     if (!lNumericBlanks(3)) {
    5063            1 :                         Subcooler(SubcoolerNum).LiqSuctDesignTvapIn = Numbers(3);
    5064              :                     } else {
    5065            0 :                         ShowSevereError(state,
    5066            0 :                                         format("{}{}=\"{}\" {} must be specified.",
    5067              :                                                RoutineName,
    5068              :                                                CurrentModuleObject,
    5069            0 :                                                Subcooler(SubcoolerNum).Name,
    5070              :                                                cNumericFieldNames(3)));
    5071            0 :                         ErrorsFound = true;
    5072              :                     }
    5073            1 :                     if (Subcooler(SubcoolerNum).LiqSuctDesignTvapIn > Subcooler(SubcoolerNum).LiqSuctDesignTliqIn) {
    5074            0 :                         ShowSevereError(state,
    5075            0 :                                         format("{}{}=\"{}\" {} cannot be greater than {}.",
    5076              :                                                RoutineName,
    5077              :                                                CurrentModuleObject,
    5078            0 :                                                Subcooler(SubcoolerNum).Name,
    5079              :                                                cNumericFieldNames(3),
    5080              :                                                cNumericFieldNames(2)));
    5081            0 :                         ErrorsFound = true;
    5082              :                     } // error check
    5083            1 :                 } break;
    5084            1 :                 case SubcoolerType::Mechanical: {
    5085            1 :                     Subcooler(SubcoolerNum).MechSourceSys = Alphas(3);
    5086              :                     // Error check on system name comes later after systems have been read
    5087              : 
    5088            1 :                     if (!lNumericBlanks(4)) {
    5089            1 :                         Subcooler(SubcoolerNum).MechControlTliqOut = Numbers(4);
    5090              :                     } else {
    5091            0 :                         ShowSevereError(state,
    5092            0 :                                         format("{}{}=\"{}\" {} must be specified.",
    5093              :                                                RoutineName,
    5094              :                                                CurrentModuleObject,
    5095            0 :                                                Subcooler(SubcoolerNum).Name,
    5096              :                                                cNumericFieldNames(4)));
    5097            0 :                         ErrorsFound = true;
    5098              :                     } // error check
    5099            1 :                 } break;
    5100            0 :                 default:
    5101            0 :                     break;
    5102              :                 }
    5103              :             } // Subcooler Input
    5104              :         } // If there are subcoolers
    5105              : 
    5106              :         // ********END SUBCOOLER INPUTS ************
    5107              : 
    5108              :         //**** Read TransferLoad Lists **********************************************************
    5109           16 :         if (state.dataRefrigCase->NumSimulationTransferLoadLists > 0) {
    5110            1 :             CurrentModuleObject = "Refrigeration:TransferLoadList";
    5111            2 :             for (int ListNum = 1; ListNum <= state.dataRefrigCase->NumSimulationTransferLoadLists; ++ListNum) {
    5112            1 :                 state.dataInputProcessing->inputProcessor->getObjectItem(state,
    5113              :                                                                          CurrentModuleObject,
    5114              :                                                                          ListNum,
    5115              :                                                                          Alphas,
    5116              :                                                                          NumAlphas,
    5117              :                                                                          Numbers,
    5118              :                                                                          NumNumbers,
    5119              :                                                                          IOStatus,
    5120              :                                                                          lNumericBlanks,
    5121              :                                                                          lAlphaBlanks,
    5122              :                                                                          cAlphaFieldNames,
    5123              :                                                                          cNumericFieldNames);
    5124            1 :                 Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    5125              : 
    5126            1 :                 TransferLoadList(ListNum).Name = Alphas(1);
    5127              : 
    5128              :                 // Transfer load list alphas include TransferLoadList name and one name for each Secondary or Cascade Condenser in list
    5129              :                 // below allocates larger than needed (each allocated to sum of both), but avoids two loops through input fields
    5130            1 :                 int NumTotalLoadsOnList = NumAlphas - 1;
    5131            1 :                 if (!allocated(TransferLoadList(ListNum).CascadeLoadItemNum)) {
    5132            1 :                     TransferLoadList(ListNum).CascadeLoadItemNum.allocate(NumTotalLoadsOnList);
    5133              :                 }
    5134            1 :                 if (!allocated(TransferLoadList(ListNum).SecondaryItemNum)) {
    5135            1 :                     TransferLoadList(ListNum).SecondaryItemNum.allocate(NumTotalLoadsOnList);
    5136              :                 }
    5137              : 
    5138            1 :                 int NumSecondarysOnList = 0;
    5139            1 :                 int NumCascadeLoadsOnList = 0;
    5140            2 :                 for (int NumLoad = 1; NumLoad <= NumTotalLoadsOnList; ++NumLoad) {
    5141            1 :                     int AlphaListNum = 1 + NumLoad;
    5142            1 :                     int LoadCascadeNum = 0;
    5143            1 :                     int LoadSecondaryNum = 0;
    5144            1 :                     if (state.dataRefrigCase->NumRefrigCondensers > 0) {
    5145            1 :                         LoadCascadeNum = Util::FindItemInList(Alphas(AlphaListNum), Condenser);
    5146              :                     }
    5147            1 :                     if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
    5148            1 :                         LoadSecondaryNum = Util::FindItemInList(Alphas(AlphaListNum), Secondary);
    5149              :                     }
    5150            1 :                     if ((LoadCascadeNum == 0) && (LoadSecondaryNum == 0)) {
    5151            0 :                         ShowSevereError(state,
    5152            0 :                                         format("{}{}=\"{}\" : has an invalid value of {}",
    5153              :                                                RoutineName,
    5154              :                                                CurrentModuleObject,
    5155              :                                                cAlphaFieldNames(AlphaListNum),
    5156              :                                                Alphas(AlphaListNum)));
    5157            0 :                         ErrorsFound = true;
    5158            1 :                     } else if ((LoadCascadeNum != 0) && (LoadSecondaryNum != 0)) {
    5159            0 :                         ShowSevereError(state,
    5160            0 :                                         format("{}{}=\"{}\" : has a non-unique name : {}",
    5161              :                                                RoutineName,
    5162              :                                                CurrentModuleObject,
    5163              :                                                cAlphaFieldNames(AlphaListNum),
    5164              :                                                Alphas(AlphaListNum)));
    5165            0 :                         ErrorsFound = true;
    5166            1 :                     } else if (LoadCascadeNum != 0) {
    5167            0 :                         if (Condenser(LoadCascadeNum).CondenserType != DataHeatBalance::RefrigCondenserType::Cascade) {
    5168            0 :                             ShowSevereError(state,
    5169            0 :                                             format("{}{}=\"{}\" : has a condenser listed as a transfer load that is not a cascade condenser: {}",
    5170              :                                                    RoutineName,
    5171              :                                                    CurrentModuleObject,
    5172            0 :                                                    System(RefrigSysNum).Name,
    5173              :                                                    Alphas(AlphaListNum)));
    5174            0 :                             ErrorsFound = true;
    5175              :                         } else {
    5176            0 :                             ++NumCascadeLoadsOnList;
    5177            0 :                             TransferLoadList(ListNum).CascadeLoadItemNum(NumCascadeLoadsOnList) = LoadCascadeNum;
    5178              :                         } // /= condenser cascade type
    5179            1 :                     } else if (LoadSecondaryNum != 0) {
    5180            1 :                         ++NumSecondarysOnList;
    5181            1 :                         TransferLoadList(ListNum).SecondaryItemNum(NumSecondarysOnList) = LoadSecondaryNum;
    5182              :                     }
    5183            1 :                     TransferLoadList(ListNum).NumSecondarys = NumSecondarysOnList;
    5184            1 :                     TransferLoadList(ListNum).NumCascadeLoads = NumCascadeLoadsOnList;
    5185              :                 } // Num Total Loads on List
    5186              :             } // ListNum=1,NumSimulationTransferLoadLists
    5187              :         } //(NumSimulationTransferLoadLists > 0)
    5188              : 
    5189              :         //**** End read transfer load Lists **********************************************************
    5190              : 
    5191              :         //**** Read Compressor Lists **********************************************************
    5192           16 :         CurrentModuleObject = "Refrigeration:CompressorList";
    5193           61 :         for (int ListNum = 1; ListNum <= NumCompressorLists; ++ListNum) {
    5194           45 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
    5195              :                                                                      CurrentModuleObject,
    5196              :                                                                      ListNum,
    5197              :                                                                      Alphas,
    5198              :                                                                      NumAlphas,
    5199              :                                                                      Numbers,
    5200              :                                                                      NumNumbers,
    5201              :                                                                      IOStatus,
    5202              :                                                                      lNumericBlanks,
    5203              :                                                                      lAlphaBlanks,
    5204              :                                                                      cAlphaFieldNames,
    5205              :                                                                      cNumericFieldNames);
    5206           45 :             CompressorLists(ListNum).NumCompressors = NumAlphas - 1;
    5207           45 :             Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    5208              : 
    5209           45 :             CompressorLists(ListNum).Name = Alphas(1);
    5210           45 :             if (!allocated(CompressorLists(ListNum).CompItemNum)) {
    5211           45 :                 CompressorLists(ListNum).CompItemNum.allocate(CompressorLists(ListNum).NumCompressors);
    5212              :             }
    5213              : 
    5214          227 :             for (int CompIndex = 1; CompIndex <= CompressorLists(ListNum).NumCompressors; ++CompIndex) {
    5215          182 :                 int AlphaListNum = CompIndex + 1; // same as do loop from 2 to end of list
    5216          182 :                 if (!lAlphaBlanks(AlphaListNum)) {
    5217          182 :                     CompressorLists(ListNum).CompItemNum(CompIndex) = Util::FindItemInList(Alphas(AlphaListNum), Compressor);
    5218          182 :                     if (CompressorLists(ListNum).CompItemNum(CompIndex) == 0) {
    5219            0 :                         ShowSevereError(state,
    5220            0 :                                         format("{}{}=\"{}\", has an invalid {} defined as {}",
    5221              :                                                RoutineName,
    5222              :                                                CurrentModuleObject,
    5223            0 :                                                CompressorLists(ListNum).Name,
    5224              :                                                cAlphaFieldNames(AlphaListNum),
    5225              :                                                Alphas(AlphaListNum)));
    5226            0 :                         ErrorsFound = true;
    5227              :                     }
    5228              :                 }
    5229              :             } // NumCompressors in CompressorList
    5230              : 
    5231              :         } // NumCompressorLists
    5232              : 
    5233              :         // ********READ REFRIGERATION SYSTEMS  ***********
    5234              : 
    5235           16 :         CurrentModuleObject = "Refrigeration:System";
    5236           57 :         for (RefrigSysNum = 1; RefrigSysNum <= state.dataRefrigCase->NumRefrigSystems; ++RefrigSysNum) {
    5237              : 
    5238           41 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
    5239              :                                                                      CurrentModuleObject,
    5240              :                                                                      RefrigSysNum,
    5241              :                                                                      Alphas,
    5242              :                                                                      NumAlphas,
    5243              :                                                                      Numbers,
    5244              :                                                                      NumNumbers,
    5245              :                                                                      IOStatus,
    5246              :                                                                      lNumericBlanks,
    5247              :                                                                      lAlphaBlanks,
    5248              :                                                                      cAlphaFieldNames,
    5249              :                                                                      cNumericFieldNames);
    5250              : 
    5251           41 :             ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
    5252           41 :             Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    5253              : 
    5254           41 :             System(RefrigSysNum).Name = Alphas(1);
    5255              : 
    5256              :             // Read all loads on this System: cases, walk-ins, cascade loads, and secondary loops
    5257           41 :             if (lAlphaBlanks(2) && lAlphaBlanks(3)) {
    5258              :                 // No cases, walkins, cascade loads, or secondary loops specified, ie, System has no load
    5259            0 :                 ShowSevereError(state,
    5260            0 :                                 format("{}{}=\"{}\", has no loads, must have at least one of: {} or {} objects attached.",
    5261              :                                        RoutineName,
    5262              :                                        CurrentModuleObject,
    5263            0 :                                        System(RefrigSysNum).Name,
    5264              :                                        cAlphaFieldNames(2),
    5265              :                                        cAlphaFieldNames(3)));
    5266            0 :                 ErrorsFound = true;
    5267              :             }
    5268           41 :             NumCases = 0;
    5269           41 :             System(RefrigSysNum).NumCases = 0;
    5270           41 :             int NumCoils = 0;
    5271           41 :             System(RefrigSysNum).NumCoils = 0;
    5272           41 :             NumWalkIns = 0;
    5273           41 :             System(RefrigSysNum).NumWalkIns = 0;
    5274           41 :             int NumSecondary = 0;
    5275           41 :             System(RefrigSysNum).NumSecondarys = 0;
    5276           41 :             System(RefrigSysNum).NumCascadeLoads = 0;
    5277           41 :             System(RefrigSysNum).NumNonCascadeLoads = 0;
    5278           41 :             Real64 NominalTotalCaseCap = 0.0;
    5279           41 :             Real64 NominalTotalCoilCap = 0.0;
    5280           41 :             Real64 NominalTotalWalkInCap = 0.0;
    5281           41 :             Real64 NominalTotalSecondaryCap = 0.0;
    5282              :             Real64 NominalTotalCoolingCap;
    5283           41 :             Real64 NominalTotalCascadeLoad = 0.0;
    5284           41 :             System(RefrigSysNum).RefInventory = 0.0;
    5285              : 
    5286              :             //   Check for case or walkin or CaseAndWalkInList names
    5287           41 :             AlphaNum = 2;
    5288           41 :             if (!lAlphaBlanks(AlphaNum)) {
    5289              : 
    5290              :                 // Entry for Alphas(AlphaNum) can be either a Case, WalkIn or CaseAndWalkInList name
    5291           38 :                 int CaseAndWalkInListNum = 0;
    5292           38 :                 int CaseNum = 0;
    5293           38 :                 int WalkInNum = 0;
    5294           38 :                 int CoilNum = 0;
    5295           38 :                 if (state.dataRefrigCase->NumSimulationCaseAndWalkInLists > 0) {
    5296           38 :                     CaseAndWalkInListNum = Util::FindItemInList(Alphas(AlphaNum), CaseAndWalkInList);
    5297              :                 }
    5298           38 :                 if (state.dataRefrigCase->NumSimulationCases > 0) {
    5299           29 :                     CaseNum = Util::FindItemInList(Alphas(AlphaNum), RefrigCase);
    5300              :                 }
    5301           38 :                 if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
    5302           27 :                     WalkInNum = Util::FindItemInList(Alphas(AlphaNum), WalkIn);
    5303              :                 }
    5304           38 :                 if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0) {
    5305            9 :                     CoilNum = Util::FindItemInList(Alphas(AlphaNum), WarehouseCoil);
    5306              :                 }
    5307           38 :                 int NumNameMatches = 0;
    5308           38 :                 if (CaseAndWalkInListNum != 0) {
    5309           35 :                     ++NumNameMatches;
    5310              :                 }
    5311           38 :                 if (CaseNum != 0) {
    5312            3 :                     ++NumNameMatches;
    5313              :                 }
    5314           38 :                 if (WalkInNum != 0) {
    5315            0 :                     ++NumNameMatches;
    5316              :                 }
    5317           38 :                 if (CoilNum != 0) {
    5318            0 :                     ++NumNameMatches;
    5319              :                 }
    5320              : 
    5321           38 :                 if (NumNameMatches != 1) { // name must uniquely point to a list or a single case or walkin or coil
    5322            0 :                     ErrorsFound = true;
    5323            0 :                     if (NumNameMatches == 0) {
    5324            0 :                         ShowSevereError(state,
    5325            0 :                                         format("{}{}=\"{}\", has an invalid {}: {}",
    5326              :                                                RoutineName,
    5327              :                                                CurrentModuleObject,
    5328            0 :                                                System(RefrigSysNum).Name,
    5329              :                                                cAlphaFieldNames(AlphaNum),
    5330              :                                                Alphas(AlphaNum)));
    5331            0 :                     } else if (NumNameMatches > 1) {
    5332            0 :                         ShowSevereError(state,
    5333            0 :                                         format("{}{}=\"{}\",  has a non-unique name that could be either a {}: {}",
    5334              :                                                RoutineName,
    5335              :                                                CurrentModuleObject,
    5336            0 :                                                System(RefrigSysNum).Name,
    5337              :                                                cAlphaFieldNames(AlphaNum),
    5338              :                                                Alphas(AlphaNum)));
    5339              :                     } // num matches = 0 or > 1
    5340           38 :                 } else if (CaseAndWalkInListNum != 0) { // Name points to a CaseAndWalkInList
    5341           35 :                     NumCases = CaseAndWalkInList(CaseAndWalkInListNum).NumCases;
    5342           35 :                     NumWalkIns = CaseAndWalkInList(CaseAndWalkInListNum).NumWalkIns;
    5343           35 :                     NumCoils = CaseAndWalkInList(CaseAndWalkInListNum).NumCoils;
    5344           35 :                     System(RefrigSysNum).NumCases = NumCases;
    5345           35 :                     System(RefrigSysNum).NumWalkIns = NumWalkIns;
    5346           35 :                     System(RefrigSysNum).NumCoils = NumCoils;
    5347           35 :                     if (NumCases > 0) {
    5348           23 :                         if (!allocated(System(RefrigSysNum).CaseNum)) {
    5349           23 :                             System(RefrigSysNum).CaseNum.allocate(NumCases);
    5350              :                         }
    5351           23 :                         System(RefrigSysNum).CaseNum({1, NumCases}) = CaseAndWalkInList(CaseAndWalkInListNum).CaseItemNum({1, NumCases});
    5352              :                     }
    5353           35 :                     if (NumCoils > 0) {
    5354            9 :                         if (!allocated(System(RefrigSysNum).CoilNum)) {
    5355            9 :                             System(RefrigSysNum).CoilNum.allocate(NumCoils);
    5356              :                         }
    5357            9 :                         System(RefrigSysNum).CoilNum({1, NumCoils}) = CaseAndWalkInList(CaseAndWalkInListNum).CoilItemNum({1, NumCoils});
    5358              :                     }
    5359           35 :                     if (NumWalkIns > 0) {
    5360           15 :                         if (!allocated(System(RefrigSysNum).WalkInNum)) {
    5361           15 :                             System(RefrigSysNum).WalkInNum.allocate(NumWalkIns);
    5362              :                         }
    5363           15 :                         System(RefrigSysNum).WalkInNum({1, NumWalkIns}) = CaseAndWalkInList(CaseAndWalkInListNum).WalkInItemNum({1, NumWalkIns});
    5364              :                     }
    5365            3 :                 } else if (CaseNum != 0) { // Name points to a case
    5366            3 :                     NumCases = 1;
    5367            3 :                     System(RefrigSysNum).NumCases = 1;
    5368            3 :                     if (!allocated(System(RefrigSysNum).CaseNum)) {
    5369            3 :                         System(RefrigSysNum).CaseNum.allocate(NumCases);
    5370              :                     }
    5371            3 :                     System(RefrigSysNum).CaseNum(NumCases) = CaseNum;
    5372            0 :                 } else if (CoilNum != 0) { // Name points to a coil
    5373            0 :                     NumCoils = 1;
    5374            0 :                     System(RefrigSysNum).NumCoils = 1;
    5375            0 :                     if (!allocated(System(RefrigSysNum).CoilNum)) {
    5376            0 :                         System(RefrigSysNum).CoilNum.allocate(NumCoils);
    5377              :                     }
    5378            0 :                     System(RefrigSysNum).CoilNum(NumCoils) = CoilNum;
    5379            0 :                 } else if (WalkInNum != 0) { // Name points to a walkin
    5380            0 :                     NumWalkIns = 1;
    5381            0 :                     System(RefrigSysNum).NumWalkIns = 1;
    5382            0 :                     if (!allocated(System(RefrigSysNum).WalkInNum)) {
    5383            0 :                         System(RefrigSysNum).WalkInNum.allocate(NumWalkIns);
    5384              :                     }
    5385            0 :                     System(RefrigSysNum).WalkInNum(NumWalkIns) = WalkInNum;
    5386              :                 } // NumNameMatches /= 1
    5387              :             } // blank input for cases, walkins, or caseandwalkinlist
    5388              : 
    5389           41 :             if (NumCases > 0) {
    5390              :                 // Find lowest design evap T
    5391              :                 // Sum rated capacity of all cases on system
    5392          110 :                 for (int caseIndex = 1; caseIndex <= NumCases; ++caseIndex) {
    5393              :                     // mark all cases on system as used by this system - checking for unused or non-unique cases
    5394           84 :                     int CaseNum = System(RefrigSysNum).CaseNum(caseIndex);
    5395           84 :                     ++RefrigCase(CaseNum).NumSysAttach;
    5396           84 :                     NominalTotalCaseCap += RefrigCase(CaseNum).DesignRatedCap;
    5397           84 :                     System(RefrigSysNum).RefInventory += RefrigCase(CaseNum).DesignRefrigInventory;
    5398           84 :                     if (caseIndex == 1) { // look for lowest case design evap T for system
    5399           26 :                         System(RefrigSysNum).TEvapDesign = RefrigCase(CaseNum).EvapTempDesign;
    5400              :                     } else {
    5401           58 :                         System(RefrigSysNum).TEvapDesign = min(RefrigCase(CaseNum).EvapTempDesign, System(RefrigSysNum).TEvapDesign);
    5402              :                     }
    5403              :                 } // CaseIndex=1,NumCases
    5404           26 :                 System(RefrigSysNum).NumNonCascadeLoads += System(RefrigSysNum).NumCases;
    5405              :             } // Numcases > 0
    5406              : 
    5407           41 :             if (NumCoils > 0) {
    5408              :                 // Find lowest design evap T
    5409              :                 // Sum rated capacity of all Coils on system
    5410           92 :                 for (int CoilIndex = 1; CoilIndex <= NumCoils; ++CoilIndex) {
    5411              :                     // mark all Coils on system as used by this system - checking for unused or non-unique Coils
    5412           83 :                     int CoilNum = System(RefrigSysNum).CoilNum(CoilIndex);
    5413           83 :                     ++WarehouseCoil(CoilNum).NumSysAttach;
    5414           83 :                     NominalTotalCoilCap += WarehouseCoil(CoilNum).RatedSensibleCap;
    5415           83 :                     System(RefrigSysNum).RefInventory += WarehouseCoil(CoilNum).DesignRefrigInventory;
    5416           83 :                     if ((CoilIndex == 1) && (System(RefrigSysNum).NumCases == 0)) { // look for lowest Coil design evap T for system
    5417            9 :                         System(RefrigSysNum).TEvapDesign = WarehouseCoil(CoilNum).TEvapDesign;
    5418              :                     } else {
    5419           74 :                         System(RefrigSysNum).TEvapDesign = min(WarehouseCoil(CoilNum).TEvapDesign, System(RefrigSysNum).TEvapDesign);
    5420              :                     }
    5421              :                 } // CoilIndex=1,NumCoils
    5422            9 :                 System(RefrigSysNum).NumNonCascadeLoads += System(RefrigSysNum).NumCoils;
    5423              :             } // NumCoils > 0
    5424              : 
    5425           41 :             if (NumWalkIns > 0) {
    5426           30 :                 for (int WalkInIndex = 1; WalkInIndex <= NumWalkIns; ++WalkInIndex) {
    5427           15 :                     int WalkInID = System(RefrigSysNum).WalkInNum(WalkInIndex);
    5428              :                     // mark all WalkIns on rack as used by this system (checking for unused or non-unique WalkIns)
    5429           15 :                     ++WalkIn(WalkInID).NumSysAttach;
    5430           15 :                     NominalTotalWalkInCap += WalkIn(WalkInID).DesignRatedCap;
    5431           15 :                     System(RefrigSysNum).RefInventory += WalkIn(WalkInID).DesignRefrigInventory;
    5432              :                     // Defrost capacity is treated differently by compressor racks and detailed systems,
    5433              :                     //  so this value may be adjusted (or warnings issued) after the walkin is assigned
    5434              :                     //  to either the rack or system.
    5435              :                     // for walkins served by detailed system, need capacity for both fluid and electric types.
    5436           15 :                     if (WalkIn(WalkInID).DefrostCapacity <= -98.0) {
    5437              :                         // - 99 used as a flag for blank input error message for detailed systems
    5438            0 :                         ShowSevereError(state,
    5439            0 :                                         format("{}Refrigeration:WalkIn=\"{}\", Defrost capacity must be greater than or equal to 0 W for "
    5440              :                                                "electric and hotfluid defrost types",
    5441              :                                                RoutineName,
    5442            0 :                                                WalkIn(WalkInID).Name));
    5443            0 :                         ErrorsFound = true;
    5444              :                     }
    5445              :                     // Find design evaporating temperature for system by getting min design evap for ALL loads
    5446           15 :                     if ((WalkInIndex == 1) && (System(RefrigSysNum).NumCases == 0) && (System(RefrigSysNum).NumCoils == 0)) {
    5447              :                         // note use walk in index, not walkinid here to get
    5448              :                         // first walkin on this suction group/system
    5449            3 :                         System(RefrigSysNum).TEvapDesign = WalkIn(WalkInID).TEvapDesign;
    5450              :                     } else {
    5451           12 :                         System(RefrigSysNum).TEvapDesign = min(WalkIn(WalkInID).TEvapDesign, System(RefrigSysNum).TEvapDesign);
    5452              :                     }
    5453              :                 } // WalkInIndex=1,NumWalkIns
    5454           15 :                 System(RefrigSysNum).NumNonCascadeLoads += System(RefrigSysNum).NumWalkIns;
    5455              :             } // numwalkins > 0
    5456              : 
    5457           41 :             AlphaNum = 3;
    5458              :             // Read Transfer Loads (Secondary and Cascade) assignments for this System ,
    5459              :             //     already allow more than one mech subcooler to load onto a system so they don't need to go in list
    5460           41 :             if (!lAlphaBlanks(AlphaNum)) {
    5461              : 
    5462              :                 // Entry for Alphas(AlphaNum) can be either a Secondary, CascadeLoad name or a TransferLoadList name
    5463            3 :                 int TransferLoadListNum = 0;
    5464            3 :                 int SecondaryNum = 0;
    5465            3 :                 int CascadeLoadNum = 0;
    5466            3 :                 if (state.dataRefrigCase->NumSimulationTransferLoadLists > 0) {
    5467            2 :                     TransferLoadListNum = Util::FindItemInList(Alphas(AlphaNum), TransferLoadList);
    5468              :                 }
    5469            3 :                 if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
    5470            2 :                     SecondaryNum = Util::FindItemInList(Alphas(AlphaNum), Secondary);
    5471              :                 }
    5472            3 :                 if (state.dataRefrigCase->NumRefrigCondensers > 0) {
    5473            3 :                     CascadeLoadNum = Util::FindItemInList(Alphas(AlphaNum), Condenser);
    5474              :                 }
    5475            3 :                 int NumNameMatches = 0;
    5476            3 :                 if (TransferLoadListNum != 0) {
    5477            1 :                     ++NumNameMatches;
    5478              :                 }
    5479            3 :                 if (SecondaryNum != 0) {
    5480            1 :                     ++NumNameMatches;
    5481              :                 }
    5482            3 :                 if (CascadeLoadNum != 0) {
    5483            1 :                     ++NumNameMatches;
    5484              :                 }
    5485            3 :                 int NumCascadeLoad = 0;
    5486              : 
    5487            3 :                 if (NumNameMatches != 1) { // name must uniquely point to a list or a single transfer load
    5488            0 :                     ErrorsFound = true;
    5489            0 :                     if (NumNameMatches == 0) {
    5490            0 :                         ShowSevereError(state,
    5491            0 :                                         format("{}{}=\"{}\", has an invalid {}: {}",
    5492              :                                                RoutineName,
    5493              :                                                CurrentModuleObject,
    5494            0 :                                                System(RefrigSysNum).Name,
    5495              :                                                cAlphaFieldNames(AlphaNum),
    5496              :                                                Alphas(AlphaNum)));
    5497            0 :                     } else if (NumNameMatches > 1) {
    5498            0 :                         ShowSevereError(state,
    5499            0 :                                         format("{}{}=\"{}\", has a non-unique name that could be either a {}: {}",
    5500              :                                                RoutineName,
    5501              :                                                CurrentModuleObject,
    5502            0 :                                                System(RefrigSysNum).Name,
    5503              :                                                cAlphaFieldNames(AlphaNum),
    5504              :                                                Alphas(AlphaNum)));
    5505              :                     } // num matches = 0 or > 1
    5506            3 :                 } else if (TransferLoadListNum != 0) { // Name points to a transferLoad list
    5507            1 :                     NumSecondary = TransferLoadList(TransferLoadListNum).NumSecondarys;
    5508            1 :                     NumCascadeLoad = TransferLoadList(TransferLoadListNum).NumCascadeLoads;
    5509            1 :                     System(RefrigSysNum).NumSecondarys = NumSecondary;
    5510            1 :                     System(RefrigSysNum).NumCascadeLoads = NumCascadeLoad;
    5511            1 :                     if (!allocated(System(RefrigSysNum).SecondaryNum)) {
    5512            1 :                         System(RefrigSysNum).SecondaryNum.allocate(NumSecondary);
    5513              :                     }
    5514            1 :                     System(RefrigSysNum).SecondaryNum({1, NumSecondary}) = TransferLoadList(TransferLoadListNum).SecondaryItemNum({1, NumSecondary});
    5515            1 :                     if (!allocated(System(RefrigSysNum).CascadeLoadNum)) {
    5516            1 :                         System(RefrigSysNum).CascadeLoadNum.allocate(NumCascadeLoad);
    5517              :                     }
    5518            2 :                     System(RefrigSysNum).CascadeLoadNum({1, NumCascadeLoad}) =
    5519            3 :                         TransferLoadList(TransferLoadListNum).CascadeLoadItemNum({1, NumCascadeLoad});
    5520            2 :                 } else if (SecondaryNum != 0) { // Name points to a secondary loop load
    5521            1 :                     NumSecondary = 1;
    5522            1 :                     System(RefrigSysNum).NumSecondarys = 1;
    5523            1 :                     if (!allocated(System(RefrigSysNum).SecondaryNum)) {
    5524            1 :                         System(RefrigSysNum).SecondaryNum.allocate(NumSecondary);
    5525              :                     }
    5526            1 :                     System(RefrigSysNum).SecondaryNum(NumSecondary) = SecondaryNum;
    5527            1 :                 } else if (CascadeLoadNum != 0) { // Name points to a cascade condenser load
    5528            1 :                     NumCascadeLoad = 1;
    5529            1 :                     System(RefrigSysNum).NumCascadeLoads = 1;
    5530            1 :                     if (!allocated(System(RefrigSysNum).CascadeLoadNum)) {
    5531            1 :                         System(RefrigSysNum).CascadeLoadNum.allocate(NumCascadeLoad);
    5532              :                     }
    5533            1 :                     System(RefrigSysNum).CascadeLoadNum(NumCascadeLoad) = CascadeLoadNum;
    5534              :                 } // NumNameMatches /= 1
    5535              : 
    5536            3 :                 System(RefrigSysNum).CoilFlag = false;
    5537              :                 // Now need to loop through all transfer loads to see if they change the minimum required system evaporating temperature
    5538            3 :                 if (NumSecondary > 0) {
    5539            4 :                     for (int SecondaryIndex = 1; SecondaryIndex <= NumSecondary; ++SecondaryIndex) {
    5540            2 :                         int SecondaryID = System(RefrigSysNum).SecondaryNum(SecondaryIndex);
    5541            2 :                         if (SecondaryIndex == 1) { // check for consistency of loads (coils calc on sys time step, all others on zone time step)
    5542            2 :                             if (Secondary(SecondaryID).CoilFlag) {
    5543            0 :                                 System(RefrigSysNum).CoilFlag = true;
    5544              :                             }
    5545            0 :                         } else if (Secondary(SecondaryID).CoilFlag != System(RefrigSysNum).CoilFlag) {
    5546            0 :                             ShowSevereError(
    5547              :                                 state,
    5548            0 :                                 format("{}{}=\"{}\", Serves an inconsistent mixture of loads. Coil-type loads are served on a different time "
    5549              :                                        "step than case or walkin loads. Compare loads on system served by secondary loop \"{}",
    5550              :                                        RoutineName,
    5551              :                                        CurrentModuleObject,
    5552            0 :                                        System(RefrigSysNum).Name,
    5553            0 :                                        Secondary(SecondaryID).Name));
    5554            0 :                             ErrorsFound = true;
    5555              :                         } // check for consistency of loads (coils calc on sys time step, all others on zone time step)
    5556              :                         // mark all Secondarys on system as used by this system (checking for unused or non-unique Secondarys)
    5557            2 :                         ++Secondary(SecondaryID).NumSysAttach;
    5558            2 :                         NominalTotalSecondaryCap += Secondary(SecondaryID).CoolingLoadRated;
    5559            2 :                         System(RefrigSysNum).RefInventory += Secondary(SecondaryID).ChillerRefInventory;
    5560              :                         // Find design evaporating temperature for system by getting min design evap for ALL loads
    5561            4 :                         if ((SecondaryIndex == 1) && (System(RefrigSysNum).NumCases == 0) && (System(RefrigSysNum).NumCoils == 0) &&
    5562            2 :                             (System(RefrigSysNum).NumWalkIns == 0)) {
    5563              :                             // note use secondary index above, not secondaryid here to get
    5564              :                             // first secondary on this suction group/system
    5565              :                             // note - TMinNeeded on secondary defined by cases and walkins served by secondary, not by
    5566              :                             //       the secondary's rated evaporating temperature (which is used to calc secondary heat
    5567              :                             //       exchanger effectiveness with other rated values)
    5568            2 :                             System(RefrigSysNum).TEvapDesign = Secondary(SecondaryID).TMinNeeded;
    5569              :                         } else {
    5570            0 :                             System(RefrigSysNum).TEvapDesign = min(Secondary(SecondaryID).TMinNeeded, System(RefrigSysNum).TEvapDesign);
    5571              :                         }
    5572              :                     } // SecondaryIndex=1,NumSecondary
    5573            2 :                     System(RefrigSysNum).NumNonCascadeLoads += System(RefrigSysNum).NumSecondarys;
    5574              :                 } // numsecondary > 0
    5575              : 
    5576            3 :                 if (NumCascadeLoad > 0) {
    5577            2 :                     for (int cascadeLoadIndex = 1; cascadeLoadIndex <= NumCascadeLoad; ++cascadeLoadIndex) {
    5578            1 :                         int CondID = System(RefrigSysNum).CascadeLoadNum(cascadeLoadIndex);
    5579            1 :                         if (Condenser(CondID).CondenserType != DataHeatBalance::RefrigCondenserType::Cascade) {
    5580            0 :                             ShowSevereError(state,
    5581            0 :                                             format("{}{}=\"{}\", has a  {}: {} cascade load that is not a cascade condenser.",
    5582              :                                                    RoutineName,
    5583              :                                                    CurrentModuleObject,
    5584            0 :                                                    System(RefrigSysNum).Name,
    5585              :                                                    cAlphaFieldNames(AlphaNum),
    5586              :                                                    Alphas(AlphaNum)));
    5587            0 :                             ErrorsFound = true;
    5588              :                         }
    5589              :                         // For a cascade condenser, need to identify the system absorbing the heat
    5590            1 :                         Condenser(CondID).CascadeSinkSystemID = RefrigSysNum;
    5591            1 :                         NominalTotalCascadeLoad += Condenser(CondID).RatedCapacity;
    5592              :                         // Find design evaporating temperature for system by getting min design evap for ALL loads
    5593            1 :                         if (System(RefrigSysNum).NumNonCascadeLoads == 0) {
    5594            1 :                             if (cascadeLoadIndex == 1) {
    5595              :                                 // note use cascadeload index above, not condid here to get
    5596              :                                 // first cascade condenser served by this suction group/system
    5597            1 :                                 System(RefrigSysNum).TEvapDesign = Condenser(CondID).CascadeRatedEvapTemp;
    5598              :                             } else {
    5599            0 :                                 System(RefrigSysNum).TEvapDesign = min(Condenser(CondID).CascadeRatedEvapTemp, System(RefrigSysNum).TEvapDesign);
    5600              :                             } // CascadeLoadIndex == 1
    5601              :                         } else { // (NumNonCascadeLoads > 0 so initial TEvapDesign set above with those other loads)
    5602            0 :                             if (Condenser(CondID).CascadeTempControl == CascadeCndsrTempCtrlType::TempSet) {
    5603            0 :                                 System(RefrigSysNum).TEvapDesign = min(Condenser(CondID).CascadeRatedEvapTemp,
    5604            0 :                                                                        System(RefrigSysNum).TEvapDesign); // other wise TEvapDesign set by other loads
    5605              :                             }
    5606              :                         }
    5607              :                     } // CascadeLoadIndex=1,NumCascadeLoad
    5608              :                 } // CascadeLoadNum > 0
    5609              :             } // yes/no blank input for transfer loads
    5610              : 
    5611              :             // check for consistency of loads (coils calc on sys time step, all others on zone time step, so can't mix on one system)
    5612           41 :             if (System(RefrigSysNum).CoilFlag) { // could already be true if serving secondary that serves coils
    5613            0 :                 if ((System(RefrigSysNum).NumCases > 0) || (System(RefrigSysNum).NumWalkIns > 0)) {
    5614            0 :                     ShowSevereError(state,
    5615            0 :                                     format("{}{}=\"{}\", Serves an inconsistent mixture of loads. Coil-type loads are served on a different time "
    5616              :                                            "step than case or walkin loads.",
    5617              :                                            RoutineName,
    5618              :                                            CurrentModuleObject,
    5619            0 :                                            System(RefrigSysNum).Name));
    5620            0 :                     ErrorsFound = true;
    5621              :                 }
    5622              :             } else {                                     // no coils on secondary or no secondary
    5623           41 :                 if (System(RefrigSysNum).NumCoils > 0) { //(note, coilflag set to .FALSE. for all systems as default above
    5624            9 :                     System(RefrigSysNum).CoilFlag = true;
    5625            9 :                     if ((System(RefrigSysNum).NumCases > 0) || (System(RefrigSysNum).NumWalkIns > 0)) {
    5626            0 :                         ShowSevereError(state,
    5627            0 :                                         format("{}{}=\"{}\", Serves an inconsistent mixture of loads. Coil-type loads are served on a different "
    5628              :                                                "time step than case or walkin loads.",
    5629              :                                                RoutineName,
    5630              :                                                CurrentModuleObject,
    5631            0 :                                                System(RefrigSysNum).Name));
    5632            0 :                         ErrorsFound = true;
    5633              :                     }
    5634              :                 } // NumCoils > 0
    5635              :             } // Coil flag already true due to secondary coil loads
    5636              : 
    5637           41 :             NominalTotalCoolingCap = NominalTotalCaseCap + NominalTotalWalkInCap + NominalTotalSecondaryCap + NominalTotalCascadeLoad;
    5638              : 
    5639              :             // read condenser
    5640              :             // currently assumes one condenser per refrigeration system and but multiple systems allowed per condenser
    5641           41 :             AlphaNum = 4;
    5642           41 :             int NumCondensers = 1;
    5643           41 :             if (!allocated(System(RefrigSysNum).CondenserNum)) {
    5644           41 :                 System(RefrigSysNum).CondenserNum.allocate(NumCondensers);
    5645              :             }
    5646           41 :             System(RefrigSysNum).NumCondensers = 1;
    5647              :             // Find condenser number, note condensers were read in one of four objects, but all read into same list
    5648           41 :             int CondNum = Util::FindItemInList(Alphas(AlphaNum), Condenser);
    5649           41 :             if (CondNum == 0) {
    5650            0 :                 ShowSevereError(state,
    5651            0 :                                 format("{}{}=\"{}\", has an invalid {} defined as {}",
    5652              :                                        RoutineName,
    5653              :                                        CurrentModuleObject,
    5654            0 :                                        System(RefrigSysNum).Name,
    5655              :                                        cAlphaFieldNames(AlphaNum),
    5656              :                                        Alphas(AlphaNum)));
    5657            0 :                 ErrorsFound = true;
    5658              :             } else {
    5659           41 :                 System(RefrigSysNum).CondenserNum(NumCondensers) = CondNum;
    5660              :                 // Now take care of case where multiple systems share a condenser
    5661           41 :                 ++Condenser(CondNum).NumSysAttach;
    5662           41 :                 Condenser(CondNum).SysNum(Condenser(CondNum).NumSysAttach) = RefrigSysNum;
    5663              :             }
    5664              : 
    5665           82 :             System(RefrigSysNum).RefInventory +=
    5666           41 :                 Condenser(CondNum).RefReceiverInventory + Condenser(CondNum).RefPipingInventory + Condenser(CondNum).RefOpCharge;
    5667           41 :             if (Condenser(CondNum).CondenserType == DataHeatBalance::RefrigCondenserType::Cascade) {
    5668            1 :                 Condenser(CondNum).CascadeSysID = RefrigSysNum;
    5669              :             }
    5670           41 :             if ((Condenser(CondNum).CondenserType == DataHeatBalance::RefrigCondenserType::Air) && (Condenser(CondNum).CondenserRejectHeatToZone)) {
    5671            3 :                 System(RefrigSysNum).SystemRejectHeatToZone = true;
    5672              :             }
    5673              : 
    5674              :             // Now do evaporative condenser auto-sizing because it is a function of the system's cooling load
    5675           41 :             if (Condenser(CondNum).CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
    5676            4 :                 if (Condenser(CondNum).RatedAirFlowRate == Constant::AutoCalculate) {
    5677            0 :                     Condenser(CondNum).RatedAirFlowRate = AirVolRateEvapCond * Condenser(CondNum).RatedCapacity;
    5678              :                 }
    5679            4 :                 if (Condenser(CondNum).RatedAirFlowRate <= 0.0) {
    5680            0 :                     ShowSevereError(state,
    5681            0 :                                     format("{}{}=\"{}\", Evaporative Condenser Air Volume Flow Rate cannot be less than or equal to zero.",
    5682              :                                            RoutineName,
    5683              :                                            CurrentModuleObject,
    5684            0 :                                            Condenser(CondNum).Name));
    5685            0 :                     ErrorsFound = true;
    5686              :                 }
    5687            4 :                 if (Condenser(CondNum).EvapPumpPower == Constant::AutoCalculate) {
    5688            0 :                     Condenser(CondNum).EvapPumpPower = CondPumpRatePower * Condenser(CondNum).RatedCapacity;
    5689              :                 }
    5690            4 :                 if (Condenser(CondNum).EvapPumpPower < 0.0) {
    5691            0 :                     ShowSevereError(state,
    5692            0 :                                     format("{}{}=\"{}\", Design Evaporative Condenser Water Pump Power cannot be less than zero.",
    5693              :                                            RoutineName,
    5694              :                                            CurrentModuleObject,
    5695            0 :                                            Condenser(CondNum).Name));
    5696            0 :                     ErrorsFound = true;
    5697              :                 }
    5698              :             }
    5699              : 
    5700              :             // Read the compressor data.
    5701              :             // If the system consists of two stages of compression, these compressors will be the low-stage compressors.
    5702           41 :             AlphaNum = 5;
    5703           41 :             int NumCompressorsSys = 0;
    5704           41 :             if (lAlphaBlanks(AlphaNum)) {
    5705              :                 // blank input where must have compressor or compressor list input.
    5706            0 :                 ShowSevereError(state, format("{}{} {}\" : must be input.", RoutineName, CurrentModuleObject, cAlphaFieldNames(AlphaNum)));
    5707            0 :                 ErrorsFound = true;
    5708              :             } else { //     Entry for Alphas(AlphaNum) can be either a compressor name or a compressorlist name
    5709              :                 int ListNum;
    5710           41 :                 if (NumCompressorLists > 0) {
    5711           41 :                     ListNum = Util::FindItemInList(Alphas(AlphaNum), CompressorLists);
    5712              :                 } else {
    5713            0 :                     ListNum = 0;
    5714              :                 }
    5715              :                 int CompNum;
    5716           41 :                 if (state.dataRefrigCase->NumSimulationCompressors > 0) {
    5717           41 :                     CompNum = Util::FindItemInList(Alphas(AlphaNum), Compressor);
    5718              :                 } else {
    5719            0 :                     CompNum = 0;
    5720              :                 }
    5721           41 :                 if ((ListNum == 0) && (CompNum == 0)) { // name doesn't match either a compressor or a compressor list
    5722            0 :                     ShowSevereError(state,
    5723            0 :                                     format("{}{} {}, has an invalid or undefined value=\"{}\".",
    5724              :                                            RoutineName,
    5725              :                                            CurrentModuleObject,
    5726              :                                            cAlphaFieldNames(AlphaNum),
    5727              :                                            Alphas(AlphaNum)));
    5728            0 :                     ErrorsFound = true;
    5729           41 :                 } else if ((ListNum != 0) && (CompNum != 0)) { // have compressor list and compressor with same name
    5730            0 :                     ShowSevereError(state,
    5731            0 :                                     format("{}{} {}, has a non-unique name used for both Compressor and CompressorList name: \"{}\".",
    5732              :                                            RoutineName,
    5733              :                                            CurrentModuleObject,
    5734              :                                            cAlphaFieldNames(AlphaNum),
    5735              :                                            Alphas(AlphaNum)));
    5736            0 :                     ErrorsFound = true;
    5737           41 :                 } else if (ListNum != 0) {
    5738           41 :                     NumCompressorsSys = CompressorLists(ListNum).NumCompressors;
    5739           41 :                     System(RefrigSysNum).NumCompressors = NumCompressorsSys;
    5740           41 :                     if (!allocated(System(RefrigSysNum).CompressorNum)) {
    5741           41 :                         System(RefrigSysNum).CompressorNum.allocate(NumCompressorsSys);
    5742              :                     }
    5743           41 :                     System(RefrigSysNum).CompressorNum({1, NumCompressorsSys}) = CompressorLists(ListNum).CompItemNum({1, NumCompressorsSys});
    5744            0 :                 } else if (CompNum != 0) {
    5745            0 :                     NumCompressorsSys = 1;
    5746            0 :                     System(RefrigSysNum).NumCompressors = 1;
    5747            0 :                     if (!allocated(System(RefrigSysNum).CompressorNum)) {
    5748            0 :                         System(RefrigSysNum).CompressorNum.allocate(NumCompressorsSys);
    5749              :                     }
    5750            0 :                     System(RefrigSysNum).CompressorNum(NumCompressorsSys) = CompNum;
    5751              :                 }
    5752              :             }
    5753              : 
    5754           41 :             if (!lNumericBlanks(1)) {
    5755           41 :                 System(RefrigSysNum).TCondenseMin = Numbers(1);
    5756           41 :                 System(RefrigSysNum).TCondenseMinInput = System(RefrigSysNum).TCondenseMin;
    5757           41 :                 if (state.dataGlobal->AnyEnergyManagementSystemInModel) {
    5758            8 :                     SetupEMSActuator(state,
    5759              :                                      "Refrigeration:System",
    5760            4 :                                      System(RefrigSysNum).Name,
    5761              :                                      "Minimum Condensing Temperature",
    5762              :                                      "[C]",
    5763            4 :                                      System(RefrigSysNum).EMSOverrideOnTCondenseMin,
    5764            4 :                                      System(RefrigSysNum).EMSOverrideValueTCondenseMin);
    5765              :                 }
    5766              :             } else {
    5767            0 :                 ShowSevereError(
    5768              :                     state,
    5769            0 :                     format("{}{}=\"{}\", {} must be defined.", RoutineName, CurrentModuleObject, System(RefrigSysNum).Name, cNumericFieldNames(1)));
    5770            0 :                 ErrorsFound = true;
    5771              :             }
    5772           42 :             if ((Condenser(CondNum).CondenserType == DataHeatBalance::RefrigCondenserType::Cascade) &&
    5773            1 :                 (System(RefrigSysNum).TCondenseMin > Condenser(CondNum).RatedTCondense)) {
    5774            0 :                 ShowWarningError(state,
    5775            0 :                                  format("{}=\"{}\", The system specified minimum condensing temperature is greater than the rated condensing "
    5776              :                                         "temperature for the cascade condenser. ",
    5777              :                                         CurrentModuleObject,
    5778            0 :                                         System(RefrigSysNum).Name));
    5779              :             }
    5780              : 
    5781           41 :             AlphaNum = 6;
    5782           41 :             System(RefrigSysNum).RefrigerantName = Alphas(AlphaNum);
    5783           41 :             if (System(RefrigSysNum).RefrigerantName.empty()) {
    5784            0 :                 ShowSevereEmptyField(state, eoh, Alphas(AlphaNum));
    5785            0 :                 ErrorsFound = true;
    5786           41 :             } else if ((System(RefrigSysNum).refrig = Fluid::GetRefrig(state, System(RefrigSysNum).RefrigerantName)) == nullptr) {
    5787            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    5788            0 :                 ErrorsFound = true;
    5789              :             }
    5790              :             // error messages for refrigerants already found in fluidproperties
    5791              : 
    5792           41 :             AlphaNum = 7;
    5793           41 :             if (lAlphaBlanks(AlphaNum)) {
    5794            0 :                 System(RefrigSysNum).CompSuctControl = CompressorSuctionPressureCtrl::ConstantSuctionTemperature; // Default for blank
    5795           82 :             } else if ((System(RefrigSysNum).CompSuctControl = static_cast<CompressorSuctionPressureCtrl>(
    5796           41 :                             getEnumValue(compressorSuctionPressureCtrlNamesUC, Alphas(AlphaNum)))) == CompressorSuctionPressureCtrl::Invalid) {
    5797            0 :                 ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    5798            0 :                 ErrorsFound = true;
    5799           43 :             } else if (System(RefrigSysNum).CompSuctControl == CompressorSuctionPressureCtrl::FloatSuctionTemperature &&
    5800            2 :                        System(RefrigSysNum).CoilFlag) {
    5801            0 :                 ShowWarningError(state,
    5802            0 :                                  format("{}=\"{}\", The system specified a FloatSuctionTemperature, but that is not available with air "
    5803              :                                         "chiller loads so ConstantSuctionTemperature will be used. ",
    5804              :                                         CurrentModuleObject,
    5805            0 :                                         System(RefrigSysNum).Name));
    5806              :             }
    5807              : 
    5808              :             // Count subcoolers on system and allocate
    5809           41 :             AlphaNum = 8;
    5810           41 :             System(RefrigSysNum).NumSubcoolers = 0;
    5811           41 :             if (!lAlphaBlanks(AlphaNum)) {
    5812            1 :                 ++System(RefrigSysNum).NumSubcoolers;
    5813              :             }
    5814           41 :             if (!lAlphaBlanks(AlphaNum + 1)) {
    5815            1 :                 ++System(RefrigSysNum).NumSubcoolers;
    5816              :             }
    5817              : 
    5818           41 :             if (System(RefrigSysNum).NumSubcoolers > 0) {
    5819            1 :                 if (!allocated(System(RefrigSysNum).SubcoolerNum)) {
    5820            1 :                     System(RefrigSysNum).SubcoolerNum.allocate(System(RefrigSysNum).NumSubcoolers);
    5821              :                 }
    5822            1 :                 int NumSubcooler = 1;
    5823            1 :                 if (!lAlphaBlanks(AlphaNum)) {
    5824            1 :                     System(RefrigSysNum).SubcoolerNum(NumSubcooler) =
    5825            1 :                         state.dataInputProcessing->inputProcessor->getObjectItemNum(state, "Refrigeration:Subcooler", Alphas(AlphaNum));
    5826            1 :                     if (System(RefrigSysNum).SubcoolerNum(NumSubcooler) <= 0) {
    5827            0 :                         ShowSevereError(state,
    5828            0 :                                         format(R"({}{}="{}", has an invalid {} defined as "{}".)",
    5829              :                                                RoutineName,
    5830              :                                                CurrentModuleObject,
    5831            0 :                                                System(RefrigSysNum).Name,
    5832              :                                                cAlphaFieldNames(AlphaNum),
    5833              :                                                Alphas(AlphaNum)));
    5834            0 :                         ErrorsFound = true;
    5835              :                     } else {
    5836            1 :                         Subcooler(System(RefrigSysNum).SubcoolerNum(NumSubcooler)).CoilFlag = System(RefrigSysNum).CoilFlag;
    5837              :                     }
    5838            1 :                     ++NumSubcooler;
    5839              :                 }
    5840            1 :                 if (!lAlphaBlanks(AlphaNum + 1)) {
    5841            1 :                     System(RefrigSysNum).SubcoolerNum(NumSubcooler) =
    5842            1 :                         state.dataInputProcessing->inputProcessor->getObjectItemNum(state, "Refrigeration:Subcooler", Alphas(AlphaNum + 1));
    5843            1 :                     if (System(RefrigSysNum).SubcoolerNum(NumSubcooler) <= 0) {
    5844            0 :                         ShowSevereError(state,
    5845            0 :                                         format(R"({}{}="{}", has an invalid {} defined as "{}".)",
    5846              :                                                RoutineName,
    5847              :                                                CurrentModuleObject,
    5848            0 :                                                System(RefrigSysNum).Name,
    5849              :                                                cAlphaFieldNames(AlphaNum + 1),
    5850              :                                                Alphas(AlphaNum + 1)));
    5851            0 :                         ErrorsFound = true;
    5852              :                     } else {
    5853            1 :                         Subcooler(System(RefrigSysNum).SubcoolerNum(NumSubcooler)).CoilFlag = System(RefrigSysNum).CoilFlag;
    5854              :                     }
    5855              :                 }
    5856              :             }
    5857              : 
    5858              :             // Suction piping heat gain - optional
    5859              :             //  Input UA and identify the Zone containing the bulk of the suction piping
    5860              :             //  This Zone ID will be used to determine the temperature used for suction piping heat gain.
    5861              :             //  The pipe heat gains are also counted as cooling credit for the zone.
    5862              :             //  Zone Id is only required if Sum UA Suction Piping >0.0
    5863              :             //  Get the Zone and zone node numbers from the zone name entered by the user
    5864           41 :             AlphaNum = 10;
    5865           41 :             System(RefrigSysNum).SumUASuctionPiping = 0.0;
    5866           41 :             if (!lNumericBlanks(2) && !lAlphaBlanks(AlphaNum)) {
    5867            2 :                 System(RefrigSysNum).SumUASuctionPiping = Numbers(2);
    5868            2 :                 System(RefrigSysNum).SuctionPipeActualZoneNum = Util::FindItemInList(Alphas(AlphaNum), state.dataHeatBal->Zone);
    5869            4 :                 System(RefrigSysNum).SuctionPipeZoneNodeNum =
    5870            2 :                     DataZoneEquipment::GetSystemNodeNumberForZone(state, System(RefrigSysNum).SuctionPipeActualZoneNum);
    5871            2 :                 if (System(RefrigSysNum).SuctionPipeZoneNodeNum == 0) {
    5872            0 :                     ShowSevereError(
    5873              :                         state,
    5874            0 :                         format("{}{}=\"{}\", System Node Number not found for {} = {} even though {} is greater than zero. Suction piping heat gain "
    5875              :                                "cannot be calculated unless a Zone is defined to determine the environmental temperature surrounding the piping.",
    5876              :                                RoutineName,
    5877              :                                CurrentModuleObject,
    5878            0 :                                System(RefrigSysNum).Name,
    5879              :                                cAlphaFieldNames(AlphaNum),
    5880              :                                Alphas(AlphaNum),
    5881              :                                cNumericFieldNames(2)));
    5882            0 :                     ErrorsFound = true;
    5883              :                 } else {
    5884            2 :                     state.dataRefrigCase->RefrigPresentInZone(System(RefrigSysNum).SuctionPipeActualZoneNum) = true;
    5885              :                 }
    5886           39 :             } else if (!lNumericBlanks(2) && lAlphaBlanks(AlphaNum)) {
    5887            0 :                 ShowWarningError(state,
    5888            0 :                                  format("{}{}=\"{}\" {} not found even though {} is greater than zero. Suction piping heat gain will not be "
    5889              :                                         "calculated unless a Zone is defined to determine the environmental temperature surrounding the piping.",
    5890              :                                         RoutineName,
    5891              :                                         CurrentModuleObject,
    5892            0 :                                         System(RefrigSysNum).Name,
    5893              :                                         cAlphaFieldNames(AlphaNum),
    5894              :                                         cNumericFieldNames(2)));
    5895           39 :             } else if (lNumericBlanks(2) && !lAlphaBlanks(AlphaNum)) {
    5896            0 :                 ShowWarningError(state,
    5897            0 :                                  format("{}{}=\"{}\" {} will not be used and suction piping heat gain will not be calculated because {} was blank.",
    5898              :                                         RoutineName,
    5899              :                                         CurrentModuleObject,
    5900            0 :                                         System(RefrigSysNum).Name,
    5901              :                                         cAlphaFieldNames(AlphaNum),
    5902              :                                         cNumericFieldNames(2)));
    5903              :             } // suction piping heat gains
    5904              : 
    5905           41 :             AlphaNum = 11;
    5906           41 :             if (!lAlphaBlanks(AlphaNum)) {
    5907           41 :                 System(RefrigSysNum).EndUseSubcategory = Alphas(AlphaNum);
    5908              :             }
    5909              : 
    5910              :             // Single-stage or two-stage compression system
    5911           41 :             if (!lNumericBlanks(3)) {
    5912            2 :                 System(RefrigSysNum).NumStages = Numbers(3);
    5913            2 :                 if (System(RefrigSysNum).NumStages < 1 || System(RefrigSysNum).NumStages > 2) {
    5914            0 :                     ShowSevereError(state,
    5915            0 :                                     format("{}{}=\"{}\", {}{}",
    5916              :                                            RoutineName,
    5917              :                                            CurrentModuleObject,
    5918            0 :                                            System(RefrigSysNum).Name,
    5919              :                                            cNumericFieldNames(3),
    5920              :                                            R"( has an invalid value.  Only \"1\" or \"2\" compressor stages are allowed.)"));
    5921            0 :                     ErrorsFound = true;
    5922              :                 }
    5923              :             } else {
    5924           39 :                 System(RefrigSysNum).NumStages = 1; // Default for blank
    5925              :             }
    5926              : 
    5927              :             // Intercooler type
    5928              :             // None (0) for single-stage compression systems
    5929              :             // Flash intercooler (1) or coil-and-shell intercooler (2) for two-stage compression systems
    5930           41 :             AlphaNum = 12;
    5931           41 :             if (lAlphaBlanks(AlphaNum)) {
    5932           39 :                 System(RefrigSysNum).intercoolerType = IntercoolerType::None; // Default for blank
    5933            4 :             } else if ((System(RefrigSysNum).intercoolerType =
    5934            2 :                             static_cast<IntercoolerType>(getEnumValue(intercoolerTypeNamesUC, Alphas(AlphaNum)))) == IntercoolerType::Invalid) {
    5935            0 :                 ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    5936            0 :                 ErrorsFound = true;
    5937              :             }
    5938              : 
    5939           80 :             if (System(RefrigSysNum).NumStages == 1 && (System(RefrigSysNum).intercoolerType == IntercoolerType::Flash ||
    5940           39 :                                                         System(RefrigSysNum).intercoolerType == IntercoolerType::ShellAndCoil)) {
    5941            0 :                 ShowSevereError(
    5942            0 :                     state, format("{}{}=\"{}\", A single-stage compression system", RoutineName, CurrentModuleObject, System(RefrigSysNum).Name));
    5943            0 :                 ShowContinueError(state, "has been specified with an intercooler.  Verify that the number of compressor stages");
    5944            0 :                 ShowContinueError(state, "and the intercooler type are consistent.");
    5945            0 :                 ErrorsFound = true;
    5946           41 :             } else if (System(RefrigSysNum).NumStages == 2 && System(RefrigSysNum).intercoolerType == IntercoolerType::None) {
    5947            0 :                 ShowSevereError(state,
    5948            0 :                                 format("{}{}=\"{}\", A two-stage compression system", RoutineName, CurrentModuleObject, System(RefrigSysNum).Name));
    5949            0 :                 ShowContinueError(state, "has been specified without an intercooler.  Verify that the number of compressor stages");
    5950            0 :                 ShowContinueError(state, "and the intercooler type are consistent.");
    5951            0 :                 ErrorsFound = true;
    5952              :             }
    5953              : 
    5954              :             // Shell-and-coil intercooler effectiveness
    5955           41 :             if (!lNumericBlanks(4)) {
    5956            1 :                 System(RefrigSysNum).IntercoolerEffectiveness = Numbers(4);
    5957            1 :                 if (System(RefrigSysNum).IntercoolerEffectiveness < 0.0 || System(RefrigSysNum).IntercoolerEffectiveness > 1.0) {
    5958            0 :                     ShowWarningError(state,
    5959            0 :                                      format("{}{}=\"{}\", The specified value for the", RoutineName, CurrentModuleObject, System(RefrigSysNum).Name));
    5960            0 :                     ShowContinueError(
    5961              :                         state,
    5962            0 :                         format("{} = {:.2R} is invalid.  This value must be", cNumericFieldNames(4), System(RefrigSysNum).IntercoolerEffectiveness));
    5963            0 :                     ShowContinueError(state, "between 0.0 and 1.0.  The default value of 0.8 will be used.");
    5964            0 :                     System(RefrigSysNum).IntercoolerEffectiveness = 0.8;
    5965              :                 }
    5966              :             } else {
    5967           40 :                 System(RefrigSysNum).IntercoolerEffectiveness = 0.8;
    5968              :             }
    5969              : 
    5970              :             // Read the high-stage compressor info, if two-stage compression has been specified.
    5971           41 :             AlphaNum = 13;
    5972           41 :             int NumHiStageCompressorsSys = 0;
    5973           41 :             if (System(RefrigSysNum).NumStages == 2) {
    5974            2 :                 if (lAlphaBlanks(AlphaNum)) {
    5975              :                     // blank input where must have high-stage compressor or compressor list input.
    5976            0 :                     ShowSevereError(state,
    5977            0 :                                     format("{}{}=\"{}\", {} must be input for two-stage compression systems.",
    5978              :                                            RoutineName,
    5979              :                                            CurrentModuleObject,
    5980            0 :                                            System(RefrigSysNum).Name,
    5981              :                                            cAlphaFieldNames(AlphaNum)));
    5982            0 :                     ErrorsFound = true;
    5983              :                 } else { //     Entry for Alphas(AlphaNum) can be either a compressor name or a compressorlist name
    5984            2 :                     int ListNum = Util::FindItemInList(Alphas(AlphaNum), CompressorLists);
    5985            2 :                     int CompNum = Util::FindItemInList(Alphas(AlphaNum), Compressor);
    5986            2 :                     if ((ListNum == 0) && (CompNum == 0)) { // name doesn't match either a compressor or a compressor list
    5987            0 :                         ShowSevereError(state,
    5988            0 :                                         format(R"({}{}="{}", {} has an invalid or undefined value="{}".)",
    5989              :                                                RoutineName,
    5990              :                                                CurrentModuleObject,
    5991            0 :                                                System(RefrigSysNum).Name,
    5992              :                                                cAlphaFieldNames(AlphaNum),
    5993              :                                                Alphas(AlphaNum)));
    5994            0 :                         ErrorsFound = true;
    5995            2 :                     } else if ((ListNum != 0) && (CompNum != 0)) { // have compressor list and compressor with same name
    5996            0 :                         ShowSevereError(state,
    5997            0 :                                         format(R"({}{}="{}", {} has a non-unique name used for both Compressor and CompressorList name: "{}".)",
    5998              :                                                RoutineName,
    5999              :                                                CurrentModuleObject,
    6000            0 :                                                System(RefrigSysNum).Name,
    6001              :                                                cAlphaFieldNames(AlphaNum),
    6002              :                                                Alphas(AlphaNum)));
    6003            0 :                         ErrorsFound = true;
    6004            2 :                     } else if (ListNum != 0) {
    6005            2 :                         NumHiStageCompressorsSys = CompressorLists(ListNum).NumCompressors;
    6006            2 :                         System(RefrigSysNum).NumHiStageCompressors = NumHiStageCompressorsSys;
    6007            2 :                         if (!allocated(System(RefrigSysNum).HiStageCompressorNum)) {
    6008            2 :                             System(RefrigSysNum).HiStageCompressorNum.allocate(NumHiStageCompressorsSys);
    6009              :                         }
    6010            4 :                         System(RefrigSysNum).HiStageCompressorNum({1, NumHiStageCompressorsSys}) =
    6011            6 :                             CompressorLists(ListNum).CompItemNum({1, NumHiStageCompressorsSys});
    6012            0 :                     } else if (CompNum != 0) {
    6013            0 :                         NumHiStageCompressorsSys = 1;
    6014            0 :                         System(RefrigSysNum).NumHiStageCompressors = 1;
    6015            0 :                         if (!allocated(System(RefrigSysNum).HiStageCompressorNum)) {
    6016            0 :                             System(RefrigSysNum).HiStageCompressorNum.allocate(NumHiStageCompressorsSys);
    6017              :                         }
    6018            0 :                         System(RefrigSysNum).HiStageCompressorNum(NumHiStageCompressorsSys) = CompNum;
    6019              :                     }
    6020              :                 }
    6021              :             }
    6022              : 
    6023              :             // Determine intercooler pressure and temperature at design conditions
    6024           41 :             if (System(RefrigSysNum).NumStages == 2) {
    6025              :                 Real64 PCond =
    6026            2 :                     System(RefrigSysNum).refrig->getSatPressure(state, Condenser(System(RefrigSysNum).CondenserNum(1)).RatedTCondense, RoutineName);
    6027            2 :                 Real64 PEvap = System(RefrigSysNum).refrig->getSatPressure(state, System(RefrigSysNum).TEvapDesign, RoutineName);
    6028            2 :                 System(RefrigSysNum).PIntercooler = std::sqrt(PCond * PEvap);
    6029            2 :                 System(RefrigSysNum).TIntercooler =
    6030            2 :                     System(RefrigSysNum).refrig->getSatTemperature(state, System(RefrigSysNum).PIntercooler, RoutineName);
    6031              :             } // NumStages
    6032              : 
    6033              :             // Sum capacity of single-stage compressors or low-stage compressors if two-stage system
    6034           41 :             Real64 NominalTotalCompCap = 0.0;
    6035          209 :             for (int CompIndex = 1; CompIndex <= NumCompressorsSys; ++CompIndex) {
    6036          168 :                 int CompNum = System(RefrigSysNum).CompressorNum(CompIndex);
    6037          168 :                 if (!Compressor(CompNum).TransFlag) {          //  Subcritical Compressor
    6038          168 :                     if (System(RefrigSysNum).NumStages == 1) { //  Single-stage compression
    6039          162 :                         Compressor(CompNum).NomCap = Curve::CurveValue(state,
    6040          162 :                                                                        Compressor(CompNum).CapacityCurvePtr,
    6041          162 :                                                                        System(RefrigSysNum).TEvapDesign,
    6042          162 :                                                                        Condenser(System(RefrigSysNum).CondenserNum(1)).RatedTCondense);
    6043          162 :                         NominalTotalCompCap += Compressor(CompNum).NomCap;
    6044          162 :                         ++Compressor(CompNum).NumSysAttach;
    6045              :                     } else { //  Two-stage compression, low-stage compressors
    6046            6 :                         Compressor(CompNum).NomCap = Curve::CurveValue(
    6047            6 :                             state, Compressor(CompNum).CapacityCurvePtr, System(RefrigSysNum).TEvapDesign, System(RefrigSysNum).TIntercooler);
    6048            6 :                         NominalTotalCompCap += Compressor(CompNum).NomCap;
    6049            6 :                         ++Compressor(CompNum).NumSysAttach;
    6050              :                     } // NumStages
    6051              :                 } else { //  Transcritical compressor attached to subcritical refrigeration cycle
    6052            0 :                     ShowSevereError(state,
    6053            0 :                                     format("{}{}. A transcritical compressor is attached to a subcritical refrigeration system.",
    6054              :                                            RoutineName,
    6055              :                                            CurrentModuleObject));
    6056            0 :                     ShowContinueError(state,
    6057              :                                       "Check input to ensure that subcritical compressors are connected only to subcritical systems and "
    6058              :                                       "transcritical compressors are connected only to transcritical systems.");
    6059            0 :                     ErrorsFound = true;
    6060              :                 } // .NOT. Compressor(CompNum)%TransFlag
    6061              :             }
    6062              : 
    6063           41 :             Real64 NominalTotalHiStageCompCap(0.0); // Total of nominal high-stage compressor capacities, used for rough input check (W)
    6064              : 
    6065              :             // Sum capacity of high-stage compressors if two stage system
    6066           41 :             if (System(RefrigSysNum).NumStages == 2) {
    6067           10 :                 for (int CompIndex = 1; CompIndex <= NumHiStageCompressorsSys; ++CompIndex) {
    6068            8 :                     int CompNum = System(RefrigSysNum).HiStageCompressorNum(CompIndex);
    6069            8 :                     if (!Compressor(CompNum).TransFlag) { //  Subcritical Compressor
    6070            8 :                         Compressor(CompNum).NomCap = Curve::CurveValue(state,
    6071            8 :                                                                        Compressor(CompNum).CapacityCurvePtr,
    6072            8 :                                                                        System(RefrigSysNum).TIntercooler,
    6073            8 :                                                                        Condenser(System(RefrigSysNum).CondenserNum(1)).RatedTCondense);
    6074            8 :                         NominalTotalHiStageCompCap += Compressor(CompNum).NomCap;
    6075            8 :                         ++Compressor(CompNum).NumSysAttach;
    6076              :                     } else { //  Transcritical compressor attached to subcritical refrigeration cycle
    6077            0 :                         ShowSevereError(state,
    6078            0 :                                         format("{}{}. A transcritical compressor is attached to a subcritical refrigeration system.",
    6079              :                                                RoutineName,
    6080              :                                                CurrentModuleObject));
    6081            0 :                         ShowContinueError(state,
    6082              :                                           "Check input to ensure that subcritical compressors are connected only to subcritical systems and "
    6083              :                                           "transcritical compressors are connected only to transcritical systems.");
    6084            0 :                         ErrorsFound = true;
    6085              :                     }
    6086              :                 }
    6087              :             } // NumStages
    6088              : 
    6089              :             // Compare the rated capacity of compressor, condenser, and cases.
    6090              :             // Note, rated capacities can be far off from operating capacities, but rough check.
    6091           41 :             Real64 NominalCondCap = Condenser(System(RefrigSysNum).CondenserNum(1)).RatedCapacity;
    6092           41 :             if (System(RefrigSysNum).SystemRejectHeatToZone) {
    6093            3 :                 NominalCondCap *= 2.0;
    6094              :             }
    6095           41 :             if (System(RefrigSysNum).NumStages == 1) { // Single-stage system
    6096           39 :                 if ((NominalTotalCompCap < (0.7 * NominalTotalCoolingCap)) || (NominalCondCap < (1.3 * NominalTotalCoolingCap))) {
    6097            2 :                     ShowWarningError(state,
    6098            2 :                                      format("{}=\"{}\", You may wish to check the system sizing. Total nominal cooling capacity is {:.0R}W. "
    6099              :                                             "Condenser capacity is {:.0R}W. Nominal compressor capacity is {:.0R}W.",
    6100              :                                             CurrentModuleObject,
    6101            1 :                                             System(RefrigSysNum).Name,
    6102              :                                             NominalTotalCoolingCap,
    6103              :                                             NominalCondCap,
    6104              :                                             NominalTotalCompCap));
    6105              :                 }
    6106            2 :             } else if (System(RefrigSysNum).NumStages == 2) { // Two-stage system
    6107            2 :                 if ((NominalTotalHiStageCompCap < (0.7 * NominalTotalCoolingCap)) || (NominalCondCap < (1.3 * NominalTotalCoolingCap))) {
    6108            0 :                     ShowWarningError(state,
    6109            0 :                                      format("{}=\"{}\", You may wish to check the system sizing. Total nominal cooling capacity is {:.0R}W. "
    6110              :                                             "Condenser capacity is {:.0R}W. Nominal compressor capacity is {:.0R}W.",
    6111              :                                             CurrentModuleObject,
    6112            0 :                                             System(RefrigSysNum).Name,
    6113              :                                             NominalTotalCoolingCap,
    6114              :                                             NominalCondCap,
    6115              :                                             NominalTotalCompCap));
    6116              :                 }
    6117              :             } // NumStages
    6118              : 
    6119              :         } // Refrigeration systems
    6120              : 
    6121              :         // Assign coilflags to compressors, condensers, and subcoolers (coils calc on sys time step, all other refrig loads on zone time step, so
    6122              :         // can't mix on one system) need to do here once again after all cascade condensers and cascade sink systems have been identified
    6123           57 :         for (RefrigSysNum = 1; RefrigSysNum <= state.dataRefrigCase->NumRefrigSystems; ++RefrigSysNum) {
    6124              :             // assign flags to all condensers to match system below condenser (system rejecting heat to cascade condenser)
    6125           41 :             int CondNum = System(RefrigSysNum).CondenserNum(1); // right now only have one condenser per system
    6126           41 :             Condenser(CondNum).CoilFlag = System(RefrigSysNum).CoilFlag;
    6127          209 :             for (int CompIndex = 1; CompIndex <= System(RefrigSysNum).NumCompressors; ++CompIndex) {
    6128          168 :                 int CompNum = System(RefrigSysNum).CompressorNum(CompIndex);
    6129          168 :                 Compressor(CompNum).CoilFlag = System(RefrigSysNum).CoilFlag;
    6130              :             }
    6131              : 
    6132              :         } // assign coil flags to all condensers
    6133              : 
    6134              :         // Finished setting cascade condenser coilflags to match system rejecting heat to the cascade condenser
    6135              :         // Now have to see if there's a mismatch in the coilflag with the system absorbing heat from the cascade condenser
    6136              :         // Note a system can cool multiple cascade condensers.  If so, need to be sure all are consistent - all coil or all non-coil(called case
    6137              :         // here) check for consistency of loads (coils calc on sys time step, all others on zone time step, so can't mix on one system)
    6138           57 :         for (RefrigSysNum = 1; RefrigSysNum <= state.dataRefrigCase->NumRefrigSystems;
    6139              :              ++RefrigSysNum) { // check flags for systems reflect all cascade loads
    6140           41 :             if (System(RefrigSysNum).NumCascadeLoads == 0) {
    6141           40 :                 continue;
    6142              :             }
    6143            1 :             if (System(RefrigSysNum).CoilFlag) { // system already identified as serving coils
    6144            0 :                 for (int CondID = 1; CondID <= state.dataRefrigCase->NumRefrigCondensers; ++CondID) {
    6145            0 :                     if (Condenser(CondID).CondenserType != DataHeatBalance::RefrigCondenserType::Cascade) {
    6146            0 :                         continue;
    6147              :                     }
    6148            0 :                     if (RefrigSysNum != Condenser(CondID).CascadeSinkSystemID) {
    6149            0 :                         continue; // this condenser is not a cascade load on this system
    6150              :                     }
    6151            0 :                     if (!Condenser(CondID).CoilFlag) {
    6152              :                         // would mean system already serving coil loads and this condenser cooling system with case-type loads
    6153            0 :                         ShowSevereError(state,
    6154            0 :                                         format("{}{}=\"{}\", Serves an inconsistent mixture of loads. Coil-type loads are served on a different "
    6155              :                                                "time step than case or walkin loads. Compare loads on system served by cascade condenser \"{}",
    6156              :                                                RoutineName,
    6157              :                                                CurrentModuleObject,
    6158            0 :                                                System(RefrigSysNum).Name,
    6159            0 :                                                Condenser(CondID).Name));
    6160            0 :                         ErrorsFound = true;
    6161              :                     }
    6162              :                 } // CondID
    6163              :             } else { // %coilflag == false, so no coil loads prev identified directly or through secondary loop
    6164              :                 // Flag to help verify load type with loads served by systems cooled by cascade condensers
    6165            1 :                 bool CaseLoads = false;
    6166            1 :                 int NumCascadeLoadsChecked = 0;
    6167            4 :                 for (int CondID = 1; CondID <= state.dataRefrigCase->NumRefrigCondensers; ++CondID) { // look at All cascade condenser loads on system
    6168            3 :                     if (Condenser(CondID).CondenserType != DataHeatBalance::RefrigCondenserType::Cascade) {
    6169            2 :                         continue;
    6170              :                     }
    6171            1 :                     if (RefrigSysNum != Condenser(CondID).CascadeSinkSystemID) {
    6172            0 :                         continue; // this condenser is not a cascade load on this system
    6173              :                     }
    6174            1 :                     ++NumCascadeLoadsChecked;
    6175            1 :                     if ((CaseLoads) && (!Condenser(CondID).CoilFlag) && (!System(RefrigSysNum).CoilFlag)) {
    6176            0 :                         continue;
    6177              :                     }
    6178              :                     // all loads to date are case-type and properly flagged with consistent coilflags
    6179              :                     //(note caseloads could be true if prev cascade load checked is serving a case-type system)
    6180            1 :                     if (NumCascadeLoadsChecked == 1) {
    6181            1 :                         if (Condenser(CondID).CoilFlag) {
    6182            0 :                             System(RefrigSysNum).CoilFlag = true;
    6183              :                             // setting system coilflag if 1st cascade condenser served has coils (system has no case-type loads up to this point)
    6184              :                         } else { // condenser is not serving coils, but case-type loads
    6185            1 :                             CaseLoads = true;
    6186              :                             // system coilflag already set to false
    6187              :                         } // Condenser%CoilFlag
    6188              :                     } else { // numcascadeloadschecked > 1
    6189            0 :                         if (System(RefrigSysNum).CoilFlag != Condenser(CondID).CoilFlag) {
    6190            0 :                             ShowSevereError(
    6191              :                                 state,
    6192            0 :                                 format("{}{}=\"{}\", Serves an inconsistent mixture of loads. Coil-type loads are served on a different time "
    6193              :                                        "step than case or walkin loads. Compare loads on system served by cascade condenser \"{}",
    6194              :                                        RoutineName,
    6195              :                                        CurrentModuleObject,
    6196            0 :                                        System(RefrigSysNum).Name,
    6197            0 :                                        Condenser(CondID).Name));
    6198            0 :                             ErrorsFound = true;
    6199              :                         }
    6200              :                     } // numcascadeloadschecked > 1
    6201              :                 } // CondID
    6202              :             } //(System%coilflag)
    6203              :         } // Refrigeration systems checking coilflag consistency with cascade condenser loads
    6204              : 
    6205              :     } //(NumRefrigSystems > 0)
    6206              : 
    6207              :     // after the systems have been read, can finish the mechanical subcooler/system interactions
    6208              :     // System%NumMechSCServed=0
    6209          801 :     if (state.dataRefrigCase->NumSimulationSubcoolers > 0) {
    6210            3 :         for (int SubcoolerNum = 1; SubcoolerNum <= state.dataRefrigCase->NumSimulationSubcoolers; ++SubcoolerNum) {
    6211            2 :             if (Subcooler(SubcoolerNum).subcoolerType == SubcoolerType::LiquidSuction) {
    6212            1 :                 continue;
    6213              :             }
    6214            2 :             Subcooler(SubcoolerNum).MechSourceSysID =
    6215            1 :                 state.dataInputProcessing->inputProcessor->getObjectItemNum(state, "Refrigeration:System", Subcooler(SubcoolerNum).MechSourceSys);
    6216            1 :             if (Subcooler(SubcoolerNum).MechSourceSysID == 0) {
    6217            0 :                 ShowSevereError(state,
    6218            0 :                                 format(R"({}{}="{}", Mechanical Subcooler has an invalid Source Refrigeration:System="{}".)",
    6219              :                                        RoutineName,
    6220              :                                        CurrentModuleObject,
    6221            0 :                                        Subcooler(SubcoolerNum).Name,
    6222            0 :                                        Subcooler(SubcoolerNum).MechSourceSys));
    6223            0 :                 ErrorsFound = true;
    6224              :             } else {
    6225            1 :                 if (System(Subcooler(SubcoolerNum).MechSourceSysID).CoilFlag != Subcooler(SubcoolerNum).CoilFlag) {
    6226            0 :                     ShowSevereError(state,
    6227            0 :                                     format("{}{}=\"{}\", Serves an inconsistent mixture of loads. Coil-type loads are served on a different time "
    6228              :                                            "step than case or walkin loads. Compare loads on system served by mechanical subcooler \"{}",
    6229              :                                            RoutineName,
    6230              :                                            CurrentModuleObject,
    6231            0 :                                            System(RefrigSysNum).Name,
    6232            0 :                                            Subcooler(SubcoolerNum).Name));
    6233            0 :                     ErrorsFound = true;
    6234              :                 }
    6235              :             } // error check
    6236              :         } // numsubcoolers
    6237              : 
    6238            3 :         for (RefrigSysNum = 1; RefrigSysNum <= state.dataRefrigCase->NumRefrigSystems; ++RefrigSysNum) {
    6239            6 :             for (int SubcoolerNum = 1; SubcoolerNum <= state.dataRefrigCase->NumSimulationSubcoolers; ++SubcoolerNum) {
    6240            4 :                 if (Subcooler(SubcoolerNum).subcoolerType == SubcoolerType::LiquidSuction) {
    6241            2 :                     continue;
    6242              :                 }
    6243            2 :                 if (Subcooler(SubcoolerNum).MechSourceSysID == RefrigSysNum) {
    6244            1 :                     ++System(RefrigSysNum).NumMechSCServed;
    6245              :                 }
    6246              :             }
    6247            2 :             if (System(RefrigSysNum).NumMechSCServed > 0) {
    6248            1 :                 if (!allocated(System(RefrigSysNum).MechSCLoad)) {
    6249            1 :                     System(RefrigSysNum).MechSCLoad.allocate(state.dataRefrigCase->NumSimulationSubcoolers);
    6250              :                 }
    6251              :             }
    6252              :         }
    6253              :     } // NumSimulationSubcoolers > 0
    6254              : 
    6255              :     // **********  READ TRANSCRITICAL REFRIGERATION SYSTEMS  **********
    6256              : 
    6257          801 :     if (state.dataRefrigCase->NumTransRefrigSystems > 0) {
    6258            1 :         CurrentModuleObject = "Refrigeration:TranscriticalSystem";
    6259            2 :         for (int TransRefrigSysNum = 1; TransRefrigSysNum <= state.dataRefrigCase->NumTransRefrigSystems; ++TransRefrigSysNum) {
    6260            1 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
    6261              :                                                                      CurrentModuleObject,
    6262              :                                                                      TransRefrigSysNum,
    6263              :                                                                      Alphas,
    6264              :                                                                      NumAlphas,
    6265              :                                                                      Numbers,
    6266              :                                                                      NumNumbers,
    6267              :                                                                      IOStatus,
    6268              :                                                                      lNumericBlanks,
    6269              :                                                                      lAlphaBlanks,
    6270              :                                                                      cAlphaFieldNames,
    6271              :                                                                      cNumericFieldNames);
    6272              : 
    6273            1 :             ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)};
    6274              : 
    6275            1 :             Util::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound);
    6276              : 
    6277            1 :             TransSystem(TransRefrigSysNum).Name = Alphas(1);
    6278              : 
    6279              :             // Read refrigerant for this system
    6280            1 :             AlphaNum = 8;
    6281            1 :             TransSystem(TransRefrigSysNum).RefrigerantName = Alphas(AlphaNum);
    6282            1 :             if (TransSystem(TransRefrigSysNum).RefrigerantName.empty()) {
    6283            0 :                 ShowSevereEmptyField(state, eoh, Alphas(AlphaNum));
    6284            0 :                 ErrorsFound = true;
    6285            1 :             } else if ((TransSystem(TransRefrigSysNum).refrig = Fluid::GetRefrig(state, TransSystem(TransRefrigSysNum).RefrigerantName)) == nullptr) {
    6286            0 :                 ShowSevereItemNotFound(state, eoh, cAlphaFieldNames(AlphaNum), Alphas(AlphaNum));
    6287            0 :                 ErrorsFound = true;
    6288              :             }
    6289              :             // error messages for refrigerants already found in fluidproperties
    6290              : 
    6291              :             // Read Transcritical System Type:  SingleStage or TwoStage
    6292            1 :             if (lAlphaBlanks(2)) {
    6293            0 :                 ShowSevereEmptyField(state, eoh, cAlphaFieldNames(2));
    6294            0 :                 ErrorsFound = true;
    6295            1 :             } else if ((TransSystem(TransRefrigSysNum).transSysType = static_cast<TransSysType>(getEnumValue(transSysTypeNamesUC, Alphas(2)))) ==
    6296              :                        TransSysType::Invalid) {
    6297            0 :                 ShowSevereInvalidKey(state, eoh, cAlphaFieldNames(1), Alphas(2));
    6298            0 :                 ErrorsFound = true;
    6299            1 :             } else if (TransSystem(TransRefrigSysNum).transSysType == TransSysType::SingleStage && lAlphaBlanks(3)) {
    6300              :                 // No medium temperature loads specified for a SingleStage system - display error
    6301            0 :                 ShowSevereEmptyField(state, eoh, cAlphaFieldNames(3), cAlphaFieldNames(2), Alphas(2));
    6302            0 :                 ErrorsFound = true;
    6303            1 :             } else if (TransSystem(TransRefrigSysNum).transSysType == TransSysType::TwoStage && lAlphaBlanks(4)) {
    6304            0 :                 ShowSevereEmptyField(state, eoh, cAlphaFieldNames(3), cAlphaFieldNames(2), Alphas(2));
    6305            0 :                 ErrorsFound = true;
    6306              :             }
    6307              : 
    6308            1 :             int NumCasesMT = 0;
    6309            1 :             TransSystem(TransRefrigSysNum).NumCasesMT = 0;
    6310            1 :             int NumCasesLT = 0;
    6311            1 :             TransSystem(TransRefrigSysNum).NumCasesLT = 0;
    6312            1 :             int NumWalkInsMT = 0;
    6313            1 :             TransSystem(TransRefrigSysNum).NumWalkInsMT = 0;
    6314            1 :             int NumWalkInsLT = 0;
    6315            1 :             TransSystem(TransRefrigSysNum).NumWalkInsLT = 0;
    6316            1 :             Real64 NominalTotalCaseCapMT = 0.0;
    6317            1 :             Real64 NominalTotalCaseCapLT = 0.0;
    6318            1 :             Real64 NominalTotalWalkInCapMT = 0.0;
    6319            1 :             Real64 NominalTotalWalkInCapLT = 0.0;
    6320              :             Real64 NominalTotalCoolingCap;
    6321            1 :             TransSystem(TransRefrigSysNum).RefInventory = 0.0;
    6322              : 
    6323              :             //   Check for Medium Temperature Case or Walk-In or CaseAndWalkInList names
    6324            1 :             AlphaNum = 3;
    6325              : 
    6326            1 :             if (!lAlphaBlanks(AlphaNum)) {
    6327              : 
    6328              :                 // Entry for Alphas(AlphaNum) can be either a Case, WalkIn or CaseAndWalkInList name
    6329            1 :                 int CaseAndWalkInListNum = 0;
    6330            1 :                 int CaseNum = 0;
    6331            1 :                 int WalkInNum = 0;
    6332            1 :                 if (state.dataRefrigCase->NumSimulationCaseAndWalkInLists > 0) {
    6333            1 :                     CaseAndWalkInListNum = Util::FindItemInList(Alphas(AlphaNum), CaseAndWalkInList);
    6334              :                 }
    6335            1 :                 if (state.dataRefrigCase->NumSimulationCases > 0) {
    6336            1 :                     CaseNum = Util::FindItemInList(Alphas(AlphaNum), RefrigCase);
    6337              :                 }
    6338            1 :                 if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
    6339            1 :                     WalkInNum = Util::FindItemInList(Alphas(AlphaNum), WalkIn);
    6340              :                 }
    6341            1 :                 int NumNameMatches = 0;
    6342            1 :                 if (CaseAndWalkInListNum != 0) {
    6343            1 :                     ++NumNameMatches;
    6344              :                 }
    6345            1 :                 if (CaseNum != 0) {
    6346            0 :                     ++NumNameMatches;
    6347              :                 }
    6348            1 :                 if (WalkInNum != 0) {
    6349            0 :                     ++NumNameMatches;
    6350              :                 }
    6351              : 
    6352            1 :                 if (NumNameMatches != 1) { // name must uniquely point to a list or a single case or walkin or coil
    6353            0 :                     ErrorsFound = true;
    6354            0 :                     if (NumNameMatches == 0) {
    6355            0 :                         ShowSevereError(state,
    6356            0 :                                         format("{}{}=\"{}\", has an invalid {}: {}",
    6357              :                                                RoutineName,
    6358              :                                                CurrentModuleObject,
    6359            0 :                                                TransSystem(TransRefrigSysNum).Name,
    6360              :                                                cAlphaFieldNames(AlphaNum),
    6361              :                                                Alphas(AlphaNum)));
    6362            0 :                     } else if (NumNameMatches > 1) {
    6363            0 :                         ShowSevereError(state,
    6364            0 :                                         format("{}{}=\"{}\",  has a non-unique name that could be either a {}: {}",
    6365              :                                                RoutineName,
    6366              :                                                CurrentModuleObject,
    6367            0 :                                                TransSystem(TransRefrigSysNum).Name,
    6368              :                                                cAlphaFieldNames(AlphaNum),
    6369              :                                                Alphas(AlphaNum)));
    6370              :                     } // num matches = 0 or > 1
    6371            1 :                 } else if (CaseAndWalkInListNum != 0) { // Name points to a CaseAndWalkInList
    6372            1 :                     NumCasesMT = CaseAndWalkInList(CaseAndWalkInListNum).NumCases;
    6373            1 :                     NumWalkInsMT = CaseAndWalkInList(CaseAndWalkInListNum).NumWalkIns;
    6374            1 :                     TransSystem(TransRefrigSysNum).NumCasesMT = NumCasesMT;
    6375            1 :                     TransSystem(TransRefrigSysNum).NumWalkInsMT = NumWalkInsMT;
    6376            1 :                     if (NumCasesMT > 0) {
    6377            1 :                         if (!allocated(TransSystem(TransRefrigSysNum).CaseNumMT)) {
    6378            1 :                             TransSystem(TransRefrigSysNum).CaseNumMT.allocate(NumCasesMT);
    6379              :                         }
    6380            2 :                         TransSystem(TransRefrigSysNum).CaseNumMT({1, NumCasesMT}) =
    6381            3 :                             CaseAndWalkInList(CaseAndWalkInListNum).CaseItemNum({1, NumCasesMT});
    6382              :                     }
    6383            1 :                     if (NumWalkInsMT > 0) {
    6384            0 :                         if (!allocated(TransSystem(TransRefrigSysNum).WalkInNumMT)) {
    6385            0 :                             TransSystem(TransRefrigSysNum).WalkInNumMT.allocate(NumWalkInsMT);
    6386              :                         }
    6387            0 :                         TransSystem(TransRefrigSysNum).WalkInNumMT({1, NumWalkInsMT}) =
    6388            0 :                             CaseAndWalkInList(CaseAndWalkInListNum).WalkInItemNum({1, NumWalkInsMT});
    6389              :                     }
    6390            0 :                 } else if (CaseNum != 0) { // Name points to a case
    6391            0 :                     NumCasesMT = 1;
    6392            0 :                     TransSystem(TransRefrigSysNum).NumCasesMT = 1;
    6393            0 :                     if (!allocated(TransSystem(TransRefrigSysNum).CaseNumMT)) {
    6394            0 :                         TransSystem(TransRefrigSysNum).CaseNumMT.allocate(NumCasesMT);
    6395              :                     }
    6396            0 :                     TransSystem(TransRefrigSysNum).CaseNumMT(NumCases) = CaseNum;
    6397            0 :                 } else if (WalkInNum != 0) { // Name points to a walkin
    6398            0 :                     NumWalkInsMT = 1;
    6399            0 :                     TransSystem(TransRefrigSysNum).NumWalkInsMT = 1;
    6400            0 :                     if (!allocated(TransSystem(TransRefrigSysNum).WalkInNumMT)) {
    6401            0 :                         TransSystem(TransRefrigSysNum).WalkInNumMT.allocate(NumWalkInsMT);
    6402              :                     }
    6403            0 :                     TransSystem(TransRefrigSysNum).WalkInNumMT(NumWalkIns) = WalkInNum;
    6404              :                 } // NumNameMatches /= 1
    6405              :             } // blank input for cases, walkins, or caseandwalkinlist
    6406              : 
    6407            1 :             if (NumCasesMT > 0) {
    6408              :                 // Find lowest design evap T
    6409              :                 // Sum rated capacity of all MT cases on system
    6410            4 :                 for (int caseIndex = 1; caseIndex <= NumCasesMT; ++caseIndex) {
    6411              :                     // mark all cases on system as used by this system - checking for unused or non-unique cases
    6412            3 :                     int CaseNum = TransSystem(TransRefrigSysNum).CaseNumMT(caseIndex);
    6413            3 :                     ++RefrigCase(CaseNum).NumSysAttach;
    6414            3 :                     NominalTotalCaseCapMT += RefrigCase(CaseNum).DesignRatedCap;
    6415            3 :                     TransSystem(TransRefrigSysNum).RefInventory += RefrigCase(CaseNum).DesignRefrigInventory;
    6416            3 :                     if (caseIndex == 1) { // look for lowest case design evap T for system
    6417            1 :                         TransSystem(TransRefrigSysNum).TEvapDesignMT = RefrigCase(CaseNum).EvapTempDesign;
    6418              :                     } else {
    6419            2 :                         TransSystem(TransRefrigSysNum).TEvapDesignMT =
    6420            2 :                             min(RefrigCase(CaseNum).EvapTempDesign, TransSystem(TransRefrigSysNum).TEvapDesignMT);
    6421              :                     }
    6422              :                 } // CaseIndex=1,NumCases
    6423              :             } // NumcasesMT > 0
    6424              : 
    6425            1 :             if (NumWalkInsMT > 0) {
    6426            0 :                 for (int WalkInIndex = 1; WalkInIndex <= NumWalkInsMT; ++WalkInIndex) {
    6427            0 :                     int WalkInID = TransSystem(TransRefrigSysNum).WalkInNumMT(WalkInIndex);
    6428              :                     // mark all WalkIns on rack as used by this system (checking for unused or non-unique WalkIns)
    6429            0 :                     ++WalkIn(WalkInID).NumSysAttach;
    6430            0 :                     NominalTotalWalkInCapMT += WalkIn(WalkInID).DesignRatedCap;
    6431            0 :                     TransSystem(TransRefrigSysNum).RefInventory += WalkIn(WalkInID).DesignRefrigInventory;
    6432              :                     // Defrost capacity is treated differently by compressor racks and detailed systems,
    6433              :                     //  so this value may be adjusted (or warnings issued) after the walkin is assigned
    6434              :                     //  to either the rack or system.
    6435              :                     // for walkins served by detailed system, need capacity for both fluid and electric types.
    6436            0 :                     if (WalkIn(WalkInID).DefrostCapacity <= -98.0) {
    6437              :                         // - 99 used as a flag for blank input error message for detailed systems
    6438            0 :                         ShowSevereError(state,
    6439            0 :                                         format("{}Refrigeration:WalkIn=\"{}\", Defrost capacity must be greater than or equal to 0 W for "
    6440              :                                                "electric and hotfluid defrost types",
    6441              :                                                RoutineName,
    6442            0 :                                                WalkIn(WalkInID).Name));
    6443            0 :                         ErrorsFound = true;
    6444              :                     }
    6445              :                     // Find design evaporating temperature for system by getting min design evap for ALL loads
    6446            0 :                     if ((WalkInIndex == 1) && (TransSystem(TransRefrigSysNum).NumCasesMT == 0)) {
    6447              :                         // note use walk in index, not walkinid here to get
    6448              :                         // first walkin on this suction group/system
    6449            0 :                         TransSystem(TransRefrigSysNum).TEvapDesignMT = WalkIn(WalkInID).TEvapDesign;
    6450              :                     } else {
    6451            0 :                         TransSystem(TransRefrigSysNum).TEvapDesignMT =
    6452            0 :                             min(WalkIn(WalkInID).TEvapDesign, TransSystem(TransRefrigSysNum).TEvapDesignMT);
    6453              :                     }
    6454              :                 } // WalkInIndex=1,NumWalkIns
    6455              :             } // NumWalkInsMT > 0
    6456              : 
    6457              :             //   Check for Low Temperature Case or Walk-In or CaseAndWalkInList names
    6458            1 :             AlphaNum = 4;
    6459            1 :             if (!lAlphaBlanks(AlphaNum)) {
    6460              : 
    6461              :                 // Entry for Alphas(AlphaNum) can be either a Case, WalkIn or CaseAndWalkInList name
    6462            1 :                 int CaseAndWalkInListNum = 0;
    6463            1 :                 int CaseNum = 0;
    6464            1 :                 int WalkInNum = 0;
    6465            1 :                 if (state.dataRefrigCase->NumSimulationCaseAndWalkInLists > 0) {
    6466            1 :                     CaseAndWalkInListNum = Util::FindItemInList(Alphas(AlphaNum), CaseAndWalkInList);
    6467              :                 }
    6468            1 :                 if (state.dataRefrigCase->NumSimulationCases > 0) {
    6469            1 :                     CaseNum = Util::FindItemInList(Alphas(AlphaNum), RefrigCase);
    6470              :                 }
    6471            1 :                 if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
    6472            1 :                     WalkInNum = Util::FindItemInList(Alphas(AlphaNum), WalkIn);
    6473              :                 }
    6474            1 :                 int NumNameMatches = 0;
    6475            1 :                 if (CaseAndWalkInListNum != 0) {
    6476            1 :                     ++NumNameMatches;
    6477              :                 }
    6478            1 :                 if (CaseNum != 0) {
    6479            0 :                     ++NumNameMatches;
    6480              :                 }
    6481            1 :                 if (WalkInNum != 0) {
    6482            0 :                     ++NumNameMatches;
    6483              :                 }
    6484              : 
    6485            1 :                 if (NumNameMatches != 1) { // name must uniquely point to a list or a single case or walkin or coil
    6486            0 :                     ErrorsFound = true;
    6487            0 :                     if (NumNameMatches == 0) {
    6488            0 :                         ShowSevereError(state,
    6489            0 :                                         format("{}{}=\"{}\", has an invalid {}: {}",
    6490              :                                                RoutineName,
    6491              :                                                CurrentModuleObject,
    6492            0 :                                                TransSystem(TransRefrigSysNum).Name,
    6493              :                                                cAlphaFieldNames(AlphaNum),
    6494              :                                                Alphas(AlphaNum)));
    6495            0 :                     } else if (NumNameMatches > 1) {
    6496            0 :                         ShowSevereError(state,
    6497            0 :                                         format("{}{}=\"{}\",  has a non-unique name that could be either a {}: {}",
    6498              :                                                RoutineName,
    6499              :                                                CurrentModuleObject,
    6500            0 :                                                TransSystem(TransRefrigSysNum).Name,
    6501              :                                                cAlphaFieldNames(AlphaNum),
    6502              :                                                Alphas(AlphaNum)));
    6503              :                     } // num matches = 0 or > 1
    6504            1 :                 } else if (CaseAndWalkInListNum != 0) { // Name points to a CaseAndWalkInList
    6505            1 :                     NumCasesLT = CaseAndWalkInList(CaseAndWalkInListNum).NumCases;
    6506            1 :                     NumWalkInsLT = CaseAndWalkInList(CaseAndWalkInListNum).NumWalkIns;
    6507            1 :                     TransSystem(TransRefrigSysNum).NumCasesLT = NumCasesLT;
    6508            1 :                     TransSystem(TransRefrigSysNum).NumWalkInsLT = NumWalkInsLT;
    6509            1 :                     if (NumCasesLT > 0) {
    6510            1 :                         if (!allocated(TransSystem(TransRefrigSysNum).CaseNumLT)) {
    6511            1 :                             TransSystem(TransRefrigSysNum).CaseNumLT.allocate(NumCasesLT);
    6512              :                         }
    6513            2 :                         TransSystem(TransRefrigSysNum).CaseNumLT({1, NumCasesLT}) =
    6514            3 :                             CaseAndWalkInList(CaseAndWalkInListNum).CaseItemNum({1, NumCasesLT});
    6515              :                     }
    6516            1 :                     if (NumWalkInsLT > 0) {
    6517            1 :                         if (!allocated(TransSystem(TransRefrigSysNum).WalkInNumLT)) {
    6518            1 :                             TransSystem(TransRefrigSysNum).WalkInNumLT.allocate(NumWalkInsLT);
    6519              :                         }
    6520            2 :                         TransSystem(TransRefrigSysNum).WalkInNumLT({1, NumWalkInsLT}) =
    6521            3 :                             CaseAndWalkInList(CaseAndWalkInListNum).WalkInItemNum({1, NumWalkInsLT});
    6522              :                     }
    6523            0 :                 } else if (CaseNum != 0) { // Name points to a case
    6524            0 :                     NumCasesLT = 1;
    6525            0 :                     TransSystem(TransRefrigSysNum).NumCasesLT = 1;
    6526            0 :                     if (!allocated(TransSystem(TransRefrigSysNum).CaseNumLT)) {
    6527            0 :                         TransSystem(TransRefrigSysNum).CaseNumLT.allocate(NumCasesLT);
    6528              :                     }
    6529            0 :                     TransSystem(TransRefrigSysNum).CaseNumLT(NumCases) = CaseNum;
    6530            0 :                 } else if (WalkInNum != 0) { // Name points to a walkin
    6531            0 :                     NumWalkInsLT = 1;
    6532            0 :                     TransSystem(TransRefrigSysNum).NumWalkInsLT = 1;
    6533            0 :                     if (!allocated(TransSystem(TransRefrigSysNum).WalkInNumLT)) {
    6534            0 :                         TransSystem(TransRefrigSysNum).WalkInNumLT.allocate(NumWalkInsLT);
    6535              :                     }
    6536            0 :                     TransSystem(TransRefrigSysNum).WalkInNumLT(NumWalkIns) = WalkInNum;
    6537              :                 } // NumNameMatches /= 1
    6538              :             } // blank input for cases, walkins, or caseandwalkinlist
    6539              : 
    6540            1 :             if (NumCasesLT > 0) {
    6541              :                 // Find lowest design evap T
    6542              :                 // Sum rated capacity of all LT cases on system
    6543            5 :                 for (int caseIndex = 1; caseIndex <= NumCasesLT; ++caseIndex) {
    6544              :                     // mark all cases on system as used by this system - checking for unused or non-unique cases
    6545            4 :                     int CaseNum = TransSystem(TransRefrigSysNum).CaseNumLT(caseIndex);
    6546            4 :                     ++RefrigCase(CaseNum).NumSysAttach;
    6547            4 :                     NominalTotalCaseCapLT += RefrigCase(CaseNum).DesignRatedCap;
    6548            4 :                     TransSystem(TransRefrigSysNum).RefInventory += RefrigCase(CaseNum).DesignRefrigInventory;
    6549            4 :                     if (caseIndex == 1) { // look for lowest case design evap T for system
    6550            1 :                         TransSystem(TransRefrigSysNum).TEvapDesignLT = RefrigCase(CaseNum).EvapTempDesign;
    6551              :                     } else {
    6552            3 :                         TransSystem(TransRefrigSysNum).TEvapDesignLT =
    6553            3 :                             min(RefrigCase(CaseNum).EvapTempDesign, TransSystem(TransRefrigSysNum).TEvapDesignLT);
    6554              :                     }
    6555              :                 } // CaseIndex=1,NumCases
    6556              :             } // NumcasesLT > 0
    6557              : 
    6558            1 :             if (NumWalkInsLT > 0) {
    6559            2 :                 for (int WalkInIndex = 1; WalkInIndex <= NumWalkInsLT; ++WalkInIndex) {
    6560            1 :                     int WalkInID = TransSystem(TransRefrigSysNum).WalkInNumLT(WalkInIndex);
    6561              :                     // mark all WalkIns on rack as used by this system (checking for unused or non-unique WalkIns)
    6562            1 :                     ++WalkIn(WalkInID).NumSysAttach;
    6563            1 :                     NominalTotalWalkInCapLT += WalkIn(WalkInID).DesignRatedCap;
    6564            1 :                     TransSystem(TransRefrigSysNum).RefInventory += WalkIn(WalkInID).DesignRefrigInventory;
    6565              :                     // Defrost capacity is treated differently by compressor racks and detailed systems,
    6566              :                     //  so this value may be adjusted (or warnings issued) after the walkin is assigned
    6567              :                     //  to either the rack or system.
    6568              :                     // for walkins served by detailed system, need capacity for both fluid and electric types.
    6569            1 :                     if (WalkIn(WalkInID).DefrostCapacity <= -98.0) {
    6570              :                         // - 99 used as a flag for blank input error message for detailed systems
    6571            0 :                         ShowSevereError(state,
    6572            0 :                                         format("{}Refrigeration:WalkIn=\"{}\", Defrost capacity must be greater than or equal to 0 W for "
    6573              :                                                "electric and hotfluid defrost types",
    6574              :                                                RoutineName,
    6575            0 :                                                WalkIn(WalkInID).Name));
    6576            0 :                         ErrorsFound = true;
    6577              :                     }
    6578              :                     // Find design evaporating temperature for system by getting min design evap for ALL loads
    6579            1 :                     if ((WalkInIndex == 1) && (TransSystem(TransRefrigSysNum).NumCasesLT == 0)) {
    6580              :                         // note use walk in index, not walkinid here to get
    6581              :                         // first walkin on this suction group/system
    6582            0 :                         TransSystem(TransRefrigSysNum).TEvapDesignLT = WalkIn(WalkInID).TEvapDesign;
    6583              :                     } else {
    6584            1 :                         TransSystem(TransRefrigSysNum).TEvapDesignLT =
    6585            1 :                             min(WalkIn(WalkInID).TEvapDesign, TransSystem(TransRefrigSysNum).TEvapDesignLT);
    6586              :                     }
    6587              :                 } // WalkInIndex=1,NumWalkIns
    6588              :             } // NumWalkInsMT > 0
    6589              : 
    6590            1 :             NominalTotalCoolingCap = NominalTotalCaseCapMT + NominalTotalCaseCapLT + NominalTotalWalkInCapMT + NominalTotalWalkInCapLT;
    6591              : 
    6592              :             // Read Gas Cooler
    6593              :             // currently assumes one gas cooler per refrigeration system and but multiple systems allowed per gas cooler
    6594            1 :             AlphaNum = 5;
    6595            1 :             int NumGasCoolers = 1;
    6596            1 :             if (!allocated(TransSystem(TransRefrigSysNum).GasCoolerNum)) {
    6597            1 :                 TransSystem(TransRefrigSysNum).GasCoolerNum.allocate(NumGasCoolers);
    6598              :             }
    6599            1 :             TransSystem(TransRefrigSysNum).NumGasCoolers = 1;
    6600              :             // Find gascooler number
    6601            1 :             int GCNum = Util::FindItemInList(Alphas(AlphaNum), GasCooler);
    6602              : 
    6603            1 :             if (GCNum == 0) { //  Invalid Gas Cooler attached to Transcritical Refrigeration System
    6604            0 :                 ShowSevereError(state,
    6605            0 :                                 format(R"({}{}="{}", has an invalid {} defined as "{}".)",
    6606              :                                        RoutineName,
    6607              :                                        CurrentModuleObject,
    6608            0 :                                        TransSystem(TransRefrigSysNum).Name,
    6609              :                                        cAlphaFieldNames(AlphaNum),
    6610              :                                        Alphas(AlphaNum)));
    6611            0 :                 ErrorsFound = true;
    6612            1 :             } else if (GCNum != 0) { //  Gas Cooler attached to Transcritical Refrigeration System
    6613            1 :                 TransSystem(TransRefrigSysNum).GasCoolerNum(NumGasCoolers) = GCNum;
    6614            1 :                 TransSystem(TransRefrigSysNum).NumGasCoolers = 1;
    6615              :                 // Now take care of case where multiple systems share a gas cooler
    6616            1 :                 ++GasCooler(GCNum).NumSysAttach;
    6617            1 :                 GasCooler(GCNum).SysNum(GasCooler(GCNum).NumSysAttach) = TransRefrigSysNum;
    6618            2 :                 TransSystem(TransRefrigSysNum).RefInventory +=
    6619            1 :                     GasCooler(GCNum).RefReceiverInventory + GasCooler(GCNum).RefPipingInventory + GasCooler(GCNum).RefOpCharge;
    6620            1 :                 if (GasCooler(GCNum).GasCoolerRejectHeatToZone) {
    6621            0 :                     TransSystem(TransRefrigSysNum).SystemRejectHeatToZone = true;
    6622              :                 }
    6623              :             }
    6624              : 
    6625              :             // Read High Pressure Compressor
    6626            1 :             AlphaNum = 6;
    6627            1 :             int NumCompressorsSys = 0;
    6628            1 :             if (lAlphaBlanks(AlphaNum)) {
    6629              :                 // blank input where must have compressor or compressor list input.
    6630            0 :                 ShowSevereError(state, format("{}{} {}\" : must be input.", RoutineName, CurrentModuleObject, cAlphaFieldNames(AlphaNum)));
    6631            0 :                 ErrorsFound = true;
    6632              :             } else { //     Entry for Alphas(AlphaNum) can be either a compressor name or a compressorlist name
    6633            1 :                 int ListNum = Util::FindItemInList(Alphas(AlphaNum), CompressorLists);
    6634            1 :                 int CompNum = Util::FindItemInList(Alphas(AlphaNum), Compressor);
    6635            1 :                 if ((ListNum == 0) && (CompNum == 0)) { // name doesn't match either a compressor or a compressor list
    6636            0 :                     ShowSevereError(state,
    6637            0 :                                     format(R"({}{}, "{}", has an invalid or undefined value="{}".)",
    6638              :                                            RoutineName,
    6639              :                                            CurrentModuleObject,
    6640              :                                            cAlphaFieldNames(AlphaNum),
    6641              :                                            Alphas(AlphaNum)));
    6642            0 :                     ErrorsFound = true;
    6643            1 :                 } else if ((ListNum != 0) && (CompNum != 0)) { // have compressor list and compressor with same name
    6644            0 :                     ShowSevereError(state,
    6645            0 :                                     format("{}{} {}, has a non-unique name used for both Compressor and CompressorList name: \"{}\".",
    6646              :                                            RoutineName,
    6647              :                                            CurrentModuleObject,
    6648              :                                            cAlphaFieldNames(AlphaNum),
    6649              :                                            Alphas(AlphaNum)));
    6650            0 :                     ErrorsFound = true;
    6651            1 :                 } else if (ListNum != 0) {
    6652            1 :                     NumCompressorsSys = CompressorLists(ListNum).NumCompressors;
    6653            1 :                     TransSystem(TransRefrigSysNum).NumCompressorsHP = NumCompressorsSys;
    6654            1 :                     if (!allocated(TransSystem(TransRefrigSysNum).CompressorNumHP)) {
    6655            1 :                         TransSystem(TransRefrigSysNum).CompressorNumHP.allocate(NumCompressorsSys);
    6656              :                     }
    6657            2 :                     TransSystem(TransRefrigSysNum).CompressorNumHP({1, NumCompressorsSys}) =
    6658            3 :                         CompressorLists(ListNum).CompItemNum({1, NumCompressorsSys});
    6659            0 :                 } else if (CompNum != 0) {
    6660            0 :                     NumCompressorsSys = 1;
    6661            0 :                     TransSystem(TransRefrigSysNum).NumCompressorsHP = 1;
    6662            0 :                     if (!allocated(TransSystem(TransRefrigSysNum).CompressorNumHP)) {
    6663            0 :                         TransSystem(TransRefrigSysNum).CompressorNumHP.allocate(NumCompressorsSys);
    6664              :                     }
    6665            0 :                     TransSystem(TransRefrigSysNum).CompressorNumHP(NumCompressorsSys) = CompNum;
    6666              :                 }
    6667              :                 // Sum rated capacity of all HP compressors on system
    6668            1 :                 NominalTotalCompCapHP = 0.0;
    6669            4 :                 for (int CompIndex = 1; CompIndex <= NumCompressorsSys; ++CompIndex) {
    6670            3 :                     CompNum = TransSystem(TransRefrigSysNum).CompressorNumHP(CompIndex);
    6671              : 
    6672            3 :                     if (Compressor(CompNum).TransFlag) { //  Calculate nominal capacity of transcritical Compressor
    6673            3 :                         Real64 GCOutletH = TransSystem(TransRefrigSysNum)
    6674           12 :                                                .refrig->getSupHeatEnthalpy(state,
    6675            3 :                                                                            GasCooler(TransSystem(TransRefrigSysNum).GasCoolerNum(1)).RatedOutletT,
    6676            3 :                                                                            GasCooler(TransSystem(TransRefrigSysNum).GasCoolerNum(1)).RatedOutletP,
    6677              :                                                                            routineName);
    6678            3 :                         Compressor(CompNum).NomCap = Curve::CurveValue(
    6679            3 :                             state, Compressor(CompNum).TransCapacityCurvePtr, TransSystem(TransRefrigSysNum).TEvapDesignMT, GCOutletH);
    6680            3 :                         NominalTotalCompCapHP += Compressor(CompNum).NomCap;
    6681            3 :                         ++Compressor(CompNum).NumSysAttach;
    6682              :                     } else { //  Subcritical compressor attached to transcritical system - show error
    6683            0 :                         ShowSevereError(
    6684              :                             state,
    6685            0 :                             format("{}{}, No transcritical CO2 compressors are attached to the transcritical refrigeration system, \"{}\".",
    6686              :                                    RoutineName,
    6687              :                                    CurrentModuleObject,
    6688            0 :                                    TransSystem(TransRefrigSysNum).Name));
    6689            0 :                         ErrorsFound = true;
    6690              :                     }
    6691              :                 }
    6692              :             }
    6693              : 
    6694              :             // Read Low Pressure Compressor
    6695            1 :             AlphaNum = 7;
    6696            1 :             NumCompressorsSys = 0;
    6697              : 
    6698            1 :             if ((lAlphaBlanks(AlphaNum)) && (TransSystem(TransRefrigSysNum).transSysType == TransSysType::TwoStage)) {
    6699              :                 // TwoStage system type is specified but low pressure compressor input is blank
    6700            0 :                 ShowSevereError(state,
    6701            0 :                                 format("{}{}, The transcritical refrigeration system, \"{}\", is specified to be \"TwoStage\", "
    6702              :                                        "however, the \"{}\" is not given.",
    6703              :                                        RoutineName,
    6704              :                                        CurrentModuleObject,
    6705            0 :                                        TransSystem(TransRefrigSysNum).Name,
    6706              :                                        cAlphaFieldNames(AlphaNum)));
    6707            0 :                 ErrorsFound = true;
    6708            1 :             } else if ((!(lAlphaBlanks(AlphaNum))) && (TransSystem(TransRefrigSysNum).transSysType == TransSysType::SingleStage)) {
    6709              :                 // SingleStage system type with low pressure compressors specified. Ignore low pressure compressors
    6710            0 :                 ShowWarningError(state,
    6711            0 :                                  format("{}{}, The transcritical refrigeration system, \"{}\", is specified to be \"SingleStage\", "
    6712              :                                         "however, a \"{}\" was found.  The low pressure compressors will be ignored and will not simulated.",
    6713              :                                         RoutineName,
    6714              :                                         CurrentModuleObject,
    6715            0 :                                         TransSystem(TransRefrigSysNum).Name,
    6716              :                                         cAlphaFieldNames(AlphaNum)));
    6717            1 :             } else if ((!(lAlphaBlanks(AlphaNum))) && (TransSystem(TransRefrigSysNum).transSysType == TransSysType::TwoStage)) {
    6718              :                 // TwoStage system with low pressure compressors specified
    6719            1 :                 int ListNum = Util::FindItemInList(Alphas(AlphaNum), CompressorLists);
    6720            1 :                 int CompNum = Util::FindItemInList(Alphas(AlphaNum), Compressor);
    6721            1 :                 if ((ListNum == 0) && (CompNum == 0)) { // name doesn't match either a compressor or a compressor list
    6722            0 :                     ShowSevereError(state,
    6723            0 :                                     format(R"({}{}, "{}", has an invalid or undefined value="{}".)",
    6724              :                                            RoutineName,
    6725              :                                            CurrentModuleObject,
    6726              :                                            cAlphaFieldNames(AlphaNum),
    6727              :                                            Alphas(AlphaNum)));
    6728            0 :                     ErrorsFound = true;
    6729            1 :                 } else if ((ListNum != 0) && (CompNum != 0)) { // have compressor list and compressor with same name
    6730            0 :                     ShowSevereError(state,
    6731            0 :                                     format("{}{} {}, has a non-unique name used for both Compressor and CompressorList name: \"{}\".",
    6732              :                                            RoutineName,
    6733              :                                            CurrentModuleObject,
    6734              :                                            cAlphaFieldNames(AlphaNum),
    6735              :                                            Alphas(AlphaNum)));
    6736            0 :                     ErrorsFound = true;
    6737            1 :                 } else if (ListNum != 0) {
    6738            1 :                     NumCompressorsSys = CompressorLists(ListNum).NumCompressors;
    6739            1 :                     TransSystem(TransRefrigSysNum).NumCompressorsLP = NumCompressorsSys;
    6740            1 :                     if (!allocated(TransSystem(TransRefrigSysNum).CompressorNumLP)) {
    6741            1 :                         TransSystem(TransRefrigSysNum).CompressorNumLP.allocate(NumCompressorsSys);
    6742              :                     }
    6743            2 :                     TransSystem(TransRefrigSysNum).CompressorNumLP({1, NumCompressorsSys}) =
    6744            3 :                         CompressorLists(ListNum).CompItemNum({1, NumCompressorsSys});
    6745            0 :                 } else if (CompNum != 0) {
    6746            0 :                     NumCompressorsSys = 1;
    6747            0 :                     TransSystem(TransRefrigSysNum).NumCompressorsLP = 1;
    6748            0 :                     if (!allocated(TransSystem(TransRefrigSysNum).CompressorNumLP)) {
    6749            0 :                         TransSystem(TransRefrigSysNum).CompressorNumLP.allocate(NumCompressorsSys);
    6750              :                     }
    6751            0 :                     TransSystem(TransRefrigSysNum).CompressorNumLP(NumCompressorsSys) = CompNum;
    6752              :                 }
    6753              :                 // Sum rated capacity of all LP compressors on system
    6754            1 :                 NominalTotalCompCapLP = 0.0;
    6755            4 :                 for (int CompIndex = 1; CompIndex <= NumCompressorsSys; ++CompIndex) {
    6756            3 :                     CompNum = TransSystem(TransRefrigSysNum).CompressorNumLP(CompIndex);
    6757            3 :                     if (TransSystem(TransRefrigSysNum).transSysType == TransSysType::TwoStage) { //  Calculate capacity of LP compressors
    6758            3 :                         Compressor(CompNum).NomCap = Curve::CurveValue(state,
    6759            3 :                                                                        Compressor(CompNum).CapacityCurvePtr,
    6760            3 :                                                                        TransSystem(TransRefrigSysNum).TEvapDesignLT,
    6761            3 :                                                                        TransSystem(TransRefrigSysNum).TEvapDesignMT);
    6762            3 :                         NominalTotalCompCapLP += Compressor(CompNum).NomCap;
    6763            3 :                         ++Compressor(CompNum).NumSysAttach;
    6764              :                     }
    6765              :                 }
    6766              :             }
    6767              : 
    6768              :             // Read Receiver Pressure
    6769            1 :             if (!lNumericBlanks(1)) {
    6770            1 :                 TransSystem(TransRefrigSysNum).PReceiver = Numbers(1);
    6771              :             } else { // Default value receiver pressure = 4000000 Pa
    6772            0 :                 TransSystem(TransRefrigSysNum).PReceiver = 4.0e6;
    6773              :             }
    6774              : 
    6775              :             // Check receiver temperature against minimum condensing temperature (from gas cooler input) and design evaporator temperatures
    6776            2 :             TransSystem(TransRefrigSysNum).TReceiver =
    6777            1 :                 TransSystem(TransRefrigSysNum).refrig->getSatTemperature(state, TransSystem(TransRefrigSysNum).PReceiver, routineName);
    6778            1 :             if (TransSystem(TransRefrigSysNum).TReceiver > GasCooler(TransSystem(TransRefrigSysNum).GasCoolerNum(NumGasCoolers)).MinCondTemp) {
    6779            0 :                 ShowWarningError(state,
    6780            0 :                                  format("{}{}=\"{}: The receiver temperature ({:.2R}C) is greater than the minimum condensing temperature "
    6781              :                                         "specified for subcritical operation ({:.2R}C).",
    6782              :                                         RoutineName,
    6783              :                                         CurrentModuleObject,
    6784            0 :                                         TransSystem(TransRefrigSysNum).Name,
    6785            0 :                                         TransSystem(TransRefrigSysNum).TReceiver,
    6786            0 :                                         GasCooler(TransSystem(TransRefrigSysNum).GasCoolerNum(NumGasCoolers)).MinCondTemp));
    6787            0 :                 ShowContinueError(state, "  The minimum condensing temperature will be set at 5C greater than the receiver temperature.");
    6788            0 :                 GasCooler(TransSystem(TransRefrigSysNum).GasCoolerNum(NumGasCoolers)).MinCondTemp = TransSystem(TransRefrigSysNum).TReceiver + 5.0;
    6789              :             }
    6790            1 :             if (NominalTotalCompCapLP > 0.0) {
    6791            1 :                 if (TransSystem(TransRefrigSysNum).TReceiver <= TransSystem(TransRefrigSysNum).TEvapDesignLT) {
    6792            0 :                     ShowSevereError(state,
    6793            0 :                                     format("{}{}=\"{}: The receiver temperature ({:.2R}C) is less than the design evaporator temperature for the "
    6794              :                                            "low temperature loads ({:.2R}C).",
    6795              :                                            RoutineName,
    6796              :                                            CurrentModuleObject,
    6797            0 :                                            TransSystem(TransRefrigSysNum).Name,
    6798            0 :                                            TransSystem(TransRefrigSysNum).TReceiver,
    6799            0 :                                            TransSystem(TransRefrigSysNum).TEvapDesignLT));
    6800            0 :                     ShowContinueError(state,
    6801              :                                       "  Ensure that the receiver temperature is sufficiently greater than the design evaporator temperature for "
    6802              :                                       "the low temperature loads.");
    6803            0 :                     ShowContinueError(state,
    6804              :                                       "  A receiver pressure between 3.0 MPa to 4.0 MPa will typically result in an adequate receiver temperature.");
    6805            0 :                     ErrorsFound = true;
    6806              :                 }
    6807              :             }
    6808            1 :             if (NominalTotalCompCapHP > 0.0) {
    6809            1 :                 if (TransSystem(TransRefrigSysNum).TReceiver <= TransSystem(TransRefrigSysNum).TEvapDesignMT) {
    6810            0 :                     ShowSevereError(state,
    6811            0 :                                     format("{}{}=\"{}: The receiver temperature ({:.2R}C) is less than the design evaporator temperature for the "
    6812              :                                            "medium temperature loads ({:.2R}C).",
    6813              :                                            RoutineName,
    6814              :                                            CurrentModuleObject,
    6815            0 :                                            TransSystem(TransRefrigSysNum).Name,
    6816            0 :                                            TransSystem(TransRefrigSysNum).TReceiver,
    6817            0 :                                            TransSystem(TransRefrigSysNum).TEvapDesignMT));
    6818            0 :                     ShowContinueError(state,
    6819              :                                       "  Ensure that the receiver temperature is sufficiently greater than the design evaporator temperature for "
    6820              :                                       "the medium temperature loads.");
    6821            0 :                     ShowContinueError(state,
    6822              :                                       "  A receiver pressure between 3.0 MPa to 4.0 MPa will typically result in an adequate receiver temperature.");
    6823            0 :                     ErrorsFound = true;
    6824              :                 }
    6825              :             }
    6826              : 
    6827              :             // Read subcooler effectiveness
    6828            1 :             if (!lNumericBlanks(2)) {
    6829            1 :                 TransSystem(TransRefrigSysNum).SCEffectiveness = Numbers(2);
    6830              :             } else { // Default value effectiveness = 0.4
    6831            0 :                 TransSystem(TransRefrigSysNum).PReceiver = 0.4;
    6832              :             }
    6833              :             // Check subcooler effectiveness value, must be value between 0 and 1
    6834            1 :             if ((TransSystem(TransRefrigSysNum).SCEffectiveness < 0) || (TransSystem(TransRefrigSysNum).SCEffectiveness > 1)) {
    6835            0 :                 ShowSevereError(state,
    6836            0 :                                 format("{}{}=\"{}: The value for subcooler effectiveness is invalid.  The subcooler effectiveness must be a value "
    6837              :                                        "greater than or equal to zero and less than or equal to one.",
    6838              :                                        RoutineName,
    6839              :                                        CurrentModuleObject,
    6840            0 :                                        TransSystem(TransRefrigSysNum).Name));
    6841            0 :                 ErrorsFound = true;
    6842              :             }
    6843              : 
    6844              :             // Suction piping heat gain - optional
    6845              :             //  Input UA and identify the Zone containing the bulk of the suction piping
    6846              :             //  This Zone ID will be used to determine the temperature used for suction piping heat gain.
    6847              :             //  The pipe heat gains are also counted as cooling credit for the zone.
    6848              :             //  Zone Id is only required if Sum UA Suction Piping >0.0
    6849              :             //  Get the Zone and zone node numbers from the zone name entered by the user
    6850            1 :             AlphaNum = 9; // Medium temperature suction piping
    6851            1 :             TransSystem(TransRefrigSysNum).SumUASuctionPipingMT = 0.0;
    6852            1 :             if (!lNumericBlanks(3) && !lAlphaBlanks(AlphaNum)) {
    6853            0 :                 TransSystem(TransRefrigSysNum).SumUASuctionPipingMT = Numbers(3);
    6854            0 :                 TransSystem(TransRefrigSysNum).SuctionPipeActualZoneNumMT = Util::FindItemInList(Alphas(AlphaNum), state.dataHeatBal->Zone);
    6855            0 :                 TransSystem(TransRefrigSysNum).SuctionPipeZoneNodeNumMT =
    6856            0 :                     DataZoneEquipment::GetSystemNodeNumberForZone(state, TransSystem(TransRefrigSysNum).SuctionPipeActualZoneNumMT);
    6857            0 :                 if (TransSystem(TransRefrigSysNum).SuctionPipeZoneNodeNumMT == 0) {
    6858            0 :                     ShowSevereError(state,
    6859            0 :                                     format(R"({}{}="{}", System Node Number not found for {} = "{}" even though {} is greater than zero.)",
    6860              :                                            RoutineName,
    6861              :                                            CurrentModuleObject,
    6862            0 :                                            TransSystem(TransRefrigSysNum).Name,
    6863              :                                            cAlphaFieldNames(AlphaNum),
    6864              :                                            Alphas(AlphaNum),
    6865              :                                            cNumericFieldNames(3)));
    6866            0 :                     ShowContinueError(state,
    6867              :                                       "  The medium temperature suction piping heat gain cannot be calculated unless a Zone is defined to "
    6868              :                                       "determine the environmental temperature surrounding the piping.");
    6869            0 :                     ErrorsFound = true;
    6870              :                 } else {
    6871            0 :                     state.dataRefrigCase->RefrigPresentInZone(TransSystem(TransRefrigSysNum).SuctionPipeActualZoneNumMT) = true;
    6872              :                 }
    6873            1 :             } else if (!lNumericBlanks(3) && lAlphaBlanks(AlphaNum)) {
    6874            0 :                 ShowWarningError(state,
    6875            0 :                                  format("{}{}=\"{}\" {} not found even though {} is greater than zero.",
    6876              :                                         RoutineName,
    6877              :                                         CurrentModuleObject,
    6878            0 :                                         TransSystem(TransRefrigSysNum).Name,
    6879              :                                         cAlphaFieldNames(AlphaNum),
    6880              :                                         cNumericFieldNames(3)));
    6881            0 :                 ShowContinueError(state,
    6882              :                                   "  The medium temperature suction piping heat gain will not be calculated unless a Zone is defined to "
    6883              :                                   "determine the environmental temperature surrounding the piping.");
    6884            1 :             } else if (lNumericBlanks(3) && !lAlphaBlanks(AlphaNum)) {
    6885            0 :                 ShowWarningError(state,
    6886            0 :                                  format("{}{}=\"{}\" {} will not be used and suction piping heat gain will not be calculated because {} was blank.",
    6887              :                                         RoutineName,
    6888              :                                         CurrentModuleObject,
    6889            0 :                                         TransSystem(TransRefrigSysNum).Name,
    6890              :                                         cAlphaFieldNames(AlphaNum),
    6891              :                                         cNumericFieldNames(3)));
    6892              :             } // Medium temperature suction piping heat gains
    6893              : 
    6894            1 :             AlphaNum = 10; // Low temperature suction piping
    6895            1 :             TransSystem(TransRefrigSysNum).SumUASuctionPipingLT = 0.0;
    6896            1 :             if (!lNumericBlanks(4) && !lAlphaBlanks(AlphaNum)) {
    6897            0 :                 TransSystem(TransRefrigSysNum).SumUASuctionPipingLT = Numbers(4);
    6898            0 :                 TransSystem(TransRefrigSysNum).SuctionPipeActualZoneNumLT = Util::FindItemInList(Alphas(AlphaNum), state.dataHeatBal->Zone);
    6899            0 :                 TransSystem(TransRefrigSysNum).SuctionPipeZoneNodeNumLT =
    6900            0 :                     DataZoneEquipment::GetSystemNodeNumberForZone(state, TransSystem(TransRefrigSysNum).SuctionPipeActualZoneNumLT);
    6901            0 :                 if (TransSystem(TransRefrigSysNum).SuctionPipeZoneNodeNumLT == 0) {
    6902            0 :                     ShowSevereError(state,
    6903            0 :                                     format(R"({}{}="{}", System Node Number not found for {} = "{}" even though {} is greater than zero.)",
    6904              :                                            RoutineName,
    6905              :                                            CurrentModuleObject,
    6906            0 :                                            TransSystem(TransRefrigSysNum).Name,
    6907              :                                            cAlphaFieldNames(AlphaNum),
    6908              :                                            Alphas(AlphaNum),
    6909              :                                            cNumericFieldNames(4)));
    6910            0 :                     ShowContinueError(state,
    6911              :                                       "  The low temperature suction piping heat gain cannot be calculated unless a Zone is defined to "
    6912              :                                       "determine the environmental temperature surrounding the piping.");
    6913            0 :                     ErrorsFound = true;
    6914              :                 } else {
    6915            0 :                     state.dataRefrigCase->RefrigPresentInZone(TransSystem(TransRefrigSysNum).SuctionPipeActualZoneNumLT) = true;
    6916              :                 }
    6917            1 :             } else if (!lNumericBlanks(4) && lAlphaBlanks(AlphaNum)) {
    6918            0 :                 ShowWarningError(state,
    6919            0 :                                  format("{}{}=\"{}\" {} not found even though {} is greater than zero.",
    6920              :                                         RoutineName,
    6921              :                                         CurrentModuleObject,
    6922            0 :                                         TransSystem(TransRefrigSysNum).Name,
    6923              :                                         cAlphaFieldNames(AlphaNum),
    6924              :                                         cNumericFieldNames(4)));
    6925            0 :                 ShowContinueError(state,
    6926              :                                   "  The low temperature suction piping heat gain will not be calculated unless a Zone is defined to determine "
    6927              :                                   "the environmental temperature surrounding the piping.");
    6928            1 :             } else if (lNumericBlanks(4) && !lAlphaBlanks(AlphaNum)) {
    6929            0 :                 ShowWarningError(state,
    6930            0 :                                  format("{}{}=\"{}\" {} will not be used and suction piping heat gain will not be calculated because {} was blank.",
    6931              :                                         RoutineName,
    6932              :                                         CurrentModuleObject,
    6933            0 :                                         TransSystem(TransRefrigSysNum).Name,
    6934              :                                         cAlphaFieldNames(AlphaNum),
    6935              :                                         cNumericFieldNames(4)));
    6936              :             } // Low temperature suction piping heat gains
    6937              : 
    6938            1 :             AlphaNum = 11;
    6939            1 :             if (!lAlphaBlanks(AlphaNum)) {
    6940            1 :                 TransSystem(TransRefrigSysNum).EndUseSubcategory = Alphas(AlphaNum);
    6941              :             }
    6942              : 
    6943              :             // Compare the rated capacity of compressor, condenser, and cases.
    6944              :             // Note, rated capacities can be far off from operating capacities, but rough check.
    6945            1 :             Real64 NominalCondCap = GasCooler(TransSystem(TransRefrigSysNum).GasCoolerNum(1)).RatedCapacity;
    6946            1 :             Real64 NominalTotalCompCap = NominalTotalCompCapHP + NominalTotalCompCapLP;
    6947            1 :             if ((NominalTotalCompCap < (0.7 * NominalTotalCoolingCap)) || (NominalCondCap < (1.3 * NominalTotalCoolingCap))) {
    6948            0 :                 ShowWarningError(
    6949            0 :                     state, format("{}=\"{}\", You may wish to check the system sizing.", CurrentModuleObject, TransSystem(TransRefrigSysNum).Name));
    6950            0 :                 ShowContinueError(
    6951              :                     state,
    6952            0 :                     format("Total nominal cooling capacity is {:.0R}W. Condenser capacity is {:.0R}W. Nominal compressor capacity is {:.0R}W.",
    6953              :                            NominalTotalCoolingCap,
    6954              :                            NominalCondCap,
    6955              :                            NominalTotalCompCap));
    6956              :             }
    6957              : 
    6958              :         } // Transcritical refrigeration systems
    6959              : 
    6960              :     } //(NumTransRefrigSystems > 0)
    6961              : 
    6962          801 :     DayValues.deallocate();
    6963          801 :     Alphas.deallocate();
    6964          801 :     Numbers.deallocate();
    6965          801 :     cAlphaFieldNames.deallocate();
    6966          801 :     cNumericFieldNames.deallocate();
    6967          801 :     lAlphaBlanks.deallocate();
    6968          801 :     lNumericBlanks.deallocate();
    6969              : 
    6970          801 :     if (state.dataRefrigCase->NumSimulationCases > 0) {
    6971              :         // Find unused and non-unique display case objects to report in eio and err file and sum
    6972              :         //    all HVAC RA fractions and write error message if greater than 1 for any zone
    6973          881 :         for (int ZoneIndex = 1; ZoneIndex <= state.dataGlobal->NumOfZones; ++ZoneIndex) { // numofzones from dataglobals
    6974          844 :             Real64 TempRAFraction = CaseRAFraction(ZoneIndex).TotalCaseRAFraction;
    6975         3568 :             for (int CaseNum = 1; CaseNum <= state.dataRefrigCase->NumSimulationCases; ++CaseNum) {
    6976              :                 // TempRaFraction already includes contributions from ALL cases in zone
    6977              :                 // Want to delete portion from unused cases (numsysattach = 0)that will never be simulated
    6978         2724 :                 if (RefrigCase(CaseNum).ActualZoneNum != ZoneIndex || RefrigCase(CaseNum).NumSysAttach > 0) {
    6979         2724 :                     continue;
    6980              :                 }
    6981            0 :                 TempRAFraction -= RefrigCase(CaseNum).RAFrac;
    6982              :             } // NumSimulationCases
    6983          844 :             if (TempRAFraction > 1.0) {
    6984            0 :                 ShowSevereError(
    6985              :                     state,
    6986            0 :                     format("{}: Refrigeration:Case, Refrigerated case return air fraction for all cases in zone=\"{}\" is greater than 1.0.",
    6987              :                            RoutineName,
    6988            0 :                            CaseRAFraction(ZoneIndex).ZoneName));
    6989              :                 // check in comment, can't use "currentModuleObject" because not in get input subroutine where that is known
    6990            0 :                 ErrorsFound = true;
    6991              :             }
    6992              :         } // ZoneIndex=1,DataGlobals::NumOfZones
    6993              : 
    6994           37 :         CaseRAFraction.deallocate(); // only used for input check just completed
    6995              :         // check for cases not connected to systems and cases connected
    6996              :         // more than once (twice in a system or to more than one system)
    6997              : 
    6998           37 :         state.dataRefrigCase->NumUnusedRefrigCases = 0;
    6999          227 :         for (int CaseNum = 1; CaseNum <= state.dataRefrigCase->NumSimulationCases; ++CaseNum) {
    7000          190 :             if (RefrigCase(CaseNum).NumSysAttach == 1) {
    7001          190 :                 continue;
    7002              :             }
    7003            0 :             if (RefrigCase(CaseNum).NumSysAttach < 1) {
    7004            0 :                 ++state.dataRefrigCase->NumUnusedRefrigCases;
    7005            0 :                 if (state.dataGlobal->DisplayExtraWarnings) {
    7006              :                     //  individual case names listed if DataGlobals::DisplayExtraWarnings option selected
    7007            0 :                     ShowWarningError(state, format("{}: Refrigeration:Case=\"{}\" unused. ", RoutineName, RefrigCase(CaseNum).Name));
    7008              :                 } // display extra warnings - give a list of unused cases
    7009              :             } // unused case
    7010            0 :             if (RefrigCase(CaseNum).NumSysAttach > 1) {
    7011            0 :                 ErrorsFound = true;
    7012            0 :                 ShowSevereError(
    7013            0 :                     state, format("{}: Refrigeration:Case=\"{}\", Same refrigerated case name referenced ", RoutineName, RefrigCase(CaseNum).Name));
    7014            0 :                 ShowContinueError(state, " by more than one refrigeration system and/or compressor rack.");
    7015              :             } // if looking for same case attached to multiple systems/racks
    7016              :         } // NumSimulationCases
    7017              : 
    7018           37 :         if ((state.dataRefrigCase->NumUnusedRefrigCases > 0) && (!state.dataGlobal->DisplayExtraWarnings)) {
    7019              :             //  write to error file,
    7020              :             //  summary number of unused cases given if DataGlobals::DisplayExtraWarnings option not selected
    7021            0 :             ShowWarningError(state,
    7022            0 :                              format("Refrigeration:Case -> {} unused refrigerated case(s) found during input processing.",
    7023            0 :                                     state.dataRefrigCase->NumUnusedRefrigCases));
    7024            0 :             ShowContinueError(state, "  These refrigerated cases are in the input file but are not connected to a ");
    7025            0 :             ShowContinueError(state, "  Refrigeration:CompressorRack, Refrigeration:System, or Refrigeration:SecondarySystem object.");
    7026            0 :             ShowContinueError(state, "  These unused refrigeration cases will not be simulated.");
    7027            0 :             ShowContinueError(state, "  Use Output:Diagnostics,DisplayUnusedObjects; to see them. ");
    7028              :         } // NumUnusedRefrigCases
    7029              :     } // numsimulation cases > 0
    7030              : 
    7031          801 :     if (state.dataRefrigCase->NumSimulationCompressors > 0) {
    7032              :         // check for compressors not connected to systems and compressors connected more than once
    7033              :         // (twice in a system or to more than one system)
    7034           16 :         state.dataRefrigCase->NumUnusedCompressors = 0;
    7035          198 :         for (int CompNum = 1; CompNum <= state.dataRefrigCase->NumSimulationCompressors; ++CompNum) {
    7036          182 :             if (Compressor(CompNum).NumSysAttach == 1) {
    7037          182 :                 continue;
    7038              :             }
    7039            0 :             if (Compressor(CompNum).NumSysAttach < 1) {
    7040            0 :                 ++state.dataRefrigCase->NumUnusedCompressors;
    7041            0 :                 if (state.dataGlobal->DisplayExtraWarnings) {
    7042              :                     //  individual compressor names listed if DataGlobals::DisplayExtraWarnings option selected
    7043            0 :                     ShowWarningError(state, format("{}: Refrigeration:Compressor=\"{}\" unused. ", RoutineName, Compressor(CompNum).Name));
    7044              :                 } // display extra warnings - give a list of unused compressors
    7045              :             } // unused compressor
    7046            0 :             if (Compressor(CompNum).NumSysAttach > 1) {
    7047            0 :                 ErrorsFound = true;
    7048            0 :                 ShowSevereError(state,
    7049            0 :                                 format("{}: Refrigeration:Compressor=\"{}\", Same refrigeration compressor name referenced",
    7050              :                                        RoutineName,
    7051            0 :                                        Compressor(CompNum).Name));
    7052            0 :                 ShowContinueError(state, " by more than one refrigeration system.");
    7053              :             } // looking for same compressor attached to multiple systems/racks
    7054              :         } // NumSimulationCompressors
    7055              : 
    7056           16 :         if ((state.dataRefrigCase->NumUnusedCompressors > 0) && (!state.dataGlobal->DisplayExtraWarnings)) {
    7057              :             //  write to error file,
    7058              :             //  summary number of unused compressors given if DataGlobals::DisplayExtraWarnings option not selected
    7059            0 :             ShowWarningError(state,
    7060            0 :                              format("Refrigeration:Compressor -> {} unused refrigeration compressor(s) found during input processing.",
    7061            0 :                                     state.dataRefrigCase->NumUnusedCompressors));
    7062            0 :             ShowContinueError(state,
    7063              :                               "  Those refrigeration compressors are in the input file but are not connected to a Refrigeration:System object.");
    7064            0 :             ShowContinueError(state, "   These unused refrigeration compressors will not be simulated.");
    7065            0 :             ShowContinueError(state, "   Use Output:Diagnostics,DisplayUnusedObjects; to see them. ");
    7066              :         } // NumUnusedCompressors
    7067              :     } // NumSimulationCompressors > 0
    7068              : 
    7069          801 :     int NumUnusedWalkIns = 0;
    7070          801 :     if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
    7071              :         // check for refrigeration WalkIns not connected to any systems and
    7072              :         //  refrigeration WalkIns connected more than once
    7073           31 :         for (int WalkInNum = 1; WalkInNum <= state.dataRefrigCase->NumSimulationWalkIns; ++WalkInNum) {
    7074           17 :             if (WalkIn(WalkInNum).NumSysAttach == 1) {
    7075           17 :                 continue;
    7076              :             }
    7077            0 :             if (WalkIn(WalkInNum).NumSysAttach < 1) {
    7078            0 :                 ++NumUnusedWalkIns;
    7079            0 :                 if (state.dataGlobal->DisplayExtraWarnings) {
    7080              :                     //  individual walkin names listed if DataGlobals::DisplayExtraWarnings option selected
    7081            0 :                     ShowWarningError(state, format("{}: Refrigeration:WalkIn=\"{}\" unused. ", RoutineName, WalkIn(WalkInNum).Name));
    7082              :                 } // display extra warnings - give a list of unused WalkIns
    7083              :             } // unused walkin
    7084            0 :             if (WalkIn(WalkInNum).NumSysAttach > 1) {
    7085            0 :                 ErrorsFound = true;
    7086            0 :                 ShowSevereError(
    7087            0 :                     state, format("{}: Refrigeration:WalkIn=\"{}\", Same Refrigeration WalkIn name referenced", RoutineName, WalkIn(WalkInNum).Name));
    7088            0 :                 ShowContinueError(state, " by more than one refrigeration system and/or compressor rack.");
    7089              :             } // if looking for same walk in attached to multiple systems/racks
    7090              :         } // NumSimulationWalkIns
    7091              : 
    7092           14 :         if ((NumUnusedWalkIns > 0) && (!state.dataGlobal->DisplayExtraWarnings)) {
    7093              :             //  write to error file,
    7094              :             //  summary number of unused walkins given if DataGlobals::DisplayExtraWarnings option not selected
    7095            0 :             ShowWarningError(
    7096              :                 state,
    7097            0 :                 format("{}Refrigeration:WalkIn -> {} unused refrigeration WalkIns found during input processing.", RoutineName, NumUnusedWalkIns));
    7098            0 :             ShowContinueError(state, "   Those refrigeration WalkIns are in the input file but are not connected to a ");
    7099            0 :             ShowContinueError(state, "   Refrigeration:CompressorRack, Refrigeration:System or Refrigeration:SecondarySystem object.");
    7100            0 :             ShowContinueError(state, "   These unused refrigeration WalkIns will not be simulated.");
    7101            0 :             ShowContinueError(state, "   Use Output:Diagnostics,DisplayUnusedObjects; to see them. ");
    7102              :         } // NumUnusedWalkIns
    7103              :     } // NumSimulationWalkIns > 0
    7104              : 
    7105          801 :     if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0) {
    7106              :         // check for air chillers not connected to any systems and
    7107              :         //  air chillers connected more than once
    7108            1 :         state.dataRefrigCase->NumUnusedCoils = 0;
    7109           84 :         for (int CoilNum = 1; CoilNum <= state.dataRefrigCase->NumSimulationRefrigAirChillers; ++CoilNum) {
    7110           83 :             if (WarehouseCoil(CoilNum).NumSysAttach == 1) {
    7111           83 :                 continue;
    7112              :             }
    7113            0 :             if (WarehouseCoil(CoilNum).NumSysAttach < 1) {
    7114            0 :                 ++NumUnusedWalkIns;
    7115            0 :                 if (state.dataGlobal->DisplayExtraWarnings) {
    7116              :                     //  individual walkin names listed if DataGlobals::DisplayExtraWarnings option selected
    7117            0 :                     ShowWarningError(state, format("{}: Refrigeration:AirChiller=\"{}\" unused. ", RoutineName, WarehouseCoil(CoilNum).Name));
    7118              :                 } // display extra warnings - give a list of unused chillers
    7119              :             } // unused chiller
    7120            0 :             if (WarehouseCoil(CoilNum).NumSysAttach > 1) {
    7121            0 :                 ErrorsFound = true;
    7122            0 :                 ShowSevereError(state,
    7123            0 :                                 format("{}: Refrigeration:AirChiller=\"{}\", Same Refrigeration Air Chiller name referenced",
    7124              :                                        RoutineName,
    7125            0 :                                        WarehouseCoil(CoilNum).Name));
    7126            0 :                 ShowContinueError(state, " by more than one refrigeration system and/or compressor rack.");
    7127              :             } // if looking for same walk in attached to multiple systems/racks
    7128              :         } // NumSimulationRefrigAirchillers
    7129              : 
    7130            1 :         if ((state.dataRefrigCase->NumUnusedCoils > 0) && (!state.dataGlobal->DisplayExtraWarnings)) {
    7131              :             //  write to error file,
    7132              :             //  summary number of unused air chillers given if DataGlobals::DisplayExtraWarnings option not selected
    7133            0 :             ShowWarningError(state,
    7134            0 :                              format("{}Refrigeration:AirChiller -> {} unused refrigeration air chillers found during input processing.",
    7135              :                                     RoutineName,
    7136            0 :                                     state.dataRefrigCase->NumUnusedCoils));
    7137            0 :             ShowContinueError(state, "   Those refrigeration air chillers are in the input file but are not connected to a ");
    7138            0 :             ShowContinueError(state, "   Refrigeration:CompressorRack, Refrigeration:System or Refrigeration:SecondarySystem object.");
    7139            0 :             ShowContinueError(state, "   These unused refrigeration air chillers will not be simulated.");
    7140            0 :             ShowContinueError(state, "   Use Output:Diagnostics,DisplayUnusedObjects; to see them. ");
    7141              :         } // NumUnusedAirChllerss
    7142              :     } // NumSimulationAirChillers > 0
    7143              : 
    7144          801 :     if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
    7145              :         // check for refrigeration Secondarys not connected to detailed systems and
    7146              :         //  refrigeration Secondarys connected more than once
    7147            1 :         state.dataRefrigCase->NumUnusedSecondarys = 0;
    7148            3 :         for (int SecondaryNum = 1; SecondaryNum <= state.dataRefrigCase->NumSimulationSecondarySystems; ++SecondaryNum) {
    7149            2 :             if (Secondary(SecondaryNum).NumSysAttach == 1) {
    7150            2 :                 continue;
    7151              :             }
    7152            0 :             if (Secondary(SecondaryNum).NumSysAttach < 1) {
    7153            0 :                 ++state.dataRefrigCase->NumUnusedSecondarys;
    7154            0 :                 if (state.dataGlobal->DisplayExtraWarnings) {
    7155              :                     //  individual secondary names listed if DataGlobals::DisplayExtraWarnings option selected
    7156            0 :                     ShowWarningError(state, format("{}: Refrigeration:Secondary=\"{}\" unused. ", RoutineName, Secondary(SecondaryNum).Name));
    7157              :                 } // display extra warnings - give a list of unused Secondaries
    7158              :             } // unused secondary
    7159            0 :             if (Secondary(SecondaryNum).NumSysAttach > 1) {
    7160            0 :                 ErrorsFound = true;
    7161            0 :                 ShowSevereError(state,
    7162            0 :                                 format("{}: Refrigeration:Secondary=\"{}\", Same Refrigeration Secondary name referenced",
    7163              :                                        RoutineName,
    7164            0 :                                        Secondary(SecondaryNum).Name));
    7165            0 :                 ShowContinueError(state, "   by more than one refrigeration system");
    7166              :             } // looking for same secondary loop attached to multiple systems/racks
    7167              :         } // NumSimulationSecondarys
    7168              : 
    7169            1 :         if ((state.dataRefrigCase->NumUnusedSecondarys > 0) && (!state.dataGlobal->DisplayExtraWarnings)) {
    7170              :             //  write to error file,
    7171              :             //  summary number of unused secondaries given if DataGlobals::DisplayExtraWarnings option not selected
    7172            0 :             ShowWarningError(state,
    7173            0 :                              format("{}Refrigeration:Secondary -> {} unused refrigeration Secondary Loops found during input processing.",
    7174              :                                     RoutineName,
    7175            0 :                                     state.dataRefrigCase->NumUnusedSecondarys));
    7176            0 :             ShowContinueError(state, "  Those refrigeration Secondary Loops are in the input file but are not connected to a refrigeration system.");
    7177            0 :             ShowContinueError(state, "   These unused refrigeration secondaries will not be simulated.");
    7178            0 :             ShowContinueError(state, "   Use Output:Diagnostics,DisplayUnusedObjects; to see them. ");
    7179              :         } // NumUnusedSecondarys
    7180              :     } // NumSimulationSecondarySystems > 0
    7181              : 
    7182          801 :     if (state.dataRefrigCase->NumRefrigCondensers > 0) {
    7183              :         // Check for presence of shared condensers and for unused condensers
    7184              :         //     - determines number of loops through refrigeration simulation
    7185              :         //       because of dependence of performance on total condenser load
    7186           15 :         state.dataRefrigCase->NumSimulationSharedCondensers = 0;
    7187           15 :         state.dataRefrigCase->NumUnusedCondensers = 0;
    7188           54 :         for (int CondNum = 1; CondNum <= state.dataRefrigCase->NumRefrigCondensers; ++CondNum) {
    7189           39 :             if (Condenser(CondNum).NumSysAttach == 1) {
    7190           37 :                 continue;
    7191              :             }
    7192            2 :             if (Condenser(CondNum).NumSysAttach < 1) {
    7193            0 :                 ++state.dataRefrigCase->NumUnusedCondensers;
    7194            0 :                 if (state.dataGlobal->DisplayExtraWarnings) {
    7195              :                     //  individual condenser names listed if DataGlobals::DisplayExtraWarnings option selected
    7196            0 :                     ShowWarningError(state, format("{}: Refrigeration:Condenser=\"{}\" unused. ", RoutineName, Condenser(CondNum).Name));
    7197              :                 } // display extra warnings - give a list of unused condensers
    7198              :             } // unused condenser
    7199            2 :             if (Condenser(CondNum).NumSysAttach > 1) {
    7200            2 :                 ++state.dataRefrigCase->NumSimulationSharedCondensers;
    7201              :             } // looking for shared condensers
    7202              :         } // CondNum
    7203              : 
    7204           15 :         if ((state.dataRefrigCase->NumUnusedCondensers > 0) && (!state.dataGlobal->DisplayExtraWarnings)) {
    7205              :             //  write to error file,
    7206              :             //  summary number of unused condensers given if DataGlobals::DisplayExtraWarnings option not selected
    7207            0 :             ShowWarningError(state,
    7208            0 :                              format("{}Refrigeration condenser -> {} unused refrigeration condensers found during input processing.",
    7209              :                                     RoutineName,
    7210            0 :                                     state.dataRefrigCase->NumUnusedCondensers));
    7211            0 :             ShowContinueError(state, "  Those refrigeration condensers are in the input file but are not connected to a refrigeration system.");
    7212            0 :             ShowContinueError(state, "   These unused refrigeration condensers will not be simulated.");
    7213            0 :             ShowContinueError(state, "   Use Output:Diagnostics,DisplayUnusedObjects; to see them. ");
    7214              :         } // NumUnusedCondensers and displayextra warnings
    7215              :     } // DataHeatBalance::NumRefrigCondensers > 0
    7216              : 
    7217          801 :     if (state.dataRefrigCase->NumSimulationGasCooler > 0) {
    7218              :         // Check for presence of shared gas coolers and for unused gas coolers
    7219            1 :         state.dataRefrigCase->NumSimulationSharedGasCoolers = 0;
    7220            1 :         state.dataRefrigCase->NumUnusedGasCoolers = 0;
    7221            2 :         for (int GCNum = 1; GCNum <= state.dataRefrigCase->NumSimulationGasCooler; ++GCNum) {
    7222            1 :             if (GasCooler(GCNum).NumSysAttach == 1) {
    7223            1 :                 continue;
    7224              :             }
    7225            0 :             if (GasCooler(GCNum).NumSysAttach < 1) {
    7226            0 :                 ++state.dataRefrigCase->NumUnusedGasCoolers;
    7227            0 :                 if (state.dataGlobal->DisplayExtraWarnings) {
    7228              :                     //  individual gas cooler names listed if DataGlobals::DisplayExtraWarnings option selected
    7229            0 :                     ShowWarningError(state, format("{}: Refrigeration:GasCooler=\"{}\" unused. ", RoutineName, GasCooler(GCNum).Name));
    7230              :                 } // display extra warnings - give a list of unused gas coolers
    7231              :             } // unused gas cooler
    7232            0 :             if (GasCooler(GCNum).NumSysAttach > 1) {
    7233            0 :                 ++state.dataRefrigCase->NumSimulationSharedGasCoolers;
    7234              :             } // looking for shared gas coolers
    7235              :         } // GCNum
    7236              : 
    7237            1 :         if ((state.dataRefrigCase->NumUnusedGasCoolers > 0) && (!state.dataGlobal->DisplayExtraWarnings)) {
    7238              :             //  write to error file,
    7239              :             //  summary number of unused gas coolers given if DataGlobals::DisplayExtraWarnings option not selected
    7240            0 :             ShowWarningError(state,
    7241            0 :                              format("{}Refrigeration gas cooler -> {} unused refrigeration gas cooler(s) found during input processing.",
    7242              :                                     RoutineName,
    7243            0 :                                     state.dataRefrigCase->NumUnusedGasCoolers));
    7244            0 :             ShowContinueError(state, "  These refrigeration gas coolers are in the input file but are not connected to a refrigeration system.");
    7245            0 :             ShowContinueError(state, "  These unused refrigeration gas coolers will not be simulated.");
    7246            0 :             ShowContinueError(state, "  Use Output:Diagnostics,DisplayUnusedObjects; to see them. ");
    7247              :         } // NumUnusedGasCoolers and displayextra warnings
    7248              :     } // NumSimulationGasCooler > 0
    7249              : 
    7250              :     // echo input to eio file.
    7251          801 :     ReportRefrigerationComponents(state);
    7252              : 
    7253          801 :     if (ErrorsFound) {
    7254            0 :         ShowFatalError(state, format("{} Previous errors cause program termination", RoutineName));
    7255              :     }
    7256          801 : }
    7257              : 
    7258          801 : void SetupReportInput(EnergyPlusData &state)
    7259              : {
    7260              :     // SUBROUTINE INFORMATION:
    7261              :     //       AUTHOR         Richard Raustad, FSEC
    7262              :     //       DATE WRITTEN   Oct/Nov 2004
    7263              :     //       MODIFIED       Hudson, ORNL July 2007, Stovall, ORNL, 2008 and 09
    7264              :     //       MODIFIED       Fricke, ORNL, Fall 2011, added transcritical CO2 refrigeration system variables
    7265              :     //       RE-ENGINEERED  na
    7266              : 
    7267              :     // PURPOSE OF THIS SUBROUTINE:
    7268              :     // Set up the report variables.
    7269              : 
    7270          801 :     auto &RefrigCase = state.dataRefrigCase->RefrigCase;
    7271          801 :     auto &RefrigRack = state.dataRefrigCase->RefrigRack;
    7272          801 :     auto &System = state.dataRefrigCase->System;
    7273          801 :     auto &TransSystem = state.dataRefrigCase->TransSystem;
    7274          801 :     auto &Condenser = state.dataRefrigCase->Condenser;
    7275          801 :     auto &Compressor = state.dataRefrigCase->Compressor;
    7276          801 :     auto &GasCooler = state.dataRefrigCase->GasCooler;
    7277          801 :     auto &Subcooler = state.dataRefrigCase->Subcooler;
    7278          801 :     auto &Secondary = state.dataRefrigCase->Secondary;
    7279          801 :     auto &WalkIn = state.dataRefrigCase->WalkIn;
    7280          801 :     auto &WarehouseCoil = state.dataRefrigCase->WarehouseCoil;
    7281          801 :     auto &CoilSysCredit = state.dataRefrigCase->CoilSysCredit;
    7282          801 :     auto &CaseWIZoneReport = state.dataRefrigCase->CaseWIZoneReport;
    7283              : 
    7284          801 :     std::string Walkin_and_zone_name; // concat name for walk-in/zone credit reporting
    7285              : 
    7286          801 :     if (state.dataRefrigCase->NumSimulationCases > 0) {
    7287              :         // Setup Report Variables for simulated Refrigerated Case (do not report unused cases)
    7288              :         // CurrentModuleObject='Refrigeration:Case'
    7289          227 :         for (int caseNum = 1; caseNum <= state.dataRefrigCase->NumSimulationCases; ++caseNum) {
    7290          190 :             auto &thisCase = RefrigCase(caseNum);
    7291          190 :             if (thisCase.NumSysAttach == 1) {
    7292          380 :                 SetupOutputVariable(state,
    7293              :                                     "Refrigeration Case Evaporator Total Cooling Rate",
    7294              :                                     Constant::Units::W,
    7295          190 :                                     thisCase.TotalCoolingLoad,
    7296              :                                     OutputProcessor::TimeStepType::Zone,
    7297              :                                     OutputProcessor::StoreType::Average,
    7298          190 :                                     thisCase.Name);
    7299          380 :                 SetupOutputVariable(state,
    7300              :                                     "Refrigeration Case Evaporator Total Cooling Energy",
    7301              :                                     Constant::Units::J,
    7302          190 :                                     thisCase.TotalCoolingEnergy,
    7303              :                                     OutputProcessor::TimeStepType::Zone,
    7304              :                                     OutputProcessor::StoreType::Sum,
    7305          190 :                                     thisCase.Name,
    7306              :                                     Constant::eResource::EnergyTransfer,
    7307              :                                     OutputProcessor::Group::Building,
    7308              :                                     OutputProcessor::EndUseCat::Refrigeration,
    7309              :                                     "", // End-use sub category
    7310          190 :                                     thisCase.ZoneName);
    7311          380 :                 SetupOutputVariable(state,
    7312              :                                     "Refrigeration Case Evaporator Sensible Cooling Rate",
    7313              :                                     Constant::Units::W,
    7314          190 :                                     thisCase.SensCoolingEnergyRate,
    7315              :                                     OutputProcessor::TimeStepType::Zone,
    7316              :                                     OutputProcessor::StoreType::Average,
    7317          190 :                                     thisCase.Name);
    7318          380 :                 SetupOutputVariable(state,
    7319              :                                     "Refrigeration Case Evaporator Sensible Cooling Energy",
    7320              :                                     Constant::Units::J,
    7321          190 :                                     thisCase.SensCoolingEnergy,
    7322              :                                     OutputProcessor::TimeStepType::Zone,
    7323              :                                     OutputProcessor::StoreType::Sum,
    7324          190 :                                     thisCase.Name);
    7325          380 :                 SetupOutputVariable(state,
    7326              :                                     "Refrigeration Case Evaporator Latent Cooling Rate",
    7327              :                                     Constant::Units::W,
    7328          190 :                                     thisCase.LatCoolingEnergyRate,
    7329              :                                     OutputProcessor::TimeStepType::Zone,
    7330              :                                     OutputProcessor::StoreType::Average,
    7331          190 :                                     thisCase.Name);
    7332          380 :                 SetupOutputVariable(state,
    7333              :                                     "Refrigeration Case Evaporator Latent Cooling Energy",
    7334              :                                     Constant::Units::J,
    7335          190 :                                     thisCase.LatCoolingEnergy,
    7336              :                                     OutputProcessor::TimeStepType::Zone,
    7337              :                                     OutputProcessor::StoreType::Sum,
    7338          190 :                                     thisCase.Name);
    7339              : 
    7340          380 :                 SetupOutputVariable(state,
    7341              :                                     "Refrigeration Case Zone Sensible Cooling Rate",
    7342              :                                     Constant::Units::W,
    7343          190 :                                     thisCase.SensZoneCreditCoolRate,
    7344              :                                     OutputProcessor::TimeStepType::Zone,
    7345              :                                     OutputProcessor::StoreType::Average,
    7346          190 :                                     thisCase.Name);
    7347          380 :                 SetupOutputVariable(state,
    7348              :                                     "Refrigeration Case Zone Sensible Cooling Energy",
    7349              :                                     Constant::Units::J,
    7350          190 :                                     thisCase.SensZoneCreditCool,
    7351              :                                     OutputProcessor::TimeStepType::Zone,
    7352              :                                     OutputProcessor::StoreType::Sum,
    7353          190 :                                     thisCase.Name);
    7354          380 :                 SetupOutputVariable(state,
    7355              :                                     "Refrigeration Case Zone Sensible Heating Rate",
    7356              :                                     Constant::Units::W,
    7357          190 :                                     thisCase.SensZoneCreditHeatRate,
    7358              :                                     OutputProcessor::TimeStepType::Zone,
    7359              :                                     OutputProcessor::StoreType::Average,
    7360          190 :                                     thisCase.Name);
    7361          380 :                 SetupOutputVariable(state,
    7362              :                                     "Refrigeration Case Zone Sensible Heating Energy",
    7363              :                                     Constant::Units::J,
    7364          190 :                                     thisCase.SensZoneCreditHeat,
    7365              :                                     OutputProcessor::TimeStepType::Zone,
    7366              :                                     OutputProcessor::StoreType::Sum,
    7367          190 :                                     thisCase.Name);
    7368              : 
    7369          380 :                 SetupOutputVariable(state,
    7370              :                                     "Refrigeration Case Zone Latent Rate",
    7371              :                                     Constant::Units::W,
    7372          190 :                                     thisCase.LatZoneCreditRate,
    7373              :                                     OutputProcessor::TimeStepType::Zone,
    7374              :                                     OutputProcessor::StoreType::Average,
    7375          190 :                                     thisCase.Name);
    7376          380 :                 SetupOutputVariable(state,
    7377              :                                     "Refrigeration Case Zone Latent Energy",
    7378              :                                     Constant::Units::J,
    7379          190 :                                     thisCase.LatZoneCredit,
    7380              :                                     OutputProcessor::TimeStepType::Zone,
    7381              :                                     OutputProcessor::StoreType::Sum,
    7382          190 :                                     thisCase.Name);
    7383              : 
    7384          380 :                 SetupOutputVariable(state,
    7385              :                                     "Refrigeration Case Return Air Sensible Cooling Rate",
    7386              :                                     Constant::Units::W,
    7387          190 :                                     thisCase.SensHVACCreditCoolRate,
    7388              :                                     OutputProcessor::TimeStepType::Zone,
    7389              :                                     OutputProcessor::StoreType::Average,
    7390          190 :                                     thisCase.Name);
    7391          380 :                 SetupOutputVariable(state,
    7392              :                                     "Refrigeration Case Return Air Sensible Cooling Energy",
    7393              :                                     Constant::Units::J,
    7394          190 :                                     thisCase.SensHVACCreditCool,
    7395              :                                     OutputProcessor::TimeStepType::Zone,
    7396              :                                     OutputProcessor::StoreType::Sum,
    7397          190 :                                     thisCase.Name);
    7398          380 :                 SetupOutputVariable(state,
    7399              :                                     "Refrigeration Case Return Air Sensible Heating Rate",
    7400              :                                     Constant::Units::W,
    7401          190 :                                     thisCase.SensHVACCreditHeatRate,
    7402              :                                     OutputProcessor::TimeStepType::Zone,
    7403              :                                     OutputProcessor::StoreType::Average,
    7404          190 :                                     thisCase.Name);
    7405          380 :                 SetupOutputVariable(state,
    7406              :                                     "Refrigeration Case Return Air Sensible Heating Energy",
    7407              :                                     Constant::Units::J,
    7408          190 :                                     thisCase.SensHVACCreditHeat,
    7409              :                                     OutputProcessor::TimeStepType::Zone,
    7410              :                                     OutputProcessor::StoreType::Sum,
    7411          190 :                                     thisCase.Name);
    7412              : 
    7413          380 :                 SetupOutputVariable(state,
    7414              :                                     "Refrigeration Case Return Air Latent Rate",
    7415              :                                     Constant::Units::W,
    7416          190 :                                     thisCase.LatHVACCreditRate,
    7417              :                                     OutputProcessor::TimeStepType::Zone,
    7418              :                                     OutputProcessor::StoreType::Average,
    7419          190 :                                     thisCase.Name);
    7420          380 :                 SetupOutputVariable(state,
    7421              :                                     "Refrigeration Case Return Air Latent Energy",
    7422              :                                     Constant::Units::J,
    7423          190 :                                     thisCase.LatHVACCredit,
    7424              :                                     OutputProcessor::TimeStepType::Zone,
    7425              :                                     OutputProcessor::StoreType::Sum,
    7426          190 :                                     thisCase.Name);
    7427              : 
    7428          380 :                 SetupOutputVariable(state,
    7429              :                                     "Refrigeration Case Evaporator Fan Electricity Rate",
    7430              :                                     Constant::Units::W,
    7431          190 :                                     thisCase.ElecFanPower,
    7432              :                                     OutputProcessor::TimeStepType::Zone,
    7433              :                                     OutputProcessor::StoreType::Average,
    7434          190 :                                     thisCase.Name);
    7435          380 :                 SetupOutputVariable(state,
    7436              :                                     "Refrigeration Case Evaporator Fan Electricity Energy",
    7437              :                                     Constant::Units::J,
    7438          190 :                                     thisCase.ElecFanConsumption,
    7439              :                                     OutputProcessor::TimeStepType::Zone,
    7440              :                                     OutputProcessor::StoreType::Sum,
    7441          190 :                                     thisCase.Name,
    7442              :                                     Constant::eResource::Electricity,
    7443              :                                     OutputProcessor::Group::Building,
    7444              :                                     OutputProcessor::EndUseCat::Refrigeration,
    7445              :                                     "General",
    7446          190 :                                     thisCase.ZoneName);
    7447          380 :                 SetupOutputVariable(state,
    7448              :                                     "Refrigeration Case Lighting Electricity Rate",
    7449              :                                     Constant::Units::W,
    7450          190 :                                     thisCase.ElecLightingPower,
    7451              :                                     OutputProcessor::TimeStepType::Zone,
    7452              :                                     OutputProcessor::StoreType::Average,
    7453          190 :                                     thisCase.Name);
    7454          380 :                 SetupOutputVariable(state,
    7455              :                                     "Refrigeration Case Lighting Electricity Energy",
    7456              :                                     Constant::Units::J,
    7457          190 :                                     thisCase.ElecLightingConsumption,
    7458              :                                     OutputProcessor::TimeStepType::Zone,
    7459              :                                     OutputProcessor::StoreType::Sum,
    7460          190 :                                     thisCase.Name,
    7461              :                                     Constant::eResource::Electricity,
    7462              :                                     OutputProcessor::Group::Building,
    7463              :                                     OutputProcessor::EndUseCat::Refrigeration,
    7464              :                                     "General",
    7465          190 :                                     thisCase.ZoneName);
    7466              : 
    7467              :                 // Report defrost energy curve value only for cases having electric or hot-gas defrost with temperature termination
    7468          190 :                 if (thisCase.defrostType == RefCaseDefrostType::ElectricTerm || thisCase.defrostType == RefCaseDefrostType::HotFluidTerm) {
    7469          116 :                     SetupOutputVariable(state,
    7470              :                                         "Refrigeration Case Defrost Energy Correction Curve Value",
    7471              :                                         Constant::Units::None,
    7472           58 :                                         thisCase.DefEnergyCurveValue,
    7473              :                                         OutputProcessor::TimeStepType::Zone,
    7474              :                                         OutputProcessor::StoreType::Average,
    7475           58 :                                         thisCase.Name);
    7476              :                 }
    7477              : 
    7478          380 :                 SetupOutputVariable(state,
    7479              :                                     "Refrigeration Case Latent Credit Curve Value",
    7480              :                                     Constant::Units::None,
    7481          190 :                                     thisCase.LatEnergyCurveValue,
    7482              :                                     OutputProcessor::TimeStepType::Zone,
    7483              :                                     OutputProcessor::StoreType::Average,
    7484          190 :                                     thisCase.Name);
    7485              : 
    7486              :                 // Report only for cases having anti-sweat heaters
    7487          190 :                 if (thisCase.AntiSweatControlType > ASHtrCtrlType::None) {
    7488          158 :                     SetupOutputVariable(state,
    7489              :                                         "Refrigeration Case Anti Sweat Electricity Rate",
    7490              :                                         Constant::Units::W,
    7491           79 :                                         thisCase.ElecAntiSweatPower,
    7492              :                                         OutputProcessor::TimeStepType::Zone,
    7493              :                                         OutputProcessor::StoreType::Average,
    7494           79 :                                         thisCase.Name);
    7495          158 :                     SetupOutputVariable(state,
    7496              :                                         "Refrigeration Case Anti Sweat Electricity Energy",
    7497              :                                         Constant::Units::J,
    7498           79 :                                         thisCase.ElecAntiSweatConsumption,
    7499              :                                         OutputProcessor::TimeStepType::Zone,
    7500              :                                         OutputProcessor::StoreType::Sum,
    7501           79 :                                         thisCase.Name,
    7502              :                                         Constant::eResource::Electricity,
    7503              :                                         OutputProcessor::Group::Building,
    7504              :                                         OutputProcessor::EndUseCat::Refrigeration,
    7505              :                                         "General",
    7506           79 :                                         thisCase.ZoneName);
    7507              :                 }
    7508              : 
    7509              :                 // Report only for cases using electric defrost
    7510              : 
    7511          190 :                 if (thisCase.defrostType == RefCaseDefrostType::Electric || thisCase.defrostType == RefCaseDefrostType::ElectricOnDemand ||
    7512          162 :                     thisCase.defrostType == RefCaseDefrostType::ElectricTerm) {
    7513           92 :                     SetupOutputVariable(state,
    7514              :                                         "Refrigeration Case Defrost Electricity Rate",
    7515              :                                         Constant::Units::W,
    7516           46 :                                         thisCase.ElecDefrostPower,
    7517              :                                         OutputProcessor::TimeStepType::Zone,
    7518              :                                         OutputProcessor::StoreType::Average,
    7519           46 :                                         thisCase.Name);
    7520           92 :                     SetupOutputVariable(state,
    7521              :                                         "Refrigeration Case Defrost Electricity Energy",
    7522              :                                         Constant::Units::J,
    7523           46 :                                         thisCase.ElecDefrostConsumption,
    7524              :                                         OutputProcessor::TimeStepType::Zone,
    7525              :                                         OutputProcessor::StoreType::Sum,
    7526           46 :                                         thisCase.Name,
    7527              :                                         Constant::eResource::Electricity,
    7528              :                                         OutputProcessor::Group::Building,
    7529              :                                         OutputProcessor::EndUseCat::Refrigeration,
    7530              :                                         "General",
    7531           46 :                                         thisCase.ZoneName);
    7532              :                 }
    7533              : 
    7534              :                 // register refrigeration case credits as internal gains
    7535          190 :                 if (thisCase.ActualZoneNum > 0) {
    7536          190 :                     SetupZoneInternalGain(state,
    7537              :                                           thisCase.ActualZoneNum,
    7538              :                                           thisCase.Name,
    7539              :                                           DataHeatBalance::IntGainType::RefrigerationCase,
    7540              :                                           &thisCase.SensZoneCreditRate,
    7541              :                                           &thisCase.SensHVACCreditRate,
    7542              :                                           nullptr,
    7543              :                                           &thisCase.LatZoneCreditRate,
    7544              :                                           &thisCase.LatHVACCreditRate,
    7545              :                                           nullptr,
    7546              :                                           nullptr,
    7547              :                                           thisCase.ZoneRANode);
    7548              :                 }
    7549              :             } // END IF (.NOT. RefrigCase(CaseNum)%unusedCase)
    7550              :         }
    7551              :     } // NumSimulationCases > 0
    7552              : 
    7553          801 :     if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
    7554              :         // Setup Report Variables for simulated  Walk In (do not report unused WalkIns)
    7555              :         // CurrentModuleObject='Refrigeration:WalkIn'
    7556           31 :         for (int walkInNum = 1; walkInNum <= state.dataRefrigCase->NumSimulationWalkIns; ++walkInNum) {
    7557           17 :             auto &walkin = WalkIn(walkInNum);
    7558           17 :             if (walkin.NumSysAttach == 1) { // ensure no unuseds reported
    7559           34 :                 SetupOutputVariable(state,
    7560              :                                     "Refrigeration Walk In Evaporator Total Cooling Rate",
    7561              :                                     Constant::Units::W,
    7562           17 :                                     walkin.TotalCoolingLoad,
    7563              :                                     OutputProcessor::TimeStepType::Zone,
    7564              :                                     OutputProcessor::StoreType::Average,
    7565           17 :                                     walkin.Name);
    7566           34 :                 SetupOutputVariable(state,
    7567              :                                     "Refrigeration Walk In Evaporator Total Cooling Energy",
    7568              :                                     Constant::Units::J,
    7569           17 :                                     walkin.TotalCoolingEnergy,
    7570              :                                     OutputProcessor::TimeStepType::Zone,
    7571              :                                     OutputProcessor::StoreType::Sum,
    7572           17 :                                     walkin.Name);
    7573           34 :                 SetupOutputVariable(state,
    7574              :                                     "Refrigeration Walk In Evaporator Sensible Cooling Rate",
    7575              :                                     Constant::Units::W,
    7576           17 :                                     walkin.TotSensCoolingEnergyRate,
    7577              :                                     OutputProcessor::TimeStepType::Zone,
    7578              :                                     OutputProcessor::StoreType::Average,
    7579           17 :                                     walkin.Name);
    7580           34 :                 SetupOutputVariable(state,
    7581              :                                     "Refrigeration Walk In Evaporator Sensible Cooling Energy",
    7582              :                                     Constant::Units::J,
    7583           17 :                                     walkin.TotSensCoolingEnergy,
    7584              :                                     OutputProcessor::TimeStepType::Zone,
    7585              :                                     OutputProcessor::StoreType::Sum,
    7586           17 :                                     walkin.Name);
    7587           34 :                 SetupOutputVariable(state,
    7588              :                                     "Refrigeration Walk In Evaporator Latent Cooling Rate",
    7589              :                                     Constant::Units::W,
    7590           17 :                                     walkin.TotLatCoolingEnergyRate,
    7591              :                                     OutputProcessor::TimeStepType::Zone,
    7592              :                                     OutputProcessor::StoreType::Average,
    7593           17 :                                     walkin.Name);
    7594           34 :                 SetupOutputVariable(state,
    7595              :                                     "Refrigeration Walk In Evaporator Latent Cooling Energy",
    7596              :                                     Constant::Units::J,
    7597           17 :                                     walkin.TotLatCoolingEnergy,
    7598              :                                     OutputProcessor::TimeStepType::Zone,
    7599              :                                     OutputProcessor::StoreType::Sum,
    7600           17 :                                     walkin.Name);
    7601           34 :                 SetupOutputVariable(state,
    7602              :                                     "Refrigeration Walk In Ancillary Electricity Rate",
    7603              :                                     Constant::Units::W,
    7604           17 :                                     walkin.TotalElecPower,
    7605              :                                     OutputProcessor::TimeStepType::Zone,
    7606              :                                     OutputProcessor::StoreType::Average,
    7607           17 :                                     walkin.Name);
    7608           34 :                 SetupOutputVariable(state,
    7609              :                                     "Refrigeration Walk In Ancillary Electricity Energy",
    7610              :                                     Constant::Units::J,
    7611           17 :                                     walkin.TotalElecConsumption,
    7612              :                                     OutputProcessor::TimeStepType::Zone,
    7613              :                                     OutputProcessor::StoreType::Sum,
    7614           17 :                                     walkin.Name);
    7615           34 :                 SetupOutputVariable(state,
    7616              :                                     "Refrigeration Walk In Fan Electricity Rate",
    7617              :                                     Constant::Units::W,
    7618           17 :                                     walkin.ElecFanPower,
    7619              :                                     OutputProcessor::TimeStepType::Zone,
    7620              :                                     OutputProcessor::StoreType::Average,
    7621           17 :                                     walkin.Name);
    7622           34 :                 SetupOutputVariable(state,
    7623              :                                     "Refrigeration Walk In Fan Electricity Energy",
    7624              :                                     Constant::Units::J,
    7625           17 :                                     walkin.ElecFanConsumption,
    7626              :                                     OutputProcessor::TimeStepType::Zone,
    7627              :                                     OutputProcessor::StoreType::Sum,
    7628           17 :                                     walkin.Name,
    7629              :                                     Constant::eResource::Electricity,
    7630              :                                     OutputProcessor::Group::Building,
    7631              :                                     OutputProcessor::EndUseCat::Refrigeration,
    7632              :                                     "General");
    7633           34 :                 SetupOutputVariable(state,
    7634              :                                     "Refrigeration Walk In Lighting Electricity Rate",
    7635              :                                     Constant::Units::W,
    7636           17 :                                     walkin.ElecLightingPower,
    7637              :                                     OutputProcessor::TimeStepType::Zone,
    7638              :                                     OutputProcessor::StoreType::Average,
    7639           17 :                                     walkin.Name);
    7640           34 :                 SetupOutputVariable(state,
    7641              :                                     "Refrigeration Walk In Lighting Electricity Energy",
    7642              :                                     Constant::Units::J,
    7643           17 :                                     walkin.ElecLightingConsumption,
    7644              :                                     OutputProcessor::TimeStepType::Zone,
    7645              :                                     OutputProcessor::StoreType::Sum,
    7646           17 :                                     walkin.Name,
    7647              :                                     Constant::eResource::Electricity,
    7648              :                                     OutputProcessor::Group::Building,
    7649              :                                     OutputProcessor::EndUseCat::Refrigeration,
    7650              :                                     "General");
    7651           34 :                 SetupOutputVariable(state,
    7652              :                                     "Refrigeration Walk In Heater Electricity Rate",
    7653              :                                     Constant::Units::W,
    7654           17 :                                     walkin.ElecHeaterPower,
    7655              :                                     OutputProcessor::TimeStepType::Zone,
    7656              :                                     OutputProcessor::StoreType::Average,
    7657           17 :                                     walkin.Name);
    7658           34 :                 SetupOutputVariable(state,
    7659              :                                     "Refrigeration Walk In Heater Electricity Energy",
    7660              :                                     Constant::Units::J,
    7661           17 :                                     walkin.ElecHeaterConsumption,
    7662              :                                     OutputProcessor::TimeStepType::Zone,
    7663              :                                     OutputProcessor::StoreType::Sum,
    7664           17 :                                     walkin.Name,
    7665              :                                     Constant::eResource::Electricity,
    7666              :                                     OutputProcessor::Group::Building,
    7667              :                                     OutputProcessor::EndUseCat::Refrigeration,
    7668              :                                     "General");
    7669              : 
    7670              :                 // Report only for WalkIns using electric defrost
    7671           17 :                 if (walkin.defrostType == DefrostType::Elec) {
    7672           28 :                     SetupOutputVariable(state,
    7673              :                                         "Refrigeration Walk In Defrost Electricity Rate",
    7674              :                                         Constant::Units::W,
    7675           14 :                                         walkin.ElecDefrostPower,
    7676              :                                         OutputProcessor::TimeStepType::Zone,
    7677              :                                         OutputProcessor::StoreType::Average,
    7678           14 :                                         walkin.Name);
    7679           28 :                     SetupOutputVariable(state,
    7680              :                                         "Refrigeration Walk In Defrost Electricity Energy",
    7681              :                                         Constant::Units::J,
    7682           14 :                                         walkin.ElecDefrostConsumption,
    7683              :                                         OutputProcessor::TimeStepType::Zone,
    7684              :                                         OutputProcessor::StoreType::Sum,
    7685           14 :                                         walkin.Name,
    7686              :                                         Constant::eResource::Electricity,
    7687              :                                         OutputProcessor::Group::Building,
    7688              :                                         OutputProcessor::EndUseCat::Refrigeration,
    7689              :                                         "General");
    7690              :                 }
    7691              : 
    7692              :                 // Report walkin variables that are specified for each zone exposed to the walkin
    7693              :                 // For "IDOut" variable in SetupOutputVariable, need to create a single name that includes
    7694              :                 //    both the walk-in name and the zone name - see "Walkin_and_zone_name" concatenation
    7695              :                 //    This new variable name is important if using an rvi file!
    7696           34 :                 for (int zoneId = 1; zoneId <= walkin.NumZones; ++zoneId) {
    7697              : 
    7698           17 :                     Walkin_and_zone_name = walkin.Name + "InZone" + walkin.ZoneName(zoneId);
    7699              : 
    7700           34 :                     SetupOutputVariable(state,
    7701              :                                         "Refrigeration Walk In Zone Sensible Cooling Rate",
    7702              :                                         Constant::Units::W,
    7703           17 :                                         walkin.SensZoneCreditCoolRate(zoneId),
    7704              :                                         OutputProcessor::TimeStepType::Zone,
    7705              :                                         OutputProcessor::StoreType::Average,
    7706              :                                         Walkin_and_zone_name);
    7707           34 :                     SetupOutputVariable(state,
    7708              :                                         "Refrigeration Walk In Zone Sensible Cooling Energy",
    7709              :                                         Constant::Units::J,
    7710           17 :                                         walkin.SensZoneCreditCool(zoneId),
    7711              :                                         OutputProcessor::TimeStepType::Zone,
    7712              :                                         OutputProcessor::StoreType::Sum,
    7713              :                                         Walkin_and_zone_name);
    7714           34 :                     SetupOutputVariable(state,
    7715              :                                         "Refrigeration Walk In Zone Sensible Heating Rate",
    7716              :                                         Constant::Units::W,
    7717           17 :                                         walkin.SensZoneCreditHeatRate(zoneId),
    7718              :                                         OutputProcessor::TimeStepType::Zone,
    7719              :                                         OutputProcessor::StoreType::Average,
    7720              :                                         Walkin_and_zone_name);
    7721           34 :                     SetupOutputVariable(state,
    7722              :                                         "Refrigeration Walk In Zone Sensible Heating Energy",
    7723              :                                         Constant::Units::J,
    7724           17 :                                         walkin.SensZoneCreditHeat(zoneId),
    7725              :                                         OutputProcessor::TimeStepType::Zone,
    7726              :                                         OutputProcessor::StoreType::Sum,
    7727              :                                         Walkin_and_zone_name);
    7728           34 :                     SetupOutputVariable(state,
    7729              :                                         "Refrigeration Walk In Zone Latent Rate",
    7730              :                                         Constant::Units::W,
    7731           17 :                                         walkin.LatZoneCreditRate(zoneId),
    7732              :                                         OutputProcessor::TimeStepType::Zone,
    7733              :                                         OutputProcessor::StoreType::Average,
    7734              :                                         Walkin_and_zone_name);
    7735           34 :                     SetupOutputVariable(state,
    7736              :                                         "Refrigeration Walk In Zone Latent Energy",
    7737              :                                         Constant::Units::J,
    7738           17 :                                         walkin.LatZoneCredit(zoneId),
    7739              :                                         OutputProcessor::TimeStepType::Zone,
    7740              :                                         OutputProcessor::StoreType::Sum,
    7741              :                                         Walkin_and_zone_name);
    7742              : 
    7743           17 :                     if (walkin.ZoneNum(zoneId) > 0) {
    7744           34 :                         SetupZoneInternalGain(state,
    7745           17 :                                               walkin.ZoneNum(zoneId),
    7746              :                                               Walkin_and_zone_name,
    7747              :                                               DataHeatBalance::IntGainType::RefrigerationWalkIn,
    7748           17 :                                               &walkin.SensZoneCreditRate(zoneId),
    7749              :                                               nullptr,
    7750              :                                               nullptr,
    7751           17 :                                               &walkin.LatZoneCreditRate(zoneId));
    7752              :                     }
    7753              : 
    7754              :                 } // ZoneID
    7755              :             } //(.NOT.  WalkIn( WalkInNum)%unusedWalkIn)
    7756              :         } // NumSimulationWalkIns
    7757              :     } // NumSimulationWalkIns > 0
    7758              : 
    7759          801 :     if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0) {
    7760              :         // Setup Report Variables for simulated Warehouse coils (do not report unused warehouse coils)
    7761              :         // CurrentModuleObject='Refrigeration:AirChiller'
    7762           84 :         for (int coilNum = 1; coilNum <= state.dataRefrigCase->NumSimulationRefrigAirChillers; ++coilNum) {
    7763           83 :             auto &coil = WarehouseCoil(coilNum);
    7764           83 :             if (coil.NumSysAttach == 1) { // ensure no unuseds reported
    7765          166 :                 SetupOutputVariable(state,
    7766              :                                     "Refrigeration Zone Air Chiller Total Cooling Rate",
    7767              :                                     Constant::Units::W,
    7768           83 :                                     coil.TotalCoolingLoad,
    7769              :                                     OutputProcessor::TimeStepType::System,
    7770              :                                     OutputProcessor::StoreType::Average,
    7771           83 :                                     coil.Name);
    7772          166 :                 SetupOutputVariable(state,
    7773              :                                     "Refrigeration Zone Air Chiller Total Cooling Energy",
    7774              :                                     Constant::Units::J,
    7775           83 :                                     coil.TotalCoolingEnergy,
    7776              :                                     OutputProcessor::TimeStepType::System,
    7777              :                                     OutputProcessor::StoreType::Sum,
    7778           83 :                                     coil.Name);
    7779          166 :                 SetupOutputVariable(state,
    7780              :                                     "Refrigeration Zone Air Chiller Sensible Cooling Rate",
    7781              :                                     Constant::Units::W,
    7782           83 :                                     coil.SensCoolingEnergyRate,
    7783              :                                     OutputProcessor::TimeStepType::System,
    7784              :                                     OutputProcessor::StoreType::Average,
    7785           83 :                                     coil.Name);
    7786          166 :                 SetupOutputVariable(state,
    7787              :                                     "Refrigeration Zone Air Chiller Sensible Cooling Energy",
    7788              :                                     Constant::Units::J,
    7789           83 :                                     coil.SensCoolingEnergy,
    7790              :                                     OutputProcessor::TimeStepType::System,
    7791              :                                     OutputProcessor::StoreType::Sum,
    7792           83 :                                     coil.Name);
    7793          166 :                 SetupOutputVariable(state,
    7794              :                                     "Refrigeration Zone Air Chiller Latent Cooling Rate",
    7795              :                                     Constant::Units::W,
    7796           83 :                                     coil.LatCreditRate,
    7797              :                                     OutputProcessor::TimeStepType::System,
    7798              :                                     OutputProcessor::StoreType::Average,
    7799           83 :                                     coil.Name);
    7800          166 :                 SetupOutputVariable(state,
    7801              :                                     "Refrigeration Zone Air Chiller Latent Cooling Energy",
    7802              :                                     Constant::Units::J,
    7803           83 :                                     coil.LatCreditEnergy,
    7804              :                                     OutputProcessor::TimeStepType::System,
    7805              :                                     OutputProcessor::StoreType::Sum,
    7806           83 :                                     coil.Name);
    7807          166 :                 SetupOutputVariable(state,
    7808              :                                     "Refrigeration Zone Air Chiller Water Removed Mass Flow Rate",
    7809              :                                     Constant::Units::kg_s,
    7810           83 :                                     coil.LatKgPerS_ToZone,
    7811              :                                     OutputProcessor::TimeStepType::System,
    7812              :                                     OutputProcessor::StoreType::Average,
    7813           83 :                                     coil.Name);
    7814          166 :                 SetupOutputVariable(state,
    7815              :                                     "Refrigeration Zone Air Chiller Total Electricity Rate",
    7816              :                                     Constant::Units::W,
    7817           83 :                                     coil.TotalElecPower,
    7818              :                                     OutputProcessor::TimeStepType::System,
    7819              :                                     OutputProcessor::StoreType::Average,
    7820           83 :                                     coil.Name);
    7821          166 :                 SetupOutputVariable(state,
    7822              :                                     "Refrigeration Zone Air Chiller Total Electricity Energy",
    7823              :                                     Constant::Units::J,
    7824           83 :                                     coil.TotalElecConsumption,
    7825              :                                     OutputProcessor::TimeStepType::System,
    7826              :                                     OutputProcessor::StoreType::Sum,
    7827           83 :                                     coil.Name); // components are metered separately
    7828          166 :                 SetupOutputVariable(state,
    7829              :                                     "Refrigeration Zone Air Chiller Fan Electricity Rate",
    7830              :                                     Constant::Units::W,
    7831           83 :                                     coil.ElecFanPower,
    7832              :                                     OutputProcessor::TimeStepType::System,
    7833              :                                     OutputProcessor::StoreType::Average,
    7834           83 :                                     coil.Name);
    7835          166 :                 SetupOutputVariable(state,
    7836              :                                     "Refrigeration Zone Air Chiller Fan Electric Energy",
    7837              :                                     Constant::Units::J,
    7838           83 :                                     coil.ElecFanConsumption,
    7839              :                                     OutputProcessor::TimeStepType::System,
    7840              :                                     OutputProcessor::StoreType::Sum,
    7841           83 :                                     coil.Name,
    7842              :                                     Constant::eResource::Electricity,
    7843              :                                     OutputProcessor::Group::Building,
    7844              :                                     OutputProcessor::EndUseCat::Refrigeration,
    7845              :                                     "General");
    7846          166 :                 SetupOutputVariable(state,
    7847              :                                     "Refrigeration Zone Air Chiller Heater Electricity Rate",
    7848              :                                     Constant::Units::W,
    7849           83 :                                     coil.ElecHeaterPower,
    7850              :                                     OutputProcessor::TimeStepType::System,
    7851              :                                     OutputProcessor::StoreType::Average,
    7852           83 :                                     coil.Name);
    7853          166 :                 SetupOutputVariable(state,
    7854              :                                     "Refrigeration Zone Air Chiller Heater Electricity Energy",
    7855              :                                     Constant::Units::J,
    7856           83 :                                     coil.ElecHeaterConsumption,
    7857              :                                     OutputProcessor::TimeStepType::System,
    7858              :                                     OutputProcessor::StoreType::Sum,
    7859           83 :                                     coil.Name,
    7860              :                                     Constant::eResource::Electricity,
    7861              :                                     OutputProcessor::Group::Building,
    7862              :                                     OutputProcessor::EndUseCat::Refrigeration,
    7863              :                                     "General");
    7864          166 :                 SetupOutputVariable(state,
    7865              :                                     "Refrigeration Zone Air Chiller Sensible Heat Ratio",
    7866              :                                     Constant::Units::None,
    7867           83 :                                     coil.SensHeatRatio,
    7868              :                                     OutputProcessor::TimeStepType::System,
    7869              :                                     OutputProcessor::StoreType::Average,
    7870           83 :                                     coil.Name);
    7871          166 :                 SetupOutputVariable(state,
    7872              :                                     "Refrigeration Zone Air Chiller Frost Accumulation Mass",
    7873              :                                     Constant::Units::kg,
    7874           83 :                                     coil.KgFrost,
    7875              :                                     OutputProcessor::TimeStepType::System,
    7876              :                                     OutputProcessor::StoreType::Average,
    7877           83 :                                     coil.Name);
    7878          166 :                 SetupOutputVariable(state,
    7879              :                                     "Refrigeration Zone Air Chiller Zone Total Cooling Rate",
    7880              :                                     Constant::Units::W,
    7881           83 :                                     coil.ReportTotalCoolCreditRate,
    7882              :                                     OutputProcessor::TimeStepType::System,
    7883              :                                     OutputProcessor::StoreType::Average,
    7884           83 :                                     coil.Name);
    7885          166 :                 SetupOutputVariable(state,
    7886              :                                     "Refrigeration Zone Air Chiller Zone Total Cooling Energy",
    7887              :                                     Constant::Units::J,
    7888           83 :                                     coil.ReportTotalCoolCreditEnergy,
    7889              :                                     OutputProcessor::TimeStepType::System,
    7890              :                                     OutputProcessor::StoreType::Sum,
    7891           83 :                                     coil.Name);
    7892          166 :                 SetupOutputVariable(state,
    7893              :                                     "Refrigeration Zone Air Chiller Zone Sensible Cooling Rate",
    7894              :                                     Constant::Units::W,
    7895           83 :                                     coil.ReportSensCoolCreditRate,
    7896              :                                     OutputProcessor::TimeStepType::System,
    7897              :                                     OutputProcessor::StoreType::Average,
    7898           83 :                                     coil.Name);
    7899          166 :                 SetupOutputVariable(state,
    7900              :                                     "Refrigeration Zone Air Chiller Zone Sensible Cooling Energy",
    7901              :                                     Constant::Units::J,
    7902           83 :                                     coil.ReportSensCoolCreditEnergy,
    7903              :                                     OutputProcessor::TimeStepType::System,
    7904              :                                     OutputProcessor::StoreType::Sum,
    7905           83 :                                     coil.Name);
    7906          166 :                 SetupOutputVariable(state,
    7907              :                                     "Refrigeration Zone Air Chiller Zone Heating Rate",
    7908              :                                     Constant::Units::W,
    7909           83 :                                     coil.ReportHeatingCreditRate,
    7910              :                                     OutputProcessor::TimeStepType::System,
    7911              :                                     OutputProcessor::StoreType::Average,
    7912           83 :                                     coil.Name);
    7913          166 :                 SetupOutputVariable(state,
    7914              :                                     "Refrigeration Zone Air Chiller Zone Heating Energy",
    7915              :                                     Constant::Units::J,
    7916           83 :                                     coil.ReportHeatingCreditEnergy,
    7917              :                                     OutputProcessor::TimeStepType::System,
    7918              :                                     OutputProcessor::StoreType::Sum,
    7919           83 :                                     coil.Name);
    7920              : 
    7921              :                 // Report only for Warehouse coils using electric defrost
    7922           83 :                 if (coil.defrostType == DefrostType::Elec) {
    7923          164 :                     SetupOutputVariable(state,
    7924              :                                         "Refrigeration Zone Air Chiller Defrost Electricity Rate",
    7925              :                                         Constant::Units::W,
    7926           82 :                                         coil.ElecDefrostPower,
    7927              :                                         OutputProcessor::TimeStepType::System,
    7928              :                                         OutputProcessor::StoreType::Average,
    7929           82 :                                         coil.Name);
    7930          164 :                     SetupOutputVariable(state,
    7931              :                                         "Refrigeration Zone Air Chiller Defrost Electricity Energy",
    7932              :                                         Constant::Units::J,
    7933           82 :                                         coil.ElecDefrostConsumption,
    7934              :                                         OutputProcessor::TimeStepType::System,
    7935              :                                         OutputProcessor::StoreType::Sum,
    7936           82 :                                         coil.Name,
    7937              :                                         Constant::eResource::Electricity,
    7938              :                                         OutputProcessor::Group::Building,
    7939              :                                         OutputProcessor::EndUseCat::Refrigeration,
    7940              :                                         "General");
    7941              :                 } // electric defrost coil
    7942              :             } //(.NOT.  coil%unusedWarehouseCoil)
    7943              :         } // NumSimulationWarehouseCoils
    7944              :     } // NumSimulationRefrigAirChillers > 0
    7945              : 
    7946              :     // There are no report variables for Chiller sets because they are
    7947              :     // used to pass the demand to the coils, but are NOT used to provide the
    7948              :     // cooling energy to the zone (because more than one set may cool a zone)
    7949              : 
    7950              :     // Report sum of all refrigeration interactions with each zone
    7951              : 
    7952         6002 :     for (int zoneID = 1; zoneID <= state.dataGlobal->NumOfZones; ++zoneID) {
    7953         5201 :         if (state.dataRefrigCase->RefrigPresentInZone(zoneID)) {
    7954           71 :             if (state.dataRefrigCase->HaveCasesOrWalkins) {
    7955          122 :                 SetupOutputVariable(state,
    7956              :                                     "Refrigeration Zone Case and Walk In Total Sensible Cooling Rate",
    7957              :                                     Constant::Units::W,
    7958           61 :                                     state.dataHeatBal->RefrigCaseCredit(zoneID).SenCaseCreditToZone,
    7959              :                                     OutputProcessor::TimeStepType::Zone,
    7960              :                                     OutputProcessor::StoreType::Average,
    7961           61 :                                     state.dataHeatBal->Zone(zoneID).Name);
    7962          122 :                 SetupOutputVariable(state,
    7963              :                                     "Refrigeration Zone Case and Walk In Total Sensible Cooling Energy",
    7964              :                                     Constant::Units::J,
    7965           61 :                                     CaseWIZoneReport(zoneID).SenCaseCreditToZoneEnergy,
    7966              :                                     OutputProcessor::TimeStepType::Zone,
    7967              :                                     OutputProcessor::StoreType::Sum,
    7968           61 :                                     state.dataHeatBal->Zone(zoneID).Name);
    7969          122 :                 SetupOutputVariable(state,
    7970              :                                     "Refrigeration Zone Case and Walk In Heating Rate",
    7971              :                                     Constant::Units::W,
    7972           61 :                                     CaseWIZoneReport(zoneID).HeatingToZoneRate,
    7973              :                                     OutputProcessor::TimeStepType::Zone,
    7974              :                                     OutputProcessor::StoreType::Average,
    7975           61 :                                     state.dataHeatBal->Zone(zoneID).Name);
    7976          122 :                 SetupOutputVariable(state,
    7977              :                                     "Refrigeration Zone Case and Walk In Heating Energy",
    7978              :                                     Constant::Units::J,
    7979           61 :                                     CaseWIZoneReport(zoneID).HeatingToZoneEnergy,
    7980              :                                     OutputProcessor::TimeStepType::Zone,
    7981              :                                     OutputProcessor::StoreType::Sum,
    7982           61 :                                     state.dataHeatBal->Zone(zoneID).Name);
    7983          122 :                 SetupOutputVariable(state,
    7984              :                                     "Refrigeration Zone Case and Walk In Sensible Cooling Rate",
    7985              :                                     Constant::Units::W,
    7986           61 :                                     CaseWIZoneReport(zoneID).SenCoolingToZoneRate,
    7987              :                                     OutputProcessor::TimeStepType::Zone,
    7988              :                                     OutputProcessor::StoreType::Average,
    7989           61 :                                     state.dataHeatBal->Zone(zoneID).Name);
    7990          122 :                 SetupOutputVariable(state,
    7991              :                                     "Refrigeration Zone Case and Walk In Sensible Cooling Energy",
    7992              :                                     Constant::Units::J,
    7993           61 :                                     CaseWIZoneReport(zoneID).SenCoolingToZoneEnergy,
    7994              :                                     OutputProcessor::TimeStepType::Zone,
    7995              :                                     OutputProcessor::StoreType::Sum,
    7996           61 :                                     state.dataHeatBal->Zone(zoneID).Name);
    7997          122 :                 SetupOutputVariable(state,
    7998              :                                     "Refrigeration Zone Case and Walk In Total Latent Cooling Rate",
    7999              :                                     Constant::Units::W,
    8000           61 :                                     CaseWIZoneReport(zoneID).LatCoolingToZoneRate,
    8001              :                                     OutputProcessor::TimeStepType::Zone,
    8002              :                                     OutputProcessor::StoreType::Average,
    8003           61 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8004          122 :                 SetupOutputVariable(state,
    8005              :                                     "Refrigeration Zone Case and Walk In Total Latent Cooling Energy",
    8006              :                                     Constant::Units::J,
    8007           61 :                                     CaseWIZoneReport(zoneID).LatCoolingToZoneEnergy,
    8008              :                                     OutputProcessor::TimeStepType::Zone,
    8009              :                                     OutputProcessor::StoreType::Sum,
    8010           61 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8011          122 :                 SetupOutputVariable(state,
    8012              :                                     "Refrigeration Zone Case and Walk In Total Cooling Rate",
    8013              :                                     Constant::Units::W,
    8014           61 :                                     CaseWIZoneReport(zoneID).TotCoolingToZoneRate,
    8015              :                                     OutputProcessor::TimeStepType::Zone,
    8016              :                                     OutputProcessor::StoreType::Average,
    8017           61 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8018          122 :                 SetupOutputVariable(state,
    8019              :                                     "Refrigeration Zone Case and Walk In Total Cooling Energy",
    8020              :                                     Constant::Units::J,
    8021           61 :                                     CaseWIZoneReport(zoneID).TotCoolingToZoneEnergy,
    8022              :                                     OutputProcessor::TimeStepType::Zone,
    8023              :                                     OutputProcessor::StoreType::Sum,
    8024           61 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8025          122 :                 SetupOutputVariable(state,
    8026              :                                     "Refrigeration Zone Case and Walk In Total Heat Transfer Rate",
    8027              :                                     Constant::Units::W,
    8028           61 :                                     CaseWIZoneReport(zoneID).TotHtXferToZoneRate,
    8029              :                                     OutputProcessor::TimeStepType::Zone,
    8030              :                                     OutputProcessor::StoreType::Average,
    8031           61 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8032          122 :                 SetupOutputVariable(state,
    8033              :                                     "Refrigeration Zone Case and Walk In Total Heat Transfer Energy",
    8034              :                                     Constant::Units::J,
    8035           61 :                                     CaseWIZoneReport(zoneID).TotHtXferToZoneEnergy,
    8036              :                                     OutputProcessor::TimeStepType::Zone,
    8037              :                                     OutputProcessor::StoreType::Sum,
    8038           61 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8039              :             } // HaveCasesOrWalkIns
    8040              : 
    8041           71 :             if (state.dataRefrigCase->HaveChillers) {
    8042           20 :                 SetupOutputVariable(state,
    8043              :                                     "Refrigeration Zone Air Chiller Sensible Heat Transfer Rate",
    8044              :                                     Constant::Units::W,
    8045           10 :                                     CoilSysCredit(zoneID).SenCreditToZoneRate,
    8046              :                                     OutputProcessor::TimeStepType::System,
    8047              :                                     OutputProcessor::StoreType::Average,
    8048           10 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8049           20 :                 SetupOutputVariable(state,
    8050              :                                     "Refrigeration Zone Air Chiller Sensible Heat Transfer Energy",
    8051              :                                     Constant::Units::J,
    8052           10 :                                     CoilSysCredit(zoneID).SenCreditToZoneEnergy,
    8053              :                                     OutputProcessor::TimeStepType::System,
    8054              :                                     OutputProcessor::StoreType::Sum,
    8055           10 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8056           20 :                 SetupOutputVariable(state,
    8057              :                                     "Refrigeration Zone Air Chiller Sensible Cooling Rate",
    8058              :                                     Constant::Units::W,
    8059           10 :                                     CoilSysCredit(zoneID).ReportSenCoolingToZoneRate,
    8060              :                                     OutputProcessor::TimeStepType::System,
    8061              :                                     OutputProcessor::StoreType::Average,
    8062           10 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8063           20 :                 SetupOutputVariable(state,
    8064              :                                     "Refrigeration Zone Air Chiller Sensible Cooling Energy",
    8065              :                                     Constant::Units::J,
    8066           10 :                                     CoilSysCredit(zoneID).ReportSenCoolingToZoneEnergy,
    8067              :                                     OutputProcessor::TimeStepType::System,
    8068              :                                     OutputProcessor::StoreType::Sum,
    8069           10 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8070           20 :                 SetupOutputVariable(state,
    8071              :                                     "Refrigeration Zone Air Chiller Latent Cooling Rate",
    8072              :                                     Constant::Units::W,
    8073           10 :                                     CoilSysCredit(zoneID).ReportLatCreditToZoneRate,
    8074              :                                     OutputProcessor::TimeStepType::System,
    8075              :                                     OutputProcessor::StoreType::Average,
    8076           10 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8077           20 :                 SetupOutputVariable(state,
    8078              :                                     "Refrigeration Zone Air Chiller Latent Cooling Energy",
    8079              :                                     Constant::Units::J,
    8080           10 :                                     CoilSysCredit(zoneID).ReportLatCreditToZoneEnergy,
    8081              :                                     OutputProcessor::TimeStepType::System,
    8082              :                                     OutputProcessor::StoreType::Sum,
    8083           10 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8084           20 :                 SetupOutputVariable(state,
    8085              :                                     "Refrigeration Zone Air Chiller Water Removed Mass Flow Rate",
    8086              :                                     Constant::Units::kg_s,
    8087           10 :                                     CoilSysCredit(zoneID).ReportH2ORemovedKgPerS_FromZoneRate,
    8088              :                                     OutputProcessor::TimeStepType::System,
    8089              :                                     OutputProcessor::StoreType::Average,
    8090           10 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8091           20 :                 SetupOutputVariable(state,
    8092              :                                     "Refrigeration Zone Air Chiller Total Cooling Rate",
    8093              :                                     Constant::Units::W,
    8094           10 :                                     CoilSysCredit(zoneID).ReportTotCoolingToZoneRate,
    8095              :                                     OutputProcessor::TimeStepType::System,
    8096              :                                     OutputProcessor::StoreType::Average,
    8097           10 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8098           20 :                 SetupOutputVariable(state,
    8099              :                                     "Refrigeration Zone Air Chiller Total Cooling Energy",
    8100              :                                     Constant::Units::J,
    8101           10 :                                     CoilSysCredit(zoneID).ReportTotCoolingToZoneEnergy,
    8102              :                                     OutputProcessor::TimeStepType::System,
    8103              :                                     OutputProcessor::StoreType::Sum,
    8104           10 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8105           20 :                 SetupOutputVariable(state,
    8106              :                                     "Refrigeration Zone Air Chiller Heating Rate",
    8107              :                                     Constant::Units::W,
    8108           10 :                                     CoilSysCredit(zoneID).ReportHeatingToZoneRate,
    8109              :                                     OutputProcessor::TimeStepType::System,
    8110              :                                     OutputProcessor::StoreType::Average,
    8111           10 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8112           20 :                 SetupOutputVariable(state,
    8113              :                                     "Refrigeration Zone Air Chiller Heating Energy",
    8114              :                                     Constant::Units::J,
    8115           10 :                                     CoilSysCredit(zoneID).ReportHeatingToZoneEnergy,
    8116              :                                     OutputProcessor::TimeStepType::System,
    8117              :                                     OutputProcessor::StoreType::Sum,
    8118           10 :                                     state.dataHeatBal->Zone(zoneID).Name);
    8119              :             } // HaveChillers
    8120              :         } // RefrigPresentInZone(ZoneID)
    8121              :     } // ZoneID
    8122              : 
    8123          801 :     if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
    8124              :         // CurrentModuleObject='Refrigeration:SecondarySystem'
    8125            3 :         for (int secondNum = 1; secondNum <= state.dataRefrigCase->NumSimulationSecondarySystems; ++secondNum) {
    8126            2 :             auto &secondary = Secondary(secondNum);
    8127            2 :             if (secondary.NumSysAttach == 1) {
    8128            2 :                 if (secondary.CoilFlag) { // secondary system serves chillers and is solved on HVAC time step
    8129            0 :                     SetupOutputVariable(state,
    8130              :                                         "Refrigeration Air Chiller Secondary Loop Pump Electricity Rate",
    8131              :                                         Constant::Units::W,
    8132            0 :                                         secondary.PumpPowerTotal,
    8133              :                                         OutputProcessor::TimeStepType::System,
    8134              :                                         OutputProcessor::StoreType::Average,
    8135            0 :                                         secondary.Name);
    8136            0 :                     SetupOutputVariable(state,
    8137              :                                         "Refrigeration Air Chiller Secondary Loop Pump Electricity Energy",
    8138              :                                         Constant::Units::J,
    8139            0 :                                         secondary.PumpElecEnergyTotal,
    8140              :                                         OutputProcessor::TimeStepType::System,
    8141              :                                         OutputProcessor::StoreType::Sum,
    8142            0 :                                         secondary.Name,
    8143              :                                         Constant::eResource::Electricity,
    8144              :                                         OutputProcessor::Group::Plant,
    8145              :                                         OutputProcessor::EndUseCat::Refrigeration,
    8146              :                                         secondary.EndUseSubcategory);
    8147            0 :                     SetupOutputVariable(state,
    8148              :                                         "Refrigeration Air Chiller Secondary Loop Load Heat Transfer Rate",
    8149              :                                         Constant::Units::W,
    8150            0 :                                         secondary.TotalRefrigLoad,
    8151              :                                         OutputProcessor::TimeStepType::System,
    8152              :                                         OutputProcessor::StoreType::Average,
    8153            0 :                                         secondary.Name);
    8154            0 :                     SetupOutputVariable(state,
    8155              :                                         "Refrigeration Air Chiller Secondary Loop Load Heat Transfer Energy",
    8156              :                                         Constant::Units::J,
    8157            0 :                                         secondary.TotalRefrigEnergy,
    8158              :                                         OutputProcessor::TimeStepType::System,
    8159              :                                         OutputProcessor::StoreType::Sum,
    8160            0 :                                         secondary.Name);
    8161            0 :                     SetupOutputVariable(state,
    8162              :                                         "Refrigeration Air Chiller Secondary Loop Total Heat Transfer Rate",
    8163              :                                         Constant::Units::W,
    8164            0 :                                         secondary.TotalCoolingLoad,
    8165              :                                         OutputProcessor::TimeStepType::System,
    8166              :                                         OutputProcessor::StoreType::Average,
    8167            0 :                                         secondary.Name);
    8168            0 :                     SetupOutputVariable(state,
    8169              :                                         "Refrigeration Air Chiller Secondary Loop Total Heat Transfer Energy",
    8170              :                                         Constant::Units::J,
    8171            0 :                                         secondary.TotalCoolingEnergy,
    8172              :                                         OutputProcessor::TimeStepType::System,
    8173              :                                         OutputProcessor::StoreType::Sum,
    8174            0 :                                         secondary.Name);
    8175            0 :                     SetupOutputVariable(state,
    8176              :                                         "Refrigeration Air Chiller Secondary Loop Estimated Refrigerant Inventory Mass",
    8177              :                                         Constant::Units::kg,
    8178            0 :                                         secondary.RefInventory,
    8179              :                                         OutputProcessor::TimeStepType::System,
    8180              :                                         OutputProcessor::StoreType::Average,
    8181            0 :                                         secondary.Name);
    8182            0 :                     SetupOutputVariable(state,
    8183              :                                         "Refrigeration Air Chiller Secondary Loop Volume Flow Rate",
    8184              :                                         Constant::Units::m3_s,
    8185            0 :                                         secondary.FlowVolActual,
    8186              :                                         OutputProcessor::TimeStepType::System,
    8187              :                                         OutputProcessor::StoreType::Average,
    8188            0 :                                         secondary.Name);
    8189            0 :                     SetupOutputVariable(state,
    8190              :                                         "Refrigeration Air Chiller Secondary Loop Pipe Heat Gain Rate",
    8191              :                                         Constant::Units::W,
    8192            0 :                                         secondary.DistPipeHeatGain,
    8193              :                                         OutputProcessor::TimeStepType::System,
    8194              :                                         OutputProcessor::StoreType::Average,
    8195            0 :                                         secondary.Name);
    8196            0 :                     SetupOutputVariable(state,
    8197              :                                         "Refrigeration Air Chiller Secondary Loop Pipe Heat Gain Energy",
    8198              :                                         Constant::Units::J,
    8199            0 :                                         secondary.DistPipeHeatGainEnergy,
    8200              :                                         OutputProcessor::TimeStepType::System,
    8201              :                                         OutputProcessor::StoreType::Sum,
    8202            0 :                                         secondary.Name);
    8203            0 :                     SetupOutputVariable(state,
    8204              :                                         "Refrigeration Air Chiller Secondary Loop Receiver Heat Gain Rate",
    8205              :                                         Constant::Units::W,
    8206            0 :                                         secondary.ReceiverHeatGain,
    8207              :                                         OutputProcessor::TimeStepType::System,
    8208              :                                         OutputProcessor::StoreType::Average,
    8209            0 :                                         secondary.Name);
    8210            0 :                     SetupOutputVariable(state,
    8211              :                                         "Refrigeration Air Chiller Secondary Loop Receiver Heat Gain Energy",
    8212              :                                         Constant::Units::J,
    8213            0 :                                         secondary.ReceiverHeatGainEnergy,
    8214              :                                         OutputProcessor::TimeStepType::System,
    8215              :                                         OutputProcessor::StoreType::Sum,
    8216            0 :                                         secondary.Name);
    8217              :                 } else { // Secondary loop serves cases and walk-ins on zone(load) time step
    8218            4 :                     SetupOutputVariable(state,
    8219              :                                         "Refrigeration Secondary Loop Pump Electricity Rate",
    8220              :                                         Constant::Units::W,
    8221            2 :                                         secondary.PumpPowerTotal,
    8222              :                                         OutputProcessor::TimeStepType::Zone,
    8223              :                                         OutputProcessor::StoreType::Average,
    8224            2 :                                         secondary.Name);
    8225            4 :                     SetupOutputVariable(state,
    8226              :                                         "Refrigeration Secondary Loop Pump Electricity Energy",
    8227              :                                         Constant::Units::J,
    8228            2 :                                         secondary.PumpElecEnergyTotal,
    8229              :                                         OutputProcessor::TimeStepType::Zone,
    8230              :                                         OutputProcessor::StoreType::Sum,
    8231            2 :                                         secondary.Name,
    8232              :                                         Constant::eResource::Electricity,
    8233              :                                         OutputProcessor::Group::Plant,
    8234              :                                         OutputProcessor::EndUseCat::Refrigeration,
    8235              :                                         secondary.EndUseSubcategory);
    8236            4 :                     SetupOutputVariable(state,
    8237              :                                         "Refrigeration Secondary Loop Load Heat Transfer Rate",
    8238              :                                         Constant::Units::W,
    8239            2 :                                         secondary.TotalRefrigLoad,
    8240              :                                         OutputProcessor::TimeStepType::Zone,
    8241              :                                         OutputProcessor::StoreType::Average,
    8242            2 :                                         secondary.Name);
    8243            4 :                     SetupOutputVariable(state,
    8244              :                                         "Refrigeration Secondary Loop Load Heat Transfer Energy",
    8245              :                                         Constant::Units::J,
    8246            2 :                                         secondary.TotalRefrigEnergy,
    8247              :                                         OutputProcessor::TimeStepType::Zone,
    8248              :                                         OutputProcessor::StoreType::Sum,
    8249            2 :                                         secondary.Name);
    8250            4 :                     SetupOutputVariable(state,
    8251              :                                         "Refrigeration Secondary Loop Total Heat Transfer Rate",
    8252              :                                         Constant::Units::W,
    8253            2 :                                         secondary.TotalCoolingLoad,
    8254              :                                         OutputProcessor::TimeStepType::Zone,
    8255              :                                         OutputProcessor::StoreType::Average,
    8256            2 :                                         secondary.Name);
    8257            4 :                     SetupOutputVariable(state,
    8258              :                                         "Refrigeration Secondary Loop Total Heat Transfer Energy",
    8259              :                                         Constant::Units::J,
    8260            2 :                                         secondary.TotalCoolingEnergy,
    8261              :                                         OutputProcessor::TimeStepType::Zone,
    8262              :                                         OutputProcessor::StoreType::Sum,
    8263            2 :                                         secondary.Name);
    8264            4 :                     SetupOutputVariable(state,
    8265              :                                         "Refrigeration Secondary Loop Estimated Refrigerant Inventory Mass",
    8266              :                                         Constant::Units::kg,
    8267            2 :                                         secondary.RefInventory,
    8268              :                                         OutputProcessor::TimeStepType::Zone,
    8269              :                                         OutputProcessor::StoreType::Average,
    8270            2 :                                         secondary.Name);
    8271            4 :                     SetupOutputVariable(state,
    8272              :                                         "Refrigeration Secondary Loop Volume Flow Rate",
    8273              :                                         Constant::Units::m3_s,
    8274            2 :                                         secondary.FlowVolActual,
    8275              :                                         OutputProcessor::TimeStepType::Zone,
    8276              :                                         OutputProcessor::StoreType::Average,
    8277            2 :                                         secondary.Name);
    8278            4 :                     SetupOutputVariable(state,
    8279              :                                         "Refrigeration Secondary Loop Pipe Heat Gain Rate",
    8280              :                                         Constant::Units::W,
    8281            2 :                                         secondary.DistPipeHeatGain,
    8282              :                                         OutputProcessor::TimeStepType::Zone,
    8283              :                                         OutputProcessor::StoreType::Average,
    8284            2 :                                         secondary.Name);
    8285            4 :                     SetupOutputVariable(state,
    8286              :                                         "Refrigeration Secondary Loop Pipe Heat Gain Energy",
    8287              :                                         Constant::Units::J,
    8288            2 :                                         secondary.DistPipeHeatGainEnergy,
    8289              :                                         OutputProcessor::TimeStepType::Zone,
    8290              :                                         OutputProcessor::StoreType::Sum,
    8291            2 :                                         secondary.Name);
    8292            4 :                     SetupOutputVariable(state,
    8293              :                                         "Refrigeration Secondary Loop Receiver Heat Gain Rate",
    8294              :                                         Constant::Units::W,
    8295            2 :                                         secondary.ReceiverHeatGain,
    8296              :                                         OutputProcessor::TimeStepType::Zone,
    8297              :                                         OutputProcessor::StoreType::Average,
    8298            2 :                                         secondary.Name);
    8299            4 :                     SetupOutputVariable(state,
    8300              :                                         "Refrigeration Secondary Loop Receiver Heat Gain Energy",
    8301              :                                         Constant::Units::J,
    8302            2 :                                         secondary.ReceiverHeatGainEnergy,
    8303              :                                         OutputProcessor::TimeStepType::Zone,
    8304              :                                         OutputProcessor::StoreType::Sum,
    8305            2 :                                         secondary.Name);
    8306              :                 } // NOT coilflag so on Zone timestep
    8307            2 :                 if (secondary.ReceiverZoneNum > 0) {
    8308            1 :                     SetupZoneInternalGain(state,
    8309              :                                           secondary.ReceiverZoneNum,
    8310              :                                           secondary.Name,
    8311              :                                           DataHeatBalance::IntGainType::RefrigerationSecondaryReceiver,
    8312              :                                           &secondary.ReceiverZoneHeatGain);
    8313              :                 }
    8314            2 :                 if (secondary.DistPipeZoneNum > 0) {
    8315            2 :                     SetupZoneInternalGain(state,
    8316              :                                           secondary.DistPipeZoneNum,
    8317              :                                           secondary.Name,
    8318              :                                           DataHeatBalance::IntGainType::RefrigerationSecondaryPipe,
    8319              :                                           &secondary.DistPipeZoneHeatGain);
    8320              :                 }
    8321              :             } // not an unused
    8322              :         } // NumSimulationSecondarySystems
    8323              :     } // NumSimulationSecondarySystems > 0
    8324              : 
    8325              :     // Setup Report Variables for Refrigeration Compressor Rack
    8326          801 :     if (state.dataRefrigCase->NumRefrigeratedRacks > 0) {
    8327              :         // CurrentModuleObject='Refrigeration:CompressorRack'
    8328           92 :         for (int rackNum = 1; rackNum <= state.dataRefrigCase->NumRefrigeratedRacks; ++rackNum) {
    8329           61 :             auto &rack = RefrigRack(rackNum);
    8330           61 :             if (rack.CoilFlag) { // rack serves chillers and is solved on HVAC time step
    8331            0 :                 SetupOutputVariable(state,
    8332              :                                     "Refrigeration Air Chiller Compressor Rack Electricity Rate",
    8333              :                                     Constant::Units::W,
    8334            0 :                                     rack.RackCompressorPower,
    8335              :                                     OutputProcessor::TimeStepType::System,
    8336              :                                     OutputProcessor::StoreType::Average,
    8337            0 :                                     rack.Name);
    8338            0 :                 SetupOutputVariable(state,
    8339              :                                     "Refrigeration Air Chiller Compressor Rack Electricity Energy",
    8340              :                                     Constant::Units::J,
    8341            0 :                                     rack.RackElecConsumption,
    8342              :                                     OutputProcessor::TimeStepType::System,
    8343              :                                     OutputProcessor::StoreType::Sum,
    8344            0 :                                     rack.Name,
    8345              :                                     Constant::eResource::Electricity,
    8346              :                                     OutputProcessor::Group::Plant,
    8347              :                                     OutputProcessor::EndUseCat::Refrigeration,
    8348              :                                     rack.EndUseSubcategory);
    8349            0 :                 SetupOutputVariable(state,
    8350              :                                     "Refrigeration Air Chiller Compressor Rack Condenser Fan Electricity Rate",
    8351              :                                     Constant::Units::W,
    8352            0 :                                     rack.ActualCondenserFanPower,
    8353              :                                     OutputProcessor::TimeStepType::System,
    8354              :                                     OutputProcessor::StoreType::Average,
    8355            0 :                                     rack.Name);
    8356            0 :                 SetupOutputVariable(state,
    8357              :                                     "Refrigeration Air Chiller Compressor Rack Condenser Fan Electricity Energy",
    8358              :                                     Constant::Units::J,
    8359            0 :                                     rack.CondenserFanConsumption,
    8360              :                                     OutputProcessor::TimeStepType::System,
    8361              :                                     OutputProcessor::StoreType::Sum,
    8362            0 :                                     rack.Name,
    8363              :                                     Constant::eResource::Electricity,
    8364              :                                     OutputProcessor::Group::Plant,
    8365              :                                     OutputProcessor::EndUseCat::Refrigeration,
    8366              :                                     rack.EndUseSubcategory);
    8367            0 :                 SetupOutputVariable(state,
    8368              :                                     "Refrigeration Air Chiller Compressor Rack Total Heat Transfer Rate",
    8369              :                                     Constant::Units::W,
    8370            0 :                                     rack.RackCapacity,
    8371              :                                     OutputProcessor::TimeStepType::System,
    8372              :                                     OutputProcessor::StoreType::Average,
    8373            0 :                                     rack.Name);
    8374            0 :                 SetupOutputVariable(state,
    8375              :                                     "Refrigeration Air Chiller Compressor Rack Total Heat Transfer Energy",
    8376              :                                     Constant::Units::J,
    8377            0 :                                     rack.RackCoolingEnergy,
    8378              :                                     OutputProcessor::TimeStepType::System,
    8379              :                                     OutputProcessor::StoreType::Sum,
    8380            0 :                                     rack.Name,
    8381              :                                     Constant::eResource::EnergyTransfer,
    8382              :                                     OutputProcessor::Group::Plant,
    8383              :                                     OutputProcessor::EndUseCat::Refrigeration,
    8384              :                                     rack.EndUseSubcategory);
    8385            0 :                 SetupOutputVariable(state,
    8386              :                                     "Refrigeration Air Chiller Compressor Rack COP",
    8387              :                                     Constant::Units::W_W,
    8388            0 :                                     rack.RackCompressorCOP,
    8389              :                                     OutputProcessor::TimeStepType::System,
    8390              :                                     OutputProcessor::StoreType::Average,
    8391            0 :                                     rack.Name);
    8392              : 
    8393            0 :                 if (rack.CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
    8394            0 :                     SetupOutputVariable(state,
    8395              :                                         "Refrigeration Air Chiller Compressor Rack Evaporative Condenser Pump Electricity Rate",
    8396              :                                         Constant::Units::W,
    8397            0 :                                         rack.ActualEvapPumpPower,
    8398              :                                         OutputProcessor::TimeStepType::System,
    8399              :                                         OutputProcessor::StoreType::Average,
    8400            0 :                                         rack.Name);
    8401            0 :                     SetupOutputVariable(state,
    8402              :                                         "Refrigeration Air Chiller Compressor Rack Evaporative Condenser Pump Electricity Energy",
    8403              :                                         Constant::Units::J,
    8404            0 :                                         rack.EvapPumpConsumption,
    8405              :                                         OutputProcessor::TimeStepType::System,
    8406              :                                         OutputProcessor::StoreType::Sum,
    8407            0 :                                         rack.Name,
    8408              :                                         Constant::eResource::Electricity,
    8409              :                                         OutputProcessor::Group::Plant,
    8410              :                                         OutputProcessor::EndUseCat::Refrigeration,
    8411              :                                         rack.EndUseSubcategory);
    8412            0 :                     SetupOutputVariable(state,
    8413              :                                         "Refrigeration Air Chiller Compressor Rack Evaporative Condenser Basin Heater Electricity Rate",
    8414              :                                         Constant::Units::W,
    8415            0 :                                         rack.BasinHeaterPower,
    8416              :                                         OutputProcessor::TimeStepType::System,
    8417              :                                         OutputProcessor::StoreType::Average,
    8418            0 :                                         rack.Name);
    8419            0 :                     SetupOutputVariable(state,
    8420              :                                         "Refrigeration Air Chiller Compressor Rack Evaporative Condenser Basin Heater Electricity Energy",
    8421              :                                         Constant::Units::J,
    8422            0 :                                         rack.BasinHeaterConsumption,
    8423              :                                         OutputProcessor::TimeStepType::System,
    8424              :                                         OutputProcessor::StoreType::Sum,
    8425            0 :                                         rack.Name,
    8426              :                                         Constant::eResource::Electricity,
    8427              :                                         OutputProcessor::Group::Plant,
    8428              :                                         OutputProcessor::EndUseCat::Refrigeration,
    8429              :                                         rack.EndUseSubcategory);
    8430            0 :                     SetupOutputVariable(state,
    8431              :                                         "Refrigeration Air Chiller Compressor Rack Evaporative Condenser Water Volume Flow Rate",
    8432              :                                         Constant::Units::m3_s,
    8433            0 :                                         rack.EvapWaterConsumpRate,
    8434              :                                         OutputProcessor::TimeStepType::System,
    8435              :                                         OutputProcessor::StoreType::Average,
    8436            0 :                                         rack.Name);
    8437            0 :                     SetupOutputVariable(state,
    8438              :                                         "Refrigeration Air Chiller Compressor Rack Evaporative Condenser Water Volume",
    8439              :                                         Constant::Units::m3,
    8440            0 :                                         rack.EvapWaterConsumption,
    8441              :                                         OutputProcessor::TimeStepType::System,
    8442              :                                         OutputProcessor::StoreType::Sum,
    8443            0 :                                         rack.Name,
    8444              :                                         Constant::eResource::Water,
    8445              :                                         OutputProcessor::Group::Plant,
    8446              :                                         OutputProcessor::EndUseCat::Refrigeration,
    8447              :                                         rack.EndUseSubcategory);
    8448              :                 } // Evap condenser
    8449              : 
    8450            0 :                 if (rack.HeatRejectionLocation == HeatRejLocation::Zone) {
    8451            0 :                     SetupOutputVariable(state,
    8452              :                                         "Refrigeration Air Chiller Compressor Rack Zone Sensible Heating Rate",
    8453              :                                         Constant::Units::W,
    8454            0 :                                         rack.SensZoneCreditHeatRate,
    8455              :                                         OutputProcessor::TimeStepType::System,
    8456              :                                         OutputProcessor::StoreType::Average,
    8457            0 :                                         rack.Name);
    8458            0 :                     SetupOutputVariable(state,
    8459              :                                         "Refrigeration Air Chiller Compressor Rack Zone Sensible Heating Energy",
    8460              :                                         Constant::Units::J,
    8461            0 :                                         rack.SensZoneCreditHeat,
    8462              :                                         OutputProcessor::TimeStepType::System,
    8463              :                                         OutputProcessor::StoreType::Sum,
    8464            0 :                                         rack.Name);
    8465              : 
    8466            0 :                     SetupOutputVariable(state,
    8467              :                                         "Refrigeration Air Chiller Compressor Rack Return Air Sensible Heating Rate",
    8468              :                                         Constant::Units::W,
    8469            0 :                                         rack.SensHVACCreditHeatRate,
    8470              :                                         OutputProcessor::TimeStepType::System,
    8471              :                                         OutputProcessor::StoreType::Average,
    8472            0 :                                         rack.Name);
    8473            0 :                     SetupOutputVariable(state,
    8474              :                                         "Refrigeration Air Chiller Compressor Rack Return Air Sensible Heating Energy",
    8475              :                                         Constant::Units::J,
    8476            0 :                                         rack.SensHVACCreditHeat,
    8477              :                                         OutputProcessor::TimeStepType::System,
    8478              :                                         OutputProcessor::StoreType::Sum,
    8479            0 :                                         rack.Name);
    8480              : 
    8481              :                     // If CoilFlag is true and Location is Zone, GetRefrigerationInput ensures you must have a Heat Rejection Zone provided already
    8482            0 :                     SetupZoneInternalGain(state,
    8483              :                                           rack.HeatRejectionZoneNum,
    8484              :                                           rack.Name,
    8485              :                                           DataHeatBalance::IntGainType::RefrigerationCompressorRack,
    8486              :                                           &rack.SensZoneCreditHeatRate,
    8487              :                                           &rack.SensHVACCreditHeatRate);
    8488              : 
    8489              :                 } // LocationZone
    8490              : 
    8491              :             } else { // Rack serves cases and walkins on zone (load) time step
    8492              : 
    8493          122 :                 SetupOutputVariable(state,
    8494              :                                     "Refrigeration Compressor Rack Electricity Rate",
    8495              :                                     Constant::Units::W,
    8496           61 :                                     rack.RackCompressorPower,
    8497              :                                     OutputProcessor::TimeStepType::Zone,
    8498              :                                     OutputProcessor::StoreType::Average,
    8499           61 :                                     rack.Name);
    8500          122 :                 SetupOutputVariable(state,
    8501              :                                     "Refrigeration Compressor Rack Electricity Energy",
    8502              :                                     Constant::Units::J,
    8503           61 :                                     rack.RackElecConsumption,
    8504              :                                     OutputProcessor::TimeStepType::Zone,
    8505              :                                     OutputProcessor::StoreType::Sum,
    8506           61 :                                     rack.Name,
    8507              :                                     Constant::eResource::Electricity,
    8508              :                                     OutputProcessor::Group::Plant,
    8509              :                                     OutputProcessor::EndUseCat::Refrigeration,
    8510              :                                     rack.EndUseSubcategory);
    8511          122 :                 SetupOutputVariable(state,
    8512              :                                     "Refrigeration Compressor Rack Condenser Fan Electricity Rate",
    8513              :                                     Constant::Units::W,
    8514           61 :                                     rack.ActualCondenserFanPower,
    8515              :                                     OutputProcessor::TimeStepType::Zone,
    8516              :                                     OutputProcessor::StoreType::Average,
    8517           61 :                                     rack.Name);
    8518          122 :                 SetupOutputVariable(state,
    8519              :                                     "Refrigeration Compressor Rack Condenser Fan Electricity Energy",
    8520              :                                     Constant::Units::J,
    8521           61 :                                     rack.CondenserFanConsumption,
    8522              :                                     OutputProcessor::TimeStepType::Zone,
    8523              :                                     OutputProcessor::StoreType::Sum,
    8524           61 :                                     rack.Name,
    8525              :                                     Constant::eResource::Electricity,
    8526              :                                     OutputProcessor::Group::Plant,
    8527              :                                     OutputProcessor::EndUseCat::Refrigeration,
    8528              :                                     rack.EndUseSubcategory);
    8529          122 :                 SetupOutputVariable(state,
    8530              :                                     "Refrigeration Compressor Rack Total Heat Transfer Rate",
    8531              :                                     Constant::Units::W,
    8532           61 :                                     rack.RackCapacity,
    8533              :                                     OutputProcessor::TimeStepType::Zone,
    8534              :                                     OutputProcessor::StoreType::Average,
    8535           61 :                                     rack.Name);
    8536          122 :                 SetupOutputVariable(state,
    8537              :                                     "Refrigeration Compressor Rack Total Heat Transfer Energy",
    8538              :                                     Constant::Units::J,
    8539           61 :                                     rack.RackCoolingEnergy,
    8540              :                                     OutputProcessor::TimeStepType::Zone,
    8541              :                                     OutputProcessor::StoreType::Sum,
    8542           61 :                                     rack.Name,
    8543              :                                     Constant::eResource::EnergyTransfer,
    8544              :                                     OutputProcessor::Group::Plant,
    8545              :                                     OutputProcessor::EndUseCat::Refrigeration,
    8546              :                                     rack.EndUseSubcategory);
    8547          122 :                 SetupOutputVariable(state,
    8548              :                                     "Refrigeration Compressor Rack COP",
    8549              :                                     Constant::Units::W_W,
    8550           61 :                                     rack.RackCompressorCOP,
    8551              :                                     OutputProcessor::TimeStepType::Zone,
    8552              :                                     OutputProcessor::StoreType::Average,
    8553           61 :                                     rack.Name);
    8554              : 
    8555           61 :                 if (rack.CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
    8556            4 :                     SetupOutputVariable(state,
    8557              :                                         "Refrigeration Compressor Rack Evaporative Condenser Pump Electricity Rate",
    8558              :                                         Constant::Units::W,
    8559            2 :                                         rack.ActualEvapPumpPower,
    8560              :                                         OutputProcessor::TimeStepType::Zone,
    8561              :                                         OutputProcessor::StoreType::Average,
    8562            2 :                                         rack.Name);
    8563            4 :                     SetupOutputVariable(state,
    8564              :                                         "Refrigeration Compressor Rack Evaporative Condenser Pump Electricity Energy",
    8565              :                                         Constant::Units::J,
    8566            2 :                                         rack.EvapPumpConsumption,
    8567              :                                         OutputProcessor::TimeStepType::Zone,
    8568              :                                         OutputProcessor::StoreType::Sum,
    8569            2 :                                         rack.Name,
    8570              :                                         Constant::eResource::Electricity,
    8571              :                                         OutputProcessor::Group::Plant,
    8572              :                                         OutputProcessor::EndUseCat::Refrigeration,
    8573              :                                         rack.EndUseSubcategory);
    8574            4 :                     SetupOutputVariable(state,
    8575              :                                         "Refrigeration Compressor Rack Evaporative Condenser Basin Heater Electricity Rate",
    8576              :                                         Constant::Units::W,
    8577            2 :                                         rack.BasinHeaterPower,
    8578              :                                         OutputProcessor::TimeStepType::Zone,
    8579              :                                         OutputProcessor::StoreType::Average,
    8580            2 :                                         rack.Name);
    8581            4 :                     SetupOutputVariable(state,
    8582              :                                         "Refrigeration Compressor Rack Evaporative Condenser Basin Heater Electricity Energy",
    8583              :                                         Constant::Units::J,
    8584            2 :                                         rack.BasinHeaterConsumption,
    8585              :                                         OutputProcessor::TimeStepType::Zone,
    8586              :                                         OutputProcessor::StoreType::Sum,
    8587            2 :                                         rack.Name,
    8588              :                                         Constant::eResource::Electricity,
    8589              :                                         OutputProcessor::Group::Plant,
    8590              :                                         OutputProcessor::EndUseCat::Refrigeration,
    8591              :                                         rack.EndUseSubcategory);
    8592            4 :                     SetupOutputVariable(state,
    8593              :                                         "Refrigeration Compressor Rack Evaporative Condenser Water Volume Flow Rate",
    8594              :                                         Constant::Units::m3_s,
    8595            2 :                                         rack.EvapWaterConsumpRate,
    8596              :                                         OutputProcessor::TimeStepType::Zone,
    8597              :                                         OutputProcessor::StoreType::Average,
    8598            2 :                                         rack.Name);
    8599            4 :                     SetupOutputVariable(state,
    8600              :                                         "Refrigeration Compressor Rack Evaporative Condenser Water Volume",
    8601              :                                         Constant::Units::m3,
    8602            2 :                                         rack.EvapWaterConsumption,
    8603              :                                         OutputProcessor::TimeStepType::Zone,
    8604              :                                         OutputProcessor::StoreType::Sum,
    8605            2 :                                         rack.Name,
    8606              :                                         Constant::eResource::Water,
    8607              :                                         OutputProcessor::Group::Plant,
    8608              :                                         OutputProcessor::EndUseCat::Refrigeration,
    8609              :                                         rack.EndUseSubcategory);
    8610              :                 } // condenser evap
    8611              : 
    8612           61 :                 if (rack.HeatRejectionLocation == HeatRejLocation::Zone) {
    8613           54 :                     SetupOutputVariable(state,
    8614              :                                         "Refrigeration Compressor Rack Zone Sensible Heating Rate",
    8615              :                                         Constant::Units::W,
    8616           27 :                                         rack.SensZoneCreditHeatRate,
    8617              :                                         OutputProcessor::TimeStepType::Zone,
    8618              :                                         OutputProcessor::StoreType::Average,
    8619           27 :                                         rack.Name);
    8620           54 :                     SetupOutputVariable(state,
    8621              :                                         "Refrigeration Compressor Rack Zone Sensible Heating Energy",
    8622              :                                         Constant::Units::J,
    8623           27 :                                         rack.SensZoneCreditHeat,
    8624              :                                         OutputProcessor::TimeStepType::Zone,
    8625              :                                         OutputProcessor::StoreType::Sum,
    8626           27 :                                         rack.Name);
    8627              : 
    8628           54 :                     SetupOutputVariable(state,
    8629              :                                         "Refrigeration Compressor Rack Return Air Sensible Heating Rate",
    8630              :                                         Constant::Units::W,
    8631           27 :                                         rack.SensHVACCreditHeatRate,
    8632              :                                         OutputProcessor::TimeStepType::Zone,
    8633              :                                         OutputProcessor::StoreType::Average,
    8634           27 :                                         rack.Name);
    8635           54 :                     SetupOutputVariable(state,
    8636              :                                         "Refrigeration Compressor Rack Return Air Sensible Heating Energy",
    8637              :                                         Constant::Units::J,
    8638           27 :                                         rack.SensHVACCreditHeat,
    8639              :                                         OutputProcessor::TimeStepType::Zone,
    8640              :                                         OutputProcessor::StoreType::Sum,
    8641           27 :                                         rack.Name);
    8642              : 
    8643              :                     // if Location is Zone, GetRefrigerationInputEither checks that you have at least one load and that either:
    8644              :                     // * You have only cases, and they must be all in the same zone
    8645              :                     // * Or you must have a Heat Rejection Zone provided
    8646           27 :                     int rackZoneNum = -1;
    8647           27 :                     if (rack.HeatRejectionZoneNum > 0) {
    8648            0 :                         rackZoneNum = rack.HeatRejectionZoneNum;
    8649              :                     } else {
    8650           27 :                         rackZoneNum = RefrigCase(rack.CaseNum(1)).ActualZoneNum;
    8651              :                     }
    8652           27 :                     SetupZoneInternalGain(state,
    8653              :                                           rackZoneNum,
    8654              :                                           rack.Name,
    8655              :                                           DataHeatBalance::IntGainType::RefrigerationCompressorRack,
    8656              :                                           &rack.SensZoneCreditHeatRate,
    8657              :                                           &rack.SensHVACCreditHeatRate);
    8658              : 
    8659              :                 } // location zone
    8660              :             } // Serves coils or case/walkin loads
    8661              : 
    8662           61 :             if (rack.CondenserType == DataHeatBalance::RefrigCondenserType::Water) { // on HVAC time step no matter what
    8663            2 :                 SetupOutputVariable(state,
    8664              :                                     "Refrigeration Compressor Rack Condenser Mass Flow Rate",
    8665              :                                     Constant::Units::kg_s,
    8666            1 :                                     rack.MassFlowRate,
    8667              :                                     OutputProcessor::TimeStepType::System,
    8668              :                                     OutputProcessor::StoreType::Average,
    8669            1 :                                     rack.Name);
    8670              : 
    8671            2 :                 SetupOutputVariable(state,
    8672              :                                     "Refrigeration Compressor Rack Condenser Heat Transfer Rate",
    8673              :                                     Constant::Units::W,
    8674            1 :                                     rack.CondLoad,
    8675              :                                     OutputProcessor::TimeStepType::System,
    8676              :                                     OutputProcessor::StoreType::Average,
    8677            1 :                                     rack.Name);
    8678              : 
    8679            2 :                 SetupOutputVariable(state,
    8680              :                                     "Refrigeration Compressor Rack Condenser Heat Transfer Energy",
    8681              :                                     Constant::Units::J,
    8682            1 :                                     rack.CondEnergy,
    8683              :                                     OutputProcessor::TimeStepType::System,
    8684              :                                     OutputProcessor::StoreType::Sum,
    8685            1 :                                     rack.Name,
    8686              :                                     Constant::eResource::EnergyTransfer,
    8687              :                                     OutputProcessor::Group::Plant,
    8688              :                                     OutputProcessor::EndUseCat::Heating);
    8689              : 
    8690              :             } // Condenser cooling water
    8691              :         } // Refrigerated Racks
    8692              :     } // NumRefrigeratedRacks > 0
    8693              : 
    8694          801 :     if (state.dataRefrigCase->NumRefrigSystems > 0) {
    8695              :         // CurrentModuleObject='Refrigeration:System'
    8696           56 :         for (int refrigSysNum = 1; refrigSysNum <= state.dataRefrigCase->NumRefrigSystems; ++refrigSysNum) {
    8697           41 :             auto &sys = System(refrigSysNum);
    8698           41 :             if (sys.CoilFlag) { // system serves chillers and is solved on HVAC time step
    8699            9 :                 if (sys.NumStages == 1) {
    8700           18 :                     SetupOutputVariable(state,
    8701              :                                         "Refrigeration Air Chiller System Total Compressor Electricity Rate",
    8702              :                                         Constant::Units::W,
    8703            9 :                                         sys.TotCompPower,
    8704              :                                         OutputProcessor::TimeStepType::System,
    8705              :                                         OutputProcessor::StoreType::Average,
    8706            9 :                                         sys.Name);
    8707           18 :                     SetupOutputVariable(state,
    8708              :                                         "Refrigeration Air Chiller System Total Compressor Electricity Energy",
    8709              :                                         Constant::Units::J,
    8710            9 :                                         sys.TotCompElecConsump,
    8711              :                                         OutputProcessor::TimeStepType::System,
    8712              :                                         OutputProcessor::StoreType::Sum,
    8713            9 :                                         sys.Name);
    8714            0 :                 } else if (sys.NumStages == 2) {
    8715            0 :                     SetupOutputVariable(state,
    8716              :                                         "Refrigeration Air Chiller System Total Low Stage Compressor Electricity Rate",
    8717              :                                         Constant::Units::W,
    8718            0 :                                         sys.TotCompPower,
    8719              :                                         OutputProcessor::TimeStepType::System,
    8720              :                                         OutputProcessor::StoreType::Average,
    8721            0 :                                         sys.Name);
    8722            0 :                     SetupOutputVariable(state,
    8723              :                                         "Refrigeration Air Chiller System Total Low Stage Compressor Electricity Energy",
    8724              :                                         Constant::Units::J,
    8725            0 :                                         sys.TotCompElecConsump,
    8726              :                                         OutputProcessor::TimeStepType::System,
    8727              :                                         OutputProcessor::StoreType::Sum,
    8728            0 :                                         sys.Name);
    8729            0 :                     SetupOutputVariable(state,
    8730              :                                         "Refrigeration Air Chiller System Total High Stage Compressor Electricity Rate",
    8731              :                                         Constant::Units::W,
    8732            0 :                                         sys.TotHiStageCompPower,
    8733              :                                         OutputProcessor::TimeStepType::System,
    8734              :                                         OutputProcessor::StoreType::Average,
    8735            0 :                                         sys.Name);
    8736            0 :                     SetupOutputVariable(state,
    8737              :                                         "Refrigeration Air Chiller System Total High Stage Compressor Electricity Energy",
    8738              :                                         Constant::Units::J,
    8739            0 :                                         sys.TotHiStageCompElecConsump,
    8740              :                                         OutputProcessor::TimeStepType::System,
    8741              :                                         OutputProcessor::StoreType::Sum,
    8742            0 :                                         sys.Name);
    8743            0 :                     SetupOutputVariable(state,
    8744              :                                         "Refrigeration Air Chiller System Total Low and High Stage Compressor Electricity Energy",
    8745              :                                         Constant::Units::J,
    8746            0 :                                         sys.TotCompElecConsumpTwoStage,
    8747              :                                         OutputProcessor::TimeStepType::System,
    8748              :                                         OutputProcessor::StoreType::Sum,
    8749            0 :                                         sys.Name);
    8750              :                 } // NumStages
    8751           18 :                 SetupOutputVariable(state,
    8752              :                                     "Refrigeration Air Chiller System Average Compressor COP",
    8753              :                                     Constant::Units::W_W,
    8754            9 :                                     sys.AverageCompressorCOP,
    8755              :                                     OutputProcessor::TimeStepType::System,
    8756              :                                     OutputProcessor::StoreType::Average,
    8757            9 :                                     sys.Name);
    8758           18 :                 SetupOutputVariable(state,
    8759              :                                     "Refrigeration Air Chiller System Total Air Chiller Heat Transfer Rate",
    8760              :                                     Constant::Units::W,
    8761            9 :                                     sys.TotalCoolingLoad,
    8762              :                                     OutputProcessor::TimeStepType::System,
    8763              :                                     OutputProcessor::StoreType::Average,
    8764            9 :                                     sys.Name);
    8765           18 :                 SetupOutputVariable(state,
    8766              :                                     "Refrigeration Air Chiller System Total Case and Walk In Heat Transfer Energy",
    8767              :                                     Constant::Units::J,
    8768            9 :                                     sys.TotalCoolingEnergy,
    8769              :                                     OutputProcessor::TimeStepType::System,
    8770              :                                     OutputProcessor::StoreType::Sum,
    8771            9 :                                     sys.Name);
    8772           18 :                 SetupOutputVariable(state,
    8773              :                                     "Refrigeration Air Chiller System Total Transferred Load Heat Transfer Rate",
    8774              :                                     Constant::Units::W,
    8775            9 :                                     sys.TotTransferLoad,
    8776              :                                     OutputProcessor::TimeStepType::System,
    8777              :                                     OutputProcessor::StoreType::Average,
    8778            9 :                                     sys.Name);
    8779           18 :                 SetupOutputVariable(state,
    8780              :                                     "Refrigeration Air Chiller System Total Transferred Load Heat Transfer Energy",
    8781              :                                     Constant::Units::J,
    8782            9 :                                     sys.TotTransferEnergy,
    8783              :                                     OutputProcessor::TimeStepType::System,
    8784              :                                     OutputProcessor::StoreType::Sum,
    8785            9 :                                     sys.Name);
    8786           18 :                 SetupOutputVariable(state,
    8787              :                                     "Refrigeration Air Chiller System Total Suction Pipe Heat Gain Rate",
    8788              :                                     Constant::Units::W,
    8789            9 :                                     sys.PipeHeatLoad,
    8790              :                                     OutputProcessor::TimeStepType::System,
    8791              :                                     OutputProcessor::StoreType::Average,
    8792            9 :                                     sys.Name);
    8793           18 :                 SetupOutputVariable(state,
    8794              :                                     "Refrigeration Air Chiller System Total Suction Pipe Heat Gain Energy",
    8795              :                                     Constant::Units::J,
    8796            9 :                                     sys.PipeHeatEnergy,
    8797              :                                     OutputProcessor::TimeStepType::System,
    8798              :                                     OutputProcessor::StoreType::Sum,
    8799            9 :                                     sys.Name);
    8800            9 :                 if (sys.NumStages == 1) {
    8801           18 :                     SetupOutputVariable(state,
    8802              :                                         "Refrigeration Air Chiller System Total Compressor Heat Transfer Rate",
    8803              :                                         Constant::Units::W,
    8804            9 :                                         sys.TotCompCapacity,
    8805              :                                         OutputProcessor::TimeStepType::System,
    8806              :                                         OutputProcessor::StoreType::Average,
    8807            9 :                                         sys.Name);
    8808           18 :                     SetupOutputVariable(state,
    8809              :                                         "Refrigeration Air Chiller System Total Compressor Heat Transfer Energy",
    8810              :                                         Constant::Units::J,
    8811            9 :                                         sys.TotCompCoolingEnergy,
    8812              :                                         OutputProcessor::TimeStepType::System,
    8813              :                                         OutputProcessor::StoreType::Sum,
    8814            9 :                                         sys.Name); // indiv compressors go to meter, not system sum
    8815            0 :                 } else if (sys.NumStages == 2) {
    8816            0 :                     SetupOutputVariable(state,
    8817              :                                         "Refrigeration Air Chiller System Total Low Stage Compressor Heat Transfer Rate",
    8818              :                                         Constant::Units::W,
    8819            0 :                                         sys.TotCompCapacity,
    8820              :                                         OutputProcessor::TimeStepType::System,
    8821              :                                         OutputProcessor::StoreType::Average,
    8822            0 :                                         sys.Name);
    8823            0 :                     SetupOutputVariable(state,
    8824              :                                         "Refrigeration Air Chiller System Total Low Stage Compressor Heat Transfer Energy",
    8825              :                                         Constant::Units::J,
    8826            0 :                                         sys.TotCompCoolingEnergy,
    8827              :                                         OutputProcessor::TimeStepType::System,
    8828              :                                         OutputProcessor::StoreType::Sum,
    8829            0 :                                         sys.Name); // indiv compressors go to meter, not system sum
    8830            0 :                     SetupOutputVariable(state,
    8831              :                                         "Refrigeration Air Chiller System Total High Stage Compressor Heat Transfer Rate",
    8832              :                                         Constant::Units::W,
    8833            0 :                                         sys.TotHiStageCompCapacity,
    8834              :                                         OutputProcessor::TimeStepType::System,
    8835              :                                         OutputProcessor::StoreType::Average,
    8836            0 :                                         sys.Name);
    8837            0 :                     SetupOutputVariable(state,
    8838              :                                         "Refrigeration Air Chiller System Total High Stage Compressor Heat Transfer Energy",
    8839              :                                         Constant::Units::J,
    8840            0 :                                         sys.TotHiStageCompCoolingEnergy,
    8841              :                                         OutputProcessor::TimeStepType::System,
    8842              :                                         OutputProcessor::StoreType::Sum,
    8843            0 :                                         sys.Name); // indiv compressors go to meter, not system sum
    8844              :                 } // NumStages
    8845           18 :                 SetupOutputVariable(state,
    8846              :                                     "Refrigeration Air Chiller System Net Rejected Heat Transfer Rate",
    8847              :                                     Constant::Units::W,
    8848            9 :                                     sys.NetHeatRejectLoad,
    8849              :                                     OutputProcessor::TimeStepType::System,
    8850              :                                     OutputProcessor::StoreType::Average,
    8851            9 :                                     sys.Name);
    8852           18 :                 SetupOutputVariable(state,
    8853              :                                     "Refrigeration Air Chiller System Net Rejected Heat Transfer Energy",
    8854              :                                     Constant::Units::J,
    8855            9 :                                     sys.NetHeatRejectEnergy,
    8856              :                                     OutputProcessor::TimeStepType::System,
    8857              :                                     OutputProcessor::StoreType::Sum,
    8858            9 :                                     sys.Name);
    8859           18 :                 SetupOutputVariable(state,
    8860              :                                     "Refrigeration Air Chiller System Estimated Refrigerant Inventory Mass",
    8861              :                                     Constant::Units::kg,
    8862            9 :                                     sys.RefInventory,
    8863              :                                     OutputProcessor::TimeStepType::System,
    8864              :                                     OutputProcessor::StoreType::Average,
    8865            9 :                                     sys.Name);
    8866            9 :                 if (sys.NumStages == 1) {
    8867           18 :                     SetupOutputVariable(state,
    8868              :                                         "Refrigeration Air Chiller System Estimated Refrigerant Mass Flow Rate",
    8869              :                                         Constant::Units::kg_s,
    8870            9 :                                         sys.RefMassFlowComps,
    8871              :                                         OutputProcessor::TimeStepType::System,
    8872              :                                         OutputProcessor::StoreType::Average,
    8873            9 :                                         sys.Name);
    8874            0 :                 } else if (sys.NumStages == 2) {
    8875            0 :                     SetupOutputVariable(state,
    8876              :                                         "Refrigeration Air Chiller System Estimated Low Stage Refrigerant Mass Flow Rate",
    8877              :                                         Constant::Units::kg_s,
    8878            0 :                                         sys.RefMassFlowComps,
    8879              :                                         OutputProcessor::TimeStepType::System,
    8880              :                                         OutputProcessor::StoreType::Average,
    8881            0 :                                         sys.Name);
    8882            0 :                     SetupOutputVariable(state,
    8883              :                                         "Refrigeration Air Chiller System Estimated High Stage Refrigerant Mass Flow Rate",
    8884              :                                         Constant::Units::kg_s,
    8885            0 :                                         sys.RefMassFlowHiStageComps,
    8886              :                                         OutputProcessor::TimeStepType::System,
    8887              :                                         OutputProcessor::StoreType::Average,
    8888            0 :                                         sys.Name);
    8889              :                 } // NumStages
    8890            9 :                 if (sys.NumStages == 2) {
    8891            0 :                     SetupOutputVariable(state,
    8892              :                                         "Refrigeration Air Chiller System Intercooler Temperature",
    8893              :                                         Constant::Units::C,
    8894            0 :                                         sys.TIntercooler,
    8895              :                                         OutputProcessor::TimeStepType::System,
    8896              :                                         OutputProcessor::StoreType::Average,
    8897            0 :                                         sys.Name);
    8898            0 :                     SetupOutputVariable(state,
    8899              :                                         "Refrigeration Air Chiller System Intercooler Pressure",
    8900              :                                         Constant::Units::Pa,
    8901            0 :                                         sys.PIntercooler,
    8902              :                                         OutputProcessor::TimeStepType::System,
    8903              :                                         OutputProcessor::StoreType::Average,
    8904            0 :                                         sys.Name);
    8905              :                 }
    8906           18 :                 SetupOutputVariable(state,
    8907              :                                     "Refrigeration Air Chiller System Condensing Temperature",
    8908              :                                     Constant::Units::C,
    8909            9 :                                     sys.TCondense,
    8910              :                                     OutputProcessor::TimeStepType::System,
    8911              :                                     OutputProcessor::StoreType::Average,
    8912            9 :                                     sys.Name);
    8913           18 :                 SetupOutputVariable(state,
    8914              :                                     "Refrigeration Air Chiller System Evaporating Temperature",
    8915              :                                     Constant::Units::C,
    8916            9 :                                     sys.TEvapNeeded,
    8917              :                                     OutputProcessor::TimeStepType::System,
    8918              :                                     OutputProcessor::StoreType::Average,
    8919            9 :                                     sys.Name);
    8920           18 :                 SetupOutputVariable(state,
    8921              :                                     "Refrigeration Air Chiller System Suction Temperature",
    8922              :                                     Constant::Units::C,
    8923            9 :                                     sys.TCompIn,
    8924              :                                     OutputProcessor::TimeStepType::System,
    8925              :                                     OutputProcessor::StoreType::Average,
    8926            9 :                                     sys.Name);
    8927           18 :                 SetupOutputVariable(state,
    8928              :                                     "Refrigeration Air Chiller System TXV Liquid Temperature",
    8929              :                                     Constant::Units::C,
    8930            9 :                                     sys.TLiqInActual,
    8931              :                                     OutputProcessor::TimeStepType::System,
    8932              :                                     OutputProcessor::StoreType::Average,
    8933            9 :                                     sys.Name);
    8934           18 :                 SetupOutputVariable(state,
    8935              :                                     "Refrigeration Air Chiller System Liquid Suction Subcooler Heat Transfer Rate",
    8936              :                                     Constant::Units::W,
    8937            9 :                                     sys.LSHXTrans,
    8938              :                                     OutputProcessor::TimeStepType::System,
    8939              :                                     OutputProcessor::StoreType::Average,
    8940            9 :                                     sys.Name);
    8941           18 :                 SetupOutputVariable(state,
    8942              :                                     "Refrigeration Air Chiller System Liquid Suction Subcooler Heat Transfer Energy",
    8943              :                                     Constant::Units::J,
    8944            9 :                                     sys.LSHXTransEnergy,
    8945              :                                     OutputProcessor::TimeStepType::System,
    8946              :                                     OutputProcessor::StoreType::Sum,
    8947            9 :                                     sys.Name);
    8948              :             } else { // NOT System(SysNum)%CoilFlag, so serving loads on zone timestep
    8949           32 :                 if (sys.NumStages == 1) {
    8950           60 :                     SetupOutputVariable(state,
    8951              :                                         "Refrigeration System Total Compressor Electricity Rate",
    8952              :                                         Constant::Units::W,
    8953           30 :                                         sys.TotCompPower,
    8954              :                                         OutputProcessor::TimeStepType::Zone,
    8955              :                                         OutputProcessor::StoreType::Average,
    8956           30 :                                         sys.Name);
    8957           60 :                     SetupOutputVariable(state,
    8958              :                                         "Refrigeration System Total Compressor Electricity Energy",
    8959              :                                         Constant::Units::J,
    8960           30 :                                         sys.TotCompElecConsump,
    8961              :                                         OutputProcessor::TimeStepType::Zone,
    8962              :                                         OutputProcessor::StoreType::Sum,
    8963           30 :                                         sys.Name);
    8964            2 :                 } else if (sys.NumStages == 2) {
    8965            4 :                     SetupOutputVariable(state,
    8966              :                                         "Refrigeration System Total Low Stage Compressor Electricity Rate",
    8967              :                                         Constant::Units::W,
    8968            2 :                                         sys.TotCompPower,
    8969              :                                         OutputProcessor::TimeStepType::Zone,
    8970              :                                         OutputProcessor::StoreType::Average,
    8971            2 :                                         sys.Name);
    8972            4 :                     SetupOutputVariable(state,
    8973              :                                         "Refrigeration System Total Low Stage Compressor Electricity Energy",
    8974              :                                         Constant::Units::J,
    8975            2 :                                         sys.TotCompElecConsump,
    8976              :                                         OutputProcessor::TimeStepType::Zone,
    8977              :                                         OutputProcessor::StoreType::Sum,
    8978            2 :                                         sys.Name);
    8979            4 :                     SetupOutputVariable(state,
    8980              :                                         "Refrigeration System Total High Stage Compressor Electricity Rate",
    8981              :                                         Constant::Units::W,
    8982            2 :                                         sys.TotHiStageCompPower,
    8983              :                                         OutputProcessor::TimeStepType::Zone,
    8984              :                                         OutputProcessor::StoreType::Average,
    8985            2 :                                         sys.Name);
    8986            4 :                     SetupOutputVariable(state,
    8987              :                                         "Refrigeration System Total High Stage Compressor Electricity Energy",
    8988              :                                         Constant::Units::J,
    8989            2 :                                         sys.TotHiStageCompElecConsump,
    8990              :                                         OutputProcessor::TimeStepType::Zone,
    8991              :                                         OutputProcessor::StoreType::Sum,
    8992            2 :                                         sys.Name);
    8993            4 :                     SetupOutputVariable(state,
    8994              :                                         "Refrigeration System Total Low and High Stage Compressor Electricity Energy",
    8995              :                                         Constant::Units::J,
    8996            2 :                                         sys.TotCompElecConsumpTwoStage,
    8997              :                                         OutputProcessor::TimeStepType::Zone,
    8998              :                                         OutputProcessor::StoreType::Sum,
    8999            2 :                                         sys.Name);
    9000              :                 } // NumStages
    9001           64 :                 SetupOutputVariable(state,
    9002              :                                     "Refrigeration System Average Compressor COP",
    9003              :                                     Constant::Units::W_W,
    9004           32 :                                     sys.AverageCompressorCOP,
    9005              :                                     OutputProcessor::TimeStepType::Zone,
    9006              :                                     OutputProcessor::StoreType::Average,
    9007           32 :                                     sys.Name);
    9008           64 :                 SetupOutputVariable(state,
    9009              :                                     "Refrigeration System Total Cases and Walk Ins Heat Transfer Rate",
    9010              :                                     Constant::Units::W,
    9011           32 :                                     sys.TotalCoolingLoad,
    9012              :                                     OutputProcessor::TimeStepType::Zone,
    9013              :                                     OutputProcessor::StoreType::Average,
    9014           32 :                                     sys.Name);
    9015           64 :                 SetupOutputVariable(state,
    9016              :                                     "Refrigeration System Total Cases and Walk Ins Heat Transfer Energy",
    9017              :                                     Constant::Units::J,
    9018           32 :                                     sys.TotalCoolingEnergy,
    9019              :                                     OutputProcessor::TimeStepType::Zone,
    9020              :                                     OutputProcessor::StoreType::Sum,
    9021           32 :                                     sys.Name);
    9022           64 :                 SetupOutputVariable(state,
    9023              :                                     "Refrigeration System Total Transferred Load Heat Transfer Rate",
    9024              :                                     Constant::Units::W,
    9025           32 :                                     sys.TotTransferLoad,
    9026              :                                     OutputProcessor::TimeStepType::Zone,
    9027              :                                     OutputProcessor::StoreType::Average,
    9028           32 :                                     sys.Name);
    9029           64 :                 SetupOutputVariable(state,
    9030              :                                     "Refrigeration System Total Transferred Load Heat Transfer Energy",
    9031              :                                     Constant::Units::J,
    9032           32 :                                     sys.TotTransferEnergy,
    9033              :                                     OutputProcessor::TimeStepType::Zone,
    9034              :                                     OutputProcessor::StoreType::Sum,
    9035           32 :                                     sys.Name);
    9036           64 :                 SetupOutputVariable(state,
    9037              :                                     "Refrigeration System Total Suction Pipe Heat Gain Rate",
    9038              :                                     Constant::Units::W,
    9039           32 :                                     sys.PipeHeatLoad,
    9040              :                                     OutputProcessor::TimeStepType::Zone,
    9041              :                                     OutputProcessor::StoreType::Average,
    9042           32 :                                     sys.Name);
    9043           64 :                 SetupOutputVariable(state,
    9044              :                                     "Refrigeration System Total Suction Pipe Heat Gain Energy",
    9045              :                                     Constant::Units::J,
    9046           32 :                                     sys.PipeHeatEnergy,
    9047              :                                     OutputProcessor::TimeStepType::Zone,
    9048              :                                     OutputProcessor::StoreType::Sum,
    9049           32 :                                     sys.Name);
    9050           32 :                 if (sys.NumStages == 1) {
    9051           60 :                     SetupOutputVariable(state,
    9052              :                                         "Refrigeration System Total Compressor Heat Transfer Rate",
    9053              :                                         Constant::Units::W,
    9054           30 :                                         sys.TotCompCapacity,
    9055              :                                         OutputProcessor::TimeStepType::Zone,
    9056              :                                         OutputProcessor::StoreType::Average,
    9057           30 :                                         sys.Name);
    9058           60 :                     SetupOutputVariable(state,
    9059              :                                         "Refrigeration System Total Compressor Heat Transfer Energy",
    9060              :                                         Constant::Units::J,
    9061           30 :                                         sys.TotCompCoolingEnergy,
    9062              :                                         OutputProcessor::TimeStepType::Zone,
    9063              :                                         OutputProcessor::StoreType::Sum,
    9064           30 :                                         sys.Name); // indiv compressors go to meter, not system sum
    9065            2 :                 } else if (sys.NumStages == 2) {
    9066            4 :                     SetupOutputVariable(state,
    9067              :                                         "Refrigeration System Total Low Stage Compressor Heat Transfer Rate",
    9068              :                                         Constant::Units::W,
    9069            2 :                                         sys.TotCompCapacity,
    9070              :                                         OutputProcessor::TimeStepType::Zone,
    9071              :                                         OutputProcessor::StoreType::Average,
    9072            2 :                                         sys.Name);
    9073            4 :                     SetupOutputVariable(state,
    9074              :                                         "Refrigeration System Total Low Stage Compressor Heat Transfer Energy",
    9075              :                                         Constant::Units::J,
    9076            2 :                                         sys.TotCompCoolingEnergy,
    9077              :                                         OutputProcessor::TimeStepType::Zone,
    9078              :                                         OutputProcessor::StoreType::Sum,
    9079            2 :                                         sys.Name); // indiv compressors go to meter, not system sum
    9080            4 :                     SetupOutputVariable(state,
    9081              :                                         "Refrigeration System Total High Stage Compressor Heat Transfer Rate",
    9082              :                                         Constant::Units::W,
    9083            2 :                                         sys.TotHiStageCompCapacity,
    9084              :                                         OutputProcessor::TimeStepType::Zone,
    9085              :                                         OutputProcessor::StoreType::Average,
    9086            2 :                                         sys.Name);
    9087            4 :                     SetupOutputVariable(state,
    9088              :                                         "Refrigeration System Total High Stage Compressor Heat Transfer Energy",
    9089              :                                         Constant::Units::J,
    9090            2 :                                         sys.TotHiStageCompCoolingEnergy,
    9091              :                                         OutputProcessor::TimeStepType::Zone,
    9092              :                                         OutputProcessor::StoreType::Sum,
    9093            2 :                                         sys.Name); // indiv compressors go to meter, not system sum
    9094              :                 } // NumStages
    9095           64 :                 SetupOutputVariable(state,
    9096              :                                     "Refrigeration System Net Rejected Heat Transfer Rate",
    9097              :                                     Constant::Units::W,
    9098           32 :                                     sys.NetHeatRejectLoad,
    9099              :                                     OutputProcessor::TimeStepType::Zone,
    9100              :                                     OutputProcessor::StoreType::Average,
    9101           32 :                                     sys.Name);
    9102           64 :                 SetupOutputVariable(state,
    9103              :                                     "Refrigeration System Net Rejected Heat Transfer Energy",
    9104              :                                     Constant::Units::J,
    9105           32 :                                     sys.NetHeatRejectEnergy,
    9106              :                                     OutputProcessor::TimeStepType::Zone,
    9107              :                                     OutputProcessor::StoreType::Sum,
    9108           32 :                                     sys.Name);
    9109           64 :                 SetupOutputVariable(state,
    9110              :                                     "Refrigeration System Estimated Refrigerant Inventory Mass",
    9111              :                                     Constant::Units::kg,
    9112           32 :                                     sys.RefInventory,
    9113              :                                     OutputProcessor::TimeStepType::Zone,
    9114              :                                     OutputProcessor::StoreType::Average,
    9115           32 :                                     sys.Name);
    9116           32 :                 if (sys.NumStages == 1) {
    9117           60 :                     SetupOutputVariable(state,
    9118              :                                         "Refrigeration System Estimated Refrigerant Mass Flow Rate",
    9119              :                                         Constant::Units::kg_s,
    9120           30 :                                         sys.RefMassFlowComps,
    9121              :                                         OutputProcessor::TimeStepType::Zone,
    9122              :                                         OutputProcessor::StoreType::Average,
    9123           30 :                                         sys.Name);
    9124            2 :                 } else if (sys.NumStages == 2) {
    9125            4 :                     SetupOutputVariable(state,
    9126              :                                         "Refrigeration System Estimated Low Stage Refrigerant Mass Flow Rate",
    9127              :                                         Constant::Units::kg_s,
    9128            2 :                                         sys.RefMassFlowComps,
    9129              :                                         OutputProcessor::TimeStepType::Zone,
    9130              :                                         OutputProcessor::StoreType::Average,
    9131            2 :                                         sys.Name);
    9132            4 :                     SetupOutputVariable(state,
    9133              :                                         "Refrigeration System Estimated High Stage Refrigerant Mass Flow Rate",
    9134              :                                         Constant::Units::kg_s,
    9135            2 :                                         sys.RefMassFlowHiStageComps,
    9136              :                                         OutputProcessor::TimeStepType::Zone,
    9137              :                                         OutputProcessor::StoreType::Average,
    9138            2 :                                         sys.Name);
    9139              :                 } // NumStages
    9140           32 :                 if (sys.NumStages == 2) {
    9141            4 :                     SetupOutputVariable(state,
    9142              :                                         "Refrigeration System Intercooler Temperature",
    9143              :                                         Constant::Units::C,
    9144            2 :                                         sys.TIntercooler,
    9145              :                                         OutputProcessor::TimeStepType::Zone,
    9146              :                                         OutputProcessor::StoreType::Average,
    9147            2 :                                         sys.Name);
    9148            4 :                     SetupOutputVariable(state,
    9149              :                                         "Refrigeration System Intercooler Pressure",
    9150              :                                         Constant::Units::Pa,
    9151            2 :                                         sys.PIntercooler,
    9152              :                                         OutputProcessor::TimeStepType::Zone,
    9153              :                                         OutputProcessor::StoreType::Average,
    9154            2 :                                         sys.Name);
    9155              :                 }
    9156           64 :                 SetupOutputVariable(state,
    9157              :                                     "Refrigeration System Condensing Temperature",
    9158              :                                     Constant::Units::C,
    9159           32 :                                     sys.TCondense,
    9160              :                                     OutputProcessor::TimeStepType::Zone,
    9161              :                                     OutputProcessor::StoreType::Average,
    9162           32 :                                     sys.Name);
    9163           64 :                 SetupOutputVariable(state,
    9164              :                                     "Refrigeration System Evaporating Temperature",
    9165              :                                     Constant::Units::C,
    9166           32 :                                     sys.TEvapNeeded,
    9167              :                                     OutputProcessor::TimeStepType::Zone,
    9168              :                                     OutputProcessor::StoreType::Average,
    9169           32 :                                     sys.Name);
    9170           64 :                 SetupOutputVariable(state,
    9171              :                                     "Refrigeration System Suction Pipe Suction Temperature",
    9172              :                                     Constant::Units::C,
    9173           32 :                                     sys.TCompIn,
    9174              :                                     OutputProcessor::TimeStepType::Zone,
    9175              :                                     OutputProcessor::StoreType::Average,
    9176           32 :                                     sys.Name);
    9177           64 :                 SetupOutputVariable(state,
    9178              :                                     "Refrigeration System Thermostatic Expansion Valve Liquid Temperature",
    9179              :                                     Constant::Units::C,
    9180           32 :                                     sys.TLiqInActual,
    9181              :                                     OutputProcessor::TimeStepType::Zone,
    9182              :                                     OutputProcessor::StoreType::Average,
    9183           32 :                                     sys.Name);
    9184           64 :                 SetupOutputVariable(state,
    9185              :                                     "Refrigeration System Liquid Suction Subcooler Heat Transfer Rate",
    9186              :                                     Constant::Units::W,
    9187           32 :                                     sys.LSHXTrans,
    9188              :                                     OutputProcessor::TimeStepType::Zone,
    9189              :                                     OutputProcessor::StoreType::Average,
    9190           32 :                                     sys.Name);
    9191           64 :                 SetupOutputVariable(state,
    9192              :                                     "Refrigeration System Liquid Suction Subcooler Heat Transfer Energy",
    9193              :                                     Constant::Units::J,
    9194           32 :                                     sys.LSHXTransEnergy,
    9195              :                                     OutputProcessor::TimeStepType::Zone,
    9196              :                                     OutputProcessor::StoreType::Sum,
    9197           32 :                                     sys.Name);
    9198              :             } // System(coilflag)
    9199              : 
    9200           41 :             if (sys.SystemRejectHeatToZone) {
    9201            3 :                 if (Condenser(sys.CondenserNum(1)).InletAirZoneNum > 0) {
    9202            3 :                     SetupZoneInternalGain(state,
    9203            3 :                                           Condenser(sys.CondenserNum(1)).InletAirZoneNum,
    9204              :                                           sys.Name,
    9205              :                                           DataHeatBalance::IntGainType::RefrigerationSystemAirCooledCondenser,
    9206              :                                           &sys.NetHeatRejectLoad);
    9207              :                 }
    9208              : 
    9209            3 :                 if (sys.SuctionPipeActualZoneNum > 0) {
    9210            0 :                     SetupZoneInternalGain(state,
    9211              :                                           sys.SuctionPipeActualZoneNum,
    9212              :                                           sys.Name,
    9213              :                                           DataHeatBalance::IntGainType::RefrigerationSystemSuctionPipe,
    9214              :                                           &sys.PipeHeatLoad);
    9215              :                 }
    9216              :             }
    9217              :         } // numrefrigsystems
    9218              : 
    9219              :         // Report Compressor ENERGY here, not on system level for meters.
    9220          191 :         for (int compNum = 1; compNum <= state.dataRefrigCase->NumSimulationCompressors; ++compNum) {
    9221          176 :             auto &comp = Compressor(compNum);
    9222              :             // CurrentModuleObject='Refrigeration:Compressor'
    9223          176 :             if (comp.NumSysAttach == 1) { // only set up reports for compressors that are used once and only once
    9224          176 :                 if (comp.CoilFlag) {      // Compressor serving system with chillers on HVAC time step
    9225          142 :                     SetupOutputVariable(state,
    9226              :                                         "Refrigeration Air Chiller System Compressor Electricity Rate",
    9227              :                                         Constant::Units::W,
    9228           71 :                                         comp.Power,
    9229              :                                         OutputProcessor::TimeStepType::System,
    9230              :                                         OutputProcessor::StoreType::Average,
    9231           71 :                                         comp.Name);
    9232          142 :                     SetupOutputVariable(state,
    9233              :                                         "Refrigeration Air Chiller System Compressor Electricity Energy",
    9234              :                                         Constant::Units::J,
    9235           71 :                                         comp.ElecConsumption,
    9236              :                                         OutputProcessor::TimeStepType::System,
    9237              :                                         OutputProcessor::StoreType::Sum,
    9238           71 :                                         comp.Name,
    9239              :                                         Constant::eResource::Electricity,
    9240              :                                         OutputProcessor::Group::Plant,
    9241              :                                         OutputProcessor::EndUseCat::Refrigeration,
    9242              :                                         comp.EndUseSubcategory);
    9243          142 :                     SetupOutputVariable(state,
    9244              :                                         "Refrigeration Air Chiller System Compressor Heat Transfer Rate",
    9245              :                                         Constant::Units::W,
    9246           71 :                                         comp.Capacity,
    9247              :                                         OutputProcessor::TimeStepType::System,
    9248              :                                         OutputProcessor::StoreType::Average,
    9249           71 :                                         comp.Name);
    9250          142 :                     SetupOutputVariable(state,
    9251              :                                         "Refrigeration Air Chiller System Compressor Heat Transfer Energy",
    9252              :                                         Constant::Units::J,
    9253           71 :                                         comp.CoolingEnergy,
    9254              :                                         OutputProcessor::TimeStepType::System,
    9255              :                                         OutputProcessor::StoreType::Sum,
    9256           71 :                                         comp.Name);
    9257          142 :                     SetupOutputVariable(state,
    9258              :                                         "Refrigeration Air Chiller System Compressor Runtime Fraction",
    9259              :                                         Constant::Units::None,
    9260           71 :                                         comp.LoadFactor,
    9261              :                                         OutputProcessor::TimeStepType::System,
    9262              :                                         OutputProcessor::StoreType::Average,
    9263           71 :                                         comp.Name);
    9264              :                 } else { // serve cases/walkins on zone time step
    9265          210 :                     SetupOutputVariable(state,
    9266              :                                         "Refrigeration Compressor Electricity Rate",
    9267              :                                         Constant::Units::W,
    9268          105 :                                         comp.Power,
    9269              :                                         OutputProcessor::TimeStepType::Zone,
    9270              :                                         OutputProcessor::StoreType::Average,
    9271          105 :                                         comp.Name);
    9272          210 :                     SetupOutputVariable(state,
    9273              :                                         "Refrigeration Compressor Electricity Energy",
    9274              :                                         Constant::Units::J,
    9275          105 :                                         comp.ElecConsumption,
    9276              :                                         OutputProcessor::TimeStepType::Zone,
    9277              :                                         OutputProcessor::StoreType::Sum,
    9278          105 :                                         comp.Name,
    9279              :                                         Constant::eResource::Electricity,
    9280              :                                         OutputProcessor::Group::Plant,
    9281              :                                         OutputProcessor::EndUseCat::Refrigeration,
    9282              :                                         comp.EndUseSubcategory);
    9283          210 :                     SetupOutputVariable(state,
    9284              :                                         "Refrigeration Compressor Heat Transfer Rate",
    9285              :                                         Constant::Units::W,
    9286          105 :                                         comp.Capacity,
    9287              :                                         OutputProcessor::TimeStepType::Zone,
    9288              :                                         OutputProcessor::StoreType::Average,
    9289          105 :                                         comp.Name);
    9290          210 :                     SetupOutputVariable(state,
    9291              :                                         "Refrigeration Compressor Heat Transfer Energy",
    9292              :                                         Constant::Units::J,
    9293          105 :                                         comp.CoolingEnergy,
    9294              :                                         OutputProcessor::TimeStepType::Zone,
    9295              :                                         OutputProcessor::StoreType::Sum,
    9296          105 :                                         comp.Name);
    9297          210 :                     SetupOutputVariable(state,
    9298              :                                         "Refrigeration Compressor Runtime Fraction",
    9299              :                                         Constant::Units::None,
    9300          105 :                                         comp.LoadFactor,
    9301              :                                         OutputProcessor::TimeStepType::Zone,
    9302              :                                         OutputProcessor::StoreType::Average,
    9303          105 :                                         comp.Name);
    9304              :                 } // Serve coils on HVAC time step or cases/walkins on Zone time step
    9305              :             } // NumSysAttach
    9306              :         } // CompNum on NumSimulationCompressors
    9307              : 
    9308              :         // Report Variables for Refrigeration Condensers
    9309           54 :         for (int condNum = 1; condNum <= state.dataRefrigCase->NumRefrigCondensers; ++condNum) {
    9310           39 :             auto &cond = Condenser(condNum);
    9311              :             // CurrentModuleObject='Refrigeration:Condenser:*'
    9312           39 :             if (cond.CoilFlag) { // Condenser serving system with chillers on HVAC time step
    9313           18 :                 SetupOutputVariable(state,
    9314              :                                     "Refrigeration Air Chiller System Condenser Heat Transfer Rate",
    9315              :                                     Constant::Units::W,
    9316            9 :                                     cond.CondLoad,
    9317              :                                     OutputProcessor::TimeStepType::System,
    9318              :                                     OutputProcessor::StoreType::Average,
    9319            9 :                                     cond.Name);
    9320           18 :                 SetupOutputVariable(state,
    9321              :                                     "Refrigeration Air Chiller System Condenser Heat Transfer Energy",
    9322              :                                     Constant::Units::J,
    9323            9 :                                     cond.CondEnergy,
    9324              :                                     OutputProcessor::TimeStepType::System,
    9325              :                                     OutputProcessor::StoreType::Sum,
    9326            9 :                                     cond.Name);
    9327              : 
    9328            9 :                 if (cond.CondenserType != DataHeatBalance::RefrigCondenserType::Cascade) {
    9329           18 :                     SetupOutputVariable(state,
    9330              :                                         "Refrigeration Air Chiller System Condenser Total Recovered Heat Transfer Rate",
    9331              :                                         Constant::Units::W,
    9332            9 :                                         cond.TotalHeatRecoveredLoad,
    9333              :                                         OutputProcessor::TimeStepType::System,
    9334              :                                         OutputProcessor::StoreType::Average,
    9335            9 :                                         cond.Name);
    9336           18 :                     SetupOutputVariable(state,
    9337              :                                         "Refrigeration Air Chiller System Condenser Total Recovered Heat Transfer Energy",
    9338              :                                         Constant::Units::J,
    9339            9 :                                         cond.TotalHeatRecoveredEnergy,
    9340              :                                         OutputProcessor::TimeStepType::System,
    9341              :                                         OutputProcessor::StoreType::Sum,
    9342            9 :                                         cond.Name);
    9343           18 :                     SetupOutputVariable(state,
    9344              :                                         "Refrigeration Air Chiller System Condenser Non Refrigeration Recovered Heat Transfer Rate",
    9345              :                                         Constant::Units::W,
    9346            9 :                                         cond.ExternalHeatRecoveredLoad,
    9347              :                                         OutputProcessor::TimeStepType::System,
    9348              :                                         OutputProcessor::StoreType::Average,
    9349            9 :                                         cond.Name);
    9350           18 :                     SetupOutputVariable(state,
    9351              :                                         "Refrigeration Air Chiller System Condenser Non Refrigeration Recovered Heat Transfer Energy",
    9352              :                                         Constant::Units::J,
    9353            9 :                                         cond.ExternalEnergyRecovered,
    9354              :                                         OutputProcessor::TimeStepType::System,
    9355              :                                         OutputProcessor::StoreType::Sum,
    9356            9 :                                         cond.Name);
    9357           18 :                     SetupOutputVariable(state,
    9358              :                                         "Refrigeration Air Chiller System Condenser Defrost Recovered Heat Transfer Rate",
    9359              :                                         Constant::Units::W,
    9360            9 :                                         cond.InternalHeatRecoveredLoad,
    9361              :                                         OutputProcessor::TimeStepType::System,
    9362              :                                         OutputProcessor::StoreType::Average,
    9363            9 :                                         cond.Name);
    9364           18 :                     SetupOutputVariable(state,
    9365              :                                         "Refrigeration Air Chiller System Condenser Defrost Recovered Heat Transfer Energy",
    9366              :                                         Constant::Units::J,
    9367            9 :                                         cond.InternalEnergyRecovered,
    9368              :                                         OutputProcessor::TimeStepType::System,
    9369              :                                         OutputProcessor::StoreType::Sum,
    9370            9 :                                         cond.Name);
    9371              :                 } // not cascade because recovered energy on cascade systems passed up to higher temperature system
    9372              : 
    9373            9 :                 if (cond.CondenserType == DataHeatBalance::RefrigCondenserType::Air) {
    9374           18 :                     SetupOutputVariable(state,
    9375              :                                         "Refrigeration Air Chiller System Condenser Fan Electricity Rate",
    9376              :                                         Constant::Units::W,
    9377            9 :                                         cond.ActualFanPower,
    9378              :                                         OutputProcessor::TimeStepType::System,
    9379              :                                         OutputProcessor::StoreType::Average,
    9380            9 :                                         cond.Name);
    9381           18 :                     SetupOutputVariable(state,
    9382              :                                         "Refrigeration Air Chiller System Condenser Fan Electricity Energy",
    9383              :                                         Constant::Units::J,
    9384            9 :                                         cond.FanElecEnergy,
    9385              :                                         OutputProcessor::TimeStepType::System,
    9386              :                                         OutputProcessor::StoreType::Sum,
    9387            9 :                                         cond.Name,
    9388              :                                         Constant::eResource::Electricity,
    9389              :                                         OutputProcessor::Group::Plant,
    9390              :                                         OutputProcessor::EndUseCat::Refrigeration,
    9391              :                                         cond.EndUseSubcategory);
    9392              :                 } // Air cooled
    9393              : 
    9394            9 :                 if (cond.CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
    9395            0 :                     SetupOutputVariable(state,
    9396              :                                         "Refrigeration Air Chiller System Condenser Fan Electricity Rate",
    9397              :                                         Constant::Units::W,
    9398            0 :                                         cond.ActualFanPower,
    9399              :                                         OutputProcessor::TimeStepType::System,
    9400              :                                         OutputProcessor::StoreType::Average,
    9401            0 :                                         cond.Name);
    9402            0 :                     SetupOutputVariable(state,
    9403              :                                         "Refrigeration Air Chiller System Condenser Fan Electricity Energy",
    9404              :                                         Constant::Units::J,
    9405            0 :                                         cond.FanElecEnergy,
    9406              :                                         OutputProcessor::TimeStepType::System,
    9407              :                                         OutputProcessor::StoreType::Sum,
    9408            0 :                                         cond.Name,
    9409              :                                         Constant::eResource::Electricity,
    9410              :                                         OutputProcessor::Group::Plant,
    9411              :                                         OutputProcessor::EndUseCat::Refrigeration,
    9412              :                                         cond.EndUseSubcategory);
    9413            0 :                     SetupOutputVariable(state,
    9414              :                                         "Refrigeration Air Chiller System Condenser Pump Electricity Rate",
    9415              :                                         Constant::Units::W,
    9416            0 :                                         cond.ActualEvapPumpPower,
    9417              :                                         OutputProcessor::TimeStepType::System,
    9418              :                                         OutputProcessor::StoreType::Average,
    9419            0 :                                         cond.Name);
    9420            0 :                     SetupOutputVariable(state,
    9421              :                                         "Refrigeration Air Chiller System Condenser Pump Electricity Energy",
    9422              :                                         Constant::Units::J,
    9423            0 :                                         cond.EvapPumpConsumption,
    9424              :                                         OutputProcessor::TimeStepType::System,
    9425              :                                         OutputProcessor::StoreType::Sum,
    9426            0 :                                         cond.Name,
    9427              :                                         Constant::eResource::Electricity,
    9428              :                                         OutputProcessor::Group::Plant,
    9429              :                                         OutputProcessor::EndUseCat::Refrigeration,
    9430              :                                         cond.EndUseSubcategory);
    9431            0 :                     SetupOutputVariable(state,
    9432              :                                         "Refrigeration Air Chiller System Condenser Basin Heater Electricity Rate",
    9433              :                                         Constant::Units::W,
    9434            0 :                                         cond.BasinHeaterPower,
    9435              :                                         OutputProcessor::TimeStepType::System,
    9436              :                                         OutputProcessor::StoreType::Average,
    9437            0 :                                         cond.Name);
    9438            0 :                     SetupOutputVariable(state,
    9439              :                                         "Refrigeration Air Chiller System Condenser Basin Heater Electricity Energy",
    9440              :                                         Constant::Units::J,
    9441            0 :                                         cond.BasinHeaterConsumption,
    9442              :                                         OutputProcessor::TimeStepType::System,
    9443              :                                         OutputProcessor::StoreType::Sum,
    9444            0 :                                         cond.Name,
    9445              :                                         Constant::eResource::Electricity,
    9446              :                                         OutputProcessor::Group::Plant,
    9447              :                                         OutputProcessor::EndUseCat::Refrigeration,
    9448              :                                         cond.EndUseSubcategory);
    9449            0 :                     SetupOutputVariable(state,
    9450              :                                         "Refrigeration Air Chiller System Condenser Evaporated Water Volume Flow Rate",
    9451              :                                         Constant::Units::m3_s,
    9452            0 :                                         cond.EvapWaterConsumpRate,
    9453              :                                         OutputProcessor::TimeStepType::System,
    9454              :                                         OutputProcessor::StoreType::Average,
    9455            0 :                                         cond.Name);
    9456            0 :                     SetupOutputVariable(state,
    9457              :                                         "Refrigeration Air Chiller System Condenser Evaporated Water Volume",
    9458              :                                         Constant::Units::m3,
    9459            0 :                                         cond.EvapWaterConsumption,
    9460              :                                         OutputProcessor::TimeStepType::System,
    9461              :                                         OutputProcessor::StoreType::Sum,
    9462            0 :                                         cond.Name,
    9463              :                                         Constant::eResource::Water,
    9464              :                                         OutputProcessor::Group::Plant,
    9465              :                                         OutputProcessor::EndUseCat::Refrigeration,
    9466              :                                         cond.EndUseSubcategory);
    9467              :                 } // Evaporative Condenser Variables
    9468              : 
    9469            9 :                 if (cond.CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
    9470            0 :                     SetupOutputVariable(state,
    9471              :                                         "Refrigeration Air Chiller System Condenser Fluid Mass Flow Rate",
    9472              :                                         Constant::Units::kg_s,
    9473            0 :                                         cond.MassFlowRate,
    9474              :                                         OutputProcessor::TimeStepType::System,
    9475              :                                         OutputProcessor::StoreType::Average,
    9476            0 :                                         cond.Name);
    9477              : 
    9478              :                 } // Water-cooled Condenser variables
    9479              : 
    9480              :             } else { // Serving loads/systems with cases and walkins on zone time step
    9481              : 
    9482           60 :                 SetupOutputVariable(state,
    9483              :                                     "Refrigeration System Condenser Heat Transfer Rate",
    9484              :                                     Constant::Units::W,
    9485           30 :                                     cond.CondLoad,
    9486              :                                     OutputProcessor::TimeStepType::Zone,
    9487              :                                     OutputProcessor::StoreType::Average,
    9488           30 :                                     cond.Name);
    9489           60 :                 SetupOutputVariable(state,
    9490              :                                     "Refrigeration System Condenser Heat Transfer Energy",
    9491              :                                     Constant::Units::J,
    9492           30 :                                     cond.CondEnergy,
    9493              :                                     OutputProcessor::TimeStepType::Zone,
    9494              :                                     OutputProcessor::StoreType::Sum,
    9495           30 :                                     cond.Name);
    9496              : 
    9497           30 :                 if (cond.CondenserType != DataHeatBalance::RefrigCondenserType::Cascade) {
    9498           58 :                     SetupOutputVariable(state,
    9499              :                                         "Refrigeration System Condenser Total Recovered Heat Transfer Rate",
    9500              :                                         Constant::Units::W,
    9501           29 :                                         cond.TotalHeatRecoveredLoad,
    9502              :                                         OutputProcessor::TimeStepType::Zone,
    9503              :                                         OutputProcessor::StoreType::Average,
    9504           29 :                                         cond.Name);
    9505           58 :                     SetupOutputVariable(state,
    9506              :                                         "Refrigeration System Condenser Total Recovered Heat Transfer Energy",
    9507              :                                         Constant::Units::J,
    9508           29 :                                         cond.TotalHeatRecoveredEnergy,
    9509              :                                         OutputProcessor::TimeStepType::Zone,
    9510              :                                         OutputProcessor::StoreType::Sum,
    9511           29 :                                         cond.Name);
    9512           58 :                     SetupOutputVariable(state,
    9513              :                                         "Refrigeration System Condenser Non Refrigeration Recovered Heat Transfer Rate",
    9514              :                                         Constant::Units::W,
    9515           29 :                                         cond.ExternalHeatRecoveredLoad,
    9516              :                                         OutputProcessor::TimeStepType::Zone,
    9517              :                                         OutputProcessor::StoreType::Average,
    9518           29 :                                         cond.Name);
    9519           58 :                     SetupOutputVariable(state,
    9520              :                                         "Refrigeration System Condenser Non Refrigeration Recovered Heat Transfer Energy",
    9521              :                                         Constant::Units::J,
    9522           29 :                                         cond.ExternalEnergyRecovered,
    9523              :                                         OutputProcessor::TimeStepType::Zone,
    9524              :                                         OutputProcessor::StoreType::Sum,
    9525           29 :                                         cond.Name);
    9526           58 :                     SetupOutputVariable(state,
    9527              :                                         "Refrigeration System Condenser Defrost Recovered Heat Transfer Rate",
    9528              :                                         Constant::Units::W,
    9529           29 :                                         cond.InternalHeatRecoveredLoad,
    9530              :                                         OutputProcessor::TimeStepType::Zone,
    9531              :                                         OutputProcessor::StoreType::Average,
    9532           29 :                                         cond.Name);
    9533           58 :                     SetupOutputVariable(state,
    9534              :                                         "Refrigeration System Condenser Defrost Recovered Heat Transfer Energy",
    9535              :                                         Constant::Units::J,
    9536           29 :                                         cond.InternalEnergyRecovered,
    9537              :                                         OutputProcessor::TimeStepType::Zone,
    9538              :                                         OutputProcessor::StoreType::Sum,
    9539           29 :                                         cond.Name);
    9540              :                 } // not cascade because recovered energy on cascade systems passed up to higher temperature system
    9541              : 
    9542           30 :                 if (cond.CondenserType == DataHeatBalance::RefrigCondenserType::Air) {
    9543           50 :                     SetupOutputVariable(state,
    9544              :                                         "Refrigeration System Condenser Fan Electricity Rate",
    9545              :                                         Constant::Units::W,
    9546           25 :                                         cond.ActualFanPower,
    9547              :                                         OutputProcessor::TimeStepType::Zone,
    9548              :                                         OutputProcessor::StoreType::Average,
    9549           25 :                                         cond.Name);
    9550           50 :                     SetupOutputVariable(state,
    9551              :                                         "Refrigeration System Condenser Fan Electricity Energy",
    9552              :                                         Constant::Units::J,
    9553           25 :                                         cond.FanElecEnergy,
    9554              :                                         OutputProcessor::TimeStepType::Zone,
    9555              :                                         OutputProcessor::StoreType::Sum,
    9556           25 :                                         cond.Name,
    9557              :                                         Constant::eResource::Electricity,
    9558              :                                         OutputProcessor::Group::Plant,
    9559              :                                         OutputProcessor::EndUseCat::Refrigeration,
    9560              :                                         cond.EndUseSubcategory);
    9561              :                 } // Air cooled
    9562              : 
    9563           30 :                 if (cond.CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
    9564            6 :                     SetupOutputVariable(state,
    9565              :                                         "Refrigeration System Condenser Fan Electricity Rate",
    9566              :                                         Constant::Units::W,
    9567            3 :                                         cond.ActualFanPower,
    9568              :                                         OutputProcessor::TimeStepType::Zone,
    9569              :                                         OutputProcessor::StoreType::Average,
    9570            3 :                                         cond.Name);
    9571            6 :                     SetupOutputVariable(state,
    9572              :                                         "Refrigeration System Condenser Fan Electricity Energy",
    9573              :                                         Constant::Units::J,
    9574            3 :                                         cond.FanElecEnergy,
    9575              :                                         OutputProcessor::TimeStepType::Zone,
    9576              :                                         OutputProcessor::StoreType::Sum,
    9577            3 :                                         cond.Name,
    9578              :                                         Constant::eResource::Electricity,
    9579              :                                         OutputProcessor::Group::Plant,
    9580              :                                         OutputProcessor::EndUseCat::Refrigeration,
    9581              :                                         cond.EndUseSubcategory);
    9582            6 :                     SetupOutputVariable(state,
    9583              :                                         "Refrigeration System Condenser Pump Electricity Rate",
    9584              :                                         Constant::Units::W,
    9585            3 :                                         cond.ActualEvapPumpPower,
    9586              :                                         OutputProcessor::TimeStepType::Zone,
    9587              :                                         OutputProcessor::StoreType::Average,
    9588            3 :                                         cond.Name);
    9589            6 :                     SetupOutputVariable(state,
    9590              :                                         "Refrigeration System Condenser Pump Electricity Energy",
    9591              :                                         Constant::Units::J,
    9592            3 :                                         cond.EvapPumpConsumption,
    9593              :                                         OutputProcessor::TimeStepType::Zone,
    9594              :                                         OutputProcessor::StoreType::Sum,
    9595            3 :                                         cond.Name,
    9596              :                                         Constant::eResource::Electricity,
    9597              :                                         OutputProcessor::Group::Plant,
    9598              :                                         OutputProcessor::EndUseCat::Refrigeration,
    9599              :                                         cond.EndUseSubcategory);
    9600            6 :                     SetupOutputVariable(state,
    9601              :                                         "Refrigeration System Condenser Basin Heater Electricity Rate",
    9602              :                                         Constant::Units::W,
    9603            3 :                                         cond.BasinHeaterPower,
    9604              :                                         OutputProcessor::TimeStepType::Zone,
    9605              :                                         OutputProcessor::StoreType::Average,
    9606            3 :                                         cond.Name);
    9607            6 :                     SetupOutputVariable(state,
    9608              :                                         "Refrigeration System Condenser Basin Heater Electricity Energy",
    9609              :                                         Constant::Units::J,
    9610            3 :                                         cond.BasinHeaterConsumption,
    9611              :                                         OutputProcessor::TimeStepType::Zone,
    9612              :                                         OutputProcessor::StoreType::Sum,
    9613            3 :                                         cond.Name,
    9614              :                                         Constant::eResource::Electricity,
    9615              :                                         OutputProcessor::Group::Plant,
    9616              :                                         OutputProcessor::EndUseCat::Refrigeration,
    9617              :                                         cond.EndUseSubcategory);
    9618            6 :                     SetupOutputVariable(state,
    9619              :                                         "Refrigeration System Condenser Evaporated Water Volume Flow Rate",
    9620              :                                         Constant::Units::m3_s,
    9621            3 :                                         cond.EvapWaterConsumpRate,
    9622              :                                         OutputProcessor::TimeStepType::Zone,
    9623              :                                         OutputProcessor::StoreType::Average,
    9624            3 :                                         cond.Name);
    9625            6 :                     SetupOutputVariable(state,
    9626              :                                         "Refrigeration System Condenser Evaporated Water Volume",
    9627              :                                         Constant::Units::m3,
    9628            3 :                                         cond.EvapWaterConsumption,
    9629              :                                         OutputProcessor::TimeStepType::Zone,
    9630              :                                         OutputProcessor::StoreType::Sum,
    9631            3 :                                         cond.Name,
    9632              :                                         Constant::eResource::Water,
    9633              :                                         OutputProcessor::Group::Plant,
    9634              :                                         OutputProcessor::EndUseCat::Refrigeration,
    9635              :                                         cond.EndUseSubcategory);
    9636              :                 } // Evaporative Condenser Variables
    9637              : 
    9638           30 :                 if (cond.CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
    9639            2 :                     SetupOutputVariable(state,
    9640              :                                         "Refrigeration System Condenser Water Mass Flow Rate",
    9641              :                                         Constant::Units::kg_s,
    9642            1 :                                         cond.MassFlowRate,
    9643              :                                         OutputProcessor::TimeStepType::System,
    9644              :                                         OutputProcessor::StoreType::Average,
    9645            1 :                                         cond.Name);
    9646              : 
    9647              :                 } // Water-cooled Condenser variables
    9648              :             } // Condenser%CoilFlag to distinguish HVAC vs Zone time steps
    9649              :         } // CondNum on DataHeatBalance::NumRefrigCondensers
    9650              : 
    9651           15 :         if (state.dataRefrigCase->NumSimulationSubcoolers > 0) {
    9652            3 :             for (int subcoolNum = 1; subcoolNum <= state.dataRefrigCase->NumSimulationSubcoolers; ++subcoolNum) {
    9653            2 :                 auto &cooler = Subcooler(subcoolNum);
    9654              :                 // CurrentModuleObject='Refrigeration:Subcooler'
    9655            2 :                 if (cooler.CoilFlag) { // Subcooler serving system with chillers on HVAC time step
    9656            0 :                     if (cooler.subcoolerType == SubcoolerType::Mechanical) {
    9657            0 :                         SetupOutputVariable(state,
    9658              :                                             "Refrigeration Air Chiller System Mechanical Subcooler Heat Transfer Rate",
    9659              :                                             Constant::Units::W,
    9660            0 :                                             cooler.MechSCTransLoad,
    9661              :                                             OutputProcessor::TimeStepType::Zone,
    9662              :                                             OutputProcessor::StoreType::Average,
    9663            0 :                                             cooler.Name);
    9664            0 :                         SetupOutputVariable(state,
    9665              :                                             "Refrigeration Air Chiller System Mechanical Subcooler Heat Transfer Energy",
    9666              :                                             Constant::Units::J,
    9667            0 :                                             cooler.MechSCTransEnergy,
    9668              :                                             OutputProcessor::TimeStepType::Zone,
    9669              :                                             OutputProcessor::StoreType::Sum,
    9670            0 :                                             cooler.Name);
    9671              :                     }
    9672              :                 } else { // Subcooler on system serving cases and/or walkins
    9673            2 :                     if (cooler.subcoolerType == SubcoolerType::Mechanical) {
    9674            2 :                         SetupOutputVariable(state,
    9675              :                                             "Refrigeration System Mechanical Subcooler Heat Transfer Rate",
    9676              :                                             Constant::Units::W,
    9677            1 :                                             cooler.MechSCTransLoad,
    9678              :                                             OutputProcessor::TimeStepType::System,
    9679              :                                             OutputProcessor::StoreType::Average,
    9680            1 :                                             cooler.Name);
    9681            2 :                         SetupOutputVariable(state,
    9682              :                                             "Refrigeration System Mechanical Subcooler Heat Transfer Energy",
    9683              :                                             Constant::Units::J,
    9684            1 :                                             cooler.MechSCTransEnergy,
    9685              :                                             OutputProcessor::TimeStepType::System,
    9686              :                                             OutputProcessor::StoreType::Sum,
    9687            1 :                                             cooler.Name);
    9688              :                     }
    9689              :                 } // Subcoolers on system serving chillers
    9690              :             } // Subcoolnum on NumSimulationSubcoolers
    9691              :         } // NumSimulationSubcoolers > 0
    9692              : 
    9693              :     } // NumRefrigSystems > 0
    9694              : 
    9695          801 :     if (state.dataRefrigCase->NumTransRefrigSystems > 0) {
    9696              :         // CurrentModuleObject='Refrigeration:TranscriticalSystem'
    9697            2 :         for (int refrigSysNum = 1; refrigSysNum <= state.dataRefrigCase->NumTransRefrigSystems; ++refrigSysNum) {
    9698            1 :             auto &sys = TransSystem(refrigSysNum);
    9699              :             // for both SingleStage and TwoStage systems (medium temperature loads present)
    9700            2 :             SetupOutputVariable(state,
    9701              :                                 "Refrigeration Transcritical System Total High Pressure Compressor Electricity Rate",
    9702              :                                 Constant::Units::W,
    9703            1 :                                 sys.TotCompPowerHP,
    9704              :                                 OutputProcessor::TimeStepType::Zone,
    9705              :                                 OutputProcessor::StoreType::Average,
    9706            1 :                                 sys.Name);
    9707            2 :             SetupOutputVariable(state,
    9708              :                                 "Refrigeration Transcritical System Total High Pressure Compressor Electricity Energy",
    9709              :                                 Constant::Units::J,
    9710            1 :                                 sys.TotCompElecConsumpHP,
    9711              :                                 OutputProcessor::TimeStepType::Zone,
    9712              :                                 OutputProcessor::StoreType::Sum,
    9713            1 :                                 sys.Name);
    9714            2 :             SetupOutputVariable(state,
    9715              :                                 "Refrigeration Transcritical System Total Compressor Electricity Energy",
    9716              :                                 Constant::Units::J,
    9717            1 :                                 sys.TotCompElecConsump,
    9718              :                                 OutputProcessor::TimeStepType::Zone,
    9719              :                                 OutputProcessor::StoreType::Sum,
    9720            1 :                                 sys.Name);
    9721            2 :             SetupOutputVariable(state,
    9722              :                                 "Refrigeration Transcritical System Average COP",
    9723              :                                 Constant::Units::W_W,
    9724            1 :                                 sys.AverageCompressorCOP,
    9725              :                                 OutputProcessor::TimeStepType::Zone,
    9726              :                                 OutputProcessor::StoreType::Average,
    9727            1 :                                 sys.Name);
    9728            2 :             SetupOutputVariable(state,
    9729              :                                 "Refrigeration Transcritical System Medium Temperature Cases and Walk Ins Heat Transfer Rate",
    9730              :                                 Constant::Units::W,
    9731            1 :                                 sys.TotalCoolingLoadMT,
    9732              :                                 OutputProcessor::TimeStepType::Zone,
    9733              :                                 OutputProcessor::StoreType::Average,
    9734            1 :                                 sys.Name);
    9735            2 :             SetupOutputVariable(state,
    9736              :                                 "Refrigeration Transcritical System Medium Temperature Cases and Walk Ins Heat Transfer Energy",
    9737              :                                 Constant::Units::J,
    9738            1 :                                 sys.TotalCoolingEnergyMT,
    9739              :                                 OutputProcessor::TimeStepType::Zone,
    9740              :                                 OutputProcessor::StoreType::Sum,
    9741            1 :                                 sys.Name);
    9742            2 :             SetupOutputVariable(state,
    9743              :                                 "Refrigeration Transcritical System Total Cases and Walk Ins Heat Transfer Energy",
    9744              :                                 Constant::Units::J,
    9745            1 :                                 sys.TotalCoolingEnergy,
    9746              :                                 OutputProcessor::TimeStepType::Zone,
    9747              :                                 OutputProcessor::StoreType::Sum,
    9748            1 :                                 sys.Name);
    9749            2 :             SetupOutputVariable(state,
    9750              :                                 "Refrigeration Transcritical System Medium Temperature Suction Pipe Heat Transfer Rate",
    9751              :                                 Constant::Units::W,
    9752            1 :                                 sys.PipeHeatLoadMT,
    9753              :                                 OutputProcessor::TimeStepType::Zone,
    9754              :                                 OutputProcessor::StoreType::Average,
    9755            1 :                                 sys.Name);
    9756            2 :             SetupOutputVariable(state,
    9757              :                                 "Refrigeration Transcritical System Medium Temperature Suction Pipe Heat Transfer Energy",
    9758              :                                 Constant::Units::J,
    9759            1 :                                 sys.PipeHeatEnergyMT,
    9760              :                                 OutputProcessor::TimeStepType::Zone,
    9761              :                                 OutputProcessor::StoreType::Sum,
    9762            1 :                                 sys.Name);
    9763            2 :             SetupOutputVariable(state,
    9764              :                                 "Refrigeration Transcritical System High Pressure Compressor Heat Transfer Rate",
    9765              :                                 Constant::Units::W,
    9766            1 :                                 sys.TotCompCapacityHP,
    9767              :                                 OutputProcessor::TimeStepType::Zone,
    9768              :                                 OutputProcessor::StoreType::Average,
    9769            1 :                                 sys.Name);
    9770            2 :             SetupOutputVariable(state,
    9771              :                                 "Refrigeration Transcritical System High Pressure Compressor Heat Transfer Energy",
    9772              :                                 Constant::Units::J,
    9773            1 :                                 sys.TotCompCoolingEnergyHP,
    9774              :                                 OutputProcessor::TimeStepType::Zone,
    9775              :                                 OutputProcessor::StoreType::Sum,
    9776            1 :                                 sys.Name); // indiv compressors go to meter, not system sum
    9777            2 :             SetupOutputVariable(state,
    9778              :                                 "Refrigeration Transcritical System Net Rejected Heat Transfer Rate",
    9779              :                                 Constant::Units::W,
    9780            1 :                                 sys.NetHeatRejectLoad,
    9781              :                                 OutputProcessor::TimeStepType::Zone,
    9782              :                                 OutputProcessor::StoreType::Average,
    9783            1 :                                 sys.Name);
    9784            2 :             SetupOutputVariable(state,
    9785              :                                 "Refrigeration Transcritical System Net Rejected Heat Transfer Energy",
    9786              :                                 Constant::Units::J,
    9787            1 :                                 sys.NetHeatRejectEnergy,
    9788              :                                 OutputProcessor::TimeStepType::Zone,
    9789              :                                 OutputProcessor::StoreType::Sum,
    9790            1 :                                 sys.Name);
    9791            2 :             SetupOutputVariable(state,
    9792              :                                 "Refrigeration Transcritical System Estimated Refrigerant Inventory Mass",
    9793              :                                 Constant::Units::kg,
    9794            1 :                                 sys.RefInventory,
    9795              :                                 OutputProcessor::TimeStepType::Zone,
    9796              :                                 OutputProcessor::StoreType::Average,
    9797            1 :                                 sys.Name);
    9798            2 :             SetupOutputVariable(state,
    9799              :                                 "Refrigeration Transcritical System Refrigerant Mass Flow Rate",
    9800              :                                 Constant::Units::kg_s,
    9801            1 :                                 sys.RefMassFlowComps,
    9802              :                                 OutputProcessor::TimeStepType::Zone,
    9803              :                                 OutputProcessor::StoreType::Average,
    9804            1 :                                 sys.Name);
    9805            2 :             SetupOutputVariable(state,
    9806              :                                 "Refrigeration Transcritical System Medium Temperature Evaporating Temperature",
    9807              :                                 Constant::Units::C,
    9808            1 :                                 sys.TEvapNeededMT,
    9809              :                                 OutputProcessor::TimeStepType::Zone,
    9810              :                                 OutputProcessor::StoreType::Average,
    9811            1 :                                 sys.Name);
    9812            2 :             SetupOutputVariable(state,
    9813              :                                 "Refrigeration Transcritical System Medium Temperature Suction Temperature",
    9814              :                                 Constant::Units::C,
    9815            1 :                                 sys.TCompInHP,
    9816              :                                 OutputProcessor::TimeStepType::Zone,
    9817              :                                 OutputProcessor::StoreType::Average,
    9818            1 :                                 sys.Name);
    9819            1 :             if (sys.transSysType == TransSysType::TwoStage) { // for TwoStage system only (low temperature loads present)
    9820            2 :                 SetupOutputVariable(state,
    9821              :                                     "Refrigeration Transcritical System Low Pressure Compressor Electricity Rate",
    9822              :                                     Constant::Units::W,
    9823            1 :                                     sys.TotCompPowerLP,
    9824              :                                     OutputProcessor::TimeStepType::Zone,
    9825              :                                     OutputProcessor::StoreType::Average,
    9826            1 :                                     sys.Name);
    9827            2 :                 SetupOutputVariable(state,
    9828              :                                     "Refrigeration Transcritical System Low Pressure Compressor Electricity Energy",
    9829              :                                     Constant::Units::J,
    9830            1 :                                     sys.TotCompElecConsumpLP,
    9831              :                                     OutputProcessor::TimeStepType::Zone,
    9832              :                                     OutputProcessor::StoreType::Sum,
    9833            1 :                                     sys.Name);
    9834            2 :                 SetupOutputVariable(state,
    9835              :                                     "Refrigeration Transcritical System Low Temperature Cases and Walk Ins Heat Transfer Rate",
    9836              :                                     Constant::Units::W,
    9837            1 :                                     sys.TotalCoolingLoadLT,
    9838              :                                     OutputProcessor::TimeStepType::Zone,
    9839              :                                     OutputProcessor::StoreType::Average,
    9840            1 :                                     sys.Name);
    9841            2 :                 SetupOutputVariable(state,
    9842              :                                     "Refrigeration Transcritical System Low Temperature Cases and Walk Ins Heat Transfer Energy",
    9843              :                                     Constant::Units::J,
    9844            1 :                                     sys.TotalCoolingEnergyLT,
    9845              :                                     OutputProcessor::TimeStepType::Zone,
    9846              :                                     OutputProcessor::StoreType::Sum,
    9847            1 :                                     sys.Name);
    9848            2 :                 SetupOutputVariable(state,
    9849              :                                     "Refrigeration Transcritical System Low Temperature Suction Pipe Heat Transfer Rate",
    9850              :                                     Constant::Units::W,
    9851            1 :                                     sys.PipeHeatLoadLT,
    9852              :                                     OutputProcessor::TimeStepType::Zone,
    9853              :                                     OutputProcessor::StoreType::Average,
    9854            1 :                                     sys.Name);
    9855            2 :                 SetupOutputVariable(state,
    9856              :                                     "Refrigeration Transcritical System Low Temperature Suction Pipe Heat Transfer Energy",
    9857              :                                     Constant::Units::J,
    9858            1 :                                     sys.PipeHeatEnergyLT,
    9859              :                                     OutputProcessor::TimeStepType::Zone,
    9860              :                                     OutputProcessor::StoreType::Sum,
    9861            1 :                                     sys.Name);
    9862            2 :                 SetupOutputVariable(state,
    9863              :                                     "Refrigeration Transcritical System Low Pressure Compressor Heat Transfer Rate",
    9864              :                                     Constant::Units::W,
    9865            1 :                                     sys.TotCompCapacityLP,
    9866              :                                     OutputProcessor::TimeStepType::Zone,
    9867              :                                     OutputProcessor::StoreType::Average,
    9868            1 :                                     sys.Name);
    9869            2 :                 SetupOutputVariable(state,
    9870              :                                     "Refrigeration Transcritical System Low Pressure Compressor Heat Transfer Energy",
    9871              :                                     Constant::Units::J,
    9872            1 :                                     sys.TotCompCoolingEnergyLP,
    9873              :                                     OutputProcessor::TimeStepType::Zone,
    9874              :                                     OutputProcessor::StoreType::Sum,
    9875            1 :                                     sys.Name); // indiv compressors go to meter, not system sum
    9876            2 :                 SetupOutputVariable(state,
    9877              :                                     "Refrigeration Transcritical System Low Temperature Evaporating Temperature",
    9878              :                                     Constant::Units::C,
    9879            1 :                                     sys.TEvapNeededLT,
    9880              :                                     OutputProcessor::TimeStepType::Zone,
    9881              :                                     OutputProcessor::StoreType::Average,
    9882            1 :                                     sys.Name);
    9883            2 :                 SetupOutputVariable(state,
    9884              :                                     "Refrigeration Transcritical System Low Temperature Suction Temperature",
    9885              :                                     Constant::Units::C,
    9886            1 :                                     sys.TCompInLP,
    9887              :                                     OutputProcessor::TimeStepType::Zone,
    9888              :                                     OutputProcessor::StoreType::Average,
    9889            1 :                                     sys.Name);
    9890              :             } // (sys%TransSysType == 2)
    9891              : 
    9892            1 :             if (sys.SystemRejectHeatToZone) {
    9893            0 :                 if (GasCooler(sys.GasCoolerNum(1)).InletAirZoneNum > 0) {
    9894            0 :                     SetupZoneInternalGain(state,
    9895            0 :                                           GasCooler(sys.GasCoolerNum(1)).InletAirZoneNum,
    9896              :                                           sys.Name,
    9897              :                                           DataHeatBalance::IntGainType::RefrigerationTransSysAirCooledGasCooler,
    9898              :                                           &sys.NetHeatRejectLoad);
    9899              :                 }
    9900              :             } // (sys%SystemRejectHeatToZone)
    9901            1 :             if (sys.SuctionPipeActualZoneNumMT > 0) {
    9902            0 :                 SetupZoneInternalGain(state,
    9903              :                                       sys.SuctionPipeActualZoneNumMT,
    9904              :                                       sys.Name,
    9905              :                                       DataHeatBalance::IntGainType::RefrigerationTransSysSuctionPipeMT,
    9906              :                                       &sys.PipeHeatLoadMT);
    9907              :             } // sys%SuctionPipeActualZoneNumMT > 0
    9908            1 :             if (sys.SuctionPipeActualZoneNumLT > 0) {
    9909            0 :                 SetupZoneInternalGain(state,
    9910              :                                       sys.SuctionPipeActualZoneNumLT,
    9911              :                                       sys.Name,
    9912              :                                       DataHeatBalance::IntGainType::RefrigerationTransSysSuctionPipeLT,
    9913              :                                       &sys.PipeHeatLoadLT);
    9914              :             } // sys%SuctionPipeActualZoneNumLT > 0
    9915              : 
    9916              :             // Report Compressor ENERGY here, not on system level for meters.
    9917              :             // LP compressors
    9918            4 :             for (int compIndex = 1; compIndex <= sys.NumCompressorsLP; ++compIndex) {
    9919            3 :                 int compNum = sys.CompressorNumLP(compIndex);
    9920              :                 // CurrentModuleObject='Refrigeration:Compressor'
    9921            3 :                 if (Compressor(compNum).NumSysAttach == 1) { // only set up reports for compressors that are used once and only once
    9922            6 :                     SetupOutputVariable(state,
    9923              :                                         "Refrigeration Compressor Electricity Rate",
    9924              :                                         Constant::Units::W,
    9925            3 :                                         Compressor(compNum).Power,
    9926              :                                         OutputProcessor::TimeStepType::Zone,
    9927              :                                         OutputProcessor::StoreType::Average,
    9928            3 :                                         Compressor(compNum).Name);
    9929            6 :                     SetupOutputVariable(state,
    9930              :                                         "Refrigeration Compressor Electricity Energy",
    9931              :                                         Constant::Units::J,
    9932            3 :                                         Compressor(compNum).ElecConsumption,
    9933              :                                         OutputProcessor::TimeStepType::Zone,
    9934              :                                         OutputProcessor::StoreType::Sum,
    9935            3 :                                         Compressor(compNum).Name,
    9936              :                                         Constant::eResource::Electricity,
    9937              :                                         OutputProcessor::Group::Plant,
    9938              :                                         OutputProcessor::EndUseCat::Refrigeration,
    9939            3 :                                         Compressor(compNum).EndUseSubcategory);
    9940            6 :                     SetupOutputVariable(state,
    9941              :                                         "Refrigeration Compressor Heat Transfer Rate",
    9942              :                                         Constant::Units::W,
    9943            3 :                                         Compressor(compNum).Capacity,
    9944              :                                         OutputProcessor::TimeStepType::Zone,
    9945              :                                         OutputProcessor::StoreType::Average,
    9946            3 :                                         Compressor(compNum).Name);
    9947            6 :                     SetupOutputVariable(state,
    9948              :                                         "Refrigeration Compressor Heat Transfer Energy",
    9949              :                                         Constant::Units::J,
    9950            3 :                                         Compressor(compNum).CoolingEnergy,
    9951              :                                         OutputProcessor::TimeStepType::Zone,
    9952              :                                         OutputProcessor::StoreType::Sum,
    9953            3 :                                         Compressor(compNum).Name);
    9954            6 :                     SetupOutputVariable(state,
    9955              :                                         "Refrigeration Compressor Runtime Fraction",
    9956              :                                         Constant::Units::None,
    9957            3 :                                         Compressor(compNum).LoadFactor,
    9958              :                                         OutputProcessor::TimeStepType::Zone,
    9959              :                                         OutputProcessor::StoreType::Average,
    9960            3 :                                         Compressor(compNum).Name);
    9961              :                 } // NumSysAttach
    9962              :             } // sys%NumCompressorsLP
    9963              : 
    9964              :             // HP compressors
    9965            4 :             for (int compIndex = 1; compIndex <= sys.NumCompressorsHP; ++compIndex) {
    9966            3 :                 int compNum = sys.CompressorNumHP(compIndex);
    9967              :                 // CurrentModuleObject='Refrigeration:Compressor'
    9968            3 :                 if (Compressor(compNum).NumSysAttach == 1) { // only set up reports for compressors that are used once and only once
    9969            6 :                     SetupOutputVariable(state,
    9970              :                                         "Refrigeration Compressor Electricity Rate",
    9971              :                                         Constant::Units::W,
    9972            3 :                                         Compressor(compNum).Power,
    9973              :                                         OutputProcessor::TimeStepType::Zone,
    9974              :                                         OutputProcessor::StoreType::Average,
    9975            3 :                                         Compressor(compNum).Name);
    9976            6 :                     SetupOutputVariable(state,
    9977              :                                         "Refrigeration Compressor Electricity Energy",
    9978              :                                         Constant::Units::J,
    9979            3 :                                         Compressor(compNum).ElecConsumption,
    9980              :                                         OutputProcessor::TimeStepType::Zone,
    9981              :                                         OutputProcessor::StoreType::Sum,
    9982            3 :                                         Compressor(compNum).Name,
    9983              :                                         Constant::eResource::Electricity,
    9984              :                                         OutputProcessor::Group::Plant,
    9985              :                                         OutputProcessor::EndUseCat::Refrigeration,
    9986            3 :                                         Compressor(compNum).EndUseSubcategory);
    9987            6 :                     SetupOutputVariable(state,
    9988              :                                         "Refrigeration Compressor Heat Transfer Rate",
    9989              :                                         Constant::Units::W,
    9990            3 :                                         Compressor(compNum).Capacity,
    9991              :                                         OutputProcessor::TimeStepType::Zone,
    9992              :                                         OutputProcessor::StoreType::Average,
    9993            3 :                                         Compressor(compNum).Name);
    9994            6 :                     SetupOutputVariable(state,
    9995              :                                         "Refrigeration Compressor Heat Transfer Energy",
    9996              :                                         Constant::Units::J,
    9997            3 :                                         Compressor(compNum).CoolingEnergy,
    9998              :                                         OutputProcessor::TimeStepType::Zone,
    9999              :                                         OutputProcessor::StoreType::Sum,
   10000            3 :                                         Compressor(compNum).Name);
   10001            6 :                     SetupOutputVariable(state,
   10002              :                                         "Refrigeration Compressor Runtime Fraction",
   10003              :                                         Constant::Units::None,
   10004            3 :                                         Compressor(compNum).LoadFactor,
   10005              :                                         OutputProcessor::TimeStepType::Zone,
   10006              :                                         OutputProcessor::StoreType::Average,
   10007            3 :                                         Compressor(compNum).Name);
   10008              :                 } // NumSysAttach
   10009              :             } // sys%NumCompressorsHP
   10010              : 
   10011              :         } // NumTransRefrigSystems
   10012              :     } // (NumTransRefrigSystems > 0)
   10013              : 
   10014          801 :     if (state.dataRefrigCase->NumSimulationGasCooler > 0) {
   10015            2 :         for (int GCNum = 1; GCNum <= state.dataRefrigCase->NumSimulationGasCooler; ++GCNum) {
   10016            1 :             auto &cooler = GasCooler(GCNum);
   10017              :             // CurrentModuleObject='Refrigeration:GasCooler:AirCooled'
   10018            2 :             SetupOutputVariable(state,
   10019              :                                 "Refrigeration Transcritical System Gas Cooler Heat Transfer Rate",
   10020              :                                 Constant::Units::W,
   10021            1 :                                 cooler.GasCoolerLoad,
   10022              :                                 OutputProcessor::TimeStepType::Zone,
   10023              :                                 OutputProcessor::StoreType::Average,
   10024            1 :                                 cooler.Name);
   10025            2 :             SetupOutputVariable(state,
   10026              :                                 "Refrigeration Transcritical System Gas Cooler Heat Transfer Energy",
   10027              :                                 Constant::Units::J,
   10028            1 :                                 cooler.GasCoolerEnergy,
   10029              :                                 OutputProcessor::TimeStepType::Zone,
   10030              :                                 OutputProcessor::StoreType::Sum,
   10031            1 :                                 cooler.Name);
   10032            2 :             SetupOutputVariable(state,
   10033              :                                 "Refrigeration Transcritical System Gas Cooler Fan Electricity Rate",
   10034              :                                 Constant::Units::W,
   10035            1 :                                 cooler.ActualFanPower,
   10036              :                                 OutputProcessor::TimeStepType::Zone,
   10037              :                                 OutputProcessor::StoreType::Average,
   10038            1 :                                 cooler.Name);
   10039            2 :             SetupOutputVariable(state,
   10040              :                                 "Refrigeration Transcritical System Gas Cooler Fan Electricity Energy",
   10041              :                                 Constant::Units::J,
   10042            1 :                                 cooler.FanElecEnergy,
   10043              :                                 OutputProcessor::TimeStepType::Zone,
   10044              :                                 OutputProcessor::StoreType::Sum,
   10045            1 :                                 cooler.Name,
   10046              :                                 Constant::eResource::Electricity,
   10047              :                                 OutputProcessor::Group::Plant,
   10048              :                                 OutputProcessor::EndUseCat::Refrigeration,
   10049              :                                 cooler.EndUseSubcategory);
   10050            2 :             SetupOutputVariable(state,
   10051              :                                 "Refrigeration Transcritical System Gas Cooler Outlet Temperature",
   10052              :                                 Constant::Units::C,
   10053            1 :                                 cooler.TGasCoolerOut,
   10054              :                                 OutputProcessor::TimeStepType::Zone,
   10055              :                                 OutputProcessor::StoreType::Average,
   10056            1 :                                 cooler.Name);
   10057            2 :             SetupOutputVariable(state,
   10058              :                                 "Refrigeration Transcritical System Gas Cooler Outlet Pressure",
   10059              :                                 Constant::Units::Pa,
   10060            1 :                                 cooler.PGasCoolerOut,
   10061              :                                 OutputProcessor::TimeStepType::Zone,
   10062              :                                 OutputProcessor::StoreType::Average,
   10063            1 :                                 cooler.Name);
   10064            2 :             SetupOutputVariable(state,
   10065              :                                 "Refrigeration Transcritical System Gas Cooler Defrost Recovered Heat Transfer Rate",
   10066              :                                 Constant::Units::W,
   10067            1 :                                 cooler.InternalHeatRecoveredLoad,
   10068              :                                 OutputProcessor::TimeStepType::Zone,
   10069              :                                 OutputProcessor::StoreType::Average,
   10070            1 :                                 cooler.Name);
   10071            2 :             SetupOutputVariable(state,
   10072              :                                 "Refrigeration Transcritical System Gas Cooler Defrost Recovered Heat Transfer Energy",
   10073              :                                 Constant::Units::J,
   10074            1 :                                 cooler.InternalEnergyRecovered,
   10075              :                                 OutputProcessor::TimeStepType::Zone,
   10076              :                                 OutputProcessor::StoreType::Sum,
   10077            1 :                                 cooler.Name);
   10078              :         } // GCNum on NumSimulationGasCooler
   10079              :     } // (NumSimulationGasCooler >0)
   10080          801 : }
   10081              : 
   10082       468509 : void InitRefrigeration(EnergyPlusData &state)
   10083              : {
   10084              :     // SUBROUTINE INFORMATION:
   10085              :     //       AUTHOR         Richard Raustad, FSEC
   10086              :     //       DATE WRITTEN   Oct/Nov 2004
   10087              :     //       MODIFIED       Hudson, ORNL July 2007, Stovall, ORNL, 2008
   10088              :     //       RE-ENGINEERED  na
   10089              : 
   10090              :     // PURPOSE OF THIS SUBROUTINE:
   10091              :     // Initialize (zero) global variables before simulating compressor racks and refrigerated cases
   10092              :     // Several variables in this module are accumulative.  For example, unmet compressor loads are carried over
   10093              :     // to the next time step. Ice loads are accumulated until melted by a defrost.  Because this module can be
   10094              :     // called multiple times during any single time step, these summations need to be saved ONLY on the last time
   10095              :     // through any given time step.
   10096              : 
   10097              :     // It is necessary to decrease the condenser load by the amount of heat used elsewhere
   10098              :     //   via desuperheating water heaters and heating coils.
   10099              :     //   Because the refrigeration system is solved before the HVAC time step loops, the
   10100              :     //   refrigeration system must use the values lagged from the previous time step. In
   10101              :     //   terms of energy, this should balance out and is preferable to not making the correction,
   10102              :     //   in which case the condenser cooling water/air/fan energy are charged with energy
   10103              :     //   loads that have been accounted elsewhere.  For consistency, the lagged value must be used,
   10104              :     //   even if the Zone time step is repeated.  Therefore, the lagged variables are saved
   10105              :     //   here for use during successive iterations of same zone/load time step.
   10106              : 
   10107              :     // METHODOLOGY EMPLOYED:
   10108              :     // Global variables for Case Credit are located in DataHeatBalance. To Zone variables are used in the Air Heat
   10109              :     // Balance in ZoneTempPredictorCorrector to calculate the zone load. To HVAC variables are used in
   10110              :     // ZoneEquipmentManager to add the portion of case credits attributed to the HVAC system to the zone return air node.
   10111              : 
   10112              :     // Because we can't know apriori whether or not the time step will be repeated, we save the most recent
   10113              :     // addition/subtraction to/from each accumulating variable.  If the time step is repeated,
   10114              :     // this most recent addition/subtraction is reversed before the rest of the refrigeration simulation begins.
   10115              : 
   10116              :     // Used to adjust accumulative variables when time step is repeated
   10117              : 
   10118       468509 :     auto &RefrigCase = state.dataRefrigCase->RefrigCase;
   10119       468509 :     auto &RefrigRack = state.dataRefrigCase->RefrigRack;
   10120       468509 :     auto &System = state.dataRefrigCase->System;
   10121       468509 :     auto &TransSystem = state.dataRefrigCase->TransSystem;
   10122       468509 :     auto &Condenser = state.dataRefrigCase->Condenser;
   10123       468509 :     auto &Compressor = state.dataRefrigCase->Compressor;
   10124       468509 :     auto &GasCooler = state.dataRefrigCase->GasCooler;
   10125       468509 :     auto &Secondary = state.dataRefrigCase->Secondary;
   10126       468509 :     auto &WalkIn = state.dataRefrigCase->WalkIn;
   10127       468509 :     auto &WarehouseCoil = state.dataRefrigCase->WarehouseCoil;
   10128       468509 :     auto &CoilSysCredit = state.dataRefrigCase->CoilSysCredit;
   10129       468509 :     auto &CaseWIZoneReport = state.dataRefrigCase->CaseWIZoneReport;
   10130              : 
   10131              :     // Zero display case, air-coil, and walk-in cooler credits (summed by zone)
   10132              :     // to 0 each zone or sys time step
   10133              :     // These 'casecredit' variables are also used to transfer energy from zone-located
   10134              :     // compressor-rack condenser heat rejection, heat absorption by distribution piping,
   10135              :     // suction piping, and receiver shells to zone
   10136       468509 :     if (state.dataGlobal->NumOfZones > 0) {
   10137       468509 :         if (state.dataRefrigCase->UseSysTimeStep) {
   10138      5343915 :             for (int i = CoilSysCredit.l(), e = CoilSysCredit.u(); i <= e; ++i) {
   10139      4987654 :                 CoilSysCredit(i).reset();
   10140              :             }
   10141              :         } // UseSysTimeStep = true
   10142              : 
   10143              :         // Can arrive here when load call to refrigeration looks for cases/walkin systems and usetimestep is false
   10144       580757 :         if ((!state.dataRefrigCase->UseSysTimeStep) &&
   10145       112248 :             ((state.dataRefrigCase->NumSimulationCases > 0) || (state.dataRefrigCase->NumSimulationWalkIns > 0))) {
   10146              : 
   10147      3963942 :             for (auto &credit : state.dataHeatBal->RefrigCaseCredit) {
   10148      3854585 :                 credit.reset();
   10149       109357 :             }
   10150      3963942 :             for (auto &zoneReport : CaseWIZoneReport) {
   10151      3854585 :                 zoneReport.reset();
   10152              :             }
   10153              :         }
   10154              :     }
   10155              : 
   10156       468509 :     if (state.dataRefrigCase->NumSimulationCases > 0) {
   10157              :         // RefrigCase ALLOCATED to NumSimulationCases
   10158       591937 :         for (auto &refrig : RefrigCase) {
   10159       482580 :             refrig.reset_init();
   10160              :         }
   10161              :     } // NumSimulationCases
   10162              : 
   10163       468509 :     if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
   10164              :         // WalkIn ALLOCATED to NumSimulationWalkIns
   10165        96655 :         for (int i = WalkIn.l(), e = WalkIn.u(); i <= e; ++i) {
   10166        56999 :             WalkIn(i).reset_init();
   10167              :         }
   10168              :     }
   10169              : 
   10170       468509 :     if (state.dataRefrigCase->HaveChillers) {
   10171              :         // HaveChillers is TRUE when NumSimulationRefrigAirChillers > 0
   10172              :         // WarehouseCoil ALLOCATED to NumSimulationRefrigAirChillers
   10173     30168768 :         for (int i = WarehouseCoil.l(), e = WarehouseCoil.u(); i <= e; ++i) {
   10174     29809616 :             WarehouseCoil(i).reset_init();
   10175              :         }
   10176              :     }
   10177              : 
   10178       468509 :     if (state.dataRefrigCase->HaveRefrigRacks) {
   10179              :         // HaveRefrigRacks TRUE when NumRefrigeratedRacks > 0
   10180              :         // RefrigRack ALLOCATED to NumRefrigeratedRacks
   10181       257106 :         for (int i = RefrigRack.l(), e = RefrigRack.u(); i <= e; ++i) {
   10182       171176 :             RefrigRack(i).reset_init();
   10183              :         }
   10184       257106 :         for (auto &e : state.dataHeatBal->HeatReclaimRefrigeratedRack) {
   10185       171176 :             e.AvailCapacity = 0.0;
   10186        85930 :         }
   10187              :         // Note don't reset basin heat to zero when no load because heater would remain on
   10188              :         // RefrigRack.BasinHeaterPower = 0.0;
   10189              :         // RefrigRack.BasinHeaterConsumption = 0.0;
   10190              :     }
   10191              : 
   10192       468509 :     if (state.dataRefrigCase->NumRefrigCondensers > 0) {
   10193              :         // Condenser ALLOCATED to DataHeatBalance::NumRefrigCondensers
   10194      3714544 :         for (int i = Condenser.l(), e = Condenser.u(); i <= e; ++i) {
   10195      3315736 :             Condenser(i).reset_init();
   10196              :         }
   10197              :         // N don't reset basin heat to zero when no load because heater would remain on
   10198      3714544 :         for (auto &e : state.dataHeatBal->HeatReclaimRefrigCondenser) {
   10199      3315736 :             e.AvailCapacity = 0.0;
   10200      3315736 :             e.AvailTemperature = 0.0;
   10201       398808 :         }
   10202              :     }
   10203              : 
   10204       468509 :     if (state.dataRefrigCase->NumSimulationGasCooler > 0) {
   10205              :         // GasCooler ALLOCATED to NumSimulationGasCooler
   10206         4056 :         for (int i = GasCooler.l(), e = GasCooler.u(); i <= e; ++i) {
   10207         2028 :             GasCooler(i).reset_init();
   10208              :         }
   10209              :     }
   10210              : 
   10211       468509 :     if (state.dataRefrigCase->NumSimulationCompressors > 0) {
   10212              :         // Compressor ALLOCATED to NumSimulationCompressors
   10213     26215838 :         for (int i = Compressor.l(), e = Compressor.u(); i <= e; ++i) {
   10214     25815002 :             Compressor(i).reset_init();
   10215              :         }
   10216              :     }
   10217              : 
   10218       468509 :     if (state.dataRefrigCase->HaveDetailedRefrig) {
   10219              :         // HaveDetailedRefrig is TRUE when NumRefrigSystems > 0
   10220              :         // System is ALLOCATED to NumRefrigSystems
   10221      3718600 :         for (int i = System.l(), e = System.u(); i <= e; ++i) {
   10222      3319792 :             System(i).reset_init();
   10223              :         }
   10224              :     }
   10225              : 
   10226       468509 :     if (state.dataRefrigCase->HaveDetailedTransRefrig) {
   10227              :         // HaveDetailedTransRefrig is TRUE when NumTransRefrigSystems > 0
   10228              :         // TransSystem is ALLOCATED to NumTransRefrigSystems
   10229         4056 :         for (int i = TransSystem.l(), e = TransSystem.u(); i <= e; ++i) {
   10230         2028 :             TransSystem(i).reset_init();
   10231              :         }
   10232              :     }
   10233              : 
   10234       468509 :     if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
   10235              :         // Secondary is ALLOCATED to NumSimulationSecondarySystems
   10236         6084 :         for (int i = Secondary.l(), e = Secondary.u(); i <= e; ++i) {
   10237         4056 :             Secondary(i).reset_init();
   10238              :         }
   10239              :     }
   10240              : 
   10241              :     // Accumulative and carry-over variables are not zeroed at start of each time step, only at beginning of environment
   10242       468509 :     if (state.dataGlobal->BeginEnvrnFlag && state.dataRefrigCase->InitRefrigerationMyBeginEnvrnFlag) {
   10243          321 :         if (state.dataRefrigCase->NumSimulationCases > 0) {
   10244         1700 :             for (int i = RefrigCase.l(), e = RefrigCase.u(); i <= e; ++i) {
   10245         1385 :                 RefrigCase(i).reset_init_accum();
   10246              :             }
   10247              :         }
   10248          321 :         if (state.dataRefrigCase->NumRefrigSystems > 0) {
   10249          399 :             for (auto &e : System) {
   10250          288 :                 e.UnmetEnergy = 0.0;
   10251              :             }
   10252              :         }
   10253          321 :         if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
   10254          249 :             for (auto &e : WalkIn) {
   10255          144 :                 e.KgFrost = 0.0;
   10256          144 :                 e.StoredEnergy = 0.0;
   10257              :             }
   10258          249 :             for (int walkInID = 1; walkInID <= state.dataRefrigCase->NumSimulationWalkIns; ++walkInID) {
   10259          144 :                 WalkIn(walkInID).IceTemp = WalkIn(walkInID).TEvapDesign;
   10260              :             }
   10261              :         }
   10262          321 :         if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0) {
   10263          504 :             for (auto &e : WarehouseCoil) {
   10264          498 :                 e.KgFrost = 0.0;
   10265          498 :                 e.KgFrostSaved = 0.0;
   10266              :             }
   10267          504 :             for (int coilID = 1; coilID <= state.dataRefrigCase->NumSimulationRefrigAirChillers; ++coilID) {
   10268          498 :                 WarehouseCoil(coilID).IceTemp = WarehouseCoil(coilID).TEvapDesign;
   10269          498 :                 WarehouseCoil(coilID).IceTempSaved = WarehouseCoil(coilID).TEvapDesign;
   10270              :             }
   10271              :         }
   10272          321 :         if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
   10273           18 :             for (auto &e : Secondary) {
   10274           12 :                 e.UnmetEnergy = 0.0;
   10275              :             }
   10276              :         }
   10277          321 :         if (state.dataRefrigCase->NumRefrigeratedRacks > 0) {
   10278          772 :             for (auto &e : state.dataHeatBal->HeatReclaimRefrigeratedRack) {
   10279          514 :                 e.HVACDesuperheaterReclaimedHeatTotal = 0.0;
   10280          514 :                 e.WaterHeatingDesuperheaterReclaimedHeatTotal = 0.0;
   10281          258 :             }
   10282          772 :             for (auto &e : RefrigRack) {
   10283          514 :                 e.LaggedUsedWaterHeater = 0.0;
   10284          514 :                 e.LaggedUsedHVACCoil = 0.0;
   10285              :             }
   10286              :         }
   10287          321 :         if (state.dataRefrigCase->NumRefrigCondensers > 0) {
   10288          387 :             for (auto &e : state.dataHeatBal->HeatReclaimRefrigCondenser) {
   10289          276 :                 e.HVACDesuperheaterReclaimedHeatTotal = 0.0;
   10290          276 :                 e.WaterHeatingDesuperheaterReclaimedHeatTotal = 0.0;
   10291          111 :             }
   10292          387 :             for (auto &e : Condenser) {
   10293          276 :                 e.LaggedUsedWaterHeater = 0.0;
   10294          276 :                 e.LaggedUsedHVACCoil = 0.0;
   10295              :             }
   10296              :         }
   10297          609 :         for (int systemId = 1; systemId <= state.dataRefrigCase->NumRefrigSystems; ++systemId) {
   10298          288 :             if (allocated(System(systemId).MechSCLoad)) {
   10299            6 :                 System(systemId).MechSCLoad = 0.0;
   10300              :             }
   10301          288 :             System(systemId).LSHXTrans = 0.0;
   10302          288 :             System(systemId).LSHXTransEnergy = 0.0;
   10303              :         }
   10304              : 
   10305          321 :         if (state.dataGlobal->TimeStepsInHour > 0.0) {
   10306          321 :             state.dataRefrigCase->TimeStepFraction = 1.0 / double(state.dataGlobal->TimeStepsInHour);
   10307              :         }
   10308          321 :         state.dataRefrigCase->InitRefrigerationMyBeginEnvrnFlag = false;
   10309              : 
   10310              :     } // ( DataGlobals::BeginEnvrnFlag && MyBeginEnvrnFlag )
   10311              : 
   10312       468509 :     if (!state.dataGlobal->BeginEnvrnFlag) {
   10313       467398 :         state.dataRefrigCase->InitRefrigerationMyBeginEnvrnFlag = true;
   10314              :     }
   10315              : 
   10316              :     // Avoid multiplying accumulation if go through zone/load time step more than once.
   10317       468509 :     if (!state.dataGlobal->WarmupFlag) { // because no accumulation is done during warm up
   10318              :         // Can arrive here when load call to refrigeration looks for cases/walkin systems and usetimestep is .FALSE.
   10319        49616 :         if ((!state.dataRefrigCase->UseSysTimeStep) &&
   10320        14688 :             ((state.dataRefrigCase->NumSimulationCases > 0) || (state.dataRefrigCase->NumSimulationWalkIns > 0))) {
   10321              :             // Used to determine whether the zone time step is a repetition
   10322        14496 :             Real64 MyCurrentTime = (state.dataGlobal->HourOfDay - 1) + state.dataGlobal->TimeStep * state.dataRefrigCase->TimeStepFraction;
   10323        14496 :             if (std::abs(MyCurrentTime - state.dataRefrigCase->MyCurrentTimeSaved) < MySmallNumber) {
   10324              :                 // If the time step is repeated, need to return to correct values at start of time step
   10325            0 :                 if (state.dataRefrigCase->NumSimulationCases > 0) {
   10326            0 :                     for (int caseID = 1; caseID <= state.dataRefrigCase->NumSimulationCases; ++caseID) {
   10327            0 :                         RefrigCase(caseID).DefrostEnergy = RefrigCase(caseID).DefrostEnergySaved;
   10328            0 :                         RefrigCase(caseID).StockingEnergy = RefrigCase(caseID).StockingEnergySaved;
   10329            0 :                         RefrigCase(caseID).WarmEnvEnergy = RefrigCase(caseID).WarmEnvEnergySaved;
   10330            0 :                         RefrigCase(caseID).KgFrost = RefrigCase(caseID).KgFrostSaved;
   10331            0 :                         RefrigCase(caseID).StoredEnergy = RefrigCase(caseID).StoredEnergySaved;
   10332              :                     } // CaseID
   10333              :                 } // NumSimulationCases
   10334            0 :                 if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
   10335            0 :                     for (int walkInID = 1; walkInID <= state.dataRefrigCase->NumSimulationWalkIns; ++walkInID) {
   10336            0 :                         WalkIn(walkInID).KgFrost = WalkIn(walkInID).KgFrostSaved;
   10337            0 :                         WalkIn(walkInID).StoredEnergy = WalkIn(walkInID).StoredEnergySaved;
   10338            0 :                         WalkIn(walkInID).IceTemp = WalkIn(walkInID).IceTempSaved;
   10339              :                     }
   10340              :                 }
   10341            0 :                 if (state.dataRefrigCase->NumRefrigSystems > 0) {
   10342            0 :                     for (int systemID = 1; systemID <= state.dataRefrigCase->NumRefrigSystems; ++systemID) {
   10343            0 :                         if (System(systemID).CoilFlag) {
   10344            0 :                             continue;
   10345              :                         }
   10346            0 :                         System(systemID).UnmetEnergy = System(systemID).UnmetEnergySaved;
   10347              :                     }
   10348              :                 }
   10349            0 :                 if (state.dataRefrigCase->NumTransRefrigSystems > 0) {
   10350            0 :                     for (int systemID = 1; systemID <= state.dataRefrigCase->NumTransRefrigSystems; ++systemID) {
   10351            0 :                         TransSystem(systemID).UnmetEnergyMT = TransSystem(systemID).UnmetEnergySavedMT;
   10352            0 :                         TransSystem(systemID).UnmetEnergyLT = TransSystem(systemID).UnmetEnergySavedLT;
   10353              :                     }
   10354              :                 }
   10355            0 :                 if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
   10356            0 :                     for (int secondID = 1; secondID <= state.dataRefrigCase->NumSimulationSecondarySystems; ++secondID) {
   10357            0 :                         if (Secondary(secondID).CoilFlag) {
   10358            0 :                             continue;
   10359              :                         }
   10360            0 :                         Secondary(secondID).UnmetEnergy = Secondary(secondID).UnmetEnergySaved;
   10361              :                     }
   10362              :                 }
   10363              : 
   10364              :             } else {
   10365              :                 // First time through this Zone time step, so set saved values to those in place at start of this time step
   10366        14496 :                 state.dataRefrigCase->MyCurrentTimeSaved = MyCurrentTime;
   10367        14496 :                 if (state.dataRefrigCase->NumSimulationCases > 0) {
   10368        80640 :                     for (int caseID = 1; caseID <= state.dataRefrigCase->NumSimulationCases; ++caseID) {
   10369        66144 :                         RefrigCase(caseID).DefrostEnergySaved = RefrigCase(caseID).DefrostEnergy;
   10370        66144 :                         RefrigCase(caseID).StockingEnergySaved = RefrigCase(caseID).StockingEnergy;
   10371        66144 :                         RefrigCase(caseID).WarmEnvEnergySaved = RefrigCase(caseID).WarmEnvEnergy;
   10372        66144 :                         RefrigCase(caseID).KgFrostSaved = RefrigCase(caseID).KgFrost;
   10373        66144 :                         RefrigCase(caseID).StoredEnergySaved = RefrigCase(caseID).StoredEnergy;
   10374              :                     } // caseid
   10375              :                 } // numsimulationcases
   10376        14496 :                 if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
   10377        13248 :                     for (int walkInID = 1; walkInID <= state.dataRefrigCase->NumSimulationWalkIns; ++walkInID) {
   10378         7776 :                         WalkIn(walkInID).KgFrostSaved = WalkIn(walkInID).KgFrost;
   10379         7776 :                         WalkIn(walkInID).StoredEnergySaved = WalkIn(walkInID).StoredEnergy;
   10380         7776 :                         WalkIn(walkInID).IceTempSaved = WalkIn(walkInID).IceTemp;
   10381              :                     }
   10382              :                 }
   10383        14496 :                 if (state.dataRefrigCase->NumRefrigSystems > 0) {
   10384        17568 :                     for (int systemID = 1; systemID <= state.dataRefrigCase->NumRefrigSystems; ++systemID) {
   10385        12096 :                         if (System(systemID).CoilFlag) {
   10386            0 :                             continue;
   10387              :                         }
   10388        12096 :                         System(systemID).UnmetEnergySaved = System(systemID).UnmetEnergy;
   10389              :                     }
   10390              :                 }
   10391        14496 :                 if (state.dataRefrigCase->NumTransRefrigSystems > 0) {
   10392          576 :                     for (int systemID = 1; systemID <= state.dataRefrigCase->NumTransRefrigSystems; ++systemID) {
   10393          288 :                         TransSystem(systemID).UnmetEnergySavedMT = TransSystem(systemID).UnmetEnergyMT;
   10394          288 :                         TransSystem(systemID).UnmetEnergySavedLT = TransSystem(systemID).UnmetEnergyLT;
   10395              :                     }
   10396              :                 }
   10397        14496 :                 if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
   10398          864 :                     for (int secondID = 1; secondID <= state.dataRefrigCase->NumSimulationSecondarySystems; ++secondID) {
   10399          576 :                         if (Secondary(secondID).CoilFlag) {
   10400            0 :                             continue;
   10401              :                         }
   10402          576 :                         Secondary(secondID).UnmetEnergySaved = Secondary(secondID).UnmetEnergy;
   10403              :                     }
   10404              :                 }
   10405              :                 // Following lagged variables set for consistency to value calculated prev time through HVAC time step loops
   10406        14496 :                 if (allocated(state.dataHeatBal->HeatReclaimRefrigeratedRack)) {
   10407        33888 :                     for (int IRack = 1; IRack <= state.dataRefrigCase->NumRefrigeratedRacks; ++IRack) {
   10408        45120 :                         RefrigRack(IRack).LaggedUsedHVACCoil =
   10409        22560 :                             state.dataHeatBal->HeatReclaimRefrigeratedRack(IRack).HVACDesuperheaterReclaimedHeatTotal;
   10410        22560 :                         RefrigRack(IRack).LaggedUsedWaterHeater =
   10411        22560 :                             state.dataHeatBal->HeatReclaimRefrigeratedRack(IRack).WaterHeatingDesuperheaterReclaimedHeatTotal;
   10412              :                     }
   10413              :                 }
   10414        14496 :                 if (allocated(state.dataHeatBal->HeatReclaimRefrigCondenser)) {
   10415        16992 :                     for (int ICond = 1; ICond <= state.dataRefrigCase->NumRefrigCondensers; ++ICond) {
   10416        23040 :                         Condenser(ICond).LaggedUsedHVACCoil =
   10417        11520 :                             state.dataHeatBal->HeatReclaimRefrigCondenser(ICond).HVACDesuperheaterReclaimedHeatTotal;
   10418        11520 :                         Condenser(ICond).LaggedUsedWaterHeater =
   10419        11520 :                             state.dataHeatBal->HeatReclaimRefrigCondenser(ICond).WaterHeatingDesuperheaterReclaimedHeatTotal;
   10420              :                     }
   10421              :                 }
   10422              :             } // repeating same time step
   10423              : 
   10424              :         } else { // using UseSysTimeStep as a flag for a chiller system
   10425              : 
   10426              :             // Used to determine whether the system time step is a repetition
   10427        20432 :             Real64 MyStepStartTime = state.dataGlobal->CurrentTime - state.dataGlobal->TimeStepZone + state.dataHVACGlobal->SysTimeElapsed;
   10428        20432 :             if (std::abs(MyStepStartTime - state.dataRefrigCase->MyStepStartTimeSaved) < MySmallNumber) {
   10429              :                 // If the time step is repeated, need to return to correct values at start of time step
   10430        19576 :                 if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0) {
   10431      1644384 :                     for (int coilID = 1; coilID <= state.dataRefrigCase->NumSimulationRefrigAirChillers; ++coilID) {
   10432      1624808 :                         WarehouseCoil(coilID).KgFrost = WarehouseCoil(coilID).KgFrostSaved;
   10433      1624808 :                         WarehouseCoil(coilID).IceTemp = WarehouseCoil(coilID).IceTempSaved;
   10434              :                     }
   10435              :                 }
   10436              :             } else { // First time through this system time step or hvac loop,
   10437              :                 // so set saved values to those in place at start of this time step
   10438          856 :                 state.dataRefrigCase->MyStepStartTimeSaved = MyStepStartTime;
   10439          856 :                 if (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0) {
   10440        71904 :                     for (int coilID = 1; coilID <= state.dataRefrigCase->NumSimulationRefrigAirChillers; ++coilID) {
   10441        71048 :                         WarehouseCoil(coilID).KgFrostSaved = WarehouseCoil(coilID).KgFrost;
   10442        71048 :                         WarehouseCoil(coilID).IceTempSaved = WarehouseCoil(coilID).IceTemp;
   10443              :                     }
   10444              :                 }
   10445              :                 // Following lagged variables set for consistency to value calculated prev time through HVAC time step loops
   10446          856 :                 if (allocated(state.dataHeatBal->HeatReclaimRefrigeratedRack)) {
   10447            0 :                     for (int IRack = 1; IRack <= state.dataRefrigCase->NumRefrigeratedRacks; ++IRack) {
   10448            0 :                         RefrigRack(IRack).LaggedUsedHVACCoil =
   10449            0 :                             state.dataHeatBal->HeatReclaimRefrigeratedRack(IRack).HVACDesuperheaterReclaimedHeatTotal;
   10450            0 :                         RefrigRack(IRack).LaggedUsedWaterHeater =
   10451            0 :                             state.dataHeatBal->HeatReclaimRefrigeratedRack(IRack).WaterHeatingDesuperheaterReclaimedHeatTotal;
   10452              :                     }
   10453              :                 }
   10454          856 :                 if (allocated(state.dataHeatBal->HeatReclaimRefrigCondenser)) {
   10455         8560 :                     for (int ICond = 1; ICond <= state.dataRefrigCase->NumRefrigCondensers; ++ICond) {
   10456        15408 :                         Condenser(ICond).LaggedUsedHVACCoil =
   10457         7704 :                             state.dataHeatBal->HeatReclaimRefrigCondenser(ICond).HVACDesuperheaterReclaimedHeatTotal;
   10458         7704 :                         Condenser(ICond).LaggedUsedWaterHeater =
   10459         7704 :                             state.dataHeatBal->HeatReclaimRefrigCondenser(ICond).WaterHeatingDesuperheaterReclaimedHeatTotal;
   10460              :                     }
   10461              :                 }
   10462              :             } // if first time
   10463              :         } //(.NOT. UseSysTimeStep)
   10464              : 
   10465              :     } // warm up flag
   10466              : 
   10467       468509 :     if (state.dataGlobal->AnyEnergyManagementSystemInModel) {
   10468        30183 :         if (state.dataRefrigCase->NumRefrigSystems > 0) {
   10469        32526 :             for (int systemID = 1; systemID <= state.dataRefrigCase->NumRefrigSystems; ++systemID) {
   10470        21684 :                 if (System(systemID).EMSOverrideOnTCondenseMin) {
   10471            0 :                     System(systemID).TCondenseMin = System(systemID).EMSOverrideValueTCondenseMin;
   10472              :                 } else {
   10473        21684 :                     System(systemID).TCondenseMin = System(systemID).TCondenseMinInput;
   10474              :                 }
   10475              :             }
   10476              :         }
   10477              :     }
   10478       468509 : }
   10479              : 
   10480        71428 : void InitRefrigerationPlantConnections(EnergyPlusData &state)
   10481              : {
   10482              : 
   10483              :     // SUBROUTINE INFORMATION:
   10484              :     //       AUTHOR         B. Griffith
   10485              :     //       DATE WRITTEN   Dec 2010
   10486              :     //       MODIFIED       na
   10487              :     //       RE-ENGINEERED  na
   10488              : 
   10489              :     // PURPOSE OF THIS SUBROUTINE:
   10490              :     // do inits that should only occur when component model routines
   10491              :     // are entered from plant, for water cooled Condensers and Refrigeration Racks
   10492              : 
   10493              :     static constexpr std::string_view RoutineName = "InitRefrigerationPlantConnections";
   10494              : 
   10495        71428 :     auto &RefrigRack = state.dataRefrigCase->RefrigRack;
   10496        71428 :     auto &Condenser = state.dataRefrigCase->Condenser;
   10497              : 
   10498              :     // initialize plant topology information, if applicable
   10499        71428 :     if (state.dataRefrigCase->MyReferPlantScanFlag && allocated(state.dataPlnt->PlantLoop)) {
   10500            4 :         for (int RefCondLoop = 1; RefCondLoop <= state.dataRefrigCase->NumRefrigCondensers; ++RefCondLoop) {
   10501            2 :             if (Condenser(RefCondLoop).CondenserType != DataHeatBalance::RefrigCondenserType::Water) {
   10502            1 :                 continue;
   10503              :             }
   10504              : 
   10505            1 :             bool errFlag = false;
   10506            2 :             PlantUtilities::ScanPlantLoopsForObject(state,
   10507            1 :                                                     Condenser(RefCondLoop).Name,
   10508              :                                                     DataPlant::PlantEquipmentType::RefrigSystemWaterCondenser,
   10509            1 :                                                     Condenser(RefCondLoop).plantLoc,
   10510              :                                                     errFlag,
   10511              :                                                     _,
   10512              :                                                     _,
   10513              :                                                     _,
   10514              :                                                     _,
   10515              :                                                     _);
   10516            1 :             if (errFlag) {
   10517            0 :                 ShowFatalError(state, "InitRefrigerationPlantConnections: Program terminated due to previous condition(s).");
   10518              :             }
   10519              : 
   10520            1 :             Real64 rho = state.dataPlnt->PlantLoop(Condenser(RefCondLoop).plantLoc.loopNum).glycol->getDensity(state, 20.0, RoutineName);
   10521              : 
   10522            1 :             if (Condenser(RefCondLoop).FlowType == CndsrFlowType::Constant) {
   10523            0 :                 Condenser(RefCondLoop).MassFlowRateMax = Condenser(RefCondLoop).DesVolFlowRate * rho;
   10524            1 :             } else if (Condenser(RefCondLoop).FlowType == CndsrFlowType::Variable) {
   10525            1 :                 Condenser(RefCondLoop).MassFlowRateMax = Condenser(RefCondLoop).VolFlowRateMax * rho;
   10526              :             }
   10527              :         }
   10528              : 
   10529            6 :         for (int RefCompRackLoop = 1; RefCompRackLoop <= state.dataRefrigCase->NumRefrigeratedRacks; ++RefCompRackLoop) {
   10530            4 :             if (RefrigRack(RefCompRackLoop).CondenserType != DataHeatBalance::RefrigCondenserType::Water) {
   10531            3 :                 continue;
   10532              :             }
   10533              : 
   10534            1 :             bool errFlag = false;
   10535            2 :             PlantUtilities::ScanPlantLoopsForObject(state,
   10536            1 :                                                     RefrigRack(RefCompRackLoop).Name,
   10537              :                                                     DataPlant::PlantEquipmentType::RefrigerationWaterCoolRack,
   10538            1 :                                                     RefrigRack(RefCompRackLoop).plantLoc,
   10539              :                                                     errFlag,
   10540              :                                                     _,
   10541              :                                                     _,
   10542              :                                                     _,
   10543              :                                                     _,
   10544              :                                                     _);
   10545            1 :             if (errFlag) {
   10546            0 :                 ShowFatalError(state, "InitRefrigerationPlantConnections: Program terminated due to previous condition(s).");
   10547              :             }
   10548              : 
   10549            1 :             Real64 rho = state.dataPlnt->PlantLoop(RefrigRack(RefCompRackLoop).plantLoc.loopNum).glycol->getDensity(state, 20.0, RoutineName);
   10550              : 
   10551            1 :             if (RefrigRack(RefCompRackLoop).FlowType == CndsrFlowType::Constant) {
   10552            0 :                 RefrigRack(RefCompRackLoop).MassFlowRateMax = RefrigRack(RefCompRackLoop).DesVolFlowRate * rho;
   10553            1 :             } else if (RefrigRack(RefCompRackLoop).FlowType == CndsrFlowType::Variable) {
   10554            1 :                 RefrigRack(RefCompRackLoop).MassFlowRateMax = RefrigRack(RefCompRackLoop).VolFlowRateMax * rho;
   10555              :             }
   10556              :         }
   10557              : 
   10558            2 :         state.dataRefrigCase->MyReferPlantScanFlag = false;
   10559        71426 :     } else if (state.dataRefrigCase->MyReferPlantScanFlag && !state.dataGlobal->AnyPlantInModel) {
   10560            0 :         state.dataRefrigCase->MyReferPlantScanFlag = false;
   10561              :     }
   10562              : 
   10563        71428 :     if (state.dataGlobal->BeginEnvrnFlag && state.dataRefrigCase->InitRefrigerationPlantConnectionsMyBeginEnvrnFlag) {
   10564              : 
   10565              :         // do plant inits, if applicable
   10566           12 :         if (!state.dataRefrigCase->MyReferPlantScanFlag) {
   10567           24 :             for (int RefCondLoop = 1; RefCondLoop <= state.dataRefrigCase->NumRefrigCondensers; ++RefCondLoop) {
   10568           12 :                 if (Condenser(RefCondLoop).CondenserType != DataHeatBalance::RefrigCondenserType::Water) {
   10569            6 :                     continue;
   10570              :                 }
   10571              : 
   10572            6 :                 Real64 rho = state.dataPlnt->PlantLoop(Condenser(RefCondLoop).plantLoc.loopNum).glycol->getDensity(state, 20.0, RoutineName);
   10573              : 
   10574            6 :                 if (Condenser(RefCondLoop).FlowType == CndsrFlowType::Constant) {
   10575            0 :                     Condenser(RefCondLoop).MassFlowRateMax = Condenser(RefCondLoop).DesVolFlowRate * rho;
   10576            6 :                 } else if (Condenser(RefCondLoop).FlowType == CndsrFlowType::Variable) {
   10577            6 :                     Condenser(RefCondLoop).MassFlowRateMax = Condenser(RefCondLoop).VolFlowRateMax * rho;
   10578              :                 }
   10579              : 
   10580           18 :                 PlantUtilities::InitComponentNodes(
   10581            6 :                     state, 0.0, Condenser(RefCondLoop).MassFlowRateMax, Condenser(RefCondLoop).InletNode, Condenser(RefCondLoop).OutletNode);
   10582              :             }
   10583           36 :             for (int RefCompRackLoop = 1; RefCompRackLoop <= state.dataRefrigCase->NumRefrigeratedRacks; ++RefCompRackLoop) {
   10584           24 :                 if (RefrigRack(RefCompRackLoop).CondenserType != DataHeatBalance::RefrigCondenserType::Water) {
   10585           18 :                     continue;
   10586              :                 }
   10587              : 
   10588            6 :                 Real64 rho = state.dataPlnt->PlantLoop(RefrigRack(RefCompRackLoop).plantLoc.loopNum).glycol->getDensity(state, 20.0, RoutineName);
   10589              : 
   10590            6 :                 if (RefrigRack(RefCompRackLoop).FlowType == CndsrFlowType::Constant) {
   10591            0 :                     RefrigRack(RefCompRackLoop).MassFlowRateMax = RefrigRack(RefCompRackLoop).DesVolFlowRate * rho;
   10592            6 :                 } else if (RefrigRack(RefCompRackLoop).FlowType == CndsrFlowType::Variable) {
   10593            6 :                     RefrigRack(RefCompRackLoop).MassFlowRateMax = RefrigRack(RefCompRackLoop).VolFlowRateMax * rho;
   10594              :                 }
   10595              : 
   10596           18 :                 PlantUtilities::InitComponentNodes(state,
   10597              :                                                    0.0,
   10598            6 :                                                    RefrigRack(RefCompRackLoop).MassFlowRateMax,
   10599            6 :                                                    RefrigRack(RefCompRackLoop).InletNode,
   10600            6 :                                                    RefrigRack(RefCompRackLoop).OutletNode);
   10601              :             }
   10602              :         }
   10603           12 :         state.dataRefrigCase->InitRefrigerationPlantConnectionsMyBeginEnvrnFlag = false;
   10604              : 
   10605              :     } //(DataGlobals::BeginEnvrnFlag .AND. MyBeginEnvrnFlag)
   10606              : 
   10607        71428 :     if (!state.dataGlobal->BeginEnvrnFlag) {
   10608        70656 :         state.dataRefrigCase->InitRefrigerationPlantConnectionsMyBeginEnvrnFlag = true;
   10609              :     }
   10610        71428 : }
   10611              : 
   10612       170642 : void RefrigRackData::CalcRackSystem(EnergyPlusData &state)
   10613              : {
   10614              : 
   10615              :     // SUBROUTINE INFORMATION:
   10616              :     //       AUTHOR         Richard Raustad, FSEC
   10617              :     //       DATE WRITTEN   Oct/Nov 2004
   10618              :     //       MODIFIED       Shirey, FSEC Dec 2004; Hudson, ORNL Feb 2007, July 2007
   10619              :     //       RE-ENGINEERED  na
   10620              : 
   10621              :     // PURPOSE OF THIS SUBROUTINE:
   10622              :     // Calculate compressor rack load, power, energy consumption, and condenser fan/pump power and consumption
   10623              : 
   10624              :     // METHODOLOGY EMPLOYED:
   10625              :     // Loop through cases attached to each rack and determine total load on compressor rack
   10626              : 
   10627              :     // REFERENCES:
   10628              :     // "Impact of ASHRAE Standard 62-1989 on Florida Supermarkets",
   10629              :     //  Florida Solar Energy Center, FSEC-CR-910-96, Final Report, Oct. 1996
   10630              : 
   10631              :     Real64 COPFTempOutput;          // Curve value for COPFTemp curve object
   10632              :     Real64 CondenserFrac;           // Fraction of condenser power as a function of outdoor temperature
   10633              :     Real64 TotalHeatRejectedToZone; // Total compressor and condenser fan heat rejected to zone (based on CaseRAFactor)
   10634              :     int HeatRejectZoneNum;          // Index to zone where heat is rejected
   10635              :     int HeatRejectZoneNodeNum;      // Index to zone where heat is rejected
   10636              :     Real64 OutWbTemp;               // Outdoor wet bulb temp at condenser air inlet node [C]
   10637              :     Real64 OutDbTemp;               // Outdoor dry bulb temp at condenser air inlet node [C]
   10638              :     Real64 EffectTemp;              // Effective outdoor temp when using evap condenser cooling [C]
   10639              :     Real64 HumRatIn;                // Humidity ratio of inlet air to condenser [kg/kg]
   10640              :     Real64 HumRatOut;               // Humidity ratio of outlet air from condenser (assumed saturated) [kg/kg]
   10641              :     Real64 BPress;                  // Barometric pressure at condenser air inlet node [Pa]
   10642              :     bool EvapAvail;                 // Control for evap condenser availability
   10643              : 
   10644       170642 :     auto &RefrigCase = state.dataRefrigCase->RefrigCase;
   10645       170642 :     auto &WalkIn = state.dataRefrigCase->WalkIn;
   10646       170642 :     auto &WarehouseCoil = state.dataRefrigCase->WarehouseCoil;
   10647       170642 :     auto &AirChillerSet = state.dataRefrigCase->AirChillerSet;
   10648              : 
   10649       170642 :     state.dataRefrigCase->TotalRackDeliveredCapacity = 0.0;
   10650       170642 :     state.dataRefrigCase->CompressorCOPactual = 0.0;
   10651       170642 :     state.dataRefrigCase->TotalCompressorPower = 0.0;
   10652       170642 :     state.dataRefrigCase->TotalCondenserFanPower = 0.0;
   10653       170642 :     state.dataRefrigCase->TotalCondenserPumpPower = 0.0;
   10654       170642 :     state.dataRefrigCase->TotalBasinHeatPower = 0.0;
   10655       170642 :     state.dataRefrigCase->TotalCondenserHeat = 0.0;
   10656       170642 :     TotalHeatRejectedToZone = 0.0;
   10657       170642 :     state.dataRefrigCase->TotalEvapWaterUseRate = 0.0;
   10658       170642 :     state.dataRefrigCase->RackSenCreditToZone = 0.0;
   10659       170642 :     state.dataRefrigCase->RackSenCreditToHVAC = 0.0;
   10660       170642 :     CondenserFrac = 0.0;
   10661       170642 :     EvapAvail = true;
   10662       170642 :     HeatRejectZoneNum = 0;
   10663       170642 :     HeatRejectZoneNodeNum = 0;
   10664              : 
   10665              :     // Loads for chiller sets are set in call to zone equipment element "SimAirChillerSet"
   10666              :     // (all chiller coils within a set are located in the same zone)
   10667              :     // (note non-zone, such as refrigeration, and zone equip, such as airchillersets, called at diff times)
   10668              :     // Loads are then defined for each chiller coil within the set in "CalculateAirChillerSet"
   10669              :     // In that subroutine, dispatch coils within each set in order specified for each zone
   10670              :     //  Below will assign loads to refrigeration system or secondary loop
   10671              :     // Note that this routine will go through all refrigeration systems, but loads for multiple systems
   10672              :     // with interactions will not be known for the initial calls with first HVAC time step. They will,
   10673              :     // however, be repeated when the last chiller set is called from ZoneEquipmentManager
   10674              :     // that's why important where init goes, don't want to zero out data should keep
   10675       170642 :     if (state.dataRefrigCase->UseSysTimeStep) {
   10676            0 :         for (int CoilSetIndex = 1; CoilSetIndex <= state.dataRefrigCase->NumRefrigChillerSets; ++CoilSetIndex) {
   10677            0 :             AirChillerSet(CoilSetIndex).CalculateAirChillerSets(state);
   10678              :         }
   10679              :     }
   10680              : 
   10681       170642 :     if (this->NumCoils > 0) {
   10682            0 :         for (int CoilIndex = 1; CoilIndex <= this->NumCoils; ++CoilIndex) {
   10683            0 :             int CoilID = this->CoilNum(CoilIndex);
   10684              :             // already CALLed CalculateCoil(CoilID) in CoilSet specified order
   10685              :             // increment TotalCoolingLoad for Compressors/condenser on each system
   10686            0 :             state.dataRefrigCase->TotalRackDeliveredCapacity += WarehouseCoil(CoilID).TotalCoolingLoad;
   10687              :             //      System(SysNum)%TotalCondDefrostCredit=System(SysNum)%TotalCondDefrostCredit + WarehouseCoil(CoilID)%HotDefrostCondCredit
   10688              :         } // NumCoils systems
   10689              :     } // System(SysNum)%NumCoils > 0
   10690              : 
   10691       170642 :     if (this->NumCases > 0) {
   10692       408654 :         for (int caseNum = 1; caseNum <= this->NumCases; ++caseNum) {
   10693       238012 :             int CaseID = this->CaseNum(caseNum);
   10694       238012 :             RefrigCase(CaseID).CalculateCase(state);
   10695              : 
   10696              :             //   add evaporator load for all cases connected to rack
   10697       238012 :             state.dataRefrigCase->TotalRackDeliveredCapacity += RefrigCase(CaseID).TotalCoolingLoad;
   10698              : 
   10699              :             //   sensible and latent case credits already calculated in "CalculateCase"
   10700              :             //   Now need to calculate amount of condenser heat rejection that should be applied to zone
   10701              :             //                                     (used when HeatRejectionLocation = LocationZone)
   10702              :             //   if walk-ins are served by rack, user must specify heat rejection zone and 100% of heat
   10703              :             //   rejection goes to that zone - that is, no heat rejection goes to the HVAC return air
   10704       238012 :             if (this->HeatRejectionLocation == HeatRejLocation::Zone) {
   10705        62310 :                 if (this->NumWalkIns == 0) {
   10706        62310 :                     TotalHeatRejectedToZone += RefrigCase(CaseID).TotalCoolingLoad * (1.0 - state.dataRefrigCase->CaseRAFactor);
   10707              :                     //  CaseRAFactor is a module variable calculated in CalculateCase
   10708              :                     //   find zone number of first case on rack (all cases are in the same zone
   10709              :                     //  if HeatRejectionLocation = LocationZone and no walk-ins)
   10710        62310 :                     HeatRejectZoneNum = RefrigCase(this->CaseNum(1)).ActualZoneNum;
   10711        62310 :                     HeatRejectZoneNodeNum = RefrigCase(this->CaseNum(1)).ZoneNodeNum;
   10712              :                 } else { // have walk ins so no reduction in condenser heat rejection for caseRA factor
   10713            0 :                     TotalHeatRejectedToZone += RefrigCase(CaseID).TotalCoolingLoad;
   10714              :                 } // no walk ins
   10715              :             }
   10716              :         } // NumCases
   10717              :     } // Numcases on rack > 0
   10718              : 
   10719       170642 :     if (this->NumWalkIns > 0) {
   10720            0 :         for (int WalkInIndex = 1; WalkInIndex <= this->NumWalkIns; ++WalkInIndex) {
   10721            0 :             int WalkInID = this->WalkInNum(WalkInIndex);
   10722            0 :             WalkIn(WalkInID).CalculateWalkIn(state);
   10723            0 :             state.dataRefrigCase->TotalRackDeliveredCapacity += WalkIn(WalkInID).TotalCoolingLoad;
   10724            0 :             if (this->HeatRejectionLocation == HeatRejLocation::Zone) {
   10725            0 :                 TotalHeatRejectedToZone += WalkIn(WalkInID).TotalCoolingLoad;
   10726            0 :                 HeatRejectZoneNum = this->HeatRejectionZoneNum;
   10727            0 :                 HeatRejectZoneNodeNum = this->HeatRejectionZoneNodeNum;
   10728              :             } // reject heat to zone
   10729              :         } // WalkInIndex
   10730              :     } // NumWalkIns>0
   10731              : 
   10732       170642 :     if (this->HeatRejectionLocation == HeatRejLocation::Zone) {
   10733        62310 :         COPFTempOutput = Curve::CurveValue(state, this->COPFTempPtr, state.dataLoopNodes->Node(HeatRejectZoneNodeNum).Temp);
   10734        62310 :         EvapAvail = false;
   10735              :     } else {
   10736       108332 :         if (this->OutsideAirNodeNum != 0) {
   10737       106310 :             OutDbTemp = state.dataLoopNodes->Node(this->OutsideAirNodeNum).Temp;
   10738       106310 :             BPress = state.dataLoopNodes->Node(this->OutsideAirNodeNum).Press;
   10739              :         } else {
   10740         2022 :             OutDbTemp = state.dataEnvrn->OutDryBulbTemp;
   10741         2022 :             BPress = state.dataEnvrn->OutBaroPress;
   10742              :         }
   10743       108332 :         EffectTemp = OutDbTemp;
   10744              : 
   10745              :         // IF schedule exists, evap condenser can be scheduled OFF
   10746              :         // Check schedule to determine evap condenser availability
   10747       108332 :         if (this->evapAvailSched != nullptr && this->evapAvailSched->getCurrentVal() == 0) {
   10748            0 :             EvapAvail = false;
   10749              :         }
   10750              : 
   10751              :         // Evaporative condensers will have their water flow shut off in cold months to avoid
   10752              :         //  'spectacular' icing problems.  Ideally, the user will use the evaporative schedule input
   10753              :         //  to set such a schedule.  However, sometimes, users will use a single input deck to model
   10754              :         //  one building in multiple climates, and may not think to put in such a schedule in the colder
   10755              :         //  climates.  To accommodate such applications, the variable EvapCutOutTdb is used as an extra
   10756              :         //  check.
   10757       108332 :         if (OutDbTemp < EvapCutOutTdb) {
   10758        49276 :             EvapAvail = false;
   10759              :         }
   10760              : 
   10761       108332 :         if (this->CondenserType == DataHeatBalance::RefrigCondenserType::Evap && EvapAvail) {
   10762              :             // determine temps for evap cooling
   10763         2026 :             if (this->OutsideAirNodeNum != 0) {
   10764         2026 :                 HumRatIn = state.dataLoopNodes->Node(this->OutsideAirNodeNum).HumRat;
   10765              :             } else {
   10766            0 :                 HumRatIn = state.dataEnvrn->OutHumRat;
   10767              :             } // outsideairnode
   10768         2026 :             OutWbTemp = Psychrometrics::PsyTwbFnTdbWPb(state, OutDbTemp, HumRatIn, BPress);
   10769         2026 :             EffectTemp = OutWbTemp + (1.0 - this->EvapEffect) * (OutDbTemp - OutWbTemp);
   10770              :         } // evapAvail
   10771              : 
   10772              :         // Obtain water-cooled condenser inlet/outlet temps
   10773       108332 :         if (this->CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
   10774         2022 :             this->InletTemp = state.dataLoopNodes->Node(this->InletNode).Temp;
   10775         2022 :             EffectTemp = state.dataLoopNodes->Node(this->InletNode).Temp + 5.0; // includes approach temp
   10776         2022 :             if (this->InletTemp < this->InletTempMin) {
   10777            0 :                 if (this->LowTempWarnIndex == 0) {
   10778            0 :                     ShowWarningMessage(state, format("Refrigeration:CompressorRack: {}", this->Name));
   10779            0 :                     ShowContinueError(state,
   10780              :                                       "Water-cooled condenser inlet temp lower than minimum allowed temp. Check returning water temperature "
   10781              :                                       "and/or minimum temperature setpoints.");
   10782              :                 } // LowTempWarnIndex
   10783            0 :                 ShowRecurringWarningErrorAtEnd(state,
   10784            0 :                                                "Refrigeration Compressor Rack " + this->Name +
   10785              :                                                    " - Condenser inlet temp lower than minimum allowed ... continues",
   10786            0 :                                                this->LowTempWarnIndex);
   10787              :                 // END IF  !LowTempWarn
   10788              :             } // InletTempMin
   10789              :         } // DataHeatBalance::RefrigCondenserType::Water
   10790              : 
   10791       108332 :         COPFTempOutput = Curve::CurveValue(state, this->COPFTempPtr, EffectTemp);
   10792              :     } // Location Zone
   10793              : 
   10794       170642 :     state.dataRefrigCase->CompressorCOPactual = this->RatedCOP * COPFTempOutput;
   10795              : 
   10796       170642 :     if (state.dataRefrigCase->CompressorCOPactual > 0.0) {
   10797       170642 :         state.dataRefrigCase->TotalCompressorPower = state.dataRefrigCase->TotalRackDeliveredCapacity / state.dataRefrigCase->CompressorCOPactual;
   10798       170642 :         state.dataRefrigCase->TotalCondenserHeat = state.dataRefrigCase->TotalCompressorPower + state.dataRefrigCase->TotalRackDeliveredCapacity;
   10799              :     } else {
   10800            0 :         if (this->ShowCOPWarning) {
   10801            0 :             ShowWarningError(state, format("Refrigeration:CompressorRack: {}", this->Name));
   10802            0 :             ShowContinueError(state, " The calculated COP has a value of zero or is negative. Refer to Engineering Documentation for");
   10803            0 :             ShowContinueError(state, " further explanation of Compressor Rack COP as a Function of Temperature Curve.");
   10804            0 :             this->ShowCOPWarning = false;
   10805              :         }
   10806              :     }
   10807              : 
   10808              :     // calculate condenser fan usage here if not water-cooled; if water-cooled, fan is in separate tower object
   10809              :     // fan loads > 0 only if the connected cases are operating
   10810       170642 :     if (state.dataRefrigCase->TotalRackDeliveredCapacity > 0.0 && this->CondenserType != DataHeatBalance::RefrigCondenserType::Water) {
   10811       166236 :         if (this->TotCondFTempPtr != 0) {
   10812        83268 :             if (this->HeatRejectionLocation == HeatRejLocation::Zone) {
   10813              :                 CondenserFrac =
   10814        15356 :                     max(0.0, min(1.0, Curve::CurveValue(state, this->TotCondFTempPtr, state.dataLoopNodes->Node(HeatRejectZoneNodeNum).Temp)));
   10815        15356 :                 state.dataRefrigCase->TotalCondenserFanPower = this->CondenserFanPower * CondenserFrac;
   10816        15356 :                 state.dataHeatBal->RefrigCaseCredit(HeatRejectZoneNum).SenCaseCreditToZone += this->CondenserFanPower * CondenserFrac;
   10817              :             } else {
   10818        67912 :                 CondenserFrac = max(0.0, min(1.0, Curve::CurveValue(state, this->TotCondFTempPtr, EffectTemp)));
   10819        67912 :                 state.dataRefrigCase->TotalCondenserFanPower = this->CondenserFanPower * CondenserFrac;
   10820              :             } // location zone
   10821              :         } else {
   10822        82968 :             CondenserFrac = 1.0;
   10823        82968 :             state.dataRefrigCase->TotalCondenserFanPower = this->CondenserFanPower * CondenserFrac;
   10824              :         } // TotCondFTempPtr
   10825              :     } // Cooling Water type
   10826              : 
   10827              :     // calculate evap water use and water pump power, if applicable
   10828              :     // assumes pump runs whenever evap cooling is available to minimize scaling
   10829       170642 :     if (this->CondenserType == DataHeatBalance::RefrigCondenserType::Evap && EvapAvail) {
   10830         2026 :         state.dataRefrigCase->TotalCondenserPumpPower = this->EvapPumpPower;
   10831         2026 :         HumRatOut = Psychrometrics::PsyWFnTdbTwbPb(state, EffectTemp, OutWbTemp, BPress);
   10832         8104 :         state.dataRefrigCase->TotalEvapWaterUseRate = this->CondenserAirFlowRate * CondenserFrac *
   10833         4052 :                                                       Psychrometrics::PsyRhoAirFnPbTdbW(state, BPress, OutDbTemp, HumRatIn) * (HumRatOut - HumRatIn) /
   10834         2026 :                                                       Psychrometrics::RhoH2O(EffectTemp);
   10835              :     } // evapAvail
   10836              :     // calculate basin water heater load
   10837       170642 :     if (this->CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
   10838         4044 :         if ((state.dataRefrigCase->TotalRackDeliveredCapacity == 0.0) && (EvapAvail) && (OutDbTemp < this->BasinHeaterSetPointTemp)) {
   10839            0 :             state.dataRefrigCase->TotalBasinHeatPower = max(0.0, this->BasinHeaterPowerFTempDiff * (this->BasinHeaterSetPointTemp - OutDbTemp));
   10840              :             // provide warning if no heater power exists
   10841            0 :             if (state.dataRefrigCase->TotalBasinHeatPower == 0.0) {
   10842            0 :                 if (this->EvapFreezeWarnIndex == 0) {
   10843            0 :                     ShowWarningMessage(
   10844              :                         state,
   10845            0 :                         format("Refrigeration Compressor Rack {} - Evap cooling of condenser underway with no basin heater power", this->Name));
   10846            0 :                     ShowContinueError(state, "and condenser inlet air dry-bulb temp at or below the basin heater setpoint temperature.");
   10847            0 :                     ShowContinueErrorTimeStamp(state, "Continuing simulation.");
   10848              :                 } // EvapFreezeWarnIndex == 0
   10849            0 :                 ShowRecurringWarningErrorAtEnd(state,
   10850            0 :                                                "Refrigeration Compressor Rack " + this->Name +
   10851              :                                                    " - Evap cooling of condenser underway with no basin heater power ... continues",
   10852            0 :                                                this->EvapFreezeWarnIndex);
   10853              :                 // END IF
   10854              :             } // TotalBasinHeatPower == 0 when at outdoor freezing conditions
   10855              :         } // cap
   10856              :     } // evap condenser type
   10857              : 
   10858              :     // add in compressor and condenser fan power to rack heat rejection variables if the heat rejection location is to the zone
   10859              :     //   if walk-ins are served by rack, user must specify heat rejection zone and 100% of heat
   10860              :     //   rejection goes to that zone - that is, no condenser heat rejection goes to the HVAC return air
   10861       170642 :     if (this->HeatRejectionLocation == HeatRejLocation::Zone) {
   10862        62310 :         state.dataRefrigCase->TotalCondenserHeat = state.dataRefrigCase->TotalRackDeliveredCapacity + state.dataRefrigCase->TotalCompressorPower +
   10863        62310 :                                                    state.dataRefrigCase->TotalCondenserFanPower;
   10864        62310 :         if (HeatRejectZoneNum > 0 && state.dataRefrigCase->TotalRackDeliveredCapacity > 0.0) {
   10865        61674 :             if (this->NumWalkIns == 0) {
   10866              :                 //       rack report variables for condenser heat to Zone and/or HVAC
   10867              :                 //       The difference between TotalHeatRejectedToZone and TotalRackDeliveredCapacity is the heat sent to return air
   10868       123348 :                 state.dataRefrigCase->RackSenCreditToZone =
   10869        61674 :                     state.dataRefrigCase->TotalCondenserHeat * (TotalHeatRejectedToZone / state.dataRefrigCase->TotalRackDeliveredCapacity);
   10870        61674 :                 state.dataRefrigCase->RackSenCreditToHVAC = state.dataRefrigCase->TotalCondenserHeat - state.dataRefrigCase->RackSenCreditToZone;
   10871              :             } else { // walkins present and no rack heat rejection goes to return air
   10872            0 :                 state.dataRefrigCase->RackSenCreditToZone = state.dataRefrigCase->TotalCondenserHeat;
   10873            0 :                 state.dataRefrigCase->RackSenCreditToHVAC = 0.0;
   10874              :             } // walkins present
   10875              :             //     Update globals for use in Air Heat Balance and Zone Equipment Manager
   10876        61674 :             state.dataHeatBal->RefrigCaseCredit(HeatRejectZoneNum).SenCaseCreditToZone += state.dataRefrigCase->RackSenCreditToZone;
   10877              : 
   10878        61674 :             state.dataHeatBal->RefrigCaseCredit(HeatRejectZoneNum).SenCaseCreditToHVAC += state.dataRefrigCase->RackSenCreditToHVAC;
   10879              :         } // zone # > 0 and tot del cap > 0
   10880              :     } // rack heat rejection to zone
   10881       170642 : }
   10882              : 
   10883       170642 : void RefrigRackData::ReportRackSystem(EnergyPlusData &state, int const RackNum)
   10884              : {
   10885              : 
   10886              :     // SUBROUTINE INFORMATION:
   10887              :     //       AUTHOR         Richard Raustad, FSEC
   10888              :     //       DATE WRITTEN   Oct/Nov 2004
   10889              :     //       MODIFIED       Hudson, ORNL Feb 2007, July 2007
   10890              :     //       RE-ENGINEERED  na
   10891              : 
   10892              :     // PURPOSE OF THIS SUBROUTINE:
   10893              :     // To report compressor rack variables
   10894              : 
   10895       170642 :     Real64 localTimeStep = (state.dataRefrigCase->UseSysTimeStep) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone;
   10896       170642 :     Real64 localTimeStepSec = localTimeStep * Constant::rSecsInHour;
   10897              : 
   10898       170642 :     this->RackCompressorPower = state.dataRefrigCase->TotalCompressorPower;
   10899       170642 :     this->RackElecConsumption = state.dataRefrigCase->TotalCompressorPower * localTimeStepSec;
   10900       170642 :     this->ActualCondenserFanPower = state.dataRefrigCase->TotalCondenserFanPower;
   10901       170642 :     this->CondenserFanConsumption = state.dataRefrigCase->TotalCondenserFanPower * localTimeStepSec;
   10902       170642 :     this->RackCapacity = state.dataRefrigCase->TotalRackDeliveredCapacity;
   10903       170642 :     this->RackCoolingEnergy = state.dataRefrigCase->TotalRackDeliveredCapacity * localTimeStepSec;
   10904       170642 :     this->RackCompressorCOP = state.dataRefrigCase->CompressorCOPactual;
   10905       170642 :     this->SensHVACCreditHeatRate = state.dataRefrigCase->RackSenCreditToHVAC;
   10906       170642 :     this->SensHVACCreditHeat = state.dataRefrigCase->RackSenCreditToHVAC * localTimeStepSec;
   10907       170642 :     this->SensZoneCreditHeatRate = state.dataRefrigCase->RackSenCreditToZone;
   10908       170642 :     this->SensZoneCreditHeat = state.dataRefrigCase->RackSenCreditToZone * localTimeStepSec;
   10909       170642 :     this->EvapWaterConsumpRate = state.dataRefrigCase->TotalEvapWaterUseRate;
   10910       170642 :     this->EvapWaterConsumption = state.dataRefrigCase->TotalEvapWaterUseRate * localTimeStepSec;
   10911       170642 :     this->ActualEvapPumpPower = state.dataRefrigCase->TotalCondenserPumpPower;
   10912       170642 :     this->EvapPumpConsumption = state.dataRefrigCase->TotalCondenserPumpPower * localTimeStepSec;
   10913       170642 :     this->BasinHeaterPower = state.dataRefrigCase->TotalBasinHeatPower;
   10914       170642 :     this->BasinHeaterConsumption = state.dataRefrigCase->TotalBasinHeatPower * localTimeStepSec;
   10915       170642 :     this->CondLoad = state.dataRefrigCase->TotalCondenserHeat;
   10916       170642 :     this->CondEnergy = state.dataRefrigCase->TotalCondenserHeat * localTimeStepSec;
   10917              :     // Set total rack heat rejection used for heat reclaim. Do not allow heat reclaim on stand alone (indoor) display cases.
   10918       170642 :     if (this->HeatRejectionLocation == HeatRejLocation::Zone) {
   10919        62310 :         state.dataHeatBal->HeatReclaimRefrigeratedRack(RackNum).AvailCapacity = 0.0;
   10920              :     } else {
   10921       108332 :         state.dataHeatBal->HeatReclaimRefrigeratedRack(RackNum).AvailCapacity =
   10922       108332 :             state.dataRefrigCase->TotalRackDeliveredCapacity * (1.0 + 1.0 / state.dataRefrigCase->CompressorCOPactual);
   10923              :     }
   10924              : 
   10925              :     // set water system demand request (if needed)
   10926       170642 :     if (this->EvapWaterSupplyMode == WaterSupply::FromTank) {
   10927         2022 :         int DemandARRID = this->EvapWaterTankDemandARRID;
   10928         2022 :         int RackTankID = this->EvapWaterSupTankID;
   10929         2022 :         state.dataWaterData->WaterStorage(RackTankID).VdotRequestDemand(DemandARRID) = this->EvapWaterConsumpRate;
   10930              :     }
   10931              : 
   10932       170642 :     SumZoneImpacts(state);
   10933       170642 : }
   10934              : 
   10935       481120 : void RefrigCaseData::CalculateCase(EnergyPlusData &state) // Absolute pointer to refrigerated case
   10936              : {
   10937              : 
   10938              :     // SUBROUTINE INFORMATION:
   10939              :     //       AUTHOR         Richard Raustad and Don Shirey, FSEC
   10940              :     //       DATE WRITTEN   Oct/Nov 2004
   10941              :     //       MODIFIED       Therese Stovall, ORNL, May 2008
   10942              :     //       RE-ENGINEERED  na
   10943              : 
   10944              :     // PURPOSE OF THIS SUBROUTINE:
   10945              :     // To model refrigerated cases.
   10946              : 
   10947              :     // METHODOLOGY EMPLOYED:
   10948              :     // Case performance is based on a latent component calculated using a user input curve object. The sensible
   10949              :     // component is made up of all equipment loads (fan, light, anti-sweat) and the sensible case credit
   10950              :     // calculated during initialization. A master schedule is used for the refrigerated case operation and
   10951              :     // additional schedules control the lights and defrost operation.
   10952              :     // The fan is assumed to be off for Hot-Gas and Electric defrost.
   10953              : 
   10954              :     // Unmet loads are accumulated to be met the following time step.  This usually occurs only during the
   10955              :     // defrost period, so the case calls for full capacity at the end of defrost to make up for the sensible
   10956              :     // case gains during the defrost period. This feature is also used if needed for restocking loads.
   10957              : 
   10958              :     // REFERENCES:
   10959              : 
   10960              :     // "Calculation of Humidity Effects on Energy Requirements of Refrigerated Display Cases",
   10961              :     //  R. H. Howell, Ph. D., P.E., ASHRAE Paper, 3687 (CH-93-16-4) (RP-596)
   10962              : 
   10963              :     // "Effects of Store Relative Humidity on Refrigerated Display Case Performance",
   10964              :     //  R. H. Howell, Ph. D., P.E., ASHRAE Paper, 3686 (CH-93-16-1) (RP-596)
   10965              : 
   10966              :     // "Analysis of Supermarket Dehumidification Alternatives",
   10967              :     //  Electric Power Research Institute, EPRI TR-100352, Project 2891-03 Final Report, Nov. 1992.
   10968              : 
   10969              :     // "Impact of ASHRAE Standard 62-1989 on Florida Supermarkets",
   10970              :     //  Florida Solar Energy Center, FSEC-CR-910-96, Final Report, Oct. 1996
   10971              : 
   10972       481120 :     Real64 CaseCreditFraction(0.0);      // Reduction in case credits due to e.g., reduced door openings at night
   10973       481120 :     Real64 DefrostSchedule(0.0);         // Display case defrost schedule
   10974       481120 :     Real64 DefrostDripDownSchedule(0.0); // Display case drip-down schedule (allows coil to drain after defrost)
   10975       481120 :     Real64 DefrostRatio(0.0);            // ratio of defrost energy at current zone temp/humrat to defrost
   10976              :     //    capacity at design condition
   10977       481120 :     Real64 LatentRatio(0.0); // ratio of latent capacity at current zone temp/humrat to
   10978              :     //    latent capacity at design condition
   10979       481120 :     Real64 LatentCap_Actual(0.0);   // Refrigerated case latent capacity at specific operating conditions
   10980       481120 :     Real64 LatentCaseCredit(0.0);   // Latent case credit delivered to zone (W)
   10981       481120 :     Real64 SensibleCap_Actual(0.0); // Refrigerated case sensible capacity at specific operating conditions
   10982       481120 :     Real64 SensibleLoadPrime(0.0);  // Sensible load due to cond, conv, rad, infil (W)
   10983       481120 :     Real64 TotalCap_Actual(0.0);    // Refrigerated case total capacity at specific operating conditions
   10984       481120 :     Real64 TotalLightingLoad(0.0);  // Total lighting energy rate (W)
   10985       481120 :     Real64 TotalFan(0.0);           // Total fan energy rate (W)
   10986       481120 :     Real64 TotalAntiSweat(0.0);     // Total anti-sweat heater energy rate (W)
   10987              : 
   10988              :     // Refrigerated display case defrost type (parameters)
   10989              :     // DefNone             = 0
   10990              :     // DefOffCycle         = 1
   10991              :     // DefHotFluid           = 2
   10992              :     // DefHotFluidOnDemand   = 3 (not available)
   10993              :     // DefHotFluidTerm       = 4
   10994              :     // DefElectric         = 5
   10995              :     // DefElectricOnDemand = 6 (not available)
   10996              :     // DefElectricTerm     = 7
   10997              : 
   10998       481120 :     state.dataRefrigCase->CaseRAFactor = 0.0;
   10999              : 
   11000              :     // Zone relative humidity (%)
   11001       481120 :     Real64 ZoneRHPercent = Psychrometrics::PsyRhFnTdbWPb(state,
   11002       481120 :                                                          state.dataLoopNodes->Node(this->ZoneNodeNum).Temp,
   11003       481120 :                                                          state.dataLoopNodes->Node(this->ZoneNodeNum).HumRat,
   11004       481120 :                                                          state.dataEnvrn->OutBaroPress) *
   11005       481120 :                            100.0;
   11006              : 
   11007              :     // Zone dew point (C)
   11008       481120 :     Real64 ZoneDewPoint = Psychrometrics::PsyTdpFnWPb(state, state.dataLoopNodes->Node(this->ZoneNodeNum).HumRat, state.dataEnvrn->OutBaroPress);
   11009              : 
   11010              :     // Display case operating temperature
   11011       481120 :     Real64 TCase = this->Temperature;
   11012              : 
   11013              :     // GET ALL SCHEDULES (note all schedules can be fractions if on/off a portion of time step)
   11014              :     // case schedule should be coincident with the zone time step otherwise the simulation proceeds
   11015              : 
   11016              :     // Current value of case operating (availability) schedule
   11017       481120 :     Real64 CaseSchedule = this->availSched->getCurrentVal();
   11018       481120 :     if (CaseSchedule <= 0) {
   11019            0 :         return;
   11020              :     }
   11021              :     // get defrost schedule
   11022       481120 :     if (this->defrostType > RefCaseDefrostType::None) {
   11023       386698 :         DefrostSchedule = this->defrostSched->getCurrentVal();
   11024       386698 :         DefrostDripDownSchedule = this->defrostDripDownSched->getCurrentVal();
   11025              :         // next statement In case user doesn't understand concept of drip down schedule
   11026       386698 :         DefrostDripDownSchedule = max(DefrostDripDownSchedule, DefrostSchedule);
   11027              :     } else {
   11028        94422 :         DefrostSchedule = 0.0;
   11029        94422 :         DefrostDripDownSchedule = 0.0;
   11030              :     }
   11031              : 
   11032              :     // get product stocking schedule and load due to product stocking, if no schedule exists load is 0
   11033       481120 :     Real64 StockingSchedule = (this->stockingSched != nullptr) ? this->stockingSched->getCurrentVal() : 0.0;
   11034              : 
   11035              :     // get lighting schedule and total load due to lighting
   11036       481120 :     Real64 LightingSchedule = this->lightingSched->getCurrentVal();
   11037              : 
   11038              :     // if case credit reduction fraction schedule exists, modify both sensible and latent case credits
   11039              :     // according to schedule - used to account for variable case envelope, such as night covers.
   11040       481120 :     CaseCreditFraction = (this->caseCreditFracSched != nullptr) ? this->caseCreditFracSched->getCurrentVal() : 1.0;
   11041              : 
   11042              :     // CALCULATE AUX LOADS DUE TO LIGHTS, FAN AND STOCKING
   11043       481120 :     TotalLightingLoad = this->DesignLighting * LightingSchedule;
   11044              : 
   11045              :     // Lighting energy to case
   11046       481120 :     Real64 TotalLightToCase = TotalLightingLoad * this->LightingFractionToCase;
   11047              : 
   11048              :     // Lighting energy to zone
   11049       481120 :     Real64 TotalLightToZone = TotalLightingLoad - TotalLightToCase;
   11050              :     // cycle fan according to defrost schedule
   11051              :     // turn fan on for none or off-cycle defrost types
   11052       481120 :     if (this->defrostType == RefCaseDefrostType::None || this->defrostType == RefCaseDefrostType::OffCycle) {
   11053       244504 :         TotalFan = this->DesignFanPower;
   11054              :     } else {
   11055       236616 :         TotalFan = this->DesignFanPower * (1.0 - DefrostDripDownSchedule);
   11056              :     }
   11057              :     // get  load due to product stocking
   11058              :     // accumulate stocking loads for reporting to help evaluate any cumulative unmet loads problems
   11059              :     // only accumulate energy during actual simulation (so same if DD's are switched)
   11060              : 
   11061              :     // Total load due to stocking case product (W)
   11062       481120 :     Real64 StockingLoad = StockingSchedule * this->Length;
   11063       481120 :     if (!state.dataGlobal->WarmupFlag) {
   11064        66144 :         Real64 DeltaStockingEnergy = (StockingLoad * state.dataGlobal->TimeStepZoneSec);
   11065        66144 :         this->StockingEnergy += DeltaStockingEnergy;
   11066              :     } // warm up
   11067              :     // CALCULTE ALL LOADS INFLUENCED BY ZONE TEMPERATURE AND RH
   11068              :     // Anti-sweat heater capacity
   11069       481120 :     switch (this->AntiSweatControlType) {
   11070       319378 :     case ASHtrCtrlType::None: {
   11071       319378 :         TotalAntiSweat = 0.0;
   11072       319378 :     } break;
   11073            0 :     case ASHtrCtrlType::Constant: {
   11074            0 :         TotalAntiSweat = this->AntiSweatPower;
   11075            0 :     } break;
   11076        78172 :     case ASHtrCtrlType::Linear: {
   11077        78172 :         TotalAntiSweat =
   11078        78172 :             this->AntiSweatPower * min(1.0, max(0.0, 1.0 - (this->RatedAmbientRH - ZoneRHPercent) / (this->RatedAmbientRH - this->HumAtZeroAS)));
   11079        78172 :         TotalAntiSweat = max(this->MinimumASPower, TotalAntiSweat);
   11080        78172 :     } break;
   11081            0 :     case ASHtrCtrlType::DewPoint: {
   11082            0 :         TotalAntiSweat = this->AntiSweatPower * min(1.0, max(0.0, (ZoneDewPoint - TCase) / (this->RatedAmbientDewPoint - TCase)));
   11083            0 :         TotalAntiSweat = max(this->MinimumASPower, TotalAntiSweat);
   11084            0 :     } break;
   11085        83570 :     case ASHtrCtrlType::HeatBalance: {
   11086        83570 :         if (this->Rcase > 0.0) {
   11087        83570 :             TotalAntiSweat = (((ZoneDewPoint - state.dataLoopNodes->Node(this->ZoneNodeNum).Temp) * this->Height / Rair) +
   11088        83570 :                               ((ZoneDewPoint - TCase) * this->Height / this->Rcase));
   11089        83570 :             TotalAntiSweat = min(this->AntiSweatPower, max(this->MinimumASPower, TotalAntiSweat));
   11090              :         } else {
   11091            0 :             TotalAntiSweat = 0.0;
   11092              :         }
   11093        83570 :     } break;
   11094            0 :     default: {
   11095              :         // should never execute this CASE statement
   11096            0 :         TotalAntiSweat = 0.0;
   11097            0 :     } break;
   11098              :     }
   11099       481120 :     TotalAntiSweat *= this->Length;
   11100              : 
   11101              :     // Anti-sweat heater energy to case
   11102       481120 :     Real64 TotalASHeaterToCase = this->ASHeaterFractionToCase * TotalAntiSweat;
   11103              : 
   11104              :     // Anti-sweat heater energy to zone
   11105       481120 :     Real64 TotalASHeaterToZone = TotalAntiSweat - TotalASHeaterToCase;
   11106              : 
   11107              :     // latent capacity correction term at off-design conditions
   11108       481120 :     switch (this->LatentEnergyCurveType) {
   11109       375512 :     case EnergyEqnForm::CaseTemperatureMethod: {
   11110       375512 :         Real64 LatCapModFrac = Curve::CurveValue(state, this->LatCapCurvePtr, TCase);
   11111       375512 :         LatentRatio = max(0.0, (1.0 - (this->RatedAmbientRH - ZoneRHPercent) * LatCapModFrac));
   11112       375512 :     } break;
   11113        36392 :     case EnergyEqnForm::RHCubic: {
   11114        36392 :         LatentRatio = max(0.0, Curve::CurveValue(state, this->LatCapCurvePtr, ZoneRHPercent));
   11115        36392 :     } break;
   11116        69216 :     case EnergyEqnForm::DPCubic: {
   11117        69216 :         LatentRatio = max(0.0, Curve::CurveValue(state, this->LatCapCurvePtr, ZoneDewPoint));
   11118        69216 :     } break;
   11119            0 :     default:
   11120            0 :         break;
   11121              :     }
   11122              : 
   11123              :     // calculate latent case load (assumes no moisture load due to stocking)
   11124              :     // assume sensible case credits continue to accumulate in case during defrost/dripdown,
   11125              :     //    but latent credits/load and capacity only applied outside dripdownschedule
   11126              : 
   11127              :     // Latent load placed on case at actual zone conditions (W)
   11128       481120 :     Real64 LatentLoad = this->DesignLatentCap * LatentRatio * CaseCreditFraction * (1.0 - DefrostDripDownSchedule);
   11129       481120 :     LatentCaseCredit = -LatentLoad;
   11130              :     // adjust sensible loads and case credit for actual zone temperature
   11131              :     // If zone temp rises above rated ambient temperature, total load can exceed case design capacity,
   11132              :     // so unmet cooling loads are accumulated to meet in the next time step. (Case credit fraction allows
   11133              :     //  extra insulation, e.g. night covers, or imitating a better insulated walk-in cooler)
   11134              : 
   11135              :     // used to look at extra sensible load due to excursions in zone T
   11136       481120 :     Real64 ZoneTempFactor = (state.dataLoopNodes->Node(ZoneNodeNum).Temp - TCase) / (this->RatedAmbientTemp - TCase);
   11137       481120 :     SensibleLoadPrime = this->DesignSensCaseCredit * ZoneTempFactor * CaseCreditFraction;
   11138              : 
   11139              :     // Sensible load due to heaters, lighting (W)
   11140       481120 :     Real64 SensibleLoadAux = TotalLightToCase + TotalASHeaterToCase + TotalFan + StockingLoad;
   11141              : 
   11142              :     // Total sensible load on case, may not = capacity applied (W)
   11143       481120 :     Real64 SensibleLoadTotal = SensibleLoadPrime + SensibleLoadAux;
   11144              :     // include lighting and anti-sweat power not attributed to case load to sensible case credit
   11145              : 
   11146              :     // Sensible case credit delivered to zone (W)
   11147       481120 :     Real64 SensibleCaseCredit = TotalLightToZone + TotalASHeaterToZone - SensibleLoadPrime;
   11148              : 
   11149              :     // FROST:  keep track of frost build up on evaporator coil
   11150              :     // avoid accumulation during warm-up to avoid reverse dd test problem
   11151       481120 :     if (!state.dataGlobal->WarmupFlag) {
   11152        66144 :         Real64 DeltaFreezeKgFrost = LatentLoad * state.dataGlobal->TimeStepZoneSec / IcetoVaporEnthalpy;
   11153        66144 :         this->KgFrost += DeltaFreezeKgFrost;
   11154              :     }
   11155              : 
   11156       481120 :     if (TCase > TempTooHotToFrost) {
   11157        36392 :         this->KgFrost = 0.0;
   11158              :     }
   11159              : 
   11160       481120 :     Real64 DefrostLoad_Actual(0.0); // heat load on case due to defrost (W)
   11161       481120 :     Real64 DefrostCap_Actual(0.0);  // power used to defrost (W)
   11162              : 
   11163              :     // DEFROST CALCULATIONS
   11164       481120 :     if (DefrostSchedule > 0.0) {
   11165         9649 :         if (this->defrostType != RefCaseDefrostType::None && this->defrostType != RefCaseDefrostType::OffCycle) {
   11166         7297 :             DefrostCap_Actual = this->DesignDefrostCap * DefrostSchedule;
   11167         7297 :             if (this->defrostType == RefCaseDefrostType::ElectricTerm || this->defrostType == RefCaseDefrostType::HotFluidTerm) {
   11168              :                 // calculate correction term for temperature termination defrost control
   11169         3248 :                 switch (this->DefrostEnergyCurveType) {
   11170         3248 :                 case EnergyEqnForm::CaseTemperatureMethod: {
   11171         3248 :                     Real64 DefCapModFrac = Curve::CurveValue(state, this->DefCapCurvePtr, TCase);
   11172         3248 :                     DefrostRatio = max(0.0, (1.0 - (this->RatedAmbientRH - ZoneRHPercent) * DefCapModFrac));
   11173         3248 :                 } break;
   11174            0 :                 case EnergyEqnForm::RHCubic: {
   11175            0 :                     DefrostRatio = max(0.0, Curve::CurveValue(state, this->DefCapCurvePtr, ZoneRHPercent));
   11176            0 :                 } break;
   11177            0 :                 case EnergyEqnForm::DPCubic: {
   11178            0 :                     DefrostRatio = max(0.0, Curve::CurveValue(state, this->DefCapCurvePtr, ZoneDewPoint));
   11179            0 :                 } break;
   11180            0 :                 case EnergyEqnForm::None: {
   11181            0 :                     DefrostRatio = 1.0;
   11182            0 :                 } break;
   11183            0 :                 default:
   11184            0 :                     break;
   11185              :                 }
   11186         3248 :                 DefrostCap_Actual *= DefrostRatio;
   11187              :             }
   11188              : 
   11189              :             // frost load at start of time step (kg of ice)
   11190         7297 :             Real64 StartFrostKg = this->KgFrost;
   11191              : 
   11192              :             // Energy form of defrost capacity (J)
   11193         7297 :             Real64 defrostEnergy = DefrostCap_Actual * state.dataGlobal->TimeStepZoneSec;
   11194              : 
   11195              :             // Frost melted by defrost during a time step (kg)
   11196         7297 :             Real64 FrostMeltedKg = min(defrostEnergy / IceMeltEnthalpy, StartFrostKg);
   11197         7297 :             this->KgFrost -= FrostMeltedKg;
   11198              : 
   11199              :             // Reduce defrost heat load on case by amount of ice melted during time step
   11200              :             // However, don't reduce the defrost capacity applied
   11201              : 
   11202         7297 :             DefrostLoad_Actual = DefrostCap_Actual - FrostMeltedKg * IceMeltEnthalpy / state.dataGlobal->TimeStepZone / Constant::rSecsInHour;
   11203              : 
   11204         7297 :             if (!state.dataGlobal->WarmupFlag) { // avoid reverse dd test problems
   11205              :                 // keep running total of defrost energy above that needed to melt frost for use in evaluating
   11206              :                 //      problems of excessive unmet loads
   11207         1008 :                 this->DeltaDefrostEnergy = max(0.0, (defrostEnergy - (FrostMeltedKg * IceMeltEnthalpy)));
   11208         1008 :                 this->DefrostEnergy += this->DeltaDefrostEnergy;
   11209              :             }
   11210              :             // If hot brine or hot gas is used for defrost, need to reduce condenser load
   11211              :             // Note this condenser credit is not applied in compressor-rack systems.
   11212         7297 :             if (this->defrostType != RefCaseDefrostType::Electric && this->defrostType != RefCaseDefrostType::ElectricOnDemand &&
   11213         4256 :                 this->defrostType != RefCaseDefrostType::ElectricTerm) {
   11214         3248 :                 this->HotDefrostCondCredit = DefrostCap_Actual * DefrostSchedule;
   11215              :             }
   11216         7297 :         } else { // no defrost or off-cycle defrost
   11217         2352 :             DefrostCap_Actual = 0.0;
   11218         2352 :             DefrostLoad_Actual = 0.0;
   11219         2352 :             this->KgFrost = 0.0;
   11220              :             // Off-Cycle defrost is assumed to melt all the ice
   11221              :         } // defrost type
   11222              : 
   11223              :     } else { // DefrostSchedule = 0, so no defrost load or capacity
   11224       471471 :         DefrostLoad_Actual = 0.0;
   11225       471471 :         DefrostCap_Actual = 0.0;
   11226              :     } // Defrost calculations
   11227              : 
   11228              :     //*** See if capacity meets load and manage accumulated stored energy ***********************************
   11229              :     // total load on case at zone conditions (W)
   11230       481120 :     Real64 TotalLoad_Actual = SensibleLoadTotal + LatentLoad + DefrostLoad_Actual;
   11231              : 
   11232              :     // Rate needed to serve all stored energy during single time step (W)
   11233       481120 :     Real64 StoredEnergyRate = this->StoredEnergy / state.dataGlobal->TimeStepZone / Constant::rSecsInHour;
   11234       481120 :     Real64 LoadRequested = TotalLoad_Actual + StoredEnergyRate;
   11235              : 
   11236              :     // prorate available cooling capacity for portion of time off due to drip down.
   11237       481120 :     Real64 CapAvail = this->DesignRatedCap * (1.0 - DefrostDripDownSchedule);
   11238       481120 :     if (CapAvail >= LoadRequested) {
   11239              :         // Have more at least as much capacity available as needed, even counting stored energy
   11240       459305 :         TotalCap_Actual = LoadRequested;
   11241       459305 :         SensibleCap_Actual = SensibleLoadTotal + StoredEnergyRate;
   11242       459305 :         LatentCap_Actual = LatentLoad;
   11243       459305 :         this->StoredEnergy = 0.0;
   11244              :     } else {
   11245              :         // Don't have as much capacity as needed (during dripdown or period following dripdown)
   11246        21815 :         TotalCap_Actual = CapAvail;
   11247        21815 :         LatentCap_Actual = min(LatentLoad, CapAvail); // Latent load should never be > capavail, but just in case...
   11248        21815 :         SensibleCap_Actual = TotalCap_Actual - LatentCap_Actual;
   11249        21815 :         if (!state.dataGlobal->WarmupFlag) {
   11250         7285 :             this->StoredEnergy += (TotalLoad_Actual - CapAvail) * state.dataGlobal->TimeStepZoneSec;
   11251              :         }
   11252              :     } // CapAvail vs Load requested
   11253              : 
   11254              :     // Reset DefrostLoad_Actual to zero for non-electric defrost types, for reporting purposes
   11255       481120 :     if (this->defrostType != RefCaseDefrostType::Electric && this->defrostType != RefCaseDefrostType::ElectricOnDemand &&
   11256       398164 :         this->defrostType != RefCaseDefrostType::ElectricTerm) {
   11257       361772 :         DefrostCap_Actual = 0.0;
   11258              :     }
   11259              : 
   11260       481120 :     Real64 caseRAFraction = min(0.8, this->RAFrac);
   11261       481120 :     state.dataRefrigCase->CaseRAFactor = (1.0 - ((0.8 - caseRAFraction) / 0.8)) * 0.5;
   11262              : 
   11263              :     // Update globals for use in ZoneTemperaturePredictorCorrector (Air Heat Balance) and
   11264              :     //   Zone Equipment Manager. Sum case credits to zone and case credits to HVAC
   11265              : 
   11266              :     //** this needs a moisture variable NonAirSystemMoistureResponse (equivalent of NonAirSystemResponse) to properly
   11267              :     //** allocate moisture to the zone when the HVAC system is off.
   11268              : 
   11269              :     // Amount of sensible case credit applied to zone load (W)
   11270       481120 :     Real64 CaseSenCreditToZone = SensibleCaseCredit * (1.0 - state.dataRefrigCase->CaseRAFactor);
   11271              : 
   11272              :     // Amount of latent case credit applied to zone load (W)
   11273       481120 :     Real64 CaseLatCreditToZone = LatentCaseCredit * (1.0 - state.dataRefrigCase->CaseRAFactor);
   11274              : 
   11275              :     // Amount of sensible case credit applied to HVAC RA duct (W)
   11276       481120 :     Real64 CaseSenCreditToHVAC = SensibleCaseCredit * state.dataRefrigCase->CaseRAFactor;
   11277              : 
   11278              :     // Amount of latent case credit applied to HVAC RA duct (W)
   11279       481120 :     Real64 CaseLatCreditToHVAC = LatentCaseCredit * state.dataRefrigCase->CaseRAFactor;
   11280              : 
   11281       481120 :     state.dataHeatBal->RefrigCaseCredit(this->ActualZoneNum).SenCaseCreditToZone += CaseSenCreditToZone;
   11282       481120 :     state.dataHeatBal->RefrigCaseCredit(this->ActualZoneNum).LatCaseCreditToZone += CaseLatCreditToZone;
   11283       481120 :     state.dataHeatBal->RefrigCaseCredit(this->ActualZoneNum).SenCaseCreditToHVAC += CaseSenCreditToHVAC;
   11284       481120 :     state.dataHeatBal->RefrigCaseCredit(this->ActualZoneNum).LatCaseCreditToHVAC += CaseLatCreditToHVAC;
   11285              : 
   11286              :     // ReportRefrigeratedCase(CaseID)
   11287       481120 :     this->TotalCoolingLoad = TotalCap_Actual;
   11288       481120 :     this->TotalCoolingEnergy = TotalCap_Actual * state.dataGlobal->TimeStepZoneSec;
   11289       481120 :     this->SensCoolingEnergyRate = SensibleCap_Actual;
   11290       481120 :     this->SensCoolingEnergy = SensibleCap_Actual * state.dataGlobal->TimeStepZoneSec;
   11291       481120 :     this->LatCoolingEnergyRate = LatentCap_Actual;
   11292       481120 :     this->LatCoolingEnergy = LatentCap_Actual * state.dataGlobal->TimeStepZoneSec;
   11293              : 
   11294       481120 :     this->SensZoneCreditRate = CaseSenCreditToZone; // both positive or negative
   11295              :     // This rate can be positive or negative, split into separate output variables and always report positive value
   11296       481120 :     if (CaseSenCreditToZone <= 0.0) {
   11297       446081 :         this->SensZoneCreditCoolRate = -CaseSenCreditToZone;
   11298       446081 :         this->SensZoneCreditCool = -CaseSenCreditToZone * state.dataGlobal->TimeStepZoneSec;
   11299       446081 :         this->SensZoneCreditHeatRate = 0.0;
   11300       446081 :         this->SensZoneCreditHeat = 0.0;
   11301              :     } else {
   11302        35039 :         this->SensZoneCreditHeatRate = CaseSenCreditToZone;
   11303        35039 :         this->SensZoneCreditHeat = CaseSenCreditToZone * state.dataGlobal->TimeStepZoneSec;
   11304        35039 :         this->SensZoneCreditCoolRate = 0.0;
   11305        35039 :         this->SensZoneCreditCool = 0.0;
   11306              :     }
   11307              : 
   11308              :     // This rate should always be negative
   11309       481120 :     this->LatZoneCreditRate = CaseLatCreditToZone;
   11310       481120 :     this->LatZoneCredit = CaseLatCreditToZone * state.dataGlobal->TimeStepZoneSec;
   11311              : 
   11312       481120 :     this->SensHVACCreditRate = CaseSenCreditToHVAC;
   11313              :     // This rate can be positive or negative, split into separate output variables and always report positive value
   11314       481120 :     if (CaseSenCreditToHVAC <= 0.0) {
   11315       448082 :         this->SensHVACCreditCoolRate = -CaseSenCreditToHVAC;
   11316       448082 :         this->SensHVACCreditCool = -CaseSenCreditToHVAC * state.dataGlobal->TimeStepZoneSec;
   11317       448082 :         this->SensHVACCreditHeatRate = 0.0;
   11318       448082 :         this->SensHVACCreditHeat = 0.0;
   11319              :     } else {
   11320        33038 :         this->SensHVACCreditHeatRate = CaseSenCreditToHVAC;
   11321        33038 :         this->SensHVACCreditHeat = CaseSenCreditToHVAC * state.dataGlobal->TimeStepZoneSec;
   11322        33038 :         this->SensHVACCreditCoolRate = 0.0;
   11323        33038 :         this->SensHVACCreditCool = 0.0;
   11324              :     }
   11325              : 
   11326              :     // This rate should always be negative
   11327       481120 :     this->LatHVACCreditRate = CaseLatCreditToHVAC;
   11328       481120 :     this->LatHVACCredit = CaseLatCreditToHVAC * state.dataGlobal->TimeStepZoneSec;
   11329              : 
   11330       481120 :     this->ElecFanPower = TotalFan;
   11331       481120 :     this->ElecFanConsumption = TotalFan * state.dataGlobal->TimeStepZoneSec;
   11332       481120 :     this->ElecAntiSweatPower = TotalAntiSweat;
   11333       481120 :     this->ElecAntiSweatConsumption = TotalAntiSweat * state.dataGlobal->TimeStepZoneSec;
   11334       481120 :     this->ElecLightingPower = TotalLightingLoad;
   11335       481120 :     this->ElecLightingConsumption = TotalLightingLoad * state.dataGlobal->TimeStepZoneSec;
   11336       481120 :     this->ElecDefrostPower = DefrostCap_Actual;
   11337       481120 :     this->ElecDefrostConsumption = DefrostCap_Actual * state.dataGlobal->TimeStepZoneSec;
   11338              : 
   11339       481120 :     this->DefEnergyCurveValue = DefrostRatio;
   11340       481120 :     this->LatEnergyCurveValue = LatentRatio;
   11341              : 
   11342              :     //**************************************************************************************************
   11343              :     // Cap Energy and Kg Frost to avoid floating overflow errors
   11344              :     // 1-time warning is issued. It should be rare but could happen with unrealistic inputs.
   11345              : 
   11346              :     // Collect extra sensible load above design for possible warning if that is determining factor in
   11347              :     // excessively large stored energy
   11348       481120 :     if ((ZoneTempFactor * CaseCreditFraction) > 1.0) {
   11349       111143 :         if (!state.dataGlobal->WarmupFlag) {
   11350        14973 :             Real64 DeltaWarmEnvEnergy = (SensibleLoadPrime - this->DesignSensCaseCredit) * state.dataGlobal->TimeStepZoneSec;
   11351        14973 :             this->WarmEnvEnergy += DeltaWarmEnvEnergy;
   11352              :         }
   11353              :     }
   11354              : 
   11355       481120 :     if (this->DefrostEnergy > MyLargeNumber) {
   11356            0 :         this->DefrostEnergy = MyLargeNumber;
   11357              :     }
   11358       481120 :     if (this->WarmEnvEnergy > MyLargeNumber) {
   11359            0 :         this->WarmEnvEnergy = MyLargeNumber;
   11360              :     }
   11361       481120 :     if (this->StockingEnergy > MyLargeNumber) {
   11362            0 :         this->StockingEnergy = MyLargeNumber;
   11363              :     }
   11364       481120 :     if (this->StoredEnergy > MyLargeNumber) {
   11365            0 :         this->StoredEnergy = MyLargeNumber;
   11366            0 :         if (this->ShowStoreEnergyWarning) {
   11367            0 :             ShowWarningError(state, format("Refrigeration:Case: {}", this->Name));
   11368            0 :             if (this->StockingEnergy >= this->DefrostEnergy) {
   11369            0 :                 if (this->StockingEnergy >= this->WarmEnvEnergy) {
   11370            0 :                     ShowContinueError(state, " This case has insufficient capacity to meet excess energy associated with stocking.");
   11371            0 :                     ShowContinueError(state, " Refer to documentation for further explanation of product stocking requirements and");
   11372            0 :                     ShowContinueError(state, " Total Cooling Capacity.");
   11373              :                 } else {
   11374            0 :                     ShowContinueError(state,
   11375              :                                       " This case has insufficient capacity to meet excess energy associated with a zone environment temperature "
   11376              :                                       "greater than the design ambient for the case.");
   11377            0 :                     ShowContinueError(state, " Refer to documentation for further explanation of ");
   11378            0 :                     ShowContinueError(state, " Total Cooling Capacity.");
   11379              :                 } // Stocking energy > warm environment energy
   11380              :             } else {
   11381            0 :                 if (this->DefrostEnergy >= this->WarmEnvEnergy) {
   11382            0 :                     ShowContinueError(state, " This case has insufficient capacity to meet excess energy associated with defrost.");
   11383            0 :                     ShowContinueError(state, " Refer to documentation for further explanation of defrost control requirements and");
   11384            0 :                     ShowContinueError(state, " recommendations regarding Total Cooling Capacity, Sensible Heat Ratio, and Defrost Capacity.");
   11385              :                 } else {
   11386            0 :                     ShowContinueError(state,
   11387              :                                       " This case has insufficient capacity to meet excess energy associated with a zone environment temperature "
   11388              :                                       "greater than the design ambient for the case.");
   11389            0 :                     ShowContinueError(state, " Refer to documentation for further explanation of ");
   11390            0 :                     ShowContinueError(state, " Total Cooling Capacity.");
   11391              :                 } // defrost energy > warm environment energy
   11392              :             } // stock > defrost ELSE
   11393            0 :             this->ShowStoreEnergyWarning = false; // only give this warning once for any one case
   11394              :         } // showstoreenergy warning true
   11395              :     } // stored energy > large number
   11396              : 
   11397       481120 :     if (this->KgFrost > MyLargeNumber) {
   11398            0 :         this->KgFrost = MyLargeNumber;
   11399            0 :         if (this->ShowFrostWarning) {
   11400            0 :             ShowWarningError(state, format("Refrigeration:Case: {}", this->Name));
   11401            0 :             ShowContinueError(state, " This case has insufficient defrost capacity to remove the excess frost accumulation.");
   11402            0 :             ShowContinueError(state, " Refer to documentation for further explanation of product stocking requirements and");
   11403            0 :             ShowContinueError(state, " recommendations regarding Total Cooling Capacity, Sensible Heat Ratio, and Latent Heat Ratio.");
   11404            0 :             this->ShowFrostWarning = false;
   11405              :         }
   11406              :     }
   11407              : }
   11408              : 
   11409            1 : PlantComponent *RefrigCondenserData::factory(EnergyPlusData &state, std::string const &objectName)
   11410              : {
   11411              :     // Process the input data for boilers if it hasn't been done already
   11412            1 :     if (state.dataRefrigCase->GetRefrigerationInputFlag) {
   11413            0 :         CheckRefrigerationInput(state);
   11414            0 :         state.dataRefrigCase->GetRefrigerationInputFlag = false;
   11415              :     }
   11416              :     // Now look for this particular object in list
   11417            2 :     for (auto &obj : state.dataRefrigCase->Condenser) {
   11418            2 :         if (obj.Name == objectName) {
   11419            1 :             return &obj;
   11420              :         }
   11421              :     }
   11422              :     // If we didn't find it, fatal
   11423              :     ShowFatalError(state, format("LocalRefrigCondenserFactory: Error getting inputs for object named: {}", objectName)); // LCOV_EXCL_LINE
   11424              :     // Shut up the compiler
   11425              :     return nullptr; // LCOV_EXCL_LINE
   11426              : }
   11427              : 
   11428            5 : void RefrigCondenserData::onInitLoopEquip(EnergyPlusData &state, [[maybe_unused]] const PlantLocation &calledFromLocation)
   11429              : {
   11430            5 :     InitRefrigeration(state);
   11431            5 :     InitRefrigerationPlantConnections(state);
   11432            5 : }
   11433              : 
   11434        35133 : void RefrigCondenserData::simulate(EnergyPlusData &state,
   11435              :                                    [[maybe_unused]] const PlantLocation &calledFromLocation,
   11436              :                                    bool const FirstHVACIteration,
   11437              :                                    [[maybe_unused]] Real64 &CurLoad,
   11438              :                                    [[maybe_unused]] bool const RunFlag)
   11439              : {
   11440              : 
   11441              :     // SUBROUTINE INFORMATION:
   11442              :     //       AUTHOR         Randy Hudson, ORNL
   11443              :     //       DATE WRITTEN   July 2007
   11444              :     //       MODIFIED       Therese Stovall, ORNL May 2008
   11445              :     //                      Brent Griffith, NREL Oct 2010, generalize fluid properties
   11446              :     //                        plant upgrades, moved where called from to SimPlantEquip from ManageNonZoneEquipment
   11447              :     //       RE-ENGINEERED  na
   11448              : 
   11449              :     // PURPOSE OF THIS SUBROUTINE:
   11450              :     // Simulates the water-cooled refrigeration condenser object.
   11451              :     // Modified to add condensers for detailed refrigeration systems and to
   11452              :     // avoid double-counting heat rejection that has been used in desuperheater
   11453              :     // hvac coils or water heaters.
   11454              : 
   11455              :     // METHODOLOGY EMPLOYED:
   11456              :     // Called from SimPlantEquip in PlantLoopEquipment , previously was called from Non-Zone Equipment Manager
   11457              :     // Flow is requested and the actual available flow is set.  The outlet temperature is calculated.
   11458              : 
   11459              :     static constexpr std::string_view RoutineName("SimRefrigCondenser");
   11460        35133 :     int PlantInletNode(0);
   11461        35133 :     int PlantOutletNode(0);
   11462        35133 :     PlantLocation PlantLoc{};
   11463              : 
   11464        35133 :     InitRefrigerationPlantConnections(state);
   11465              : 
   11466        35133 :     std::string TypeName;
   11467        35133 :     std::string ErrIntro;
   11468              : 
   11469              :     // set variables depending upon system type
   11470        35133 :     PlantInletNode = this->InletNode;
   11471        35133 :     PlantOutletNode = this->OutletNode;
   11472        35133 :     PlantLoc = this->plantLoc;
   11473              : 
   11474        35133 :     state.dataRefrigCase->TotalCondenserHeat = this->CondLoad;
   11475        35133 :     TypeName = "Refrigeration:Condenser:WaterCooled";
   11476        35133 :     ErrIntro = "Condenser for refrigeration system ";
   11477              : 
   11478              :     // Current condenser is water cooled
   11479              :     // Make demand request on first HVAC iteration
   11480              : 
   11481              :     // get cooling fluid properties
   11482        35133 :     Real64 rho = state.dataPlnt->PlantLoop(PlantLoc.loopNum).glycol->getDensity(state, this->InletTemp, RoutineName);
   11483        35133 :     Real64 Cp = state.dataPlnt->PlantLoop(PlantLoc.loopNum).glycol->getSpecificHeat(state, this->InletTemp, RoutineName);
   11484              : 
   11485        35133 :     if (this->FlowType == CndsrFlowType::Variable && state.dataRefrigCase->TotalCondenserHeat > 0.0) {
   11486              : 
   11487        34752 :         this->OutletTemp = this->outletTempSched->getCurrentVal();
   11488              : 
   11489        34752 :         if (this->OutletTemp == this->InletTemp) {
   11490              : 
   11491            0 :             if (this->HighInletWarnIndex == 0) {
   11492            0 :                 ShowSevereError(
   11493              :                     state,
   11494            0 :                     format("{}, \"{}\" : has inlet water temp equal to desired outlet temp. Excessive flow resulting. ", ErrIntro, this->Name));
   11495            0 :                 ShowContinueError(state, "cooling water is not cold enough to reach desired outlet temperature");
   11496              :             }
   11497            0 :             ShowRecurringWarningErrorAtEnd(state,
   11498            0 :                                            ErrIntro + ", \"" + this->Name + "\" : has inlet water temp equal to desired outlet temp.... continues. ",
   11499            0 :                                            this->HighInletWarnIndex);
   11500            0 :             this->VolFlowRate = 9999.0;
   11501            0 :             this->MassFlowRate = this->VolFlowRate * rho;
   11502              :         } else {
   11503        34752 :             Real64 DeltaT = this->OutletTemp - this->InletTemp;
   11504        34752 :             this->MassFlowRate = state.dataRefrigCase->TotalCondenserHeat / Cp / DeltaT;
   11505              :             // Check for maximum flow in the component
   11506        34752 :             if (this->MassFlowRate > this->MassFlowRateMax) {
   11507            0 :                 if (this->HighFlowWarnIndex == 0) {
   11508            0 :                     ShowWarningMessage(state, format("{}{}", TypeName, this->Name));
   11509            0 :                     ShowContinueError(state, "Requested condenser water mass flow rate greater than maximum allowed value. ");
   11510            0 :                     ShowContinueError(state, "Flow reset to maximum value.");
   11511              :                 } // HighFlowWarnIndex
   11512            0 :                 ShowRecurringWarningErrorAtEnd(
   11513            0 :                     state, ErrIntro + this->Name + " - Flow rate higher than maximum allowed ... continues", this->HighFlowWarnIndex);
   11514              :                 // END IF
   11515            0 :                 this->MassFlowRate = this->MassFlowRateMax;
   11516              :             }
   11517              :         } // compare outlet T to inlet T
   11518              : 
   11519          381 :     } else if (this->FlowType == CndsrFlowType::Constant && state.dataRefrigCase->TotalCondenserHeat > 0.0) {
   11520              :         // this part for constant flow condition
   11521            0 :         this->VolFlowRate = this->DesVolFlowRate;
   11522            0 :         this->MassFlowRate = this->VolFlowRate * rho;
   11523              : 
   11524          381 :     } else if (state.dataRefrigCase->TotalCondenserHeat == 0.0) {
   11525          381 :         this->MassFlowRate = 0.0;
   11526              : 
   11527              :     } // on flow type
   11528              :     // check against plant, might get changed.
   11529        35133 :     PlantUtilities::SetComponentFlowRate(state, this->MassFlowRate, PlantInletNode, PlantOutletNode, PlantLoc);
   11530              : 
   11531        35133 :     this->VolFlowRate = this->MassFlowRate / rho;
   11532              : 
   11533        35133 :     if (this->MassFlowRate > 0) {
   11534        32550 :         this->OutletTemp = state.dataRefrigCase->TotalCondenserHeat / (this->MassFlowRate * Cp) + state.dataLoopNodes->Node(PlantInletNode).Temp;
   11535              :     } else {
   11536         2583 :         this->OutletTemp = this->InletTemp;
   11537         2583 :         if ((state.dataRefrigCase->TotalCondenserHeat > 0.0) && (!FirstHVACIteration)) {
   11538              : 
   11539          128 :             ShowRecurringWarningErrorAtEnd(
   11540              :                 state,
   11541           32 :                 TypeName + this->Name +
   11542              :                     "Water-cooled condenser has no cooling water flow. Heat is not being rejected from compressor rack condenser.",
   11543           16 :                 this->NoFlowWarnIndex);
   11544              :         }
   11545              :     }
   11546              :     // Check outlet water temp for max value
   11547        35133 :     if (this->OutletTemp > this->OutletTempMax) {
   11548            0 :         if (this->HighTempWarnIndex == 0) {
   11549            0 :             ShowWarningMessage(state, format("{}{}", TypeName, this->Name));
   11550            0 :             ShowContinueError(state,
   11551              :                               "Water-cooled condenser outlet temp higher than maximum allowed temp. Check flow rates and/or temperature setpoints.");
   11552              :         }
   11553            0 :         ShowRecurringWarningErrorAtEnd(
   11554            0 :             state, ErrIntro + this->Name + " - Condenser outlet temp higher than maximum allowed ... continues", this->HighTempWarnIndex);
   11555              :     }
   11556              : 
   11557        35133 :     this->UpdateCondenserOutletNode(state);
   11558        35133 : }
   11559              : 
   11560            1 : PlantComponent *RefrigRackData::factory(EnergyPlusData &state, std::string const &objectName)
   11561              : {
   11562              :     // Process the input data for boilers if it hasn't been done already
   11563            1 :     if (state.dataRefrigCase->GetRefrigerationInputFlag) {
   11564            0 :         CheckRefrigerationInput(state);
   11565            0 :         state.dataRefrigCase->GetRefrigerationInputFlag = false;
   11566              :     }
   11567              :     // Now look for this particular object in list
   11568            2 :     for (auto &obj : state.dataRefrigCase->RefrigRack) {
   11569            2 :         if (obj.Name == objectName) {
   11570            1 :             return &obj;
   11571              :         }
   11572              :     }
   11573              :     // If we didn't find it, fatal
   11574              :     ShowFatalError(state, format("LocalRefrigRackFactory: Error getting inputs for object named: {}", objectName)); // LCOV_EXCL_LINE
   11575              :     // Shut up the compiler
   11576              :     return nullptr; // LCOV_EXCL_LINE
   11577              : }
   11578              : 
   11579            5 : void RefrigRackData::onInitLoopEquip(EnergyPlusData &state, [[maybe_unused]] const PlantLocation &calledFromLocation)
   11580              : {
   11581            5 :     InitRefrigeration(state);
   11582            5 :     InitRefrigerationPlantConnections(state);
   11583            5 : }
   11584              : 
   11585        36285 : void RefrigRackData::simulate(EnergyPlusData &state,
   11586              :                               [[maybe_unused]] const PlantLocation &calledFromLocation,
   11587              :                               bool const FirstHVACIteration,
   11588              :                               [[maybe_unused]] Real64 &CurLoad,
   11589              :                               [[maybe_unused]] bool const RunFlag)
   11590              : {
   11591              : 
   11592              :     // SUBROUTINE INFORMATION:
   11593              :     //       AUTHOR         Randy Hudson, ORNL
   11594              :     //       DATE WRITTEN   July 2007
   11595              :     //       MODIFIED       Therese Stovall, ORNL May 2008
   11596              :     //                      Brent Griffith, NREL Oct 2010, generalize fluid properties
   11597              :     //                        plant upgrades, moved where called from to SimPlantEquip from ManageNonZoneEquipment
   11598              :     //       RE-ENGINEERED  na
   11599              : 
   11600              :     // PURPOSE OF THIS SUBROUTINE:
   11601              :     // Simulates the water-cooled refrigeration condenser object.
   11602              :     // Modified to add condensers for detailed refrigeration systems and to
   11603              :     // avoid double-counting heat rejection that has been used in desuperheater
   11604              :     // hvac coils or water heaters.
   11605              : 
   11606              :     // METHODOLOGY EMPLOYED:
   11607              :     // Called from SimPlantEquip in PlantLoopEquipment , previously was called from Non-Zone Equipment Manager
   11608              :     // Flow is requested and the actual available flow is set.  The outlet temperature is calculated.
   11609              : 
   11610              :     static constexpr std::string_view RoutineName("SimRefrigCondenser");
   11611        36285 :     int PlantInletNode(0);
   11612        36285 :     int PlantOutletNode(0);
   11613        36285 :     PlantLocation PlantLoc{};
   11614              : 
   11615        36285 :     InitRefrigerationPlantConnections(state);
   11616              : 
   11617        36285 :     std::string TypeName;
   11618        36285 :     std::string ErrIntro;
   11619              : 
   11620              :     // set variables depending upon system type
   11621        36285 :     PlantInletNode = this->InletNode;
   11622        36285 :     PlantOutletNode = this->OutletNode;
   11623        36285 :     PlantLoc = this->plantLoc;
   11624              : 
   11625        72570 :     state.dataRefrigCase->TotalCondenserHeat =
   11626        36285 :         state.dataHeatBal->HeatReclaimRefrigeratedRack(this->MyIdx).AvailCapacity - this->LaggedUsedWaterHeater - this->LaggedUsedHVACCoil;
   11627        36285 :     TypeName = "Refrigeration:CompressorRack:";
   11628        36285 :     ErrIntro = "Condenser for refrigeration rack ";
   11629              : 
   11630              :     // Current condenser is water cooled
   11631              :     // Make demand request on first HVAC iteration
   11632              : 
   11633              :     // get cooling fluid properties
   11634        36285 :     Real64 rho = state.dataPlnt->PlantLoop(PlantLoc.loopNum).glycol->getDensity(state, this->InletTemp, RoutineName);
   11635        36285 :     Real64 Cp = state.dataPlnt->PlantLoop(PlantLoc.loopNum).glycol->getSpecificHeat(state, this->InletTemp, RoutineName);
   11636              : 
   11637        36285 :     if (this->FlowType == CndsrFlowType::Variable && state.dataRefrigCase->TotalCondenserHeat > 0.0) {
   11638        35904 :         this->OutletTemp = this->outletTempSched->getCurrentVal();
   11639              : 
   11640        35904 :         if (this->OutletTemp == this->InletTemp) {
   11641              : 
   11642            0 :             if (this->HighInletWarnIndex == 0) {
   11643            0 :                 ShowSevereError(
   11644              :                     state,
   11645            0 :                     format("{}, \"{}\" : has inlet water temp equal to desired outlet temp. Excessive flow resulting. ", ErrIntro, this->Name));
   11646            0 :                 ShowContinueError(state, "cooling water is not cold enough to reach desired outlet temperature");
   11647              :             }
   11648            0 :             ShowRecurringWarningErrorAtEnd(state,
   11649            0 :                                            ErrIntro + ", \"" + this->Name + "\" : has inlet water temp equal to desired outlet temp.... continues. ",
   11650            0 :                                            this->HighInletWarnIndex);
   11651            0 :             this->VolFlowRate = 9999.0;
   11652            0 :             this->MassFlowRate = this->VolFlowRate * rho;
   11653              :         } else {
   11654        35904 :             Real64 DeltaT = this->OutletTemp - this->InletTemp;
   11655        35904 :             this->MassFlowRate = state.dataRefrigCase->TotalCondenserHeat / Cp / DeltaT;
   11656              :             // Check for maximum flow in the component
   11657        35904 :             if (this->MassFlowRate > this->MassFlowRateMax) {
   11658            0 :                 if (this->HighFlowWarnIndex == 0) {
   11659            0 :                     ShowWarningMessage(state, format("{}{}", TypeName, this->Name));
   11660            0 :                     ShowContinueError(state, "Requested condenser water mass flow rate greater than maximum allowed value. ");
   11661            0 :                     ShowContinueError(state, "Flow reset to maximum value.");
   11662              :                 } // HighFlowWarnIndex
   11663            0 :                 ShowRecurringWarningErrorAtEnd(
   11664            0 :                     state, ErrIntro + this->Name + " - Flow rate higher than maximum allowed ... continues", this->HighFlowWarnIndex);
   11665              :                 // END IF
   11666            0 :                 this->MassFlowRate = this->MassFlowRateMax;
   11667              :             }
   11668              :         } // compare outlet T to inlet T
   11669              : 
   11670          381 :     } else if (this->FlowType == CndsrFlowType::Constant && state.dataRefrigCase->TotalCondenserHeat > 0.0) {
   11671              :         // this part for constant flow condition
   11672            0 :         this->VolFlowRate = this->DesVolFlowRate;
   11673            0 :         this->MassFlowRate = this->VolFlowRate * rho;
   11674              : 
   11675          381 :     } else if (state.dataRefrigCase->TotalCondenserHeat == 0.0) {
   11676          381 :         this->MassFlowRate = 0.0;
   11677              : 
   11678              :     } // on flow type
   11679              :     // check against plant, might get changed.
   11680        36285 :     PlantUtilities::SetComponentFlowRate(state, this->MassFlowRate, PlantInletNode, PlantOutletNode, PlantLoc);
   11681              : 
   11682        36285 :     this->VolFlowRate = this->MassFlowRate / rho;
   11683              : 
   11684        36285 :     if (this->MassFlowRate > 0) {
   11685        33630 :         this->OutletTemp = state.dataRefrigCase->TotalCondenserHeat / (this->MassFlowRate * Cp) + state.dataLoopNodes->Node(PlantInletNode).Temp;
   11686              :     } else {
   11687         2655 :         this->OutletTemp = this->InletTemp;
   11688         2655 :         if ((state.dataRefrigCase->TotalCondenserHeat > 0.0) && (!FirstHVACIteration)) {
   11689              : 
   11690          128 :             ShowRecurringWarningErrorAtEnd(
   11691              :                 state,
   11692           32 :                 TypeName + this->Name +
   11693              :                     "Water-cooled condenser has no cooling water flow. Heat is not being rejected from compressor rack condenser.",
   11694           16 :                 this->NoFlowWarnIndex);
   11695              :         }
   11696              :     }
   11697              :     // Check outlet water temp for max value
   11698        36285 :     if (this->OutletTemp > this->OutletTempMax) {
   11699            0 :         if (this->HighTempWarnIndex == 0) {
   11700            0 :             ShowWarningMessage(state, format("{}{}", TypeName, this->Name));
   11701            0 :             ShowContinueError(state,
   11702              :                               "Water-cooled condenser outlet temp higher than maximum allowed temp. Check flow rates and/or temperature setpoints.");
   11703              :         }
   11704            0 :         ShowRecurringWarningErrorAtEnd(
   11705            0 :             state, ErrIntro + this->Name + " - Condenser outlet temp higher than maximum allowed ... continues", HighTempWarnIndex);
   11706              :     }
   11707              : 
   11708        36285 :     this->UpdateCondenserOutletNode(state);
   11709        36285 : }
   11710              : 
   11711        35133 : void RefrigCondenserData::UpdateCondenserOutletNode(EnergyPlusData &state) const
   11712              : {
   11713              : 
   11714              :     // SUBROUTINE INFORMATION:
   11715              :     //       AUTHOR         Randy Hudson, ORNL
   11716              :     //       DATE WRITTEN   July 2007
   11717              :     //       MODIFIED       na
   11718              :     //       RE-ENGINEERED  na
   11719              : 
   11720              :     // PURPOSE OF THIS SUBROUTINE:
   11721              :     // Updates the node variables with local variables.
   11722              : 
   11723              :     // Pass all variables from inlet to outlet node
   11724        35133 :     PlantUtilities::SafeCopyPlantNode(state, this->InletNode, this->OutletNode);
   11725              : 
   11726              :     // Set outlet node variables that are possibly changed
   11727        35133 :     state.dataLoopNodes->Node(this->OutletNode).Temp = this->OutletTemp;
   11728        35133 : }
   11729            0 : void RefrigCondenserData::oneTimeInit([[maybe_unused]] EnergyPlusData &state)
   11730              : {
   11731            0 : }
   11732            1 : void RefrigCondenserData::oneTimeInit_new([[maybe_unused]] EnergyPlusData &state)
   11733              : {
   11734            1 : }
   11735              : 
   11736        36285 : void RefrigRackData::UpdateCondenserOutletNode(EnergyPlusData &state) const
   11737              : {
   11738              : 
   11739              :     // SUBROUTINE INFORMATION:
   11740              :     //       AUTHOR         Randy Hudson, ORNL
   11741              :     //       DATE WRITTEN   July 2007
   11742              :     //       MODIFIED       na
   11743              :     //       RE-ENGINEERED  na
   11744              : 
   11745              :     // PURPOSE OF THIS SUBROUTINE:
   11746              :     // Updates the node variables with local variables.
   11747              : 
   11748              :     // Pass all variables from inlet to outlet node
   11749        36285 :     PlantUtilities::SafeCopyPlantNode(state, this->InletNode, this->OutletNode);
   11750              : 
   11751              :     // Set outlet node variables that are possibly changed
   11752        36285 :     state.dataLoopNodes->Node(this->OutletNode).Temp = this->OutletTemp;
   11753        36285 : }
   11754            0 : void RefrigRackData::oneTimeInit([[maybe_unused]] EnergyPlusData &state)
   11755              : {
   11756            0 : }
   11757              : 
   11758            1 : void RefrigRackData::oneTimeInit_new([[maybe_unused]] EnergyPlusData &state)
   11759              : {
   11760            1 : }
   11761              : 
   11762       395801 : void SimulateDetailedRefrigerationSystems(EnergyPlusData &state)
   11763              : {
   11764              : 
   11765              :     // SUBROUTINE INFORMATION:
   11766              :     //       AUTHOR         Therese Stovall, ORNL, Assisted by Hugh Henderson
   11767              :     //       DATE WRITTEN   Spring 2008
   11768              :     //       Based upon ManageRefrigeratedCaseRacks by Richard Raustad, FSEC
   11769              :     //          Oct/Nov 2004, and MODIFIED by Shirey, FSEC Dec 2004
   11770              :     //       RE-ENGINEERED  na
   11771              : 
   11772              :     // PURPOSE OF THIS SUBROUTINE:
   11773              :     // This subroutine is called to simulate detailed refrigeration systems
   11774              : 
   11775              :     // METHODOLOGY EMPLOYED:
   11776              :     // Each refrigeration system is modeled by first simulating the attached refrigerated cases.  The sum
   11777              :     // of the total heat transfer for all attached cases determines the load on the compressor rack.
   11778              :     // Iterations are used here to account for load transfer between independent refrigeration systems
   11779              :     // via mechanical subcoolers.
   11780              :     // The logical variable, UseSysTimeStep, determines whether we are evaluating only systems driven by
   11781              :     // ZoneEquipmentManager on the system time step, or only system driven by HVACManager on the zone time step.
   11782              : 
   11783              :     static constexpr std::string_view RoutineName = "SimulateDetailedRefrigerationSystems";
   11784       395801 :     Real64 constexpr MaxDelTFloatFrac = 0.5; // max fraction allowed for difference between case and evaporator temperature
   11785              : 
   11786       395801 :     auto &RefrigCase = state.dataRefrigCase->RefrigCase;
   11787       395801 :     auto &System = state.dataRefrigCase->System;
   11788       395801 :     auto &Condenser = state.dataRefrigCase->Condenser;
   11789       395801 :     auto &Subcooler = state.dataRefrigCase->Subcooler;
   11790       395801 :     auto &Secondary = state.dataRefrigCase->Secondary;
   11791       395801 :     auto &WalkIn = state.dataRefrigCase->WalkIn;
   11792       395801 :     auto &WarehouseCoil = state.dataRefrigCase->WarehouseCoil;
   11793       395801 :     auto &AirChillerSet = state.dataRefrigCase->AirChillerSet;
   11794       395801 :     auto &CoilSysCredit = state.dataRefrigCase->CoilSysCredit;
   11795              : 
   11796       395801 :     Real64 localTimeStep = (state.dataRefrigCase->UseSysTimeStep) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone;
   11797       395801 :     Real64 localTimeStepSec = localTimeStep * Constant::rSecsInHour;
   11798              : 
   11799              :     // Cascade condenser assumes a constant approach delta T (Tcond - Tevap), not f(load)
   11800              : 
   11801              :     // Loads for chiller sets are set in call to zone equipment element "SimAirChillerSet"
   11802              :     // (all chiller coils within a set are located in the same zone)
   11803              :     // (note non-zone, such as refrigeration, and zone equip, such as airchillersets, called at diff times)
   11804              :     // Loads are then defined for each chiller coil within the set in "CalculateAirChillerSet"
   11805              :     // In that subroutine, dispatch coils within each set in order specified for each zone
   11806              :     //  Below will assign loads to refrigeration system or secondary loop
   11807              :     // Note that this routine will go through all refrigeration systems, but loads for multiple systems
   11808              :     // with interactions will not be known for the initial calls with first HVAC time step. They will,
   11809              :     // however, be repeated when the last chiller set is called from ZoneEquipmentManager
   11810              :     // that's why important where init goes, don't want to zero out data should keep
   11811       395801 :     if (state.dataRefrigCase->UseSysTimeStep) {
   11812      3918805 :         for (int CoilSetIndex = 1; CoilSetIndex <= state.dataRefrigCase->NumRefrigChillerSets; ++CoilSetIndex) {
   11813      3562550 :             AirChillerSet(CoilSetIndex).CalculateAirChillerSets(state);
   11814              :         }
   11815              :     }
   11816              : 
   11817              :     // Do refrigeration system loop outside of iterative solution to initialize time step and
   11818              :     //  calculate case, walk-in, and secondary loop loads (that won't change during balance
   11819              :     //  of refrigeration system iterations) and prepare initial estimates for the iterative system solution
   11820      3689276 :     for (auto &thisSys : System) {
   11821              :         // Only do those systems appropriate for this analysis, supermarket type on load time step or coil type on sys time step
   11822      3293475 :         if (((!state.dataRefrigCase->UseSysTimeStep) && (!thisSys.CoilFlag)) || ((state.dataRefrigCase->UseSysTimeStep) && (thisSys.CoilFlag))) {
   11823      3293475 :             if (thisSys.NumCases > 0) {
   11824       278610 :                 for (int CaseIndex = 1; CaseIndex <= thisSys.NumCases; ++CaseIndex) {
   11825       214800 :                     auto &thisCase = RefrigCase(thisSys.CaseNum(CaseIndex));
   11826       214800 :                     thisCase.CalculateCase(state);
   11827              :                     //  TevapDesign calc in Get Input to meet lowest evap temp of any load on the system.
   11828              :                     //  Tevap needed is either fixed at this design value,
   11829              :                     //  or allowed to float to meet lowest T needed among all loads served by the system
   11830              :                     //  (Floating Tevap = Design Tevap unless load <= Design cap)
   11831       214800 :                     if (thisSys.CompSuctControl == CompressorSuctionPressureCtrl::ConstantSuctionTemperature) {
   11832       200646 :                         thisSys.TEvapNeeded = thisSys.TEvapDesign;
   11833              :                     } else { // calculate floating T evap
   11834        14154 :                         Real64 LoadFrac = min(1.0, (thisCase.TotalCoolingLoad / thisCase.DesignRatedCap));
   11835        14154 :                         Real64 MaxTEvap = thisCase.Temperature - (thisCase.Temperature - thisCase.EvapTempDesign) * max(LoadFrac, MaxDelTFloatFrac);
   11836              :                         // Compare Tevap for this case to max allowed for all previous cases on this suction group and set at the MINIMUM of the
   11837              :                         // two
   11838        14154 :                         if (CaseIndex == 1) { // note use case index, not caseid here to get first case on this suction group/system
   11839         4044 :                             thisSys.TEvapNeeded = MaxTEvap;
   11840              :                         } else {
   11841        10110 :                             thisSys.TEvapNeeded = min(MaxTEvap, thisSys.TEvapNeeded);
   11842              :                         }
   11843              :                     } // floating or constant evap temperature
   11844              :                     // increment TotalCoolingLoad for Compressors/condenser on each system and defrost condenser credits for heat recovery
   11845       214800 :                     thisSys.TotalCoolingLoad += thisCase.TotalCoolingLoad;
   11846       214800 :                     thisSys.TotalCondDefrostCredit += thisCase.HotDefrostCondCredit;
   11847              :                 } // NumCases
   11848              :             } // Num of cases > 0
   11849              : 
   11850      3293475 :             if (thisSys.NumWalkIns > 0) {
   11851       105612 :                 for (int WalkInIndex = 1; WalkInIndex <= thisSys.NumWalkIns; ++WalkInIndex) {
   11852        52806 :                     auto &thisWalkIn = WalkIn(thisSys.WalkInNum(WalkInIndex));
   11853        52806 :                     thisWalkIn.CalculateWalkIn(state);
   11854        52806 :                     if (thisSys.CompSuctControl == CompressorSuctionPressureCtrl::ConstantSuctionTemperature) {
   11855        50784 :                         thisSys.TEvapNeeded = thisSys.TEvapDesign;
   11856              :                     } else { // calculate floating T evap
   11857         2022 :                         Real64 LoadFrac = min(1.0, (thisWalkIn.TotalCoolingLoad / thisWalkIn.DesignRatedCap));
   11858              :                         Real64 MaxTEvap =
   11859         2022 :                             thisWalkIn.Temperature - (thisWalkIn.Temperature - thisWalkIn.TEvapDesign) * max(LoadFrac, MaxDelTFloatFrac);
   11860              :                         //  Compare maxTevap for this walk in to max allowed for cases and for all
   11861              :                         //  previous walk ins on this suction group and set at the MINIMUM of the two
   11862         2022 :                         if (WalkInIndex == 1 && thisSys.NumCases == 0) {
   11863            0 :                             thisSys.TEvapNeeded = MaxTEvap;
   11864              :                         } else {
   11865         2022 :                             thisSys.TEvapNeeded = min(MaxTEvap, thisSys.TEvapNeeded);
   11866              :                         }
   11867              :                     } // floating or constant evap temperature
   11868              :                     // increment TotalCoolingLoad for Compressors/condenser on each system
   11869        52806 :                     thisSys.TotalCoolingLoad += thisWalkIn.TotalCoolingLoad;
   11870        52806 :                     thisSys.TotalCondDefrostCredit += thisWalkIn.HotDefrostCondCredit;
   11871              :                 } // NumWalkIns systems
   11872              :             } // thisSys%NumWalkIns > 0
   11873              : 
   11874      3293475 :             if (thisSys.NumCoils > 0) {
   11875     32775460 :                 for (int CoilIndex = 1; CoilIndex <= thisSys.NumCoils; ++CoilIndex) {
   11876     29569165 :                     int CoilID = thisSys.CoilNum(CoilIndex);
   11877              :                     // already CALLed CalculateCoil(CoilID) in CoilSet specified order
   11878     29569165 :                     thisSys.TEvapNeeded = thisSys.TEvapDesign; // floating or constant evap temperature
   11879              :                     // increment TotalCoolingLoad for Compressors/condenser on each system
   11880     29569165 :                     thisSys.TotalCoolingLoad += WarehouseCoil(CoilID).TotalCoolingLoad;
   11881     29569165 :                     thisSys.TotalCondDefrostCredit += WarehouseCoil(CoilID).HotDefrostCondCredit;
   11882              :                 } // NumCoils systems
   11883              :             } // thisSys%NumCoils > 0
   11884              : 
   11885      3293475 :             if (thisSys.NumSecondarys > 0) {
   11886         8088 :                 for (int SecondIndex = 1; SecondIndex <= thisSys.NumSecondarys; ++SecondIndex) {
   11887         4044 :                     int SecondID = thisSys.SecondaryNum(SecondIndex);
   11888         4044 :                     Secondary(SecondID).CalculateSecondary(state, SecondID);
   11889         4044 :                     if (thisSys.CompSuctControl == CompressorSuctionPressureCtrl::ConstantSuctionTemperature) {
   11890         4044 :                         thisSys.TEvapNeeded = thisSys.TEvapDesign;
   11891              :                     } else { // check for lowest T evap design among the secondary systems and
   11892              :                         //  Compare Tevap for this second to max allowed for cases, walk ins, and
   11893              :                         //  for all previous secondary loops on this suction group and set
   11894              :                         //  at the MINIMUM (note secondary loops control capacity with
   11895              :                         //  brine flow rate, so don't float above their design evap temperature)
   11896            0 :                         if (SecondIndex == 1 && thisSys.NumNonCascadeLoads == 0) {
   11897            0 :                             thisSys.TEvapNeeded = Secondary(SecondID).TEvapDesign;
   11898              :                         } else {
   11899            0 :                             thisSys.TEvapNeeded = min(Secondary(SecondID).TEvapDesign, thisSys.TEvapNeeded);
   11900              :                         }
   11901              :                     } // floating or constant evap temperature
   11902              :                     // increment TotalCoolingLoad for Compressors/condenser on each system
   11903         4044 :                     thisSys.SumSecondaryLoopLoad += Secondary(SecondID).TotalCoolingLoad;
   11904         4044 :                     thisSys.TotalCondDefrostCredit += Secondary(SecondID).HotDefrostCondCredit;
   11905              :                 } // NumSecondarys systems
   11906              :             } // thisSys%NumSecondarys > 0
   11907              : 
   11908              :             // add suction pipe heat gains (W) if input by user
   11909              :             // Suction pipe heat gains aren't included in the reported total system load, but are heat gains that must be met in
   11910              :             //  condenser and compressor loads. However, secondary dist piping and receiver gains are included
   11911              :             //  in the total secondary system loads.
   11912      3293475 :             thisSys.PipeHeatLoad = 0.0;
   11913      3293475 :             if (thisSys.SumUASuctionPiping > MySmallNumber) {
   11914         4044 :                 Real64 SuctionPipeZoneTemp = state.dataLoopNodes->Node(thisSys.SuctionPipeZoneNodeNum)
   11915         4044 :                                                  .Temp; // Temperature for zone identified as environment for suction pipe heat gains, C
   11916         4044 :                 thisSys.PipeHeatLoad = thisSys.SumUASuctionPiping * (SuctionPipeZoneTemp - thisSys.TEvapNeeded);
   11917              :                 // pipe heat load is a positive number (ie. heat absorbed by pipe, so needs to be subtracted
   11918              :                 //     from refrigcasecredit (- for cooling zone, + for heating zone)
   11919         4044 :                 int SuctionPipeActualZoneNum = thisSys.SuctionPipeActualZoneNum;
   11920         4044 :                 if (state.dataRefrigCase->UseSysTimeStep) {
   11921            0 :                     CoilSysCredit(SuctionPipeActualZoneNum).SenCreditToZoneRate -= thisSys.PipeHeatLoad;
   11922            0 :                     CoilSysCredit(SuctionPipeActualZoneNum).ReportSenCoolingToZoneRate = -CoilSysCredit(SuctionPipeActualZoneNum).SenCreditToZoneRate;
   11923              :                 }
   11924              :                 // Can arrive here when load call to refrigeration looks for cases/walkin systems and usetimestep is .FALSE.
   11925         8088 :                 if ((!state.dataRefrigCase->UseSysTimeStep) &&
   11926         4044 :                     ((state.dataRefrigCase->NumSimulationCases > 0) || (state.dataRefrigCase->NumSimulationWalkIns > 0))) {
   11927         4044 :                     state.dataHeatBal->RefrigCaseCredit(SuctionPipeActualZoneNum).SenCaseCreditToZone -= thisSys.PipeHeatLoad;
   11928              :                 } // UseSysTimeStep
   11929              :             }
   11930              :         } //(((.NOT. UseSysTimeStep).AND.(.NOT. System(SysNum)%CoilFlag)).OR.((UseSysTimeStep).AND.(System(SysNum)%CoilFlag)))
   11931              :     } // SysNum
   11932              : 
   11933              :     // Need to know if mechanical subcoolers or cascade condensers or shared condensers
   11934              :     //    are present. If so, energy transfer between
   11935              :     //    detailed refrigeration systems requires additional iteration at this level.
   11936              : 
   11937       395801 :     int StartMechSubcoolLoop(3); // if no mechanical subcoolers transfer energy between system,
   11938       789580 :     if ((state.dataRefrigCase->NumSimulationMechSubcoolers > 0) || (state.dataRefrigCase->NumSimulationCascadeCondensers > 0) ||
   11939       789580 :         (state.dataRefrigCase->NumSimulationSharedCondensers > 0) || (state.dataRefrigCase->NumSimulationRefrigAirChillers > 0)) {
   11940       364343 :         StartMechSubcoolLoop = 1;
   11941              :     }
   11942              : 
   11943       395801 :     bool FirstSCLoop = true; // Flag first time through multi-system loop used when mech subcoolers present
   11944              : 
   11945      1520288 :     for (int LoopNum = StartMechSubcoolLoop; LoopNum <= 3;
   11946              :          ++LoopNum) { // Note, for cascade cond loads compared requiring 5 iterations to 3, no difference.
   11947              : 
   11948     10866948 :         for (int SysNum = 1; SysNum <= state.dataRefrigCase->NumRefrigSystems; ++SysNum) {
   11949      9742461 :             auto &thisSys = System(SysNum);
   11950              :             // Only do those systems appropriate for this analysis, supermarket type on load time step or coil type on sys time step
   11951      9742461 :             if (((!state.dataRefrigCase->UseSysTimeStep) && (!thisSys.CoilFlag)) || ((state.dataRefrigCase->UseSysTimeStep) && (thisSys.CoilFlag))) {
   11952      9742461 :                 thisSys.SumMechSCLoad = 0.0;
   11953      9742461 :                 thisSys.SumCascadeLoad = 0.0;
   11954      9742461 :                 thisSys.SumCascadeCondCredit = 0.0;
   11955      9742461 :                 thisSys.SumMechSCBenefit = 0.0;
   11956              : 
   11957      9742461 :                 if ((state.dataRefrigCase->NumSimulationMechSubcoolers > 0) && (!FirstSCLoop)) {
   11958              :                     // This loop places load on system providing mechanical subcooling
   11959        24264 :                     for (int SubcoolID = 1; SubcoolID <= state.dataRefrigCase->NumSimulationSubcoolers; ++SubcoolID) {
   11960        16176 :                         if (Subcooler(SubcoolID).subcoolerType == SubcoolerType::LiquidSuction) {
   11961         8088 :                             continue;
   11962              :                         }
   11963         8088 :                         if (Subcooler(SubcoolID).MechSourceSysID != SysNum) {
   11964         4044 :                             continue;
   11965              :                         }
   11966              :                         // don't have summechscload until second subcooler pass, set to zero on first pass
   11967         4044 :                         thisSys.SumMechSCLoad += thisSys.MechSCLoad(SubcoolID);
   11968              :                         // subcooler should not drive Tevap for supplying system,
   11969              :                         //    but check to see if T controlled can be met or if Tevap is at a higher temperature
   11970         4044 :                         if (Subcooler(SubcoolID).MechControlTliqOut < thisSys.TEvapNeeded) {
   11971            0 :                             ShowWarningError(state, format("Refrigeration:System: {}", thisSys.Name));
   11972            0 :                             ShowContinueError(state, " Evaporating temperature greater than the controlled ");
   11973            0 :                             ShowContinueError(state, format(" liquid outlet temperature for SUBCOOLER:{}", Subcooler(SubcoolID).Name));
   11974              :                         }
   11975              :                     } // SubcoolId
   11976              : 
   11977         8088 :                     if (thisSys.NumSubcoolers > 0) {
   11978        12132 :                         for (int SubcoolerIndex = 1; SubcoolerIndex <= thisSys.NumSubcoolers; ++SubcoolerIndex) {
   11979         8088 :                             int SubcoolID = thisSys.SubcoolerNum(SubcoolerIndex);
   11980         8088 :                             if (Subcooler(SubcoolID).subcoolerType == SubcoolerType::LiquidSuction) {
   11981         4044 :                                 continue;
   11982              :                             }
   11983         4044 :                             thisSys.SumMechSCBenefit = Subcooler(SubcoolID).MechSCTransLoad;
   11984              :                         } // subcoolerindex
   11985              :                     } // System(sysid)%numsubcoolers > 0
   11986              :                 } // NumSimulationMechSubcoolers > 0 and not first loop
   11987              : 
   11988              :                 // This loop places load on system absorbing heat from cascade condenser and &
   11989              :                 //     condenser heat reclaim credits from hot gas/brine defrosts
   11990      9742461 :                 if ((thisSys.NumCascadeLoads > 0) && (!FirstSCLoop)) {
   11991         8088 :                     for (int CascadeLoadIndex = 1; CascadeLoadIndex <= thisSys.NumCascadeLoads; ++CascadeLoadIndex) {
   11992         4044 :                         int CascadeLoadID = thisSys.CascadeLoadNum(CascadeLoadIndex);
   11993         4044 :                         if (thisSys.CompSuctControl == CompressorSuctionPressureCtrl::ConstantSuctionTemperature) {
   11994         4044 :                             thisSys.TEvapNeeded = thisSys.TEvapDesign;
   11995              :                         } else { // check for lowest T evap design among the CascadeLoad systems and
   11996              :                             //  Compare Tevap for this Cascade to max allowed for cases, walk ins, and
   11997              :                             //  for all previous CascadeLoad loops on this suction group and set
   11998              :                             //  at the MINIMUM
   11999            0 :                             if (Condenser(CascadeLoadID).CascadeTempControl == CascadeCndsrTempCtrlType::TempSet) {
   12000              :                                 // if float then set tevap based upon other loads
   12001            0 :                                 if (CascadeLoadIndex == 1 && thisSys.NumNonCascadeLoads == 0) {
   12002            0 :                                     thisSys.TEvapNeeded = Condenser(CascadeLoadID).CascadeRatedEvapTemp;
   12003              :                                 } else {
   12004            0 :                                     thisSys.TEvapNeeded = min(Condenser(CascadeLoadID).CascadeRatedEvapTemp, thisSys.TEvapNeeded);
   12005              :                                 }
   12006              :                             }
   12007              :                         } // floating or constant system evap temperature
   12008              :                         // increment Cascade condenser Loads for Compressors/condenser on each system
   12009              :                         // place any defrost credits on the same system absorbing the cascade condenser load
   12010              :                         // (CascadeSysID identifies the condenser producing the defrost credits, that is, the lower temp system)
   12011         4044 :                         thisSys.SumCascadeLoad += Condenser(CascadeLoadID).CondLoad;
   12012         4044 :                         thisSys.SumCascadeCondCredit += System(Condenser(CascadeLoadID).CascadeSysID).TotalCondDefrostCredit;
   12013              : 
   12014              :                     } // NumCascadeLoads
   12015              :                 } // thisSys%NumCascadeLoads > 0
   12016              : 
   12017              :                 // only calc detailed system if have load (could be zero first time through if only load is cascade condenser)
   12018      9742461 :                 thisSys.TotalSystemLoad = thisSys.TotalCoolingLoad + thisSys.SumSecondaryLoopLoad + thisSys.SumMechSCLoad + thisSys.SumCascadeLoad;
   12019      9742461 :                 if (thisSys.TotalSystemLoad > 0.0) {
   12020      9166860 :                     thisSys.CpSatVapEvap = thisSys.refrig->getSatSpecificHeat(state, thisSys.TEvapNeeded, 1.0, RoutineName);
   12021      9166860 :                     thisSys.HCaseOut =
   12022      9166860 :                         thisSys.refrig->getSatEnthalpy(state, thisSys.TEvapNeeded, 1.0, RoutineName) + thisSys.CpSatVapEvap * CaseSuperheat;
   12023              :                     // Establish estimates to start solution loop
   12024      9166860 :                     switch (Condenser(thisSys.CondenserNum(1)).CondenserType) {
   12025      9142596 :                     case DataHeatBalance::RefrigCondenserType::Air: {
   12026      9142596 :                         thisSys.TCondense = state.dataEnvrn->OutDryBulbTemp + 16.7;
   12027              :                         // 16.7C is delta T at rating point for air-cooled condensers, just estimate, so ok for zone-located condensers
   12028      9142596 :                     } break;
   12029        16176 :                     case DataHeatBalance::RefrigCondenserType::Evap: {
   12030        16176 :                         thisSys.TCondense = state.dataEnvrn->OutDryBulbTemp + 15.0;
   12031              :                         // 15C is delta T at rating point for evap-cooled condensers
   12032        16176 :                     } break;
   12033         2022 :                     case DataHeatBalance::RefrigCondenserType::Water: {
   12034              :                         // define starting estimate at temperature of water exiting condenser
   12035         2022 :                         thisSys.TCondense = state.dataLoopNodes->Node(Condenser(thisSys.CondenserNum(1)).OutletNode).Temp;
   12036         2022 :                     } break;
   12037         6066 :                     case DataHeatBalance::RefrigCondenserType::Cascade: {
   12038              :                         //?Don't need estimate for cascade condenser because it doesn't iterate?
   12039         6066 :                     } break;
   12040            0 :                     default:
   12041            0 :                         break;
   12042              :                     }
   12043              : 
   12044              :                     // Produce first time step estimates, assume no subcoolers
   12045      9166860 :                     thisSys.HSatLiqCond = thisSys.refrig->getSatEnthalpy(state, thisSys.TCondense, 0.0, RoutineName);
   12046      9166860 :                     thisSys.CpSatLiqCond = thisSys.refrig->getSatSpecificHeat(state, thisSys.TCondense, 0.0, RoutineName);
   12047      9166860 :                     thisSys.HCaseIn = thisSys.HSatLiqCond - thisSys.CpSatLiqCond * Condenser(thisSys.CondenserNum(1)).RatedSubcool;
   12048      9166860 :                     thisSys.RefMassFlowtoLoads = thisSys.TotalSystemLoad / (thisSys.HCaseOut - thisSys.HCaseIn);
   12049      9166860 :                     thisSys.RefMassFlowComps = thisSys.RefMassFlowtoLoads;
   12050              : 
   12051      9166860 :                     if (thisSys.NumStages == 2) { // Two-stage compression system
   12052              :                         // Initial guess for high-stage mass flow rate in two-stage compression systems
   12053         4044 :                         thisSys.RefMassFlowHiStageComps = thisSys.RefMassFlowComps / 0.65;
   12054              :                     }
   12055              : 
   12056      9166860 :                     thisSys.CalcDetailedSystem(state, SysNum);
   12057              : 
   12058              :                     bool DeRate; // If true, need to derate aircoils because load can't be met by system
   12059              : 
   12060              :                     // With air chiller coils, don't use unmet energy, instead reduce capacity on coils to match avail compressor/cond capacity
   12061              :                     // current loads on compressor, exclusive of unmet loads from prev time steps
   12062      9166860 :                     Real64 CurrentLoads = thisSys.TotalSystemLoad + thisSys.LSHXTrans; // because compressor capacity rated from txv to comp inlet
   12063      9166860 :                     if ((thisSys.CoilFlag) && (CurrentLoads > (thisSys.TotCompCapacity * 1.001))) {
   12064        90934 :                         DeRate = true;
   12065        90934 :                         FinalRateCoils(state, DeRate, SourceType::DetailedSystem, SysNum, CurrentLoads, thisSys.TotCompCapacity);
   12066        90934 :                         thisSys.TotalCoolingLoad = 0.0;
   12067        90934 :                         thisSys.TotalCondDefrostCredit = 0.0;
   12068      1127963 :                         for (int CoilIndex = 1; CoilIndex <= thisSys.NumCoils; ++CoilIndex) {
   12069      1037029 :                             int CoilID = thisSys.CoilNum(CoilIndex);
   12070              :                             // already CALLed CalculateCoil(CoilID) in CoilSet specified order
   12071      1037029 :                             if (thisSys.CompSuctControl == CompressorSuctionPressureCtrl::ConstantSuctionTemperature) {
   12072      1037029 :                                 thisSys.TEvapNeeded = thisSys.TEvapDesign;
   12073              :                             } else { // calculate floating T evap
   12074            0 :                                 thisSys.TEvapNeeded = thisSys.TEvapDesign;
   12075            0 :                                 ShowWarningError(state, format("Refrigeration:System: {}", thisSys.Name));
   12076            0 :                                 ShowContinueError(state, " Floating evaporator temperature model not yet available for warehouse coil systems. ");
   12077              :                             } // floating or constant evap temperature
   12078              :                             // increment TotalCoolingLoad for Compressors/condenser on each system
   12079      1037029 :                             thisSys.TotalCoolingLoad += WarehouseCoil(CoilID).TotalCoolingLoad;
   12080      1037029 :                             thisSys.TotalCondDefrostCredit += WarehouseCoil(CoilID).HotDefrostCondCredit;
   12081              :                         } // NumCoils systems
   12082        90934 :                         if (thisSys.NumStages == 2 &&
   12083            0 :                             thisSys.TotHiStageCompCapacity < (thisSys.TotalCoolingLoad + thisSys.LSHXTrans + thisSys.TotCompPower)) {
   12084            0 :                             ShowRecurringWarningErrorAtEnd(state,
   12085            0 :                                                            "Refrigeration:System: " + thisSys.Name +
   12086              :                                                                ":The specified high-stage compressors for this system are unable to meet the sum "
   12087              :                                                                "of the refrigeration loads, ",
   12088            0 :                                                            thisSys.HiStageWarnIndex1);
   12089            0 :                             ShowRecurringContinueErrorAtEnd(
   12090            0 :                                 state, " subcooler loads (if any), and low-stage compressor loads for this system.", thisSys.HiStageWarnIndex2);
   12091              :                         } // Hi-stage capacity<(load+LSHX load + lo-stage compressor load)
   12092              :                     } // CoilFlag (Numcoils > 0) and load > capacity
   12093              : 
   12094              :                 } // thisSys%TotalSystemLoad > 0
   12095              :             } //(((.NOT. UseSysTimeStep).AND.(.NOT. thisSys%CoilFlag)).OR.((UseSysTimeStep).AND.(thisSys%CoilFlag)))
   12096              :         } // SysNum over NumRefrigSystems
   12097      1124487 :         FirstSCLoop = false;
   12098              :     } // LoopNum, three times for buildings with multiple detailed systems connected with mechanical subcoolers
   12099              :     // or cascade condensers or shared condensers or warehouse coils that might need to be de-rated
   12100              : 
   12101              :     // Dealing with unmet load has to be done outside iterative loop
   12102      3689276 :     for (int SysNum = 1; SysNum <= state.dataRefrigCase->NumRefrigSystems; ++SysNum) {
   12103      3293475 :         auto &thisSys = System(SysNum);
   12104              :         // Only do those systems appropriate for this analysis, supermarket type on load time step or coil type on sys time step
   12105      6586950 :         if ((((!state.dataRefrigCase->UseSysTimeStep) && (!thisSys.CoilFlag)) || ((state.dataRefrigCase->UseSysTimeStep) && (thisSys.CoilFlag))) &&
   12106      3293475 :             (!state.dataGlobal->WarmupFlag)) {
   12107       194256 :             Real64 CurrentLoads = thisSys.TotalSystemLoad + thisSys.LSHXTrans; // because compressor capacity rated from txv to comp inlet
   12108       194256 :             Real64 CurrentHiStageLoads(0.0); // Current loads on high-stage compressor, exclusive of unmet loads from
   12109       194256 :             if (thisSys.NumStages == 2) {
   12110          576 :                 CurrentHiStageLoads = CurrentLoads + thisSys.TotCompPower;
   12111              :             } // NumStages==2
   12112       194256 :             if (thisSys.CoilFlag) {
   12113              :                 // don't use 'unmet energy' with air chillers, see 'derate'
   12114       182160 :                 thisSys.UnmetEnergy = 0.0;
   12115       182160 :                 thisSys.UnmetHiStageEnergy = 0.0;
   12116              :             } else {
   12117              :                 // Meeting current and possibly some portion of the previously unmet energy
   12118              :                 // perhaps future interest in reporting percent of installed capacity used(or number of compressors) ?
   12119              :                 // If the system compressors were unable to meet the current loads, save energy to be met in succeeding time step
   12120              :                 // Note the unmet energy is turned into a rate and applied to the system load at the start of calccompressor
   12121        12096 :                 thisSys.UnmetEnergy += (CurrentLoads - thisSys.TotCompCapacity) * state.dataGlobal->TimeStepZoneSec;
   12122        12096 :                 if (thisSys.NumStages == 2) {
   12123          576 :                     thisSys.UnmetHiStageEnergy += (CurrentHiStageLoads - thisSys.TotHiStageCompCapacity) * state.dataGlobal->TimeStepZoneSec;
   12124              :                 }
   12125        12096 :                 if (thisSys.UnmetEnergy > MyLargeNumber) {
   12126            0 :                     thisSys.UnmetEnergy = MyLargeNumber;
   12127            0 :                     if (state.dataRefrigCase->ShowUnmetEnergyWarning(SysNum)) {
   12128            0 :                         ShowWarningError(state, format("Refrigeration:System: {}", thisSys.Name));
   12129            0 :                         ShowContinueError(state, " The specified compressors for this system are unable to meet ");
   12130            0 :                         ShowContinueError(state, " the sum of the refrigerated case loads and subcooler loads (if any) for this system.");
   12131            0 :                         state.dataRefrigCase->ShowUnmetEnergyWarning(SysNum) = false;
   12132              :                     } // show warning
   12133              :                 } // > mylarge number
   12134        12096 :                 if (thisSys.UnmetHiStageEnergy > MyLargeNumber) {
   12135            0 :                     thisSys.UnmetHiStageEnergy = MyLargeNumber;
   12136            0 :                     if (state.dataRefrigCase->ShowHiStageUnmetEnergyWarning(SysNum)) {
   12137            0 :                         ShowWarningError(state, format("Refrigeration:System: {}", thisSys.Name));
   12138            0 :                         ShowContinueError(state, " The specified high-stage compressors for this system are unable to meet ");
   12139            0 :                         ShowContinueError(state, " the sum of the refrigerated case loads, subcooler loads (if any) and ");
   12140            0 :                         ShowContinueError(state, " low-stage compressor loads for this system.");
   12141            0 :                         state.dataRefrigCase->ShowHiStageUnmetEnergyWarning(SysNum) = false;
   12142              :                     } // show warning
   12143              :                 } // > mylarge number
   12144              :             } // numcoils > 0
   12145              : 
   12146              :             // Zone-located air-cooled condenser reject heat also has to be outside iterative loop
   12147       194256 :             if (thisSys.SystemRejectHeatToZone) {
   12148          864 :                 int CondInletAirZoneNum = Condenser(thisSys.CondenserNum(1)).InletAirZoneNum;
   12149          864 :                 if (state.dataRefrigCase->UseSysTimeStep) {
   12150            0 :                     CoilSysCredit(CondInletAirZoneNum).SenCreditToZoneRate += thisSys.NetHeatRejectLoad; // Adding heat is positive
   12151            0 :                     CoilSysCredit(CondInletAirZoneNum).ReportSenCoolingToZoneRate = -CoilSysCredit(CondInletAirZoneNum).SenCreditToZoneRate;
   12152              :                 }
   12153              :                 // Can arrive here when load call to refrigeration looks for cases/walkin systems and usetimestep is .FALSE.
   12154         1728 :                 if ((!state.dataRefrigCase->UseSysTimeStep) &&
   12155          864 :                     ((state.dataRefrigCase->NumSimulationCases > 0) || (state.dataRefrigCase->NumSimulationWalkIns > 0))) {
   12156          864 :                     state.dataHeatBal->RefrigCaseCredit(CondInletAirZoneNum).SenCaseCreditToZone +=
   12157          864 :                         thisSys.NetHeatRejectLoad; // Adding heat is positive
   12158              :                 } // UseSystimestep
   12159              :             } // Reject heat to zone
   12160              : 
   12161              :             // Report variables
   12162       194256 :             thisSys.TotTransferLoad = thisSys.SumMechSCLoad - thisSys.SumMechSCBenefit + thisSys.SumSecondaryLoopLoad + thisSys.SumCascadeLoad;
   12163       194256 :             thisSys.TotTransferEnergy = thisSys.TotTransferLoad * localTimeStepSec;
   12164       194256 :             thisSys.PipeHeatEnergy = thisSys.PipeHeatLoad * localTimeStepSec;
   12165       194256 :             thisSys.TotalCoolingEnergy = thisSys.TotalCoolingLoad * localTimeStepSec;
   12166              :         } //(((.NOT. UseSysTimeStep).AND.(.NOT. System(SysNum)%CoilFlag)).OR.((UseSysTimeStep).AND.(System(SysNum)%CoilFlag))).and.not
   12167              :           // WarmupFlag
   12168              :     } // SysNum = 1,NumRefrigSystems
   12169              : 
   12170              :     // Update for sending to zone equipment manager. (note report variables are summed elsewhere)
   12171              :     //   LatOutputProvided = CoilSysCredit(ZoneNum)%LatKgPerS_ToZoneRate
   12172              :     //   SysOutputProvided = CoilSysCredit(ZoneNum)%SenCreditToZoneRate
   12173              :     // Note that case credit is negative for cooling, thus subtract positive value calculated for coil
   12174              :     //   Note this is done whether or not the coils are derated.
   12175       395801 :     if (state.dataRefrigCase->UseSysTimeStep) {
   12176      5343825 :         for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) {
   12177      4987570 :             auto &zoneCredit = CoilSysCredit(ZoneNum);
   12178    418955880 :             for (int CoilID = 1; CoilID <= state.dataRefrigCase->NumSimulationRefrigAirChillers; ++CoilID) {
   12179    413968310 :                 auto &coil = WarehouseCoil(CoilID);
   12180    413968310 :                 if (coil.ZoneNum != ZoneNum) {
   12181    384399145 :                     continue;
   12182              :                 }
   12183     29569165 :                 zoneCredit.SenCreditToZoneRate -= coil.SensCreditRate;
   12184     29569165 :                 zoneCredit.SenCreditToZoneEnergy = zoneCredit.SenCreditToZoneRate * localTimeStepSec;
   12185     29569165 :                 zoneCredit.LatKgPerS_ToZoneRate -= coil.LatKgPerS_ToZone;
   12186     29569165 :                 zoneCredit.LatCreditToZoneRate -= coil.LatCreditRate;
   12187     29569165 :                 zoneCredit.LatCreditToZoneEnergy -= coil.LatCreditEnergy;
   12188              :             }
   12189              :         }
   12190              :     }
   12191              : 
   12192       395801 :     SumZoneImpacts(state);
   12193       395801 : }
   12194              : 
   12195         2022 : void SimulateDetailedTransRefrigSystems(EnergyPlusData &state)
   12196              : {
   12197              : 
   12198              :     // SUBROUTINE INFORMATION:
   12199              :     //       AUTHOR         Brian A. Fricke, ORNL
   12200              :     //       DATE WRITTEN   Fall 2011
   12201              :     //       RE-ENGINEERED  na
   12202              : 
   12203              :     // PURPOSE OF THIS SUBROUTINE:
   12204              :     // This subroutine is called to simulate detailed transcritical CO2 refrigeration systems
   12205              : 
   12206              :     // METHODOLOGY EMPLOYED:
   12207              :     // Each refrigeration system is modeled by first simulating the attached refrigerated cases and
   12208              :     // walk-ins. The sum of the total heat transfer for all attached cases and walk-ins determines
   12209              :     // the load on the compressors. Iterations are used here to account for sharing of gas coolers
   12210              :     // between independent refrigeration systems.
   12211              : 
   12212              :     static constexpr std::string_view RoutineName = "SimulateDetailedTransRefrigSystems";
   12213              : 
   12214         2022 :     auto &RefrigCase = state.dataRefrigCase->RefrigCase;
   12215         2022 :     auto &TransSystem = state.dataRefrigCase->TransSystem;
   12216         2022 :     auto &GasCooler = state.dataRefrigCase->GasCooler;
   12217         2022 :     auto &WalkIn = state.dataRefrigCase->WalkIn;
   12218              : 
   12219         2022 :     Real64 localTimeStep = (state.dataRefrigCase->UseSysTimeStep) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone;
   12220         2022 :     Real64 localTimeStepSec = localTimeStep * Constant::rSecsInHour;
   12221              : 
   12222              :     //  Do transcritical CO2 refrigeration system loop outside of iterative solution to initialize time step and
   12223              :     //  calculate case and and walk-ins (that won't change during balance of refrigeration system iterations)
   12224              :     //  and prepare initial estimates for the iterative system solution
   12225              : 
   12226              :     //  TransCritSysFlag = .TRUE.
   12227         4044 :     for (auto &thisSys : TransSystem) {
   12228              :         // Only do those systems appropriate for this analysis, supermarket type on load time step
   12229         2022 :         if (thisSys.NumCasesMT > 0) {
   12230         8088 :             for (int CaseIndex = 1; CaseIndex <= thisSys.NumCasesMT; ++CaseIndex) {
   12231         6066 :                 int CaseID = thisSys.CaseNumMT(CaseIndex);
   12232         6066 :                 RefrigCase(CaseID).CalculateCase(state);
   12233              :                 //  TEvapDesignMT calc in Get Input to meet lowest evap temp of any MT load on the system.
   12234              :                 //  TEvapNeededMT is fixed at this design value.
   12235         6066 :                 thisSys.TEvapNeededMT = thisSys.TEvapDesignMT;
   12236              :                 // increment TotalCoolingLoad for Compressors/gas cooler on each system and defrost gas cooler credits for heat recovery
   12237         6066 :                 thisSys.TotalCoolingLoadMT += RefrigCase(CaseID).TotalCoolingLoad;
   12238         6066 :                 thisSys.TotalCondDefrostCredit += RefrigCase(CaseID).HotDefrostCondCredit;
   12239              :             } // NumCasesMT
   12240              :         } // Num of MT cases > 0
   12241              : 
   12242         2022 :         if (thisSys.NumCasesLT > 0) {
   12243        10110 :             for (int CaseIndex = 1; CaseIndex <= thisSys.NumCasesLT; ++CaseIndex) {
   12244         8088 :                 int CaseID = thisSys.CaseNumLT(CaseIndex);
   12245         8088 :                 RefrigCase(CaseID).CalculateCase(state);
   12246              :                 //  TEvapDesignLT calc in Get Input to meet lowest evap temp of any LT load on the system.
   12247              :                 //  TEvapNeededLT is fixed at this design value.
   12248         8088 :                 thisSys.TEvapNeededLT = thisSys.TEvapDesignLT;
   12249              :                 // increment TotalCoolingLoad for Compressors/gas cooler on each system and defrost gas cooler credits for heat recovery
   12250         8088 :                 thisSys.TotalCoolingLoadLT += RefrigCase(CaseID).TotalCoolingLoad;
   12251         8088 :                 thisSys.TotalCondDefrostCredit += RefrigCase(CaseID).HotDefrostCondCredit;
   12252              :             } // NumCasesLT
   12253              :         } // Num of LT cases > 0
   12254              : 
   12255         2022 :         if (thisSys.NumWalkInsMT > 0) {
   12256            0 :             for (int WalkInIndex = 1; WalkInIndex <= thisSys.NumWalkInsMT; ++WalkInIndex) {
   12257            0 :                 int WalkInID = thisSys.WalkInNumMT(WalkInIndex);
   12258            0 :                 WalkIn(WalkInID).CalculateWalkIn(state);
   12259              :                 //  TEvapDesignMT calc in Get Input to meet lowest evap temp of any MT load on the system.
   12260              :                 //  TEvapNeededMT is fixed at this design value.
   12261            0 :                 thisSys.TEvapNeededMT = thisSys.TEvapDesignMT;
   12262              :                 // increment TotalCoolingLoad for Compressors/gas cooler on each system
   12263            0 :                 thisSys.TotalCoolingLoadMT += WalkIn(WalkInID).TotalCoolingLoad;
   12264            0 :                 thisSys.TotalCondDefrostCredit += WalkIn(WalkInID).HotDefrostCondCredit;
   12265              :             } // NumWalkInsMT systems
   12266              :         } // thisSys%NumWalkInsMT > 0
   12267              : 
   12268         2022 :         if (thisSys.NumWalkInsLT > 0) {
   12269         4044 :             for (int WalkInIndex = 1; WalkInIndex <= thisSys.NumWalkInsLT; ++WalkInIndex) {
   12270         2022 :                 int WalkInID = thisSys.WalkInNumLT(WalkInIndex);
   12271         2022 :                 WalkIn(WalkInID).CalculateWalkIn(state);
   12272              :                 //  TEvapDesignLT calc in Get Input to meet lowest evap temp of any LT load on the system.
   12273              :                 //  TEvapNeeded is fixed at this design value.
   12274         2022 :                 thisSys.TEvapNeededLT = thisSys.TEvapDesignLT;
   12275              :                 // increment TotalCoolingLoad for Compressors/gas cooler on each system
   12276         2022 :                 thisSys.TotalCoolingLoadLT += WalkIn(WalkInID).TotalCoolingLoad;
   12277         2022 :                 thisSys.TotalCondDefrostCredit += WalkIn(WalkInID).HotDefrostCondCredit;
   12278              :             } // NumWalkInsLT systems
   12279              :         } // thisSys%NumWalkInsLT > 0
   12280              : 
   12281              :         // add suction pipe heat gains (W) if input by user
   12282              :         // Suction pipe heat gains aren't included in the reported total system load, but are heat gains that must be met in
   12283              :         //  gas cooler and compressor loads.
   12284         2022 :         thisSys.PipeHeatLoadMT = 0.0;
   12285         2022 :         if (thisSys.SumUASuctionPipingMT > MySmallNumber) {
   12286            0 :             Real64 SuctionPipeZoneTemp = state.dataLoopNodes->Node(thisSys.SuctionPipeZoneNodeNumMT).Temp;
   12287            0 :             thisSys.PipeHeatLoadMT = thisSys.SumUASuctionPipingMT * (SuctionPipeZoneTemp - thisSys.TEvapNeededMT);
   12288              :             // pipe heat load is a positive number (ie. heat absorbed by pipe, so needs to be subtracted
   12289              :             //   from refrigcasecredit (- for cooling zone, + for heating zone)
   12290            0 :             int SuctionPipeActualZoneNum = thisSys.SuctionPipeActualZoneNumMT;
   12291              :             // Can arrive here when load call to refrigeration looks for cases/walkin systems and usetimestep is .FALSE.
   12292            0 :             if ((!state.dataRefrigCase->UseSysTimeStep) &&
   12293            0 :                 ((state.dataRefrigCase->NumSimulationCases > 0) || (state.dataRefrigCase->NumSimulationWalkIns > 0))) {
   12294            0 :                 state.dataHeatBal->RefrigCaseCredit(SuctionPipeActualZoneNum).SenCaseCreditToZone -= thisSys.PipeHeatLoadMT;
   12295              :             } // UseSysTimeStep
   12296              :         }
   12297              : 
   12298         2022 :         thisSys.PipeHeatLoadLT = 0.0;
   12299         2022 :         if (thisSys.SumUASuctionPipingLT > MySmallNumber) {
   12300            0 :             Real64 SuctionPipeZoneTemp = state.dataLoopNodes->Node(thisSys.SuctionPipeZoneNodeNumLT).Temp;
   12301            0 :             thisSys.PipeHeatLoadLT = thisSys.SumUASuctionPipingLT * (SuctionPipeZoneTemp - thisSys.TEvapNeededLT);
   12302              :             // pipe heat load is a positive number (ie. heat absorbed by pipe, so needs to be subtracted
   12303              :             //   from refrigcasecredit (- for cooling zone, + for heating zone)
   12304            0 :             int SuctionPipeActualZoneNum = thisSys.SuctionPipeActualZoneNumLT;
   12305              :             // Can arrive here when load call to refrigeration looks for cases/walkin systems and usetimestep is .FALSE.
   12306            0 :             if ((!state.dataRefrigCase->UseSysTimeStep) &&
   12307            0 :                 ((state.dataRefrigCase->NumSimulationCases > 0) || (state.dataRefrigCase->NumSimulationWalkIns > 0))) {
   12308            0 :                 state.dataHeatBal->RefrigCaseCredit(SuctionPipeActualZoneNum).SenCaseCreditToZone -= thisSys.PipeHeatLoadLT;
   12309              :             } // UseSysTimeStep
   12310              :         }
   12311              : 
   12312              :     } // SysNum
   12313              : 
   12314              :     // Need to know if shared gas coolers are present. If so, energy
   12315              :     // transfer between detailed transcritical refrigeration systems
   12316              :     // requires additional iteration at this level.
   12317              : 
   12318         2022 :     int StartMechSubcoolLoop(3); // if no mechanical subcoolers transfer energy between system, don't loop
   12319         2022 :     if (state.dataRefrigCase->NumSimulationSharedGasCoolers > 0) {
   12320            0 :         StartMechSubcoolLoop = 1;
   12321              :     }
   12322              : 
   12323         4044 :     for (int LoopNum = StartMechSubcoolLoop; LoopNum <= 3; ++LoopNum) {
   12324         4044 :         for (int SysNum = 1; SysNum <= state.dataRefrigCase->NumTransRefrigSystems; ++SysNum) {
   12325         2022 :             auto &sys = TransSystem(SysNum);
   12326              :             // Only do those systems appropriate for this analysis, supermarket type on load time step or coil type on sys time step
   12327              :             // only calc detailed system if have load
   12328         2022 :             sys.TotalSystemLoadMT = sys.TotalCoolingLoadMT;
   12329         2022 :             if (sys.transSysType == TransSysType::TwoStage) {
   12330         2022 :                 sys.TotalSystemLoadLT = sys.TotalCoolingLoadLT;
   12331              :             }
   12332         2022 :             sys.TotalSystemLoad = sys.TotalSystemLoadLT + sys.TotalSystemLoadMT;
   12333         2022 :             if (sys.TotalSystemLoad > 0.0) {
   12334         2022 :                 if (sys.transSysType == TransSysType::TwoStage) {
   12335         2022 :                     sys.CpSatVapEvapLT = sys.refrig->getSatSpecificHeat(state, sys.TEvapNeededLT, 1.0, RoutineName);
   12336         2022 :                     sys.HCaseOutLT = sys.refrig->getSatEnthalpy(state, sys.TEvapNeededLT, 1.0, RoutineName) + sys.CpSatVapEvapLT * TransCaseSuperheat;
   12337              :                 }
   12338         2022 :                 sys.CpSatVapEvapMT = sys.refrig->getSatSpecificHeat(state, sys.TEvapNeededMT, 1.0, RoutineName);
   12339         2022 :                 sys.HCaseOutMT = sys.refrig->getSatEnthalpy(state, sys.TEvapNeededMT, 1.0, RoutineName) + sys.CpSatVapEvapMT * TransCaseSuperheat;
   12340              : 
   12341              :                 // Produce first time step estimates.
   12342              :                 // Assume no subcoolers and neglect flow through bypass.
   12343         2022 :                 sys.TReceiver = sys.refrig->getSatTemperature(state, sys.PReceiver, RoutineName);
   12344         2022 :                 sys.HSatLiqReceiver = sys.refrig->getSatEnthalpy(state, sys.TReceiver, 0.0, RoutineName);
   12345         2022 :                 sys.CpSatLiqReceiver = sys.refrig->getSatSpecificHeat(state, sys.TReceiver, 0.0, RoutineName);
   12346         2022 :                 sys.HCaseInMT = sys.HSatLiqReceiver;
   12347         2022 :                 sys.HCaseInLT = sys.HSatLiqReceiver;
   12348         2022 :                 sys.RefMassFlowtoLTLoads = 0.0;
   12349         2022 :                 sys.RefMassFlowCompsLP = 0.0;
   12350         2022 :                 sys.DelHSubcoolerDis = 0.0;
   12351         2022 :                 sys.DelHSubcoolerSuc = 0.0;
   12352         2022 :                 if (sys.transSysType == TransSysType::TwoStage) {
   12353         2022 :                     sys.RefMassFlowtoLTLoads = sys.TotalSystemLoadLT / (sys.HCaseOutLT - sys.HCaseInLT);
   12354         2022 :                     sys.RefMassFlowCompsLP = sys.RefMassFlowtoLTLoads;
   12355              :                 } // (thisSys%TransSysType == 2)
   12356         2022 :                 sys.RefMassFlowtoMTLoads = sys.TotalSystemLoadMT / (sys.HCaseOutMT - sys.HCaseInMT);
   12357         2022 :                 sys.RefMassFlowCompsHP = sys.RefMassFlowtoLTLoads + sys.RefMassFlowtoMTLoads;
   12358              : 
   12359         2022 :                 sys.CalcDetailedTransSystem(state, SysNum);
   12360              :                 //       TransCritSysFlag = .FALSE.
   12361              : 
   12362              :             } // TransSystem(SysNum)%TotalSystemLoad > 0
   12363              :         } // SysNum over NumRefrigSystems
   12364              :     } // LoopNum, three times for buildings with multiple detailed systems connected with shared gas coolers
   12365              : 
   12366              :     // Unmet load is done outside iterative loop
   12367         4044 :     for (int SysNum = 1; SysNum <= state.dataRefrigCase->NumTransRefrigSystems; ++SysNum) {
   12368         2022 :         auto &sys = TransSystem(SysNum);
   12369              :         // Only do those systems appropriate for this analysis, supermarket type on load time step or coil type on sys time step
   12370         2022 :         if ((!state.dataRefrigCase->UseSysTimeStep) && (!state.dataGlobal->WarmupFlag)) {
   12371          288 :             Real64 CurrentLoads = sys.TotalSystemLoad;
   12372              :             // Meeting current and possibly some portion of the previously unmet energy
   12373              :             // perhaps future interest in reporting percent of installed capacity used(or number of compressors) ?
   12374              :             // If the system compressors were unable to meet the current loads, save energy to be met in succeeding time step
   12375              :             // Note the unmet energy is turned into a rate and applied to the system load at the start of calccompressor
   12376          288 :             sys.UnmetEnergy += (CurrentLoads - sys.TotCompCapacity) * state.dataGlobal->TimeStepZoneSec;
   12377              : 
   12378          288 :             if (sys.UnmetEnergy > MyLargeNumber) {
   12379            0 :                 sys.UnmetEnergy = MyLargeNumber;
   12380            0 :                 if (state.dataRefrigCase->ShowUnmetEnergyWarningTrans(SysNum)) {
   12381            0 :                     ShowWarningError(state, format("Refrigeration:TranscriticalSystem: {}", sys.Name));
   12382            0 :                     ShowContinueError(state, " The specified compressors for this system are unable to meet ");
   12383            0 :                     ShowContinueError(state, " the sum of the refrigerated case loads and subcooler loads (if any) for this system.");
   12384            0 :                     state.dataRefrigCase->ShowUnmetEnergyWarningTrans(SysNum) = false;
   12385              :                 } // show warning
   12386              :             } // > mylarge number
   12387              : 
   12388              :             // Zone-located air-cooled gas cooler reject heat also has to be outside iterative loop
   12389          288 :             if (sys.SystemRejectHeatToZone) {
   12390            0 :                 int CondInletAirZoneNum = GasCooler(sys.GasCoolerNum(1)).InletAirZoneNum;
   12391              :                 // Can arrive here when load call to refrigeration looks for cases/walkin systems and usetimestep is .FALSE.
   12392            0 :                 if ((!state.dataRefrigCase->UseSysTimeStep) &&
   12393            0 :                     ((state.dataRefrigCase->NumSimulationCases > 0) || (state.dataRefrigCase->NumSimulationWalkIns > 0))) {
   12394            0 :                     state.dataHeatBal->RefrigCaseCredit(CondInletAirZoneNum).SenCaseCreditToZone += sys.NetHeatRejectLoad; // Adding heat is positive
   12395              :                 } // UseSystimestep
   12396              :             } // Reject heat to zone
   12397              : 
   12398              :             // Report variables
   12399          288 :             sys.PipeHeatEnergy = (sys.PipeHeatLoadMT + sys.PipeHeatLoadLT) * localTimeStepSec;
   12400          288 :             sys.TotalCoolingEnergy = (sys.TotalCoolingLoadMT + sys.TotalCoolingLoadMT) * localTimeStepSec;
   12401              :         } //(.NOT. UseSysTimeStep).AND. (.not. WarmupFlag)
   12402              :     } // SysNum = 1,NumTransRefrigSystems
   12403              : 
   12404              :     // Update for sending to zone equipment manager. (note report variables are summed elsewhere)
   12405              : 
   12406         2022 :     SumZoneImpacts(state);
   12407         2022 : }
   12408              : 
   12409      9166860 : void RefrigSystemData::CalcDetailedSystem(EnergyPlusData &state, int const SysNum)
   12410              : {
   12411              : 
   12412              :     // SUBROUTINE INFORMATION:
   12413              :     //       AUTHOR         Therese Stovall, ORNL, Assisted by Hugh Henderson
   12414              :     //       DATE WRITTEN   Spring 2008
   12415              :     //       Using condenser solution algorithms written by Richard Raustad, FSEC
   12416              :     //          Oct/Nov 2004, and MODIFIED by Shirey, FSEC Dec 2004, and Hudson, ORNL in 2007
   12417              :     //       RE-ENGINEERED  na
   12418              : 
   12419              :     // PURPOSE OF THIS SUBROUTINE:
   12420              :     // Find the power and energy needed to meet the refrigeration loads for a particular detailed
   12421              :     // refrigeration system comprised of multiple cases, one condenser, and multiple compressors.
   12422              : 
   12423              :     // METHODOLOGY EMPLOYED:
   12424              :     // Sum the refrigeration loads on the system and determine the required evaporating temperature.
   12425              :     // Using the initial estimate for condensing temperature, dispatch the compressors to
   12426              :     // determine the needed power, energy consumption, and refrigerant mass flow.
   12427              :     // Calculate the condenser fan/pump power and consumption.
   12428              :     // Calculate the condensing temperature as a function of environment and load.
   12429              :     // Resolve the impact of subcooler heat transfer between and among systems
   12430              :     // Iterate until the calculated refrigerant mass flow through the compressors converges, which
   12431              :     // typically requires less than 5 iterations. This was found to be more sensitive than converging
   12432              :     // upon the calculated condensing temperature.
   12433              : 
   12434              :     // REFERENCES:
   12435              :     // "Impact of ASHRAE Standard 62-1989 on Florida Supermarkets",
   12436              :     //  Florida Solar Energy Center, FSEC-CR-910-96, Final Report, Oct. 1996
   12437              : 
   12438              :     // Kyle A. Manske, Performance Optimization of Industrial Refrigeration Systems,
   12439              :     //  A thesis submitted in partial fulfillment of the requirements for the degree of
   12440              :     //  Master of Science, University of Wisconsin-Madison, 1999
   12441              : 
   12442      9166860 :     Real64 constexpr ErrorTol(0.001); // Iterative solution tolerance
   12443              : 
   12444      9166860 :     bool NotBalanced = true;
   12445      9166860 :     int NumIter = 0;
   12446      9166860 :     Real64 ErrorMassFlowComps(0.0);        // Error in calculated low stage compressor mass flow (single- or two-stage systems)
   12447      9166860 :     Real64 ErrorMassFlowHiStageComps(0.0); // Error in calculated high-stage compressor mass flow (two-stage systems only)
   12448              : 
   12449              :     // Balance This Refrigeration System using calculated refrigerant flow
   12450      9166860 :     Real64 MassFlowHiStageCompsStart(0.0); // Mass flow through high-stage compressors (two-stage systems only)
   12451              : 
   12452     37454940 :     while (NotBalanced) {
   12453              :         // Set values for iteration convergence tolerance check
   12454     28288080 :         ++NumIter;
   12455              :         // Mass flow through (low-stage) compressors (single- or two-stage systems)
   12456     28288080 :         Real64 MassFlowCompsStart = this->RefMassFlowComps;
   12457              : 
   12458     28288080 :         if (this->NumStages == 2) { // Two-stage systems
   12459        14160 :             MassFlowHiStageCompsStart = this->RefMassFlowHiStageComps;
   12460              :         }
   12461              : 
   12462     28288080 :         if (this->NumSubcoolers > 0) {
   12463        24888 :             this->CalculateSubcoolers(state);
   12464              :         }
   12465     28288080 :         this->CalculateCompressors(state);
   12466     28288080 :         this->CalculateCondensers(state, SysNum);
   12467     28288080 :         this->RefMassFlowtoLoads = this->TotalSystemLoad / (this->HCaseOut - this->HCaseIn);
   12468     28288080 :         if (NumIter < 2) {
   12469      9166860 :             continue;
   12470              :         }
   12471              :         // Previously did error check on calculated Tcondense, but not sensitive enough
   12472     19121220 :         if ((this->RefMassFlowtoLoads == 0.0) || (MassFlowCompsStart == 0.0)) { //.OR. (MassFlowCasesStart == 0.0)
   12473            0 :             ShowWarningError(state, format("Refrigeration:System: {} showing zero refrigeration flow.", this->Name));
   12474              :         } else {
   12475     19121220 :             ErrorMassFlowComps = std::abs(MassFlowCompsStart - this->RefMassFlowComps) / MassFlowCompsStart;
   12476     19121220 :             if (this->NumStages == 2) { // Two-stage systems
   12477        10116 :                 ErrorMassFlowHiStageComps = std::abs(MassFlowHiStageCompsStart - this->RefMassFlowHiStageComps) / MassFlowCompsStart;
   12478              :             }
   12479              :         } // denominator zero check
   12480     19121220 :         if (NumIter > 20) {
   12481            0 :             break;
   12482              :         }
   12483     19121220 :         if (ErrorMassFlowComps < ErrorTol) {
   12484      9169498 :             if (this->NumStages == 1 || (this->NumStages == 2 && ErrorMassFlowHiStageComps < ErrorTol)) {
   12485      9166860 :                 NotBalanced = false;
   12486              :             }
   12487              :         }
   12488              :     } // error check
   12489      9166860 : }
   12490              : 
   12491         2022 : void TransRefrigSystemData::CalcDetailedTransSystem(EnergyPlusData &state, int const SysNum)
   12492              : {
   12493              : 
   12494              :     // SUBROUTINE INFORMATION:
   12495              :     //       AUTHOR         Brian A. Fricke, ORNL
   12496              :     //       DATE WRITTEN   Fall 2011
   12497              :     //       MODIFIED       na
   12498              :     //       RE-ENGINEERED  na
   12499              : 
   12500              :     // PURPOSE OF THIS SUBROUTINE:
   12501              :     // Find the power and energy needed to meet the refrigeration loads for a detailed transcritical
   12502              :     // CO2 refrigeration system comprised of multiple cases and walk-ins, one gas cooler, and
   12503              :     // multiple compressors.
   12504              : 
   12505              :     // METHODOLOGY EMPLOYED:
   12506              :     // Sum the refrigeration loads on the system and determine the required evaporating temperature.
   12507              :     // Dispatch the compressors to determine the needed power, energy consumption, and refrigerant
   12508              :     // mass flow. Calculate the gas cooler fan power and consumption. Calculate the gas cooler
   12509              :     // outlet temperature and pressure as a function of ambient temperature. Iterate until the
   12510              :     // calculated refrigerant mass flow through the receiver bypass converges, which typically
   12511              :     // requires less than 5 iterations.
   12512              : 
   12513         2022 :     Real64 constexpr ErrorTol(0.001); // Iterative solution tolerance
   12514              : 
   12515         2022 :     int NumIter(0);            // Iteration counter
   12516         2022 :     bool NotBalanced(true);    // Flag to indicate convergence, based on system balance
   12517         2022 :     Real64 MassFlowStart(0.5); // Initial refrigerant mass flow through receiver bypass
   12518              :     Real64 ErrorMassFlow;      // Error in calculated refrigerant mass flow through receiver bypass
   12519              : 
   12520        12550 :     while (NotBalanced) {
   12521        10701 :         ++NumIter;
   12522              : 
   12523        10701 :         if (this->NumGasCoolers >= 1) {
   12524        10701 :             this->CalcGasCooler(state, SysNum);
   12525              :         }
   12526        10701 :         this->CalculateTransCompressors(state);
   12527        10701 :         if (NumIter < 2) {
   12528         2022 :             continue;
   12529              :         }
   12530         8679 :         if ((this->RefMassFlowReceiverBypass == 0.0) || (MassFlowStart == 0.0)) {
   12531            0 :             ShowSevereError(state,
   12532            0 :                             format("Refrigeration:TranscriticalSystem: {} showing zero refrigerant flow through receiver bypass.", this->Name));
   12533            0 :             ShowContinueError(state, format("Receiver Bypass Flow = {:.6R}", this->RefMassFlowReceiverBypass));
   12534            0 :             ShowContinueError(state, "Check input file to ensure that refrigeration loads on this system are not zero.");
   12535              :         } else {
   12536         8679 :             ErrorMassFlow = std::abs(MassFlowStart - this->RefMassFlowReceiverBypass) / MassFlowStart;
   12537         8679 :             MassFlowStart = this->RefMassFlowReceiverBypass;
   12538              :         } // denominator zero check
   12539         8679 :         if (NumIter > 20) {
   12540          173 :             break;
   12541              :         }
   12542         8506 :         if (ErrorMassFlow < ErrorTol) {
   12543         1849 :             NotBalanced = false;
   12544              :         }
   12545              :     } // error check
   12546         2022 : }
   12547              : 
   12548     28288080 : void RefrigSystemData::CalculateCondensers(EnergyPlusData &state, int const SysNum)
   12549              : {
   12550              : 
   12551              :     // SUBROUTINE INFORMATION:
   12552              :     //       AUTHOR         Therese Stovall and C. R. Hudson, ORNL, Assisted by Hugh Henderson
   12553              :     //       DATE WRITTEN   Spring 2008
   12554              :     //       Using condenser solution algorithms written by Richard Raustad, FSEC
   12555              :     //          Oct/Nov 2004, and MODIFIED by Shirey, FSEC Dec 2004, and Hudson, ORNL in 2007
   12556              :     //       RE-ENGINEERED  na
   12557              : 
   12558              :     // PURPOSE OF THIS SUBROUTINE:
   12559              :     // Find the condenser heat rejection for a particular detailed
   12560              :     // refrigeration system and condensing temperature (part of iterative soln for cond temp).
   12561              : 
   12562              :     // METHODOLOGY EMPLOYED:
   12563              :     // Calculate the condenser fan/pump power and consumption
   12564              :     // using manufacturer's rating data and fan power correlations
   12565              :     // from ASHRAE and evaporative effectiveness based on enthalpy
   12566              :     // similar to work done by Manske.
   12567              : 
   12568              :     // From Heejin Cho, Re variable frequency drive fans,
   12569              :     // "From HVAC forums, I learned that it is common practice to set a
   12570              :     // minimum frequency at 15 or 20 Hz to protect motors from overheating. The
   12571              :     // full speed is at 60 Hz. The ratio of minimum and maximum frequencies
   12572              :     // will correspond to the ratio of minimum and maximum flow rates."
   12573              : 
   12574              :     // REFERENCES:
   12575              :     // "Impact of ASHRAE Standard 62-1989 on Florida Supermarkets",
   12576              :     //  Florida Solar Energy Center, FSEC-CR-910-96, Final Report, Oct. 1996
   12577              : 
   12578              :     // Kyle A. Manske, Performance Optimization of Industrial Refrigeration Systems,
   12579              :     //  A thesis submitted in partial fulfillment of the requirements for the degree of
   12580              :     //  Master of Science, University of Wisconsin-Madison, 1999
   12581              : 
   12582              :     // Lawrence Berkeley Laboratory and Resource Dynamics, Improving Fan System Performance,
   12583              :     //   A Sourcebook for Industry, DOE/GO-102003-1294, April 2003
   12584              : 
   12585     28288080 :     Real64 constexpr BleedRateConstant = 5.0E-10; // water purge rate for evaporative
   12586              :     //  condensers (m3/W-s) equal to 3 GPM per 100 tons (BAC Engineering Reference)
   12587              : 
   12588     28288080 :     auto &System = state.dataRefrigCase->System;
   12589     28288080 :     auto &Condenser = state.dataRefrigCase->Condenser;
   12590              : 
   12591              :     int CondID;               // Condenser Number
   12592              :     int CondCreditWarnIndex1; // Used to sum up warning count
   12593              :     int CondCreditWarnIndex2; // Used to sum up warning count
   12594              :     int CondCreditWarnIndex3; // Used to sum up warning count
   12595              :     int CondCreditWarnIndex4; // Used to sum up warning count
   12596              :     int CondCreditWarnIndex5; // Used to sum up warning count
   12597              :     int CondCreditWarnIndex6; // Used to sum up warning count
   12598              :     int CondCreditWarnIndex7; // Used to sum up warning count
   12599              :     int Sysloop;              // counter over number of systems attached to this condenser
   12600              :     int SystemID;             // System number rejecting heat to this condenser
   12601              :     bool EvapAvail;           // Control for evap condenser availability
   12602              : 
   12603              :     Real64 AirVolRatio;                 // Ratio of air volume needed to remove load relative to design load
   12604              :     Real64 AirDensity;                  // Density of air at condenser inlet [kg/m3]
   12605              :     Real64 AirDensityDry;               // Density of dry air at condenser inlet temperature [kg/m3]
   12606              :     Real64 ActualFanPower;              // Fan power after adjustments for partially loaded condenser [W]
   12607              :     Real64 BPress;                      // Barometric pressure at condenser air inlet node [Pa]
   12608              :     Real64 CapFac;                      // Capacity Factor
   12609              :     Real64 Effectiveness;               // for evap condenser, =capacity/max cap, where max cap is cap if Tairout equal Tcondense
   12610              :     Real64 EnthalpyAtTcond;             // enthalpy of saturated air at Tcondense
   12611              :     Real64 EnthalpyAirIn;               // Enthalpy of air entering condenser [J/kg]
   12612              :     Real64 EnthalpyAirOut;              // Enthalpy of air leaving condenser [J/kg]
   12613              :     Real64 FanMinAirFlowRatio;          // Minimum fan air flow ratio
   12614              :     Real64 FanPowerRatio;               // Calculated fan power ratio
   12615     28288080 :     Real64 HRCF(0.0);                   // Heat Rejection Capacity Factor (convention for evap condensers)
   12616              :     Real64 HRCFFullFlow;                // Heat Rejection Capacity Factor at full air flow
   12617              :     Real64 HumRatIn;                    // Humidity ratio of inlet air to condenser [kg/kg]
   12618              :     Real64 HumRatOut;                   // Humidity ratio of outlet air from condenser (assumed saturated) [kg/kg]
   12619     28288080 :     Real64 OutWbTemp(0.0);              // Outdoor wet bulb temp at condenser air inlet node [C]
   12620              :     Real64 OutDbTemp;                   // Outdoor dry bulb temp at condenser air inlet node [C]
   12621              :     Real64 PurgeRate;                   // Rate of water blow-down/bleed/purge in evap condenser (m3/s)
   12622              :     Real64 RatedFanPower;               // local variable equal to input condenser value
   12623              :     Real64 RatedAirFlowRate;            // local variable equal to input condenser value
   12624              :     Real64 SinkTemp;                    // Heat sink temperature used to derate fan power at reduced loads [C]
   12625              :     Real64 TCondCalc;                   // Calculated Condensing temperature
   12626              :     Real64 TotalCondDefrostCreditLocal; // total cond credit from hot gas/brine defr for cases etc. served
   12627              :     //     directly by all systems served by this condenser [W]
   12628              :     Real64 TotalCondDefCredfromSysID;    // cond credit for single system [W]
   12629     28288080 :     Real64 TotalLoadFromThisSystem(0.0); // total heat rejection load from the detailed system id'd in subroutine call [W]
   12630              :     Real64 TotalLoadFromSystems;         // total heat rejection load from all systems served by this condenser [W]
   12631              : 
   12632     28288080 :     Real64 localTimeStep = (state.dataRefrigCase->UseSysTimeStep) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone;
   12633     28288080 :     Real64 localTimeStepSec = localTimeStep * Constant::rSecsInHour;
   12634              : 
   12635              :     // Initialize this condenser for this time step
   12636     28288080 :     state.dataRefrigCase->TotalCondenserPumpPower = 0.0;
   12637     28288080 :     state.dataRefrigCase->TotalBasinHeatPower = 0.0;
   12638     28288080 :     state.dataRefrigCase->TotalCondenserHeat = 0.0;
   12639     28288080 :     state.dataRefrigCase->TotalEvapWaterUseRate = 0.0;
   12640     28288080 :     ActualFanPower = 0.0;
   12641     28288080 :     TotalCondDefrostCreditLocal = 0.0;
   12642     28288080 :     TotalLoadFromSystems = 0.0;
   12643     28288080 :     EvapAvail = true;
   12644     28288080 :     CondID = this->CondenserNum(1);
   12645     28288080 :     auto &condenser = Condenser(CondID);
   12646     28288080 :     RatedFanPower = condenser.RatedFanPower;
   12647     28288080 :     RatedAirFlowRate = condenser.RatedAirFlowRate;
   12648     28288080 :     FanMinAirFlowRatio = condenser.FanMinAirFlowRatio;
   12649     28288080 :     CondCreditWarnIndex1 = condenser.CondCreditWarnIndex1;
   12650     28288080 :     CondCreditWarnIndex2 = condenser.CondCreditWarnIndex2;
   12651     28288080 :     CondCreditWarnIndex3 = condenser.CondCreditWarnIndex3;
   12652     28288080 :     CondCreditWarnIndex4 = condenser.CondCreditWarnIndex4;
   12653     28288080 :     CondCreditWarnIndex5 = condenser.CondCreditWarnIndex5;
   12654     28288080 :     CondCreditWarnIndex6 = condenser.CondCreditWarnIndex6;
   12655     28288080 :     CondCreditWarnIndex7 = condenser.CondCreditWarnIndex7;
   12656              : 
   12657              :     // Sum total condenser load and defrost credits for all systems connected to this condenser
   12658              :     //  The system values will match the last time that system was solved, so some of the values may be
   12659              :     //  from the previous overall solution iteration.  However, solution goes through 3 iterations if
   12660              :     //  there are any shared condensers, so that's ok.
   12661     56665425 :     for (Sysloop = 1; Sysloop <= condenser.NumSysAttach; ++Sysloop) {
   12662     28377345 :         SystemID = condenser.SysNum(Sysloop);
   12663     28377345 :         TotalCondDefCredfromSysID = System(SystemID).TotalCondDefrostCredit + System(SystemID).SumCascadeCondCredit;
   12664     28377345 :         TotalCondDefrostCreditLocal += TotalCondDefCredfromSysID;
   12665              :         // total heat rejection load from a single detailed system [W]
   12666              :         Real64 TotalLoadFromSysID =
   12667     28377345 :             System(SystemID).TotalSystemLoad + System(SystemID).TotCompPower + System(SystemID).TotHiStageCompPower + System(SystemID).PipeHeatLoad;
   12668     28377345 :         TotalLoadFromSystems += TotalLoadFromSysID;
   12669     28377345 :         if (SystemID == SysNum) {
   12670     28288080 :             TotalLoadFromThisSystem = TotalLoadFromSysID;
   12671              :         }
   12672              :     } // Sysloop over every system connected to this condenser
   12673              : 
   12674              :     // for cascade condensers, condenser defrost credit gets passed on to the primary system condenser
   12675     28288080 :     if (condenser.CondenserType == DataHeatBalance::RefrigCondenserType::Cascade) {
   12676        12133 :         TotalCondDefrostCreditLocal = 0.0;
   12677              :     }
   12678              : 
   12679              :     // Calculate Total Heat rejection needed.  Assume hermetic compressors - conservative assumption
   12680              :     // Note that heat rejection load carried by desuperheater hvac coils or water heaters is the
   12681              :     // lagged variable from the previous time step because these are calculated after the refrigeration
   12682              :     // system is solved.
   12683     28288080 :     condenser.ExternalHeatRecoveredLoad = condenser.LaggedUsedWaterHeater + condenser.LaggedUsedHVACCoil;
   12684     28288080 :     condenser.InternalHeatRecoveredLoad = TotalCondDefrostCreditLocal;
   12685     28288080 :     condenser.TotalHeatRecoveredLoad = condenser.ExternalHeatRecoveredLoad + TotalCondDefrostCreditLocal;
   12686              : 
   12687     28288080 :     state.dataRefrigCase->TotalCondenserHeat = TotalLoadFromSystems - TotalCondDefrostCreditLocal - condenser.ExternalHeatRecoveredLoad;
   12688     28288080 :     if (state.dataRefrigCase->TotalCondenserHeat < 0.0) {
   12689              : 
   12690            6 :         state.dataRefrigCase->TotalCondenserHeat = 0.0;
   12691            6 :         if (!state.dataGlobal->WarmupFlag) {
   12692           48 :             ShowRecurringWarningErrorAtEnd(state,
   12693           12 :                                            "Refrigeration:System: " + this->Name +
   12694              :                                                ":heat reclaimed(defrost,other purposes) >current condenser load. ",
   12695              :                                            CondCreditWarnIndex1);
   12696           48 :             ShowRecurringContinueErrorAtEnd(
   12697              :                 state, "For heat recovered for defrost: ASHRAE rule of thumb: <= 25% of the load on a rack ", CondCreditWarnIndex2);
   12698           48 :             ShowRecurringContinueErrorAtEnd(
   12699              :                 state, "should be in defrost at the same time. Consider diversifying defrost schedules.", CondCreditWarnIndex3);
   12700           48 :             ShowRecurringContinueErrorAtEnd(
   12701              :                 state,
   12702              :                 "For heat recovered for other purposes: this warning may be an artifact of refrigeration calculation at the load",
   12703              :                 CondCreditWarnIndex4);
   12704           48 :             ShowRecurringContinueErrorAtEnd(
   12705              :                 state,
   12706              :                 "time step and heat recovery at the system time step. In that case, and ONLY if it occurs a large number of times",
   12707              :                 CondCreditWarnIndex5);
   12708           48 :             ShowRecurringContinueErrorAtEnd(
   12709              :                 state, "(relative to the number of time steps in the simulation), there may be a mis-match between the", CondCreditWarnIndex6);
   12710           48 :             ShowRecurringContinueErrorAtEnd(
   12711              :                 state, "operating schedules of the refrigeration system and the heat recovery load.", CondCreditWarnIndex7);
   12712              :         } // not warmup
   12713              :     } // total condenser heat < 0
   12714              : 
   12715              :     // Water side of water-cooled condensers simulated in SimRefrigCondenser,
   12716              :     //   Here, we just need load and condensing temperatures.
   12717              :     //   Condensing temperature a fixed delta (the rated approach temperature) from inlet water temp so long as above minimum.
   12718              :     //   Note, if condensing temperature falls below minimum, get warning and reset but no change in water-side calculations.
   12719     28288080 :     if (condenser.CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
   12720              :         // Obtain water-cooled condenser inlet/outlet temps
   12721         6066 :         condenser.InletTemp = state.dataLoopNodes->Node(condenser.InletNode).Temp;
   12722         6066 :         TCondCalc = state.dataLoopNodes->Node(condenser.InletNode).Temp + condenser.RatedApproachT;
   12723         6066 :         if ((condenser.InletTemp < condenser.InletTempMin) || (TCondCalc < this->TCondenseMin)) {
   12724            0 :             this->TCondense = this->TCondenseMin;
   12725              :             // condenser.LowTempWarn += 1;
   12726            0 :             if (condenser.LowTempWarnIndex == 0) {
   12727            0 :                 ShowWarningMessage(state, format("Refrigeration:Condenser:WaterCooled {}", condenser.Name));
   12728            0 :                 ShowContinueError(state,
   12729              :                                   "Water-cooled condenser inlet temp lower than minimum allowed temp. Check returning water temperature and/or "
   12730              :                                   "minimum temperature setpoints relative to minimum allowed condensing temperature.");
   12731              :             }
   12732            0 :             ShowRecurringWarningErrorAtEnd(state,
   12733            0 :                                            "Refrigeration:Condenser:WaterCooled " + condenser.Name +
   12734              :                                                " - Condenser inlet temp lower than minimum allowed ... continues",
   12735            0 :                                            condenser.LowTempWarnIndex);
   12736              :             // END IF
   12737              :         } else {
   12738         6066 :             this->TCondense = TCondCalc;
   12739              :         }
   12740              : 
   12741     28282014 :     } else if ((condenser.CondenserType == DataHeatBalance::RefrigCondenserType::Air) ||
   12742        75727 :                (condenser.CondenserType == DataHeatBalance::RefrigCondenserType::Evap)) {
   12743              :         // Condensing Temp, fan and other aux loads for air-cooled or evap-cooled
   12744              : 
   12745              :         // The rated capacity of air-cooled condenser was adjusted for elevation in get input step
   12746     28269881 :         CapFac = state.dataRefrigCase->TotalCondenserHeat / condenser.RatedCapacity;
   12747              :         // See whether condenser is at ground level or if other air conditions(ie node) have been specified.
   12748              :         //    Note that air-cooled condensers can draw air from, and reject heat to, a conditioned zone
   12749              :         //    But evaporative condensers cannot.
   12750              :         // Provides effective condensing temperature for air-cooled condenser (or evap if evap is scheduled off)
   12751     28269881 :         if (condenser.InletAirNodeNum != 0) {
   12752     28269881 :             OutDbTemp = state.dataLoopNodes->Node(condenser.InletAirNodeNum).Temp;
   12753     28269881 :             BPress = state.dataLoopNodes->Node(condenser.InletAirNodeNum).Press;
   12754     28269881 :             HumRatIn = state.dataLoopNodes->Node(condenser.InletAirNodeNum).HumRat;
   12755              :         } else {
   12756            0 :             OutDbTemp = state.dataEnvrn->OutDryBulbTemp;
   12757            0 :             BPress = state.dataEnvrn->OutBaroPress;
   12758            0 :             HumRatIn = state.dataEnvrn->OutHumRat;
   12759              :         }
   12760     28269881 :         AirDensity = Psychrometrics::PsyRhoAirFnPbTdbW(state, BPress, OutDbTemp, HumRatIn);
   12761     28269881 :         AirDensityDry = Psychrometrics::PsyRhoAirFnPbTdbW(state, BPress, OutDbTemp, 0.0);
   12762              :         // Evaporative condensers will have their water flow shut off in cold months to avoid
   12763              :         //  'spectacular' icing problems.  Ideally, the user will use the evaporative schedule input
   12764              :         //  to set such a schedule.  However, sometimes, users will use a single input deck to model
   12765              :         //  one building in multiple climates, and may not think to put in such a schedule in the colder
   12766              :         //  climates.  To accommodate such applications, the variable EvapCutOutTdb is used as an extra
   12767              :         //  check.
   12768              : 
   12769     28269881 :         if (OutDbTemp < EvapCutOutTdb) {
   12770     18346736 :             EvapAvail = false;
   12771              :         }
   12772              : 
   12773              :         // Check schedule to determine evap condenser availability
   12774              :         // IF schedule exists, evap condenser can be scheduled OFF
   12775     28333475 :         if ((condenser.CondenserType == DataHeatBalance::RefrigCondenserType::Evap) && (condenser.evapAvailSched != nullptr) &&
   12776        63594 :             (condenser.evapAvailSched->getCurrentVal() == 0)) {
   12777        32675 :             EvapAvail = false;
   12778              :         }
   12779              : 
   12780              :         // Calculate condensing temperatures for air-cooled and evap-cooled
   12781     28269881 :         if (condenser.CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
   12782              :             // Manufacturer's HRCF regressed to produce a function of the form:
   12783              :             // (Tcondense-Twb)=A1 + A2*hrcf + A3/hrcf + A4*Twb
   12784              :             // HRCF defined as rated capacity divided by load
   12785              :             // Apply ARI490 elevation correction factor here for evap condenser, then apply hrcf limits
   12786        63594 :             if (CapFac > 0.0) {
   12787        63594 :                 HRCF = condenser.EvapElevFact / CapFac;
   12788              :                 // Condenser(CondNum)%EvapElevFact=1.0d0-3.074D-5*Elevation
   12789              :             } else {
   12790            0 :                 HRCF = MyLargeNumber;
   12791              :             }
   12792        63594 :             HRCF = min(HRCF, condenser.MaxCapFacEvap);
   12793        63594 :             HRCF = max(HRCF, condenser.MinCapFacEvap);
   12794        63594 :             if (EvapAvail) {
   12795        30919 :                 OutWbTemp = Psychrometrics::PsyTwbFnTdbWPb(state, OutDbTemp, HumRatIn, BPress);
   12796        30919 :                 SinkTemp = OutWbTemp;
   12797              :             } else {         // evaporative condenser with water spray scheduled off so use Tdb
   12798        32675 :                 HRCF /= 3.0; // reference Menske, cap of evap cond operating dry about 1/3 of rated cap
   12799        32675 :                 HRCF = max(HRCF, condenser.MinCapFacEvap);
   12800        32675 :                 SinkTemp = OutDbTemp;
   12801              :             } // evap avail, still in evap condenser
   12802        63594 :             TCondCalc = condenser.EvapCoeff1 + condenser.EvapCoeff2 * HRCF + condenser.EvapCoeff3 / HRCF + (1.0 + condenser.EvapCoeff4) * SinkTemp;
   12803              :         } else { // air-cooled condenser
   12804              :             // MinCondLoad and TempSlope came from condenser capacity curve, using curve backwards
   12805     28206287 :             TCondCalc = OutDbTemp + (state.dataRefrigCase->TotalCondenserHeat - condenser.MinCondLoad) * condenser.TempSlope;
   12806     28206287 :             SinkTemp = OutDbTemp;
   12807              :         } // if evap-cooled condenser
   12808              : 
   12809              :         // Fan energy calculations apply to both air- and evap-cooled condensers
   12810              :         // Compare calculated condensing temps to minimum allowed to determine fan power/operating mode
   12811     28269881 :         if (TCondCalc >= this->TCondenseMin) {
   12812      7947730 :             this->TCondense = TCondCalc;
   12813      7947730 :             ActualFanPower = RatedFanPower;
   12814      7947730 :             AirVolRatio = 1.0;
   12815              : 
   12816              :         } else { // need to reduce fan speed to reduce air flow and keep Tcond at or above Tcond min
   12817     20322151 :             this->TCondense = this->TCondenseMin;
   12818     20322151 :             TCondCalc = this->TCondenseMin;
   12819              :             // recalculate CapFac at current delta T
   12820     20322151 :             if (condenser.CondenserType == DataHeatBalance::RefrigCondenserType::Air) {
   12821              :                 // current maximum condenser capacity at delta T present for minimum condensing temperature [W]
   12822     20307174 :                 Real64 CurMaxCapacity = Curve::CurveValue(state, condenser.CapCurvePtr, (this->TCondenseMin - OutDbTemp));
   12823     20307174 :                 CapFac = state.dataRefrigCase->TotalCondenserHeat / CurMaxCapacity;
   12824     20307174 :                 AirVolRatio = max(FanMinAirFlowRatio, std::pow(CapFac, CondAirVolExponentDry)); // Fans limited by minimum air flow ratio
   12825     20307174 :                 AirVolRatio = min(AirVolRatio, 1.0);
   12826              :             } else { // condenser.CondenserType == DataHeatBalance::RefrigCondenserType::Evap
   12827        14977 :                 HRCFFullFlow = HRCF;
   12828              :                 // if evap condenser need to back calculate the operating capacity using HRCF relationship, given known Tcond
   12829        14977 :                 Real64 QuadBterm = condenser.EvapCoeff1 - (this->TCondense - SinkTemp) + condenser.EvapCoeff4 * SinkTemp;
   12830        14977 :                 Real64 Sqrtterm = pow_2(QuadBterm) - 4.0 * condenser.EvapCoeff2 * condenser.EvapCoeff3;
   12831        14977 :                 if (Sqrtterm < 0.0) { // only happens for very high wet bulb temps
   12832            0 :                     HRCF = condenser.EvapElevFact * condenser.MaxCapFacEvap;
   12833            0 :                     if (!EvapAvail) {
   12834            0 :                         HRCF /= 3.0;
   12835              :                     }
   12836            0 :                     HRCF = max(HRCF, condenser.MinCapFacEvap);
   12837              :                 } else {
   12838        14977 :                     HRCF = condenser.EvapElevFact * (-QuadBterm - std::sqrt(Sqrtterm)) / (2.0 * condenser.EvapCoeff2);
   12839        14977 :                     if (!EvapAvail) {
   12840         9883 :                         HRCF /= 3.0;
   12841              :                     }
   12842        14977 :                     HRCF = min(HRCF, condenser.MaxCapFacEvap);
   12843        14977 :                     HRCF = max(HRCF, condenser.MinCapFacEvap);
   12844              :                 } // sqrtterm
   12845        14977 :                 CapFac = HRCF / HRCFFullFlow; // note, HRCFFullFlow previously limited between min and max,so can't be zero
   12846        14977 :                 if (EvapAvail) {
   12847         5094 :                     AirVolRatio = max(FanMinAirFlowRatio, std::pow(CapFac, CondAirVolExponentEvap)); // Fans limited by minimum air flow ratio
   12848              :                 } else {                                                                             // evap not available
   12849         9883 :                     AirVolRatio = max(FanMinAirFlowRatio, std::pow(CapFac, CondAirVolExponentDry));  // Fans limited by minimum air flow ratio
   12850              :                 } // evap available
   12851        14977 :                 AirVolRatio = min(AirVolRatio, 1.0);
   12852              :             } // condenser type = DataHeatBalance::RefrigCondenserType::Air with else for evap
   12853              : 
   12854     20322151 :             switch (condenser.FanSpeedControlType) {
   12855        71213 :             case FanSpeedCtrlType::VariableSpeed: { // fan power law, adjusted for reality, applies
   12856        71213 :                 FanPowerRatio = std::pow(AirVolRatio, 2.5);
   12857        71213 :                 ActualFanPower = FanPowerRatio * RatedFanPower;
   12858        71213 :             } break;
   12859        39240 :             case FanSpeedCtrlType::ConstantSpeed: {
   12860        39240 :                 ActualFanPower = AirVolRatio * std::exp(1.0 - AirVolRatio) * RatedFanPower;
   12861        39240 :             } break;
   12862            0 :             case FanSpeedCtrlType::ConstantSpeedLinear: {
   12863            0 :                 ActualFanPower = AirVolRatio * RatedFanPower;
   12864            0 :             } break;
   12865     20211698 :             case FanSpeedCtrlType::TwoSpeed: {
   12866              :                 // low speed setting of 1/2 fan speed can give up to 60% of capacity.
   12867              :                 // 1/2 speed corresponds to ~1/8 power consumption (FanHalfSpeedRatio = 1/(2**2.5) = 0.1768)
   12868              :                 // dampers are used to control flow within those two ranges as in FanConstantSpeed
   12869     20211698 :                 Real64 const air_vol_fan_power_fac(std::exp(1.0 - AirVolRatio) * RatedFanPower);
   12870     20211698 :                 ActualFanPower = AirVolRatio * air_vol_fan_power_fac;
   12871     20211698 :                 if (CapFac < CapFac60Percent) {
   12872     20204163 :                     ActualFanPower = ((AirVolRatio + 0.4) * FanHalfSpeedRatio) * air_vol_fan_power_fac;
   12873              :                 }
   12874     20211698 :             } break;
   12875            0 :             default:
   12876            0 :                 break;
   12877              :             } // fan speed control type
   12878              :         } // Tcondense >= Tcondense minimum
   12879              : 
   12880     28269881 :         if ((condenser.CondenserType == DataHeatBalance::RefrigCondenserType::Evap) && (EvapAvail)) {
   12881              :             // calculate evap water use,  need to include bleed down/purge water as well as water
   12882              :             // actually evaporated.  Use BAC Engineering Reference value of 3 gpm/100 tons because it's more
   12883              :             // conservative than the ASHRAE value.
   12884              :             //  Also, based on experience, running the evap water when outdoor T near freezing
   12885              :             //  leads to 'spectacular' ice, so schedule evap off when Tdb <=4 C.
   12886              :             // Calculate bleed/purge rate of water loss as a function of capacity, 3 gpm/100 tons refrigeration
   12887        30919 :             PurgeRate = state.dataRefrigCase->TotalCondenserHeat * BleedRateConstant;
   12888        30919 :             EnthalpyAirIn = Psychrometrics::PsyHFnTdbW(OutDbTemp, HumRatIn);
   12889              :             // calculate effectiveness at rated conditions, so use Tcondcalc)
   12890        30919 :             EnthalpyAtTcond = Psychrometrics::PsyHFnTdbRhPb(state, TCondCalc, 1.0, BPress);
   12891        30919 :             Effectiveness = state.dataRefrigCase->TotalCondenserHeat / (RatedAirFlowRate * AirDensity * (EnthalpyAtTcond - EnthalpyAirIn));
   12892              :             // need to limit max effectiveness for errors due to working beyond limits of HRCF in manuf data
   12893        30919 :             Effectiveness = min(Effectiveness, 0.9);
   12894        30919 :             EnthalpyAirOut = EnthalpyAirIn + Effectiveness * (EnthalpyAtTcond - EnthalpyAirIn);
   12895              :             // Air leaving the evaporative condenser is saturated
   12896        30919 :             Real64 TAirOut = Psychrometrics::PsyTsatFnHPb(state, EnthalpyAirOut, BPress);
   12897        30919 :             HumRatOut = Psychrometrics::PsyWFnTdpPb(state, TAirOut, BPress);
   12898        61838 :             state.dataRefrigCase->TotalEvapWaterUseRate =
   12899        30919 :                 PurgeRate + RatedAirFlowRate * AirVolRatio * AirDensityDry * (HumRatOut - HumRatIn) / Psychrometrics::RhoH2O(OutWbTemp);
   12900              :             // assumes evap water pump runs whenever evap cooling is available to minimize scaling
   12901        30919 :             state.dataRefrigCase->TotalCondenserPumpPower = condenser.EvapPumpPower;
   12902              :             // calculate basin water heater load
   12903        30919 :             if (state.dataRefrigCase->TotalCondenserHeat == 0.0 && OutDbTemp < condenser.BasinHeaterSetPointTemp) {
   12904            0 :                 state.dataRefrigCase->TotalBasinHeatPower =
   12905            0 :                     max(0.0, condenser.BasinHeaterPowerFTempDiff * (condenser.BasinHeaterSetPointTemp - OutDbTemp));
   12906              :                 // provide warning if no heater power exists
   12907            0 :                 if (state.dataRefrigCase->TotalBasinHeatPower == 0.0) {
   12908              :                     // condenser.EvapFreezeWarn = condenser.EvapFreezeWarn + 1;
   12909            0 :                     if (condenser.EvapFreezeWarnIndex == 0) {
   12910            0 :                         ShowWarningMessage(
   12911              :                             state,
   12912            0 :                             format("Refrigeration Condenser {} - Evap cooling of condenser underway with no basin heater power", condenser.Name));
   12913            0 :                         ShowContinueError(state, "and condenser inlet air dry-bulb temp at or below the basin heater setpoint temperature.");
   12914            0 :                         ShowContinueErrorTimeStamp(state, "Continuing simulation.");
   12915              :                     }
   12916            0 :                     ShowRecurringWarningErrorAtEnd(state,
   12917            0 :                                                    "Refrigeration Condenser " + condenser.Name +
   12918              :                                                        " - Evap cooling of condenser underway with no basin heater power ... continues",
   12919            0 :                                                    condenser.EvapFreezeWarnIndex);
   12920              :                     // END IF  !freeze warnings <= 5
   12921              :                 } // basin power == 0
   12922              :             } // no load and cold outside
   12923              :         } // EvapAvail
   12924              : 
   12925     28282014 :     } else if (condenser.CondenserType ==
   12926              :                DataHeatBalance::RefrigCondenserType::Cascade) { // continuing Condenser type = water, (evap or air), or cascade
   12927              :         // Cascade condenser does not iterate.  Condensing temperature specified as a load on higher temp system
   12928              :         //    or floats to meet other loads on that system
   12929              :         // therese ** future - here and for new phase change heat exchanger - need to handle unmet loads!
   12930              : 
   12931        12133 :         this->TCondense = condenser.RatedTCondense;
   12932              : 
   12933        12133 :         if ((this->NumNonCascadeLoads > 0) && (condenser.CascadeTempControl == CascadeCndsrTempCtrlType::TempFloat)) {
   12934            0 :             this->TCondense = System(condenser.CascadeSinkSystemID).TEvapNeeded + condenser.RatedApproachT;
   12935            0 :             if (this->TCondense < this->TCondenseMin) {
   12936            0 :                 this->TCondense = this->TCondenseMin;
   12937            0 :                 ShowRecurringWarningErrorAtEnd(state,
   12938            0 :                                                "Refrigeration Condenser " + condenser.Name +
   12939              :                                                    " - Cascade condenser floating condensing temperature less than specified minimum condensing "
   12940              :                                                    "temperature. Minimum specified temperature used for system below cascade condenser. No "
   12941              :                                                    "correction made for system absorbing heat rejected by the cascade condenser.",
   12942            0 :                                                condenser.EvapFreezeWarnIndex);
   12943              :             } // floating condensing temperature less than specified min for system
   12944              :         } // floating temperature
   12945              :     } // Condenser type = water, (evap or air), or cascade
   12946              : 
   12947     28288080 :     condenser.ActualFanPower = ActualFanPower;
   12948     28288080 :     condenser.FanElecEnergy = ActualFanPower * localTimeStepSec;
   12949     28288080 :     condenser.EvapWaterConsumpRate = state.dataRefrigCase->TotalEvapWaterUseRate;
   12950     28288080 :     condenser.EvapWaterConsumption = state.dataRefrigCase->TotalEvapWaterUseRate * localTimeStepSec;
   12951     28288080 :     condenser.ActualEvapPumpPower = state.dataRefrigCase->TotalCondenserPumpPower;
   12952     28288080 :     condenser.EvapPumpConsumption = state.dataRefrigCase->TotalCondenserPumpPower * localTimeStepSec;
   12953     28288080 :     condenser.BasinHeaterPower = state.dataRefrigCase->TotalBasinHeatPower;
   12954     28288080 :     condenser.BasinHeaterConsumption = state.dataRefrigCase->TotalBasinHeatPower * localTimeStepSec;
   12955     28288080 :     condenser.CondLoad = state.dataRefrigCase->TotalCondenserHeat;
   12956     28288080 :     condenser.CondEnergy = state.dataRefrigCase->TotalCondenserHeat * localTimeStepSec;
   12957     28288080 :     condenser.CondCreditWarnIndex1 = CondCreditWarnIndex1;
   12958     28288080 :     condenser.CondCreditWarnIndex2 = CondCreditWarnIndex2;
   12959     28288080 :     condenser.CondCreditWarnIndex3 = CondCreditWarnIndex3;
   12960     28288080 :     condenser.CondCreditWarnIndex4 = CondCreditWarnIndex4;
   12961     28288080 :     condenser.CondCreditWarnIndex5 = CondCreditWarnIndex5;
   12962     28288080 :     condenser.CondCreditWarnIndex6 = CondCreditWarnIndex6;
   12963     28288080 :     condenser.CondCreditWarnIndex7 = CondCreditWarnIndex7;
   12964     28288080 :     condenser.ExternalEnergyRecovered = condenser.ExternalHeatRecoveredLoad * localTimeStepSec;
   12965     28288080 :     condenser.InternalEnergyRecovered = condenser.InternalHeatRecoveredLoad * localTimeStepSec;
   12966     28288080 :     condenser.TotalHeatRecoveredEnergy = condenser.TotalHeatRecoveredLoad * localTimeStepSec;
   12967     28288080 :     this->NetHeatRejectLoad = state.dataRefrigCase->TotalCondenserHeat * TotalLoadFromThisSystem / TotalLoadFromSystems;
   12968     28288080 :     this->NetHeatRejectEnergy = this->NetHeatRejectLoad * localTimeStepSec;
   12969              : 
   12970              :     // set water system demand request (if needed)
   12971     28288080 :     if (condenser.EvapWaterSupplyMode == WaterSupply::FromTank) {
   12972        63594 :         state.dataWaterData->WaterStorage(condenser.EvapWaterSupTankID).VdotRequestDemand(condenser.EvapWaterTankDemandARRID) =
   12973        63594 :             condenser.EvapWaterConsumpRate;
   12974              :     }
   12975     28288080 : }
   12976              : 
   12977        10701 : void TransRefrigSystemData::CalcGasCooler(EnergyPlusData &state, int const SysNum)
   12978              : {
   12979              : 
   12980              :     // SUBROUTINE INFORMATION:
   12981              :     //       AUTHOR         Brian A. Fricke, ORNL
   12982              :     //       DATE WRITTEN   Fall 2011
   12983              :     //       MODIFIED       na
   12984              :     //       RE-ENGINEERED  na
   12985              : 
   12986              :     // PURPOSE OF THIS SUBROUTINE:
   12987              :     // Find the gas cooler outlet temperature, the optimum gas cooler pressure, heat rejection,
   12988              :     // fan power, and fan energy for a detailed transcritical CO2 refrigeration system.
   12989              : 
   12990              :     // METHODOLOGY EMPLOYED:
   12991              :     // For a specified gas cooler outlet temperature in transcritical operation, there is an optimal gas cooler
   12992              :     // pressure which produces the highest COP. A curve-fit equation similar to that presented by Ge and Tassou
   12993              :     // (2011) and Sawalha (2008) is used to determine the optimum gas cooler pressure for a given gas cooler
   12994              :     // outlet temperature. In subcritical operation, the condensing temperature and pressure are allowed to
   12995              :     // float with ambient conditions, above the minimum condensing temperature.
   12996              : 
   12997              :     // REFERENCES:
   12998              :     // Ge, Y.T., and S.A. Tassou. 2011. Performance evaluation and optimal design of supermarket refrigeration
   12999              :     //     systems with supermarket model "SuperSim", Part I: Model description and validation. International
   13000              :     //     Journal of Refrigeration 34: 527-539.
   13001              :     // Ge, Y.T., and S.A. Tassou. 2011. Performance evaluation and optimal design of supermarket refrigeration
   13002              :     //     systems with supermarket model "SuperSim", Part II: Model applications. International Journal of
   13003              :     //     Refrigeration 34: 540-549.
   13004              :     // Sawalha, S. 2008. Theoretical evaluation of trans-critical CO2 systems in supermarket refrigeration,
   13005              :     //     Part I: Modeling, simulation and optimization of two system solutions. International Journal of
   13006              :     //     Refrigeration 31: 516-524.
   13007              :     // Sawalha, S. 2008. Theoretical evaluation of trans-critical CO2 systems in supermarket refrigeration,
   13008              :     //     Part II: System modifications and comparisons of different solutions. International Journal of
   13009              :     //     Refrigeration 31: 525-534.
   13010              : 
   13011              :     static constexpr std::string_view RoutineName = "RefrigeratedCase:CalcGasCooler";
   13012              : 
   13013        10701 :     auto &TransSystem = state.dataRefrigCase->TransSystem;
   13014        10701 :     auto &GasCooler = state.dataRefrigCase->GasCooler;
   13015              : 
   13016              :     int GasCoolerCreditWarnIndex;       // Warning counter
   13017              :     Real64 ActualFanPower;              // Fan power after adjustments for partially loaded gas cooler [W]
   13018              :     Real64 AirVolRatio;                 // Ratio of air volume needed to remove load relative to design load
   13019              :     Real64 FanMinAirFlowRatio;          // Minimum fan air flow ratio
   13020              :     Real64 FanPowerRatio;               // Calculated fan power ratio
   13021              :     Real64 OutDbTemp;                   // Outdoor dry bulb temperature at gas cooler air inlet node [C]
   13022              :     Real64 RatedFanPower;               // Rated fan power for this gas cooler [W]
   13023              :     Real64 TotalCondDefCredfromSysID;   // Gas cooler defrost credit for single system [W]
   13024              :     Real64 TotalCondDefrostCreditLocal; // Total gas cooler credit from hot gas/brine defrost for cases etc. served
   13025              :     //     directly by all systems served by this gas cooler [W]
   13026              :     Real64 TotalGasCoolerHeat;           // Total gas cooler heat from system [W]
   13027              :     Real64 TotalLoadFromSysID;           // Total heat rejection load from a single detailed system [W]
   13028              :     Real64 TotalLoadFromSystems;         // Total heat rejection load from all systems served by this condenser [W]
   13029        10701 :     Real64 TotalLoadFromThisSystem(0.0); // Total heat rejection load from the detailed system identified in subroutine call [W]
   13030              : 
   13031        10701 :     Real64 localTimeStep = (state.dataRefrigCase->UseSysTimeStep) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone;
   13032        10701 :     Real64 localTimeStepSec = localTimeStep * Constant::rSecsInHour;
   13033              : 
   13034              :     // Initialize this gas cooler for this time step
   13035        10701 :     ActualFanPower = 0.0;
   13036        10701 :     TotalCondDefrostCreditLocal = 0.0;
   13037        10701 :     TotalLoadFromSystems = 0.0;
   13038        10701 :     int GasCoolerID = this->GasCoolerNum(1);
   13039        10701 :     auto &cooler = GasCooler(GasCoolerID);
   13040        10701 :     RatedFanPower = cooler.RatedFanPower;
   13041        10701 :     FanMinAirFlowRatio = cooler.FanMinAirFlowRatio;
   13042        10701 :     GasCoolerCreditWarnIndex = cooler.GasCoolerCreditWarnIndex;
   13043              : 
   13044        21402 :     for (int Sysloop = 1; Sysloop <= cooler.NumSysAttach; ++Sysloop) {
   13045        10701 :         int SystemID = cooler.SysNum(Sysloop);
   13046        10701 :         TotalCondDefCredfromSysID = TransSystem(SystemID).TotalCondDefrostCredit;
   13047        10701 :         TotalCondDefrostCreditLocal += TotalCondDefCredfromSysID;
   13048        10701 :         TotalLoadFromSysID = TransSystem(SystemID).TotalSystemLoadLT + TransSystem(SystemID).TotalSystemLoadMT +
   13049        10701 :                              TransSystem(SystemID).TotCompPowerLP + TransSystem(SystemID).TotCompPowerHP + TransSystem(SystemID).PipeHeatLoadLT +
   13050        10701 :                              TransSystem(SystemID).PipeHeatLoadMT;
   13051        10701 :         TotalLoadFromSystems += TotalLoadFromSysID;
   13052        10701 :         if (SystemID == SysNum) {
   13053        10701 :             TotalLoadFromThisSystem = TotalLoadFromSysID;
   13054              :         }
   13055              :     } // Sysloop over every system connected to this gas cooler
   13056              : 
   13057              :     // Calculate Total Heat rejection needed.
   13058        10701 :     cooler.InternalHeatRecoveredLoad = TotalCondDefrostCreditLocal;
   13059        10701 :     cooler.TotalHeatRecoveredLoad = TotalCondDefrostCreditLocal;
   13060        10701 :     TotalGasCoolerHeat = TotalLoadFromSystems - TotalCondDefrostCreditLocal;
   13061              : 
   13062        10701 :     if (TotalGasCoolerHeat < 0.0) {
   13063            0 :         TotalGasCoolerHeat = 0.0;
   13064            0 :         if (!state.dataGlobal->WarmupFlag) {
   13065            0 :             ShowRecurringWarningErrorAtEnd(state,
   13066            0 :                                            "Refrigeration:TranscriticalSystem: " + this->Name +
   13067              :                                                ":heat reclaimed (defrost,other purposes) is greater than current gas cooler load. ASHRAE rule of "
   13068              :                                                "thumb: <= 25% of the load on a system should be in defrost at the same time. Consider "
   13069              :                                                "diversifying defrost schedules.",
   13070              :                                            GasCoolerCreditWarnIndex);
   13071              :         }
   13072              :     } // total gas cooler heat < 0
   13073              : 
   13074              :     // The rated capacity of air-cooled gas cooler was adjusted for elevation in get input step
   13075        10701 :     Real64 CapFac = TotalGasCoolerHeat / cooler.RatedCapacity;
   13076              :     // See whether gas cooler is at ground level or if other air conditions (ie node) have been specified.
   13077              :     // Note that air-cooled gas coolers can draw air from, and reject heat to, a conditioned zone.
   13078        10701 :     if (cooler.InletAirNodeNum != 0) {
   13079            0 :         OutDbTemp = state.dataLoopNodes->Node(cooler.InletAirNodeNum).Temp;
   13080              :     } else {
   13081        10701 :         OutDbTemp = state.dataEnvrn->OutDryBulbTemp;
   13082              :     }
   13083              :     // Determine gas cooler outlet temperature and pressure
   13084              :     // Transcritical:  Gas cooler outlet temperature based on ambient temperature and approach temperature.
   13085              :     //                 Determine optimum gas cooler pressure to maximize COP.
   13086              :     // Subcritical:  Allow condensing temperature and pressure to float between minimum condensing temperature and
   13087              :     //               transition temperature.
   13088        10701 :     if (OutDbTemp > cooler.TransitionTemperature) { // Gas cooler in transcritical operation
   13089         4375 :         cooler.TGasCoolerOut = OutDbTemp + cooler.GasCoolerApproachT;
   13090         4375 :         cooler.PGasCoolerOut = 1.0e5 * (2.3083 * state.dataEnvrn->OutDryBulbTemp + 11.9);
   13091         4375 :         if (cooler.PGasCoolerOut < 7.5e6) { // Ensure gas cooler pressure is at least 7.5 MPa for transcritical operation
   13092          427 :             cooler.PGasCoolerOut = 7.5e6;
   13093              :         }
   13094         4375 :         cooler.HGasCoolerOut = this->refrig->getSupHeatEnthalpy(state, cooler.TGasCoolerOut, cooler.PGasCoolerOut, RoutineName);
   13095         4375 :         cooler.TransOpFlag = true;
   13096              :     } else { // Gas cooler in subcritical operation
   13097         6326 :         cooler.TGasCoolerOut = OutDbTemp + cooler.SubcriticalTempDiff;
   13098         6326 :         if (cooler.TGasCoolerOut > 30.978) { //  Gas temperature should be less than critical temperature
   13099         1966 :             cooler.PGasCoolerOut = 7.2e6;    //  Fix the pressure to be subcritical
   13100         1966 :             cooler.TGasCoolerOut = this->refrig->getSatTemperature(state, cooler.PGasCoolerOut, RoutineName);
   13101         4360 :         } else if (cooler.TGasCoolerOut > cooler.MinCondTemp) { //  Allow condensing temperature to float above the minimum
   13102         4360 :             cooler.PGasCoolerOut = this->refrig->getSatPressure(state, cooler.TGasCoolerOut, RoutineName);
   13103              :         } else { //  Don't allow condensing temperature to drop below minimum
   13104            0 :             cooler.TGasCoolerOut = cooler.MinCondTemp;
   13105            0 :             cooler.PGasCoolerOut = this->refrig->getSatPressure(state, cooler.TGasCoolerOut, RoutineName);
   13106              :         }
   13107         6326 :         cooler.HGasCoolerOut = this->refrig->getSatEnthalpy(state, cooler.TGasCoolerOut, 0.0, RoutineName);
   13108         6326 :         cooler.TransOpFlag = false;
   13109              :     } // (OutDbTemp > TransitionTemperature)
   13110              : 
   13111        10701 :     if (cooler.TGasCoolerOut < 30.978) {
   13112         7126 :         cooler.CpGasCoolerOut = this->refrig->getSatSpecificHeat(state, cooler.TGasCoolerOut, 0.0, RoutineName);
   13113              :     } else {
   13114         3575 :         cooler.CpGasCoolerOut = 0.0;
   13115              :     }
   13116              : 
   13117              :     // Gas cooler fan energy calculations
   13118        10701 :     AirVolRatio = max(FanMinAirFlowRatio, std::pow(CapFac, CondAirVolExponentDry)); // Fans limited by minimum air flow ratio
   13119              : 
   13120        10701 :     switch (cooler.FanSpeedControlType) {
   13121            0 :     case FanSpeedCtrlType::VariableSpeed: { // fan power law, adjusted for reality, applies
   13122            0 :         FanPowerRatio = std::pow(AirVolRatio, 2.5);
   13123            0 :         ActualFanPower = FanPowerRatio * RatedFanPower;
   13124            0 :     } break;
   13125        10701 :     case FanSpeedCtrlType::ConstantSpeed: {
   13126        10701 :         ActualFanPower = AirVolRatio * std::exp(1.0 - AirVolRatio) * RatedFanPower;
   13127        10701 :     } break;
   13128            0 :     case FanSpeedCtrlType::ConstantSpeedLinear: {
   13129            0 :         ActualFanPower = AirVolRatio * RatedFanPower;
   13130            0 :     } break;
   13131            0 :     case FanSpeedCtrlType::TwoSpeed: {
   13132              :         // low speed setting of 1/2 fan speed can give up to 60% of capacity.
   13133              :         // 1/2 speed corresponds to ~1/8 power consumption (FanHalfSpeedRatio = 1/(2**2.5) = 0.1768)
   13134              :         // dampers are used to control flow within those two ranges as in FanConstantSpeed
   13135            0 :         ActualFanPower = AirVolRatio * std::exp(1.0 - AirVolRatio) * RatedFanPower;
   13136            0 :         if (CapFac < CapFac60Percent) {
   13137            0 :             ActualFanPower = ((AirVolRatio + 0.4) * (FanHalfSpeedRatio)) * std::exp(1.0 - AirVolRatio) * RatedFanPower;
   13138              :         }
   13139            0 :     } break;
   13140            0 :     default:
   13141            0 :         break;
   13142              :     } // fan speed control type
   13143              : 
   13144        10701 :     cooler.ActualFanPower = ActualFanPower;
   13145        10701 :     cooler.FanElecEnergy = ActualFanPower * localTimeStepSec;
   13146        10701 :     cooler.GasCoolerLoad = TotalGasCoolerHeat;
   13147        10701 :     cooler.GasCoolerEnergy = TotalGasCoolerHeat * localTimeStepSec;
   13148        10701 :     cooler.GasCoolerCreditWarnIndex = GasCoolerCreditWarnIndex;
   13149        10701 :     cooler.InternalEnergyRecovered = cooler.InternalHeatRecoveredLoad * localTimeStepSec;
   13150        10701 :     cooler.TotalHeatRecoveredEnergy = cooler.TotalHeatRecoveredLoad * localTimeStepSec;
   13151        10701 :     this->NetHeatRejectLoad = TotalGasCoolerHeat * TotalLoadFromThisSystem / TotalLoadFromSystems;
   13152        10701 :     this->NetHeatRejectEnergy = this->NetHeatRejectLoad * localTimeStepSec;
   13153        10701 : }
   13154              : 
   13155     28288080 : void RefrigSystemData::CalculateCompressors(EnergyPlusData &state)
   13156              : {
   13157              : 
   13158              :     // SUBROUTINE INFORMATION:
   13159              :     //       AUTHOR         Therese Stovall, ORNL, Assisted by Hugh Henderson
   13160              :     //       DATE WRITTEN   Spring 2008
   13161              :     //       MODIFIED       Brian Fricke, ORNL, March 2012, added two-stage compression
   13162              :     //       RE-ENGINEERED  na
   13163              : 
   13164              :     // PURPOSE OF THIS SUBROUTINE:
   13165              :     // Find the Compressor power, energy, capacity, and efficiency for a particular detailed
   13166              :     // refrigeration system.  Routine is capable of modeling single-stage and two-stage
   13167              :     // compression refrigeration systems.
   13168              : 
   13169              :     // METHODOLOGY EMPLOYED:
   13170              :     // USe ARI compressor performance curves, the evaporating temperature and condensing temperature
   13171              : 
   13172              :     // REFERENCES:
   13173              :     // "Impact of ASHRAE Standard 62-1989 on Florida Supermarkets",
   13174              :     //  Florida Solar Energy Center, FSEC-CR-910-96, Final Report, Oct. 1996
   13175              : 
   13176              :     // ARI Standard 540, 2004, Standard for Performance Rating of Positive Displacement Refrigerant
   13177              :     //  Compressors and Compressor Units, Air-Conditioning & Refrigeration Institute,Arlington VA
   13178              : 
   13179              :     // SUBROUTINE PARAMETER DEFINITIONS:
   13180              :     // Following constants approp for R22, R134a, R404a, R507, R410a, R407c, future allow input?
   13181              :     //   May want to allow input to reflect larger pipes selected to reduce delta P and increase compressor efficiency.
   13182              :     // NOTE, these DelT...Pipes reflect the decrease in Pressure in the pipes, NOT thermal transfer through the pipe walls.
   13183     28288080 :     Real64 constexpr DelTSuctPipes(1.0);  // Tsat drop corresponding to P drop in suction pipes, ASHRAE 2006 p 2.4 (C)
   13184     28288080 :     Real64 constexpr DelTDischPipes(0.5); // Tsat drop corresponding to P drop in discharge pipes, ASHRAE 2006 p 2.5 (C)
   13185              : 
   13186              :     static constexpr std::string_view RoutineName("RefrigeratedCase:CalculateCompressors");
   13187              :     Real64 CaseEnthalpyChangeRated;   // Enthalpy change in cases at compressor rated cond, J/kg
   13188              :     Real64 CapacityCorrection;        // Capacity at existing subcool/superheat over cap at rated conditions
   13189              :     Real64 CpSatVapCondense;          // Specific heat of vapor at cond temp J/kg-C
   13190              :     Real64 DensityRated;              // Density of inlet gas at rated superheat, m3/kg
   13191              :     Real64 DensityActual;             // Density of superheated gas at compressor inlet, m3/kg
   13192     28288080 :     Real64 HCompInRated(0.0);         // Enthalpy entering compressor at rated superheat, J/kg //Autodesk:Init
   13193     28288080 :     Real64 HCaseInRated(0.0);         // Enthalpy entering cases at rated subcooling, J/kg //Autodesk:Init
   13194              :     Real64 HSatVapCondense;           // Enthalpy of saturated vapor at T condense, J/kg
   13195              :     Real64 HsatVaporforTevapneeded;   // Enthalpy saturated vapor at temperature needed at evaporator
   13196              :     Real64 LFLastComp;                // Load factor for last compressor dispatched
   13197              :     Real64 MassCorrection;            // Mass flow at existing subcool/superheat over cap at rated conditions
   13198              :     Real64 NeededCapacity;            // Sum of case loads and mech subcooler loads on suction group
   13199              :     Real64 PSuction;                  // Suction Pressure
   13200              :     Real64 PCond;                     // Condensing pressure
   13201              :     Real64 PEvap;                     // Evaporating pressure
   13202              :     Real64 TCompOutEstimate;          // Estimated temperature out of the compressor, used to flag whether heat reclaim is reasonable, C
   13203     28288080 :     Real64 TempInRated(0.0);          // Temperature entering compressor at rated superheat, C //Autodesk:Init
   13204              :     Real64 TotalEnthalpyChangeActual; // Actual enthalpy change in cases and cold side of LSHX, J/kg
   13205              :     Real64 TsatforPsuct;              // Tsat for PSuction, C
   13206     28288080 :     Real64 TsatforPdisch(0.0);        // Tsat for Pdischarge, c
   13207              :     int NumComps;                     // Number of low-stage or high-stage compressors in system
   13208              :     Real64 HHiStageCompIn;            // Enthalpy at inlet of high-stage compressor (J/kg)
   13209     28288080 :     Real64 HCaseInRated_base(0.0), HCompInRated_base(0.0); // Autodesk:Tuned Intermediate values for performance tuning
   13210              : 
   13211     28288080 :     auto &Condenser = state.dataRefrigCase->Condenser;
   13212     28288080 :     auto &Compressor = state.dataRefrigCase->Compressor;
   13213              : 
   13214     28288080 :     Real64 localTimeStep = (state.dataRefrigCase->UseSysTimeStep) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone;
   13215     28288080 :     Real64 localTimeStepSec = localTimeStep * Constant::rSecsInHour;
   13216              : 
   13217     28288080 :     int CondID = this->CondenserNum(1);
   13218     28288080 :     auto const &Condenser1 = Condenser(CondID);
   13219     28288080 :     Real64 const AccumLoad = max(0.0, (this->UnmetEnergy / localTimeStepSec)); // Load due to previously unmet compressor loads
   13220     28288080 :     Real64 const NeededCapacity_base(this->TotalSystemLoad + AccumLoad + this->PipeHeatLoad + this->LSHXTrans);
   13221              : 
   13222              :     // Before dispatching compressors, zero sum of compressor outputs and zero each compressor
   13223     28288080 :     this->TotCompCapacity = 0.0;
   13224     28288080 :     this->RefMassFlowComps = 0.0;
   13225     28288080 :     this->TotCompPower = 0.0;
   13226     28288080 :     if (this->NumStages == 2) {
   13227        14160 :         this->TotHiStageCompCapacity = 0.0;
   13228        14160 :         this->RefMassFlowHiStageComps = 0.0;
   13229        14160 :         this->TotHiStageCompPower = 0.0;
   13230              :     }
   13231              : 
   13232    241470233 :     for (int CompIndex = 1; CompIndex <= this->NumCompressors; ++CompIndex) {
   13233    213182153 :         int CompID = this->CompressorNum(CompIndex);
   13234    213182153 :         auto &compressor = Compressor(CompID);
   13235    213182153 :         compressor.Power = 0.0;
   13236    213182153 :         compressor.MassFlow = 0.0;
   13237    213182153 :         compressor.Capacity = 0.0;
   13238    213182153 :         compressor.ElecConsumption = 0.0;
   13239    213182153 :         compressor.CoolingEnergy = 0.0;
   13240    213182153 :         compressor.LoadFactor = 0.0;
   13241              :     }
   13242     28288080 :     if (this->NumStages == 2) {
   13243        70800 :         for (int CompIndex = 1; CompIndex <= this->NumHiStageCompressors; ++CompIndex) {
   13244        56640 :             int CompID = this->HiStageCompressorNum(CompIndex);
   13245        56640 :             auto &compressor = Compressor(CompID);
   13246        56640 :             compressor.Power = 0.0;
   13247        56640 :             compressor.MassFlow = 0.0;
   13248        56640 :             compressor.Capacity = 0.0;
   13249        56640 :             compressor.ElecConsumption = 0.0;
   13250        56640 :             compressor.CoolingEnergy = 0.0;
   13251        56640 :             compressor.LoadFactor = 0.0;
   13252              :         }
   13253              :     }
   13254              : 
   13255              :     // Determine properties at case inlet and compressor inlet
   13256     56590320 :     for (int StageIndex = 1; StageIndex <= min(2, this->NumStages); ++StageIndex) {
   13257     28302240 :         if (StageIndex == 1) {                                    // Do single-stage or low-stage calculations
   13258     28288080 :             if (this->NumStages == 1) {                           // Single-stage system
   13259     28273920 :                 NeededCapacity = NeededCapacity_base;             // because compressor capacity rated from txv to comp inlet
   13260     28273920 :                 TsatforPdisch = this->TCondense + DelTDischPipes; // need (Psat of (Tcond + delT corresponding to delP disch Pipes))
   13261     28273920 :                 TsatforPsuct = this->TEvapNeeded - DelTSuctPipes; // need (Psat of (Tevap - delT corresponding to del P suct Pipes))
   13262     28273920 :                 HsatVaporforTevapneeded = this->refrig->getSatEnthalpy(state, this->TEvapNeeded, 1.0, RoutineName);
   13263     28273920 :                 this->HSatLiqCond = this->refrig->getSatEnthalpy(state, this->TCondense, 0.0, RoutineName);
   13264     28273920 :                 this->CpSatLiqCond = this->refrig->getSatSpecificHeat(state, this->TCondense, 0.0, RoutineName);
   13265              :                 // HCaseIn is a function of the condenser rated subcooling, not the compressor rated subcooling
   13266              :                 // TCompIn needs to include case superheat as well as Temp change from lshx subcoolers
   13267              :                 // Calculate both here unless set previously by subcooler subroutine
   13268              :                 // HCaseOut corresponds to (tevapneeded + case superheat)
   13269              :                 // future - visit how parameter 'casesuperheat' applies when using walk-ins or transfer loads
   13270     28273920 :                 if (this->NumSubcoolers == 0) { // No subcooler on this system
   13271     28249032 :                     this->HCaseIn = this->HSatLiqCond - this->CpSatLiqCond * Condenser1.RatedSubcool;
   13272     28249032 :                     this->TCompIn = this->TEvapNeeded + CaseSuperheat; //+
   13273     28249032 :                     this->TLiqInActual = this->TCondense - Condenser1.RatedSubcool;
   13274     28249032 :                     this->HCompIn = this->HCaseOut;
   13275              :                 } else { // subcooler subroutine has been called to calc TCompIn and HCaseIn
   13276        24888 :                     this->HCompIn = this->HCaseOut + this->CpSatVapEvap * (this->TCompIn - (this->TEvapNeeded + CaseSuperheat));
   13277              :                 } // whether or not subcooler routine used
   13278     28273920 :                 PSuction = this->refrig->getSatPressure(state, TsatforPsuct, RoutineName);
   13279     28273920 :                 NumComps = this->NumCompressors;
   13280              :             } else { // Low-stage side of two-stage system
   13281        14160 :                 PCond = this->refrig->getSatPressure(state, this->TCondense, RoutineName);
   13282        14160 :                 PEvap = this->refrig->getSatPressure(state, this->TEvapNeeded, RoutineName);
   13283        14160 :                 this->PIntercooler = std::sqrt(PCond * PEvap);
   13284        14160 :                 this->TIntercooler = this->refrig->getSatTemperature(state, this->PIntercooler, RoutineName);
   13285        14160 :                 NeededCapacity = NeededCapacity_base;                // because compressor capacity rated from txv to comp inlet
   13286        14160 :                 TsatforPdisch = this->TIntercooler + DelTDischPipes; // need (Psat of (Tinter + delT corresponding to delP disch Pipes))
   13287        14160 :                 TsatforPsuct = this->TEvapNeeded - DelTSuctPipes;    // need (Psat of (Tevap - delT corresponding to del P suct Pipes))
   13288        14160 :                 HsatVaporforTevapneeded = this->refrig->getSatEnthalpy(state, this->TEvapNeeded, 1.0, RoutineName);
   13289        14160 :                 this->HSatLiqCond = this->refrig->getSatEnthalpy(state, this->TCondense, 0.0, RoutineName);
   13290        14160 :                 this->CpSatLiqCond = this->refrig->getSatSpecificHeat(state, this->TCondense, 0.0, RoutineName);
   13291              :                 // HCaseIn is a function of the condenser rated subcooling, not the compressor rated subcooling
   13292              :                 // TCompIn needs to include case superheat as well as Temp change from lshx subcoolers
   13293              :                 // Calculate both here unless set previously by subcooler subroutine
   13294              :                 // HCaseOut corresponds to (tevapneeded + case superheat)
   13295        14160 :                 if (this->NumSubcoolers == 0) { // No subcooler on this system
   13296        14160 :                     if (this->intercoolerType == IntercoolerType::Flash) {
   13297         7080 :                         this->HCaseIn = this->refrig->getSatEnthalpy(state, this->TIntercooler, 0.0, RoutineName);
   13298         7080 :                         this->TLiqInActual = this->TIntercooler;
   13299         7080 :                     } else if (this->intercoolerType == IntercoolerType::ShellAndCoil) {
   13300         7080 :                         this->TLiqInActual = this->TCondense - Condenser1.RatedSubcool -
   13301         7080 :                                              this->IntercoolerEffectiveness * (this->TCondense - Condenser1.RatedSubcool - this->TIntercooler);
   13302         7080 :                         this->HCaseIn = this->HSatLiqCond - this->CpSatLiqCond * (this->TCondense - this->TLiqInActual);
   13303              :                     } // IntercoolerType
   13304        14160 :                     this->TCompIn = this->TEvapNeeded + CaseSuperheat; //+
   13305        14160 :                     this->HCompIn = this->HCaseOut;
   13306              :                 } else { // subcooler subroutine has been called to calc TCompIn and HCaseIn
   13307            0 :                     this->HCompIn = this->HCaseOut + this->CpSatVapEvap * (this->TCompIn - (this->TEvapNeeded + CaseSuperheat));
   13308              :                 } // whether or not subcooler routine used
   13309        14160 :                 PSuction = this->refrig->getSatPressure(state, TsatforPsuct, RoutineName);
   13310        14160 :                 NumComps = this->NumCompressors;
   13311              :             } // NumStages
   13312              :         } else { // Two-stage system, high-stage side
   13313        14160 :             NeededCapacity = NeededCapacity_base + this->TotCompPower;
   13314        14160 :             TsatforPdisch = this->TCondense + DelTDischPipes;
   13315        14160 :             TsatforPsuct = this->TIntercooler;
   13316        14160 :             HsatVaporforTevapneeded = this->refrig->getSatEnthalpy(state, this->TIntercooler, 1.0, RoutineName);
   13317              :             //                HSatLiqCond = Fluid::GetSatEnthalpyRefrig(state, RefrigerantName, TCondense, 0.0, RefIndex,
   13318              :             // RoutineName
   13319              :             //);
   13320              :             ////Autodesk:Tuned These don't change for 2nd stage
   13321              :             //                CpSatLiqCond = Fluid::GetSatSpecificHeatRefrig(RefrigerantName, TCondense, 0.0, RefIndex,
   13322              :             // RoutineName );
   13323              :             ////Autodesk:Tuned These don't change for 2nd stage
   13324        14160 :             this->HCaseIn = this->HSatLiqCond - this->CpSatLiqCond * Condenser1.RatedSubcool;
   13325        14160 :             this->TCompIn = this->TIntercooler;
   13326              :             //      System(SysNum)%TLiqInActual = System(SysNum)%TCondense-Condenser(System(SysNum)%CondenserNum(1))%RatedSubcool
   13327        14160 :             this->HCompIn = HsatVaporforTevapneeded;
   13328        14160 :             PSuction = this->refrig->getSatPressure(state, TsatforPsuct, RoutineName);
   13329        14160 :             NumComps = this->NumHiStageCompressors;
   13330              :         } // StageIndex
   13331              : 
   13332              :         // dispatch compressors to meet load, note they were listed in compressor list in dispatch order
   13333     28302240 :         DensityActual = this->refrig->getSupHeatDensity(state, this->TCompIn, PSuction, RoutineName); // Autodesk:Tuned Hoisted out of CompIndex loop
   13334     28302240 :         TotalEnthalpyChangeActual = this->HCompIn - this->HCaseIn;                                    // Autodesk:Tuned Hoisted out of CompIndex loop
   13335     28302240 :         if (this->NumStages == 2) {                                                                   // Autodesk:Tuned Hoisted out of CompIndex loop
   13336        28320 :             if (StageIndex == 1) {
   13337        14160 :                 HCaseInRated_base = this->refrig->getSatEnthalpy(state, this->TIntercooler, 0.0, RoutineName);
   13338        14160 :             } else if (StageIndex == 2) {
   13339        14160 :                 HCompInRated_base = this->refrig->getSatEnthalpy(state, this->TIntercooler, 1.0, RoutineName);
   13340              :             }
   13341              :         }
   13342     62481607 :         for (int CompIndex = 1; CompIndex <= NumComps; ++CompIndex) {
   13343              :             int CompID;
   13344     61941838 :             if (StageIndex == 1) {
   13345     61919194 :                 CompID = this->CompressorNum(CompIndex);
   13346              :             } else {
   13347        22644 :                 CompID = this->HiStageCompressorNum(CompIndex);
   13348              :             } // StageIndex
   13349     61941838 :             auto &compressor = Compressor(CompID);
   13350              : 
   13351              :             // need to use indiv compressor's rated subcool and superheat to adjust capacity to actual conditions
   13352     61941838 :             switch (compressor.SubcoolRatingType) {
   13353     54880377 :             case CompRatingType::Subcooling: {
   13354     54880377 :                 if (this->NumStages == 1) { // Single-stage system
   13355     54835430 :                     HCaseInRated = this->HSatLiqCond - this->CpSatLiqCond * compressor.RatedSubcool;
   13356        44947 :                 } else if (this->NumStages == 2 && StageIndex == 1) { // Two-stage system, low-stage side
   13357        22303 :                     HCaseInRated = HCaseInRated_base - this->CpSatLiqCond * compressor.RatedSubcool;
   13358        22644 :                 } else if (this->NumStages == 2 && StageIndex == 2) { // Two-stage system, high-stage side
   13359        22644 :                     HCaseInRated = this->HSatLiqCond - this->CpSatLiqCond * compressor.RatedSubcool;
   13360              :                 } // NumStages
   13361     54880377 :             } break;
   13362      7061461 :             case CompRatingType::LiquidTemperature: { // have rated liquid temperature stored in "RatedSubcool"
   13363      7061461 :                 if (this->NumStages == 1) {           // Single-stage system
   13364      7061461 :                     HCaseInRated = this->HSatLiqCond - this->CpSatLiqCond * (this->TCondense - compressor.RatedSubcool);
   13365            0 :                 } else if (this->NumStages == 2 && StageIndex == 1) { // Two-stage system, low-stage side
   13366            0 :                     HCaseInRated = HCaseInRated_base - this->CpSatLiqCond * (this->TIntercooler - compressor.RatedSubcool);
   13367            0 :                 } else if (this->NumStages == 2 && StageIndex == 2) { // Two-stage system, high-stage side
   13368            0 :                     HCaseInRated = this->HSatLiqCond - this->CpSatLiqCond * (this->TCondense - compressor.RatedSubcool);
   13369              :                 } // NumStages
   13370      7061461 :             } break;
   13371            0 :             default:
   13372            0 :                 break;
   13373              :             } // Compressor SubcoolRatingType
   13374     61941838 :             switch (compressor.SuperheatRatingType) {
   13375     61387496 :             case CompRatingType::Superheat: {
   13376     61387496 :                 if (this->NumStages == 1) { // Single-stage system
   13377     61365193 :                     HCompInRated = HsatVaporforTevapneeded + this->CpSatVapEvap * compressor.RatedSuperheat;
   13378     61365193 :                     TempInRated = this->TEvapNeeded + compressor.RatedSuperheat;
   13379        22303 :                 } else if (this->NumStages == 2 && StageIndex == 1) { // Two-stage system, low-stage side
   13380        22303 :                     HCompInRated = HsatVaporforTevapneeded + this->CpSatVapEvap * compressor.RatedSuperheat;
   13381        22303 :                     TempInRated = this->TEvapNeeded + compressor.RatedSuperheat;
   13382            0 :                 } else if (this->NumStages == 2 && StageIndex == 2) { // Two-stage system, high-stage side
   13383            0 :                     HCompInRated = HCompInRated_base + this->CpSatVapEvap * compressor.RatedSuperheat;
   13384            0 :                     TempInRated = this->TIntercooler + compressor.RatedSuperheat;
   13385              :                 } // NumStages
   13386     61387496 :             } break;
   13387       554342 :             case CompRatingType::ReturnGasTemperature: { // have rated compressor inlet temperature stored in "RatedSuperheat"
   13388       554342 :                 if (this->NumStages == 1) {              // Single-stage system
   13389       531698 :                     TempInRated = compressor.RatedSuperheat;
   13390       531698 :                     HCompInRated = HsatVaporforTevapneeded + this->CpSatVapEvap * (TempInRated - this->TEvapNeeded);
   13391        22644 :                 } else if (this->NumStages == 2 && StageIndex == 1) { // Two-stage system, low-stage side
   13392            0 :                     TempInRated = compressor.RatedSuperheat;
   13393            0 :                     HCompInRated = HsatVaporforTevapneeded + this->CpSatVapEvap * (TempInRated - this->TEvapNeeded);
   13394        22644 :                 } else if (this->NumStages == 2 && StageIndex == 2) { // Two-stage system, high-stage side
   13395        22644 :                     TempInRated = compressor.RatedSuperheat;
   13396        22644 :                     HCompInRated = HsatVaporforTevapneeded + this->CpSatVapEvap * (TempInRated - this->TIntercooler);
   13397              :                 } // NumStages
   13398       554342 :             } break;
   13399            0 :             default:
   13400            0 :                 break;
   13401              :             } // Compressor SuperheatRatingType
   13402              : 
   13403     61941838 :             CaseEnthalpyChangeRated = HCompInRated - HCaseInRated;
   13404     61941838 :             DensityRated = this->refrig->getSupHeatDensity(state, TempInRated, PSuction, RoutineName);
   13405              :             //  Adjust capacity and mass flow to reflect the specific volume change due to superheating and
   13406              :             //  the increase in capacity due to extra subcooling
   13407     61941838 :             MassCorrection = DensityActual / DensityRated;
   13408     61941838 :             CapacityCorrection = MassCorrection * TotalEnthalpyChangeActual / CaseEnthalpyChangeRated;
   13409     61941838 :             compressor.Power = Curve::CurveValue(state, compressor.ElecPowerCurvePtr, TsatforPsuct, TsatforPdisch);
   13410     61941838 :             compressor.Capacity = CapacityCorrection * Curve::CurveValue(state, compressor.CapacityCurvePtr, TsatforPsuct, TsatforPdisch);
   13411     61941838 :             compressor.MassFlow = compressor.Capacity / TotalEnthalpyChangeActual;
   13412              : 
   13413              :             // calculate load factor for last compressor added
   13414              :             // assumes either cycling or part load eff = full load eff for last compressor
   13415     61941838 :             if (StageIndex == 1) { // Single-stage or low-stage compressors
   13416     61919194 :                 if ((this->TotCompCapacity + compressor.Capacity) >= NeededCapacity) {
   13417     27748311 :                     LFLastComp = (NeededCapacity - this->TotCompCapacity) / compressor.Capacity;
   13418     27748311 :                     compressor.Power *= LFLastComp;
   13419     27748311 :                     compressor.MassFlow *= LFLastComp;
   13420     27748311 :                     compressor.Capacity *= LFLastComp;
   13421     27748311 :                     this->TotCompCapacity += compressor.Capacity;
   13422     27748311 :                     this->RefMassFlowComps += compressor.MassFlow;
   13423     27748311 :                     this->TotCompPower += compressor.Power;
   13424     27748311 :                     compressor.ElecConsumption = compressor.Power * localTimeStepSec;
   13425     27748311 :                     compressor.CoolingEnergy = compressor.Capacity * localTimeStepSec;
   13426     27748311 :                     compressor.LoadFactor = LFLastComp;
   13427     27748311 :                     break; // numcomps do
   13428              :                 } else {   //>= needed capacity
   13429     34170883 :                     this->TotCompCapacity += compressor.Capacity;
   13430     34170883 :                     this->RefMassFlowComps += compressor.MassFlow;
   13431     34170883 :                     this->TotCompPower += compressor.Power;
   13432              :                 } //>= needed capacity
   13433              :             } else { // high-stage compressors (for two-stage systems only)
   13434        22644 :                 if ((this->TotHiStageCompCapacity + compressor.Capacity) >= NeededCapacity) {
   13435        14160 :                     LFLastComp = (NeededCapacity - this->TotHiStageCompCapacity) / compressor.Capacity;
   13436        14160 :                     compressor.Power *= LFLastComp;
   13437        14160 :                     compressor.MassFlow *= LFLastComp;
   13438        14160 :                     compressor.Capacity *= LFLastComp;
   13439        14160 :                     this->TotHiStageCompCapacity += compressor.Capacity;
   13440        14160 :                     this->RefMassFlowHiStageComps += compressor.MassFlow;
   13441        14160 :                     this->TotHiStageCompPower += compressor.Power;
   13442        14160 :                     this->FlowRatioIntercooler = this->RefMassFlowComps / this->RefMassFlowHiStageComps;
   13443        14160 :                     compressor.ElecConsumption = compressor.Power * localTimeStepSec;
   13444        14160 :                     compressor.CoolingEnergy = compressor.Capacity * localTimeStepSec;
   13445        14160 :                     compressor.LoadFactor = LFLastComp;
   13446        14160 :                     break; // numcomps do
   13447              :                 } else {   //>= needed capacity
   13448         8484 :                     this->TotHiStageCompCapacity += compressor.Capacity;
   13449         8484 :                     this->RefMassFlowHiStageComps += compressor.MassFlow;
   13450         8484 :                     this->TotHiStageCompPower += compressor.Power;
   13451              :                 } //>= needed capacity
   13452              :             } // StageIndex
   13453     34179367 :             compressor.ElecConsumption = compressor.Power * localTimeStepSec;
   13454     34179367 :             compressor.CoolingEnergy = compressor.Capacity * localTimeStepSec;
   13455     34179367 :             compressor.LoadFactor = 1.0;
   13456              :         } // NumComps
   13457              :     }
   13458              : 
   13459              :     // Calculate enthalpy at compressor discharge
   13460     28288080 :     if (this->NumStages == 1) { // Single-stage or low-stage compressors
   13461     28273920 :         this->HCompOut = this->HCompIn + this->TotCompPower / this->RefMassFlowComps;
   13462              :         // error found 9/19/2011, was System(SysNum)%TotCompPower*LocalTimeStep*DataGlobals::SecInHour/System(SysNum)%RefMassFlowComps
   13463              :     } else { // High-stage compressors (only for two-stage systems)
   13464        14160 :         HHiStageCompIn = this->refrig->getSatEnthalpy(state, this->TIntercooler, 1.0, RoutineName);
   13465        14160 :         this->HCompOut = HHiStageCompIn + this->TotHiStageCompPower / this->RefMassFlowHiStageComps;
   13466              :     }
   13467              : 
   13468              :     // Calculate superheat energy available for desuperheaters
   13469     28288080 :     HSatVapCondense = this->refrig->getSatEnthalpy(state, this->TCondense, 1.0, RoutineName);
   13470     28288080 :     CpSatVapCondense = this->refrig->getSatSpecificHeat(state, this->TCondense, 1.0, RoutineName);
   13471     28288080 :     if (this->NumStages == 1) { // Single-stage systems
   13472     28273920 :         state.dataHeatBal->HeatReclaimRefrigCondenser(CondID).AvailCapacity = this->RefMassFlowComps * (this->HCompOut - HSatVapCondense);
   13473              :     } else { // Two-stage systems
   13474        14160 :         state.dataHeatBal->HeatReclaimRefrigCondenser(CondID).AvailCapacity = this->RefMassFlowHiStageComps * (this->HCompOut - HSatVapCondense);
   13475              :     } // NumStages
   13476              : 
   13477              :     // No function available to get Tout as f(Pout, Hout), so use estimate based on constant cp in superheat range...
   13478              :     //  Use average of Tcondense and Tout of condenser as check for whether heat reclaim is reasonable.
   13479     28288080 :     TCompOutEstimate = this->TCondense + (this->HCompOut - HSatVapCondense) / CpSatVapCondense;
   13480              : 
   13481     28288080 :     state.dataHeatBal->HeatReclaimRefrigCondenser(CondID).AvailTemperature = (TsatforPdisch + TCompOutEstimate) / 2.0;
   13482     28288080 :     this->AverageCompressorCOP = this->TotCompCapacity / (this->TotCompPower + this->TotHiStageCompPower);
   13483     28288080 :     this->TotCompElecConsump = this->TotCompPower * localTimeStepSec;
   13484     28288080 :     if (this->NumStages == 2) {
   13485        14160 :         this->TotHiStageCompElecConsump = this->TotHiStageCompPower * localTimeStepSec;
   13486        14160 :         this->TotCompElecConsumpTwoStage = this->TotCompElecConsump + this->TotHiStageCompElecConsump;
   13487              :     }
   13488     28288080 :     this->TotCompCoolingEnergy = this->TotCompCapacity * localTimeStepSec;
   13489     28288080 :     this->TotHiStageCompCoolingEnergy = this->TotHiStageCompCapacity * localTimeStepSec;
   13490     28288080 : }
   13491              : 
   13492        10701 : void TransRefrigSystemData::CalculateTransCompressors(EnergyPlusData &state)
   13493              : {
   13494              : 
   13495              :     // SUBROUTINE INFORMATION:
   13496              :     //       AUTHOR         Brian A. Fricke, ORNL
   13497              :     //       DATE WRITTEN   Fall 2011
   13498              :     //       RE-ENGINEERED  na
   13499              : 
   13500              :     // PURPOSE OF THIS SUBROUTINE:
   13501              :     // Find the compressor power, energy, capacity, and efficiency for a detailed transcritical CO2
   13502              :     // refrigeration system.
   13503              : 
   13504              :     // METHODOLOGY EMPLOYED:
   13505              :     // Use AHRI compressor performance curves for subcritical compressor operation, AHRI-style compressor
   13506              :     // performance curves for transcritical compressor operation, the evaporating temperature of the
   13507              :     // medium- and low-temperature loads, and the gas cooler outlet conditions (temperature, pressure
   13508              :     // and enthalpy).
   13509              : 
   13510              :     // REFERENCES:
   13511              :     // ANSI/AHRI. 2004. Standard 540, Standard for Performance Rating of Positive Displacement Refrigerant
   13512              :     //     Compressors and Compressor Units. Arlington, VA: Air-Conditioning, Heating, and Refrigeration
   13513              :     //     Institute.
   13514              :     // Ge, Y.T., and S.A. Tassou. 2011. Performance evaluation and optimal design of supermarket refrigeration
   13515              :     //     systems with supermarket model "SuperSim", Part I: Model description and validation. International
   13516              :     //     Journal of Refrigeration 34: 527-539.
   13517              :     // Ge, Y.T., and S.A. Tassou. 2011. Performance evaluation and optimal design of supermarket refrigeration
   13518              :     //     systems with supermarket model "SuperSim", Part II: Model applications. International Journal of
   13519              :     //     Refrigeration 34: 540-549.
   13520              :     // Sawalha, S. 2008. Theoretical evaluation of trans-critical CO2 systems in supermarket refrigeration,
   13521              :     //     Part I: Modeling, simulation and optimization of two system solutions. International Journal of
   13522              :     //     Refrigeration 31: 516-524.
   13523              :     // Sawalha, S. 2008. Theoretical evaluation of trans-critical CO2 systems in supermarket refrigeration,
   13524              :     //     Part II: System modifications and comparisons of different solutions. International Journal of
   13525              :     //     Refrigeration 31: 525-534.
   13526              : 
   13527              :     // SUBROUTINE PARAMETER DEFINITIONS:
   13528              :     // Following constants approp for R22, R134a, R404a, R507, R410a, R407c.
   13529              :     // For the same pressure drop, CO2 has a corresponding temperature penalty 5 to 10 times smaller than
   13530              :     // ammonia and R-134a (ASHRAE Handbook of Refrigeration, 2010, p. 3.7).  Ignore pressure drop for CO2 calculations.
   13531              :     // NOTE, these DelT...Pipes reflect the decrease in Pressure in the pipes, NOT thermal transfer through the pipe walls.
   13532              : 
   13533        10701 :     Real64 constexpr ErrorTol(0.001); // Iterative solution tolerance
   13534              : 
   13535              :     static constexpr std::string_view RoutineName("RefrigeratedCase:CalculateTransCompressors");
   13536              :     int Iter;                           // Iteration counter
   13537              :     Real64 CapacityCorrectionMT;        // Capacity at existing subcool/superheat over cap at rated conditions for MT loads
   13538              :     Real64 CaseEnthalpyChangeRatedMT;   // Enthalpy change in medium temperature cases at compressor rated cond, J/kg
   13539              :     Real64 CaseEnthalpyChangeRatedLT;   // Enthalpy change in low temperature cases at compressor rated cond, J/kg
   13540              :     Real64 DensityActualLT;             // Density of superheated gas at LP compressor inlet, m3/kg
   13541              :     Real64 DensityActualMT;             // Density of superheated gas at HP compressor inlet, m3/kg
   13542              :     Real64 DensityRatedHP;              // Density of high pressure compressor inlet gas at rated superheat, m3/kg
   13543              :     Real64 DensityRatedLP;              // Density of low pressure compressor inlet gas at rated superheat, m3/kg
   13544              :     Real64 HCaseInRatedLT;              // Enthalpy entering low temperature cases at rated subcooling, J/kg
   13545              :     Real64 HCaseInRatedMT;              // Enthalpy entering medium temperature cases at rated subcooling, J/kg
   13546        10701 :     Real64 HCompInRatedHP(0.0);         // Enthalpy entering high pressure compressor at rated superheat, J/kg
   13547              :     Real64 HCompInRatedLP;              // Enthalpy entering low pressure compressor at rated superheat, J/kg
   13548              :     Real64 HGCOutlet;                   // Enthalpy at gas cooler outlet, J/kg
   13549              :     Real64 HIdeal;                      // Ideal enthalpy at subcooler (for 100% effectiveness)
   13550              :     Real64 HsatLiqforTevapNeededMT;     // Enthalpy of saturated liquid at MT evaporator, J/kg
   13551              :     Real64 HsatVaporforTevapneededMT;   // Enthalpy of saturated vapor at MT evaporator (transcritical cycle), J/kg
   13552              :     Real64 HsatVaporforTevapneededLT;   // Enthalpy of saturated vapor at LT evaporator (transcritical cycle), J/kg
   13553              :     Real64 LFLastComp;                  // Load factor for last compressor dispatched
   13554              :     Real64 MassCorrectionLT;            // Mass flow at existing subcool/superheat over cap at rated conditions for LT loads
   13555              :     Real64 MassCorrectionMT;            // Mass flow at existing subcool/superheat over cap at rated conditions for MT loads
   13556              :     Real64 NeededCapacityLT;            // Sum of LT case loads and mech subcooler loads (transcritical cycle), W
   13557              :     Real64 NeededCapacityMT;            // Sum of MT case loads and mech subcooler loads (transcritical cycle), W
   13558              :     Real64 PSuctionLT;                  // Suction pressure in low temperature cases, Pa
   13559              :     Real64 PSuctionMT;                  // Suction pressure in medium temperature cases, Pa
   13560              :     Real64 PGCOutlet;                   // Gas cooler outlet pressure, Pa
   13561        10701 :     Real64 QualityReceiver(0.0);        // Refrigerant quality in the receiver
   13562              :     Real64 SubcoolEffect;               // Heat exchanger effectiveness of the subcooler
   13563              :     Real64 TempInRatedHP;               // Temperature entering high pressure compressor at rated superheat, C
   13564              :     Real64 TempInRatedLP;               // Temperature entering low pressure compressor at rated superheat, C
   13565              :     Real64 TsatforPdisLT;               // Low temperature saturated discharge temperature (transcritical cycle), C
   13566              :     Real64 TsatforPdisMT;               // Medium temperature saturated discharge temperature (transcritical cycle), C
   13567              :     Real64 TsatforPsucLT;               // Low temperature saturated suction temperature (transcritical cycle), C
   13568              :     Real64 TsatforPsucMT;               // Medium temperature saturated suction temperature (transcritical cycle), C
   13569              :     Real64 TSubcoolerColdIn;            // Suction gas temperature at the inlet of the subcooler, C
   13570              :     Real64 TotalEnthalpyChangeActualLT; // Actual enthalpy change in LT cases, J/kg
   13571              :     Real64 TotalEnthalpyChangeActualMT; // Actual enthalpy change in MT cases, J/kg
   13572              :     Real64 TotalRefMassFlow;            // Total mass flow through high pressure side of system, kg/s
   13573              :     Real64 Xu;                          // Initial upper guess for iterative search
   13574              :     Real64 Xl;                          // Initial lower guess for iterative search
   13575        10701 :     Real64 Xnew(0.0);                   // New guess for iterative search
   13576              : 
   13577        10701 :     auto &Compressor = state.dataRefrigCase->Compressor;
   13578        10701 :     auto &GasCooler = state.dataRefrigCase->GasCooler;
   13579              : 
   13580        10701 :     Real64 localTimeStep = (state.dataRefrigCase->UseSysTimeStep) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone;
   13581        10701 :     Real64 localTimeStepSec = localTimeStep * Constant::rSecsInHour;
   13582              : 
   13583              :     // Determine refrigerating capacity needed
   13584              :     // Load due to previously unmet low temperature compressor loads (transcritical system)
   13585              :     Real64 AccumLoadLT;
   13586        10701 :     NeededCapacityLT = 0.0;
   13587        10701 :     if (this->transSysType == TransSysType::TwoStage) {
   13588        10701 :         AccumLoadLT = max(0.0, (this->UnmetEnergyLT / localTimeStep / Constant::rSecsInHour)); // localTimeStep / rSecsInHour?
   13589        10701 :         NeededCapacityLT = this->TotalSystemLoadLT + AccumLoadLT + this->PipeHeatLoadLT;
   13590              :     } // (TransSystem(SysNum)%TransSysType == 2)
   13591              : 
   13592              :     // Load due to previously unmet medium temperature compressor loads (transcritical system)
   13593        10701 :     Real64 AccumLoadMT = max(0.0, (this->UnmetEnergyMT / localTimeStep / Constant::rSecsInHour));
   13594        10701 :     NeededCapacityMT = this->TotalSystemLoadMT + AccumLoadMT + this->PipeHeatLoadMT;
   13595              : 
   13596              :     // Determine refrigerant properties at receiver
   13597        10701 :     this->CpSatLiqReceiver = this->refrig->getSatSpecificHeat(state, this->TReceiver, 0.0, RoutineName);
   13598              : 
   13599              :     // Enthalpy at the receiver bypass, J/kg
   13600        10701 :     Real64 HReceiverBypass = this->refrig->getSatEnthalpy(state, this->TReceiver, 1.0, RoutineName);
   13601              : 
   13602              :     // Determine refrigerant properties at low temperature (LT) loads (if present)
   13603              :     // Dispatch low pressure (LP) compressors as necessary
   13604        10701 :     if (this->transSysType == TransSysType::TwoStage) { // LT side of TwoStage transcritical system
   13605        10701 :         this->HCaseInLT = this->HSatLiqReceiver;
   13606              :         // TCompInLP and HCompInLP include case superheat plus effect of suction line heat gain
   13607        10701 :         this->TCompInLP = this->TEvapNeededLT + TransCaseSuperheat + this->PipeHeatLoadLT / (this->CpSatVapEvapLT * this->RefMassFlowtoLTLoads);
   13608        10701 :         this->HCompInLP = this->HCaseOutLT + this->PipeHeatLoadLT / this->RefMassFlowtoLTLoads;
   13609        10701 :         TsatforPsucLT = this->TEvapNeededLT;
   13610        10701 :         TsatforPdisLT = this->TEvapNeededMT;
   13611        10701 :         HsatVaporforTevapneededLT = this->refrig->getSatEnthalpy(state, this->TEvapNeededLT, 1.0, RoutineName);
   13612        10701 :         HsatLiqforTevapNeededMT = this->refrig->getSatEnthalpy(state, this->TEvapNeededMT, 0.0, RoutineName);
   13613        10701 :         PSuctionLT = this->refrig->getSatPressure(state, TsatforPsucLT, RoutineName);
   13614        10701 :         DensityActualLT = this->refrig->getSupHeatDensity(state, this->TCompInLP, PSuctionLT, RoutineName);
   13615        10701 :         TotalEnthalpyChangeActualLT = this->HCompInLP - this->HCaseInLT;
   13616              : 
   13617              :         // Dispatch low pressure (LP) compressors
   13618              :         // Before dispatching LP compressors, zero sum of compressor outputs and zero each compressor
   13619        10701 :         this->TotCompCapacityLP = 0.0;
   13620        10701 :         this->RefMassFlowCompsLP = 0.0;
   13621        10701 :         this->TotCompPowerLP = 0.0;
   13622              : 
   13623        42804 :         for (int CompIndex = 1; CompIndex <= this->NumCompressorsLP; ++CompIndex) {
   13624        32103 :             int CompID = this->CompressorNumLP(CompIndex);
   13625        32103 :             Compressor(CompID).Power = 0.0;
   13626        32103 :             Compressor(CompID).MassFlow = 0.0;
   13627        32103 :             Compressor(CompID).Capacity = 0.0;
   13628        32103 :             Compressor(CompID).ElecConsumption = 0.0;
   13629        32103 :             Compressor(CompID).CoolingEnergy = 0.0;
   13630        32103 :             Compressor(CompID).LoadFactor = 0.0;
   13631              :         }
   13632              : 
   13633        16140 :         for (int CompIndex = 1; CompIndex <= this->NumCompressorsLP; ++CompIndex) {
   13634        16140 :             int CompID = this->CompressorNumLP(CompIndex);
   13635        16140 :             auto &compressor = Compressor(CompID);
   13636              :             // need to use indiv compressor's rated subcool and superheat to adjust capacity to actual conditions
   13637        16140 :             switch (compressor.SubcoolRatingType) {
   13638        16140 :             case CompRatingType::Subcooling: {
   13639        16140 :                 HCaseInRatedLT = HsatLiqforTevapNeededMT - this->CpSatLiqReceiver * compressor.RatedSubcool;
   13640        16140 :             } break;
   13641            0 :             case CompRatingType::LiquidTemperature: { // have rated liquid temperature stored in "RatedSubcool"
   13642            0 :                 HCaseInRatedLT = this->refrig->getSatEnthalpy(state, compressor.RatedSubcool, 0.0, RoutineName);
   13643            0 :             } break;
   13644            0 :             default:
   13645            0 :                 break;
   13646              :             }
   13647        16140 :             switch (compressor.SuperheatRatingType) {
   13648        16140 :             case CompRatingType::Superheat: {
   13649        16140 :                 HCompInRatedLP = HsatVaporforTevapneededLT + this->CpSatVapEvapLT * compressor.RatedSuperheat;
   13650        16140 :                 TempInRatedLP = this->TEvapNeededLT + compressor.RatedSuperheat;
   13651        16140 :             } break;
   13652            0 :             case CompRatingType::ReturnGasTemperature: { // have rated compressor inlet temperature stored in
   13653              :                                                          // "CompRatingType::Superheat"
   13654            0 :                 TempInRatedLP = compressor.RatedSuperheat;
   13655            0 :                 HCompInRatedLP = this->refrig->getSupHeatEnthalpy(state, compressor.RatedSuperheat, PSuctionLT, RoutineName);
   13656            0 :             } break;
   13657            0 :             default:
   13658            0 :                 break;
   13659              :             }
   13660              : 
   13661        16140 :             CaseEnthalpyChangeRatedLT = HCompInRatedLP - HCaseInRatedLT;
   13662        16140 :             DensityRatedLP = this->refrig->getSupHeatDensity(state, TempInRatedLP, PSuctionLT, RoutineName);
   13663              : 
   13664              :             //  Adjust capacity and mass flow to reflect the specific volume change due to superheating and
   13665              :             //  the increase in capacity due to extra subcooling
   13666        16140 :             MassCorrectionLT = DensityActualLT / DensityRatedLP;
   13667              :             // Capacity at existing subcool/superheat over cap at rated conditions for LT loads
   13668        16140 :             Real64 CapacityCorrectionLT = MassCorrectionLT * TotalEnthalpyChangeActualLT / CaseEnthalpyChangeRatedLT;
   13669        16140 :             compressor.Power = Curve::CurveValue(state, compressor.ElecPowerCurvePtr, TsatforPsucLT, TsatforPdisLT);
   13670        16140 :             compressor.Capacity = CapacityCorrectionLT * Curve::CurveValue(state, compressor.CapacityCurvePtr, TsatforPsucLT, TsatforPdisLT);
   13671        16140 :             compressor.MassFlow = compressor.Capacity / TotalEnthalpyChangeActualLT;
   13672        16140 :             compressor.ElecConsumption = compressor.Power * localTimeStepSec;
   13673        16140 :             compressor.CoolingEnergy = compressor.Capacity * localTimeStepSec;
   13674        16140 :             compressor.LoadFactor = 1.0;
   13675        16140 :             if ((this->TotCompCapacityLP + compressor.Capacity) >= NeededCapacityLT) {
   13676        10701 :                 LFLastComp = (NeededCapacityLT - this->TotCompCapacityLP) / compressor.Capacity;
   13677        10701 :                 compressor.Power *= LFLastComp;
   13678        10701 :                 compressor.MassFlow *= LFLastComp;
   13679        10701 :                 compressor.Capacity *= LFLastComp;
   13680        10701 :                 this->TotCompCapacityLP += compressor.Capacity;
   13681        10701 :                 this->RefMassFlowCompsLP += compressor.MassFlow;
   13682        10701 :                 this->TotCompPowerLP += compressor.Power;
   13683        10701 :                 compressor.ElecConsumption = compressor.Power * localTimeStepSec;
   13684        10701 :                 compressor.CoolingEnergy = compressor.Capacity * localTimeStepSec;
   13685        10701 :                 compressor.LoadFactor = LFLastComp;
   13686        10701 :                 break;
   13687              :             } else {
   13688         5439 :                 this->TotCompCapacityLP += compressor.Capacity;
   13689         5439 :                 this->RefMassFlowCompsLP += compressor.MassFlow;
   13690         5439 :                 this->TotCompPowerLP += compressor.Power;
   13691              :             }
   13692              :         } // NumCompressorsLP
   13693        10701 :         this->HCompOutLP = this->HCompInLP + this->TotCompPowerLP / this->RefMassFlowCompsLP;
   13694              :     } // (TransSystem(SysNum)%TransSysType == 2)
   13695              : 
   13696              :     // Determine refrigerant properties at medium temperature (MT) loads
   13697              :     // Dispatch high pressure (HP) compressors as necessary
   13698        10701 :     TsatforPsucMT = this->TEvapNeededMT;
   13699        10701 :     if (GasCooler(this->GasCoolerNum(1)).TransOpFlag) { // Transcritical system is operating in transcritical region
   13700         4375 :         HGCOutlet = GasCooler(this->GasCoolerNum(1)).HGasCoolerOut;
   13701              :     } else { // Transcritical system is operating in subcritical region
   13702         6326 :         TsatforPdisMT = GasCooler(this->GasCoolerNum(1)).TGasCoolerOut;
   13703              :     }
   13704        10701 :     PSuctionMT = this->refrig->getSatPressure(state, TsatforPsucMT, RoutineName);
   13705        10701 :     PGCOutlet = GasCooler(this->GasCoolerNum(1)).PGasCoolerOut;
   13706        10701 :     HsatVaporforTevapneededMT = this->refrig->getSatEnthalpy(state, this->TEvapNeededMT, 1.0, RoutineName);
   13707        10701 :     this->HCaseInMT = this->HSatLiqReceiver;
   13708              :     // Enthalpy of refrigerant after leaving medium temperature loads and low pressure compressors
   13709              : 
   13710              :     // Combined enthalpy from the outlets of the LP compressor and MT loads, J/kg
   13711        10701 :     Real64 HCaseOutLTMT = (this->RefMassFlowtoLTLoads * this->HCompOutLP + this->RefMassFlowtoMTLoads * this->HCaseOutMT + this->PipeHeatLoadMT) /
   13712        10701 :                           (this->RefMassFlowtoLTLoads + this->RefMassFlowtoMTLoads);
   13713              : 
   13714              :     // Total refrigerant flow rate is total flow from LT and MT loads divided by (1-x) where x is the quality of the
   13715              :     // refrigerant entering the receiver.  The receiver bypass flow rate is (x)*(Total Flow).
   13716              :     // Iterate to find the quality of the refrigerant entering the receiver.
   13717        10701 :     Xu = 1.0; // upper bound on quality
   13718        10701 :     Xl = 0.0; // lower bound on quality
   13719        10701 :     if ((GasCooler(this->GasCoolerNum(1)).HGasCoolerOut + this->DelHSubcoolerDis) > this->HSatLiqReceiver) {
   13720        80814 :         for (Iter = 1; Iter <= 15; ++Iter) { // Maximum of 15 iterations to find receiver quality
   13721        80814 :             QualityReceiver = (Xu + Xl) / 2.0;
   13722        80814 :             Real64 Hnew = this->refrig->getSatEnthalpy(state, this->TReceiver, QualityReceiver, RoutineName);
   13723              : 
   13724              :             // estimated QualityReceiver is too high
   13725        80814 :             if (Hnew > (GasCooler(this->GasCoolerNum(1)).HGasCoolerOut + this->DelHSubcoolerDis)) {
   13726        44582 :                 Xu = QualityReceiver;
   13727              :             } else { // estimated QualityReceiver is too low
   13728        36232 :                 Xl = QualityReceiver;
   13729              :             }
   13730        80814 :             if (std::abs((Hnew - (GasCooler(this->GasCoolerNum(1)).HGasCoolerOut + this->DelHSubcoolerDis)) / Hnew) < ErrorTol) {
   13731        10701 :                 break;
   13732              :             }
   13733              :         }
   13734        10701 :         TotalRefMassFlow = (this->RefMassFlowtoLTLoads + this->RefMassFlowtoMTLoads) / (1.0 - QualityReceiver);
   13735        10701 :         this->RefMassFlowReceiverBypass = QualityReceiver * TotalRefMassFlow;
   13736              :     } else {
   13737            0 :         this->RefMassFlowReceiverBypass = 0.0;
   13738            0 :         TotalRefMassFlow = (this->RefMassFlowtoLTLoads + this->RefMassFlowtoMTLoads);
   13739              :     } // %HGasCoolerOut > TransSystem(SysNum)%HSatLiqReceiver)
   13740              : 
   13741        10701 :     this->HCompInHP = (HCaseOutLTMT * (this->RefMassFlowtoLTLoads + this->RefMassFlowtoMTLoads) + HReceiverBypass * this->RefMassFlowReceiverBypass) /
   13742        10701 :                       (this->RefMassFlowtoLTLoads + this->RefMassFlowtoMTLoads + this->RefMassFlowReceiverBypass);
   13743              : 
   13744              :     // Iterate to find the suction temperature entering subcooler
   13745        10701 :     Xl = this->refrig->getSatTemperature(state, PSuctionMT, RoutineName);
   13746        10701 :     Xu = Xl + 50.0;
   13747        55697 :     for (Iter = 1; Iter <= 15; ++Iter) { // Maximum of 15 iterations
   13748        55697 :         Xnew = (Xu + Xl) / 2.0;
   13749        55697 :         Real64 Hnew = this->refrig->getSupHeatEnthalpy(state, Xnew, PSuctionMT, RoutineName);
   13750        55697 :         if (Hnew > this->HCompInHP) { // xnew is too high
   13751        30438 :             Xu = Xnew;
   13752              :         } else { // xnew is too low
   13753        25259 :             Xl = Xnew;
   13754              :         }
   13755        55697 :         if (std::abs((Hnew - this->HCompInHP) / Hnew) < ErrorTol) {
   13756        10701 :             break;
   13757              :         }
   13758              :     }
   13759        10701 :     TSubcoolerColdIn = Xnew;
   13760              : 
   13761              :     // Modify receiver inlet enthalpy and HP compressor inlet enthalpy to account for subcooler
   13762        10701 :     HIdeal = this->refrig->getSupHeatEnthalpy(state, GasCooler(this->GasCoolerNum(1)).TGasCoolerOut, PSuctionMT, RoutineName);
   13763              :     // Only use subcooler if suction gas inlet temperature less than gas cooler outlet temperature
   13764        10701 :     if (TSubcoolerColdIn < GasCooler(this->GasCoolerNum(1)).TGasCoolerOut) {
   13765        10701 :         SubcoolEffect = this->SCEffectiveness;
   13766              :     } else {
   13767            0 :         SubcoolEffect = 0.0;
   13768              :     } // (TSubcoolerColdIn < GasCooler(SysNum)%TGasCoolerOut)
   13769        10701 :     this->DelHSubcoolerSuc = SubcoolEffect * (HIdeal - this->HCompInHP);
   13770        10701 :     this->HCompInHP += this->DelHSubcoolerSuc;
   13771        10701 :     this->DelHSubcoolerDis = -this->DelHSubcoolerSuc;
   13772              : 
   13773              :     // Iterate to find the temperature at the inlet of the high pressure (HP) compressors
   13774        10701 :     Xl = this->refrig->getSatTemperature(state, PSuctionMT, RoutineName);
   13775        10701 :     Xu = Xl + 50.0;
   13776        53149 :     for (Iter = 1; Iter <= 15; ++Iter) { // Maximum of 15 iterations
   13777        53149 :         Xnew = (Xu + Xl) / 2.0;
   13778        53149 :         Real64 Hnew = this->refrig->getSupHeatEnthalpy(state, Xnew, PSuctionMT, RoutineName);
   13779        53149 :         if (Hnew > this->HCompInHP) { // xnew is too high
   13780        22851 :             Xu = Xnew;
   13781              :         } else { // xnew is too low
   13782        30298 :             Xl = Xnew;
   13783              :         }
   13784        53149 :         if (std::abs((Hnew - this->HCompInHP) / Hnew) < ErrorTol) {
   13785        10701 :             break;
   13786              :         }
   13787              :     }
   13788        10701 :     this->TCompInHP = Xnew;
   13789              : 
   13790              :     //  For capacity correction of HP compressors, consider subcooler, receiver, MT loads, LT loads and LP compressors
   13791              :     //  to constitute the "load".  The actual and rated conditions at the exit of the gas cooler and the inlet of the
   13792              :     //  HP compressors are used for capacity correction calculations.
   13793        10701 :     DensityActualMT = this->refrig->getSupHeatDensity(state, this->TCompInHP, PSuctionMT, RoutineName);
   13794        10701 :     TotalEnthalpyChangeActualMT = this->HCompInHP - GasCooler(this->GasCoolerNum(1)).HGasCoolerOut;
   13795              : 
   13796              :     // Dispatch HP compressors
   13797              :     // Before dispatching HP compressors, zero sum of compressor outputs and zero each compressor
   13798        10701 :     this->TotCompCapacityHP = 0.0;
   13799        10701 :     this->RefMassFlowCompsHP = 0.0;
   13800        10701 :     this->TotCompPowerHP = 0.0;
   13801              : 
   13802        42804 :     for (int CompIndex = 1; CompIndex <= this->NumCompressorsHP; ++CompIndex) {
   13803        32103 :         int CompID = this->CompressorNumHP(CompIndex);
   13804        32103 :         auto &compressor = Compressor(CompID);
   13805        32103 :         compressor.Power = 0.0;
   13806        32103 :         compressor.MassFlow = 0.0;
   13807        32103 :         compressor.Capacity = 0.0;
   13808        32103 :         compressor.ElecConsumption = 0.0;
   13809        32103 :         compressor.CoolingEnergy = 0.0;
   13810        32103 :         compressor.LoadFactor = 0.0;
   13811              :     }
   13812              : 
   13813              :     // Dispatch High Pressure compressors to meet load, note they were listed in compressor list in dispatch order
   13814        12525 :     for (int CompIndex = 1; CompIndex <= this->NumCompressorsHP; ++CompIndex) {
   13815        12525 :         int CompID = this->CompressorNumHP(CompIndex);
   13816        12525 :         auto &compressor = Compressor(CompID);
   13817              :         // Need to use indiv compressor's rated subcool and superheat to adjust capacity to actual conditions
   13818              :         // Transcritical operation requires rated superheat
   13819              :         // Subcritical operation requires rated subcool and rated superheat
   13820        12525 :         switch (compressor.SubcoolRatingType) {
   13821        12525 :         case CompRatingType::Subcooling: {
   13822        12525 :             if (!GasCooler(this->GasCoolerNum(1)).TransOpFlag) { // Subcritical operation
   13823         6326 :                 HCaseInRatedMT =
   13824         6326 :                     GasCooler(this->GasCoolerNum(1)).HGasCoolerOut - GasCooler(this->GasCoolerNum(1)).CpGasCoolerOut * compressor.RatedSubcool;
   13825              :             } else { // Transcritical operation
   13826         6199 :                 HCaseInRatedMT = GasCooler(this->GasCoolerNum(1)).HGasCoolerOut;
   13827              :             } // (.NOT.GasCooler(SysNum)%TransOpFlag)
   13828        12525 :         } break;
   13829            0 :         case CompRatingType::LiquidTemperature: {                // have rated liquid temperature stored in "RatedSubcool"
   13830            0 :             if (!GasCooler(this->GasCoolerNum(1)).TransOpFlag) { // Subcritical operation
   13831            0 :                 HCaseInRatedMT = this->refrig->getSatEnthalpy(state, compressor.RatedSubcool, 0.0, RoutineName);
   13832              :             } else { // Transcritical operation
   13833            0 :                 HCaseInRatedMT = GasCooler(this->GasCoolerNum(1)).HGasCoolerOut;
   13834              :             } // (.NOT.GasCooler(SysNum)%TransOpFlag)
   13835            0 :         } break;
   13836            0 :         default:
   13837            0 :             break;
   13838              :         }
   13839        12525 :         switch (compressor.SuperheatRatingType) {
   13840        12525 :         case CompRatingType::Superheat: {
   13841        12525 :             HCompInRatedHP = HsatVaporforTevapneededMT + this->CpSatVapEvapMT * compressor.RatedSuperheat;
   13842        12525 :             TempInRatedHP = this->TEvapNeededMT + compressor.RatedSuperheat;
   13843        12525 :         } break;
   13844            0 :         case CompRatingType::ReturnGasTemperature: { // have rated compressor inlet temperature stored in "RatedSuperheat"
   13845            0 :             TempInRatedHP = compressor.RatedSuperheat;
   13846            0 :             HCompInRatedHP = this->refrig->getSupHeatEnthalpy(state, compressor.RatedSuperheat, PSuctionMT, RoutineName);
   13847            0 :         } break;
   13848            0 :         default:
   13849            0 :             break;
   13850              :         }
   13851              : 
   13852        12525 :         CaseEnthalpyChangeRatedMT = HCompInRatedHP - HCaseInRatedMT;
   13853        12525 :         DensityRatedHP = this->refrig->getSupHeatDensity(state, TempInRatedHP, PSuctionMT, RoutineName);
   13854              :         //  Adjust capacity and mass flow to reflect the specific volume change due to superheating and
   13855              :         //  the increase in capacity due to extra subcooling
   13856        12525 :         MassCorrectionMT = DensityActualMT / DensityRatedHP;
   13857        12525 :         CapacityCorrectionMT = MassCorrectionMT * TotalEnthalpyChangeActualMT / CaseEnthalpyChangeRatedMT;
   13858              : 
   13859        12525 :         if (GasCooler(this->GasCoolerNum(1)).TransOpFlag) { // System is operating in transcritical region
   13860         6199 :             compressor.Power = Curve::CurveValue(state, compressor.TransElecPowerCurvePtr, TsatforPsucMT, PGCOutlet);
   13861         6199 :             compressor.Capacity = CapacityCorrectionMT * Curve::CurveValue(state, compressor.TransCapacityCurvePtr, TsatforPsucMT, HGCOutlet);
   13862              :         } else { // System is operating in subcritical region
   13863         6326 :             compressor.Power = Curve::CurveValue(state, compressor.ElecPowerCurvePtr, TsatforPsucMT, TsatforPdisMT);
   13864         6326 :             compressor.Capacity = CapacityCorrectionMT * Curve::CurveValue(state, compressor.CapacityCurvePtr, TsatforPsucMT, TsatforPdisMT);
   13865              :         } // (GasCooler(SysNum)%TransOpFlag)
   13866              :         //  Mass flow through HP compressors is HP compressor refrigerating capacity divided by MT load, LT load and LP compressor power
   13867        12525 :         compressor.MassFlow = TotalRefMassFlow * compressor.Capacity / (NeededCapacityMT + NeededCapacityLT + this->TotCompPowerLP);
   13868        12525 :         compressor.ElecConsumption = compressor.Power * localTimeStepSec;
   13869        12525 :         compressor.CoolingEnergy = compressor.Capacity * localTimeStepSec;
   13870        12525 :         compressor.LoadFactor = 1.0;
   13871              :         // calculate load factor for last compressor added
   13872              :         // assumes either cycling or part load eff = full load eff for last compressor
   13873        12525 :         if ((this->TotCompCapacityHP + compressor.Capacity) >= (NeededCapacityMT + NeededCapacityLT + this->TotCompPowerLP)) {
   13874        10701 :             LFLastComp = ((NeededCapacityMT + NeededCapacityLT + this->TotCompPowerLP) - this->TotCompCapacityHP) / compressor.Capacity;
   13875        10701 :             compressor.Power *= LFLastComp;
   13876        10701 :             compressor.MassFlow *= LFLastComp;
   13877        10701 :             compressor.Capacity *= LFLastComp;
   13878        10701 :             this->TotCompCapacityHP += compressor.Capacity;
   13879        10701 :             this->RefMassFlowCompsHP += compressor.MassFlow;
   13880        10701 :             this->TotCompPowerHP += compressor.Power;
   13881        10701 :             compressor.ElecConsumption = compressor.Power * localTimeStepSec;
   13882        10701 :             compressor.CoolingEnergy = compressor.Capacity * localTimeStepSec;
   13883        10701 :             compressor.LoadFactor = LFLastComp;
   13884        10701 :             break;
   13885              :         } else {
   13886         1824 :             this->TotCompCapacityHP += compressor.Capacity;
   13887         1824 :             this->RefMassFlowCompsHP += compressor.MassFlow;
   13888         1824 :             this->TotCompPowerHP += compressor.Power;
   13889              :         }
   13890              : 
   13891              :     } // NumCompressorsHP
   13892              : 
   13893        10701 :     this->HCompOutHP = this->HCompInHP + this->TotCompPowerHP / this->RefMassFlowCompsHP;
   13894        10701 :     this->RefMassFlowComps = this->RefMassFlowCompsLP + this->RefMassFlowCompsHP;
   13895        10701 :     this->TotCompCapacity = this->TotCompCapacityHP + this->TotCompCapacityLP;
   13896        10701 :     this->AverageCompressorCOP = (this->TotCompCapacityHP - this->TotCompPowerLP) / (this->TotCompPowerLP + this->TotCompPowerHP);
   13897        10701 :     this->TotCompElecConsump = (this->TotCompPowerLP + this->TotCompPowerHP) * localTimeStepSec;
   13898        10701 :     this->TotCompCoolingEnergy = (this->TotCompCapacityLP + this->TotCompCapacityHP) * localTimeStepSec;
   13899        10701 : }
   13900              : 
   13901        24888 : void RefrigSystemData::CalculateSubcoolers(EnergyPlusData &state)
   13902              : {
   13903              : 
   13904              :     // SUBROUTINE INFORMATION:
   13905              :     //       AUTHOR         Therese Stovall, ORNL, Assisted by Hugh Henderson
   13906              :     //       DATE WRITTEN   Spring 2008
   13907              :     //       MODIFIED       Brian Fricke, ORNL, March 2012, added two-stage compression
   13908              :     //       RE-ENGINEERED  na
   13909              : 
   13910              :     // PURPOSE OF THIS SUBROUTINE:
   13911              :     // Find the subcooler energy exchange and refrigerant states for a particular detailed
   13912              :     // refrigeration system. Use the refrigerant property subroutines in FluidProperties.cc
   13913              : 
   13914              :     // METHODOLOGY EMPLOYED:
   13915              :     // Use refrigerant properties and heat exchanger correlations.  NOTE:  Assumes any Mech subcooler
   13916              :     // immediately follows condenser outlet (after pipe loss) and comes before any LSHX
   13917              : 
   13918              :     // REFERENCES:
   13919              :     // ASHRAE 1006 Section 2: Refrigeration Accessories
   13920              : 
   13921              :     static constexpr std::string_view RoutineName = "CalculateSubcoolers";
   13922        24888 :     Real64 TLiqInActualLocal = 0.0; // Liquid T in, after condenser, before any mechanical subcooler
   13923              : 
   13924        24888 :     auto &System = state.dataRefrigCase->System;
   13925        24888 :     auto &Condenser = state.dataRefrigCase->Condenser;
   13926        24888 :     auto &Subcooler = state.dataRefrigCase->Subcooler;
   13927              : 
   13928        24888 :     Real64 localTimeStep = (state.dataRefrigCase->UseSysTimeStep) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone;
   13929        24888 :     Real64 localTimeStepSec = localTimeStep * Constant::rSecsInHour;
   13930              : 
   13931              :     // HCaseIn has to be recalculated as the starting point for the subcoolers here because
   13932              :     //  of the multiple number of iterations through this subroutine and because Tcondense is evolving.
   13933        24888 :     if (this->NumStages == 1) { // Single-stage compression system
   13934        24888 :         this->HSatLiqCond = this->refrig->getSatEnthalpy(state, this->TCondense, 0.0, RoutineName);
   13935        24888 :         this->CpSatLiqCond = this->refrig->getSatSpecificHeat(state, this->TCondense, 0.0, RoutineName);
   13936        24888 :         this->HCaseIn = this->HSatLiqCond - this->CpSatLiqCond * Condenser(this->CondenserNum(1)).RatedSubcool;
   13937              : 
   13938              :         // Two-stage compression with flash intercooler
   13939            0 :     } else if (this->NumStages == 2 && this->intercoolerType == IntercoolerType::Flash) {
   13940            0 :         this->HSatLiqCond = this->refrig->getSatEnthalpy(state, this->TCondense, 0.0, RoutineName);
   13941            0 :         this->CpSatLiqCond = this->refrig->getSatSpecificHeat(state, this->TCondense, 0.0, RoutineName);
   13942            0 :         this->HCaseIn = this->refrig->getSatEnthalpy(state, this->TIntercooler, 0.0, RoutineName);
   13943              : 
   13944              :         // Two-stage compression with shell-and-coil intercooler
   13945            0 :     } else if (this->NumStages == 2 && this->intercoolerType == IntercoolerType::ShellAndCoil) {
   13946            0 :         TLiqInActualLocal = this->TCondense - Condenser(this->CondenserNum(1)).RatedSubcool -
   13947            0 :                             this->IntercoolerEffectiveness * (this->TCondense - Condenser(this->CondenserNum(1)).RatedSubcool - this->TIntercooler);
   13948            0 :         this->HSatLiqCond = this->refrig->getSatEnthalpy(state, this->TCondense, 0.0, RoutineName);
   13949            0 :         this->CpSatLiqCond = this->refrig->getSatSpecificHeat(state, this->TCondense, 0.0, RoutineName);
   13950            0 :         this->HCaseIn = this->HSatLiqCond - this->CpSatLiqCond * (this->TCondense - TLiqInActualLocal);
   13951              :     } // NumStages and IntercoolerType
   13952              : 
   13953        74664 :     for (int SubcoolerIndex = 1; SubcoolerIndex <= this->NumSubcoolers; ++SubcoolerIndex) {
   13954        49776 :         int SubcoolerID = this->SubcoolerNum(SubcoolerIndex);
   13955        49776 :         auto &cooler = Subcooler(SubcoolerID);
   13956              :         // set up local variables for convenience
   13957        49776 :         Real64 DelTLiqDes = cooler.LiqSuctDesignDelT;
   13958        49776 :         Real64 TVapInDes = cooler.LiqSuctDesignTvapIn;
   13959        49776 :         Real64 TLiqInDes = cooler.LiqSuctDesignTliqIn;
   13960        49776 :         Real64 ControlTLiqOut = cooler.MechControlTliqOut;
   13961        49776 :         Real64 CpLiquid = this->CpSatLiqCond;
   13962        49776 :         Real64 CpVapor = this->CpSatVapEvap;
   13963        49776 :         if (this->NumStages == 1) { // Single-stage compression system
   13964        49776 :             TLiqInActualLocal = this->TCondense - Condenser(this->CondenserNum(1)).RatedSubcool;
   13965              : 
   13966              :             // Two-stage compression with flash intercooler
   13967            0 :         } else if (this->NumStages == 2 && this->intercoolerType == IntercoolerType::Flash) {
   13968            0 :             TLiqInActualLocal = this->TIntercooler;
   13969              : 
   13970              :             // Two-stage compression with shell-and-coil intercooler
   13971            0 :         } else if (this->NumStages == 2 && this->intercoolerType == IntercoolerType::ShellAndCoil) {
   13972            0 :             TLiqInActualLocal =
   13973            0 :                 this->TCondense - Condenser(this->CondenserNum(1)).RatedSubcool -
   13974            0 :                 this->IntercoolerEffectiveness * (this->TCondense - Condenser(this->CondenserNum(1)).RatedSubcool - this->TIntercooler);
   13975              :         } // NumStages and IntercoolerType
   13976              : 
   13977        49776 :         switch (cooler.subcoolerType) {
   13978              :             // Mechanical subcoolers required to come first in order to take advantage of delT
   13979              :             //  from lshx. taken care of because subcooler ID assigned in that order in input.
   13980        24888 :         case SubcoolerType::Mechanical: {
   13981        24888 :             Real64 mechSCLoad = this->RefMassFlowtoLoads * CpLiquid * (TLiqInActualLocal - ControlTLiqOut);
   13982        24888 :             this->HCaseIn -= CpLiquid * (TLiqInActualLocal - ControlTLiqOut);
   13983              :             // refrigeration benefit to System(sysnum)
   13984              :             // refrigeration load must be assigned properly according to input
   13985        24888 :             int SysProvideID = cooler.MechSourceSysID;
   13986        24888 :             System(SysProvideID).MechSCLoad(SubcoolerID) = mechSCLoad;
   13987        24888 :             cooler.MechSCTransLoad = mechSCLoad;
   13988        24888 :             cooler.MechSCTransEnergy = mechSCLoad * localTimeStepSec;
   13989              :             // Reset inlet temperature for any LSHX that follows this mech subcooler
   13990        24888 :             TLiqInActualLocal = ControlTLiqOut;
   13991        24888 :             this->TCompIn = this->TEvapNeeded + CaseSuperheat;
   13992        24888 :         } break;
   13993        24888 :         case SubcoolerType::LiquidSuction: {
   13994        24888 :             Real64 LSHXeffectiveness = DelTLiqDes / (TLiqInDes - TVapInDes);
   13995        24888 :             Real64 TVapInActual = this->TEvapNeeded + CaseSuperheat;
   13996        24888 :             Real64 DelTempActual = LSHXeffectiveness * (TLiqInActualLocal - TVapInActual);
   13997        24888 :             TLiqInActualLocal -= DelTempActual;
   13998        24888 :             Real64 SubcoolLoad = this->RefMassFlowtoLoads * CpLiquid * DelTempActual;
   13999        24888 :             Real64 SubcoolerSupHeat = SubcoolLoad / CpVapor / this->RefMassFlowComps;
   14000        24888 :             this->TCompIn = TVapInActual + SubcoolerSupHeat;
   14001        24888 :             this->HCaseIn -= SubcoolLoad / this->RefMassFlowtoLoads;
   14002        24888 :             this->LSHXTrans = SubcoolLoad;
   14003        24888 :             this->LSHXTransEnergy = SubcoolLoad * localTimeStepSec;
   14004        24888 :         } break;
   14005            0 :         default:
   14006            0 :             break;
   14007              :         }
   14008              : 
   14009        49776 :         this->TLiqInActual = TLiqInActualLocal;
   14010              :     }
   14011        24888 : }
   14012              : 
   14013            2 : void GetRefrigeratedRackIndex(EnergyPlusData &state,
   14014              :                               std::string const &Name,
   14015              :                               int &IndexPtr,
   14016              :                               DataHeatBalance::RefrigSystemType const SysType,
   14017              :                               bool &ErrorsFound,
   14018              :                               std::string_view const ThisObjectType,
   14019              :                               bool const SuppressWarning)
   14020              : {
   14021              : 
   14022              :     // SUBROUTINE INFORMATION:
   14023              :     //       AUTHOR         Richard Raustad
   14024              :     //       DATE WRITTEN   June 2007
   14025              :     //       MODIFIED       Therese Stovall May 2008
   14026              :     //       RE-ENGINEERED  na
   14027              :     // PURPOSE OF THIS SUBROUTINE:
   14028              :     // This subroutine sets an index for a given refrigerated rack or refrigeration condenser
   14029              :     //  -- issues error message if the rack or condenser is not found.
   14030              : 
   14031            2 :     auto &RefrigRack = state.dataRefrigCase->RefrigRack;
   14032            2 :     auto &Condenser = state.dataRefrigCase->Condenser;
   14033              : 
   14034            2 :     CheckRefrigerationInput(state);
   14035              : 
   14036            2 :     switch (SysType) {
   14037            1 :     case DataHeatBalance::RefrigSystemType::Rack: {
   14038            1 :         IndexPtr = Util::FindItemInList(Name, RefrigRack);
   14039            1 :         if (IndexPtr == 0) {
   14040            0 :             if (SuppressWarning) {
   14041              :                 //     No warning printed if only searching for the existence of a refrigerated rack
   14042              :             } else {
   14043            0 :                 if (!ThisObjectType.empty()) {
   14044            0 :                     ShowSevereError(state, fmt::format("{}, GetRefrigeratedRackIndex: Rack not found={}", ThisObjectType, Name));
   14045              :                 } else {
   14046            0 :                     if (!ThisObjectType.empty()) {
   14047            0 :                         ShowSevereError(state, fmt::format("{}, GetRefrigeratedRackIndex: Rack not found={}", ThisObjectType, Name));
   14048              :                     } else {
   14049            0 :                         ShowSevereError(state, format("GetRefrigeratedRackIndex: Rack not found={}", Name));
   14050              :                     }
   14051              :                 }
   14052              :             }
   14053            0 :             ErrorsFound = true;
   14054              :         }
   14055            1 :     } break;
   14056            1 :     case DataHeatBalance::RefrigSystemType::Detailed: {
   14057            1 :         IndexPtr = Util::FindItemInList(Name, Condenser);
   14058            1 :         if (IndexPtr == 0) {
   14059            0 :             if (SuppressWarning) {
   14060              :                 //     No warning printed if only searching for the existence of a refrigeration Condenser
   14061              :             } else {
   14062            0 :                 if (!ThisObjectType.empty()) {
   14063            0 :                     ShowSevereError(state, fmt::format("{}, GetRefrigeratedRackIndex: Condenser not found={}", ThisObjectType, Name));
   14064              :                 } else {
   14065            0 :                     ShowSevereError(state, format("GetRefrigeratedRackIndex: Condenser not found={}", Name));
   14066              :                 }
   14067              :             }
   14068              :         }
   14069            1 :         ErrorsFound = true;
   14070            1 :     } break;
   14071            0 :     default:
   14072            0 :         break;
   14073              :     }
   14074            2 : }
   14075              : 
   14076          801 : void ReportRefrigerationComponents(EnergyPlusData &state)
   14077              : {
   14078              : 
   14079              :     // SUBROUTINE INFORMATION:
   14080              :     //       AUTHOR         Richard Raustad, FSEC
   14081              :     //       DATE WRITTEN   October 2004
   14082              :     //       MODIFIED       Shirey, FSEC Dec 2004; Lawrie, Mar 2008 - Node names, not numbers.
   14083              :     //       MODIFIED       Stovall - 2008 to 2010, new refrig variables and move orphan reporting to input.
   14084              :     //       MODIFIED       Fricke, ORNL, Fall 2011, added transcritical CO2 refrigeration system variables
   14085              :     //       RE-ENGINEERED  na
   14086              : 
   14087              :     // PURPOSE OF THIS SUBROUTINE:
   14088              :     // To report information from the input deck for refrigerated cases and racks to the eio and err file.
   14089              : 
   14090          801 :     std::string ChrOut;
   14091          801 :     std::string ChrOut2;
   14092              : 
   14093          801 :     auto &RefrigCase = state.dataRefrigCase->RefrigCase;
   14094          801 :     auto &RefrigRack = state.dataRefrigCase->RefrigRack;
   14095          801 :     auto &System = state.dataRefrigCase->System;
   14096          801 :     auto &TransSystem = state.dataRefrigCase->TransSystem;
   14097          801 :     auto &Condenser = state.dataRefrigCase->Condenser;
   14098          801 :     auto &Compressor = state.dataRefrigCase->Compressor;
   14099          801 :     auto &GasCooler = state.dataRefrigCase->GasCooler;
   14100          801 :     auto &Subcooler = state.dataRefrigCase->Subcooler;
   14101          801 :     auto &Secondary = state.dataRefrigCase->Secondary;
   14102          801 :     auto &WalkIn = state.dataRefrigCase->WalkIn;
   14103          801 :     auto &WarehouseCoil = state.dataRefrigCase->WarehouseCoil;
   14104          801 :     auto &AirChillerSet = state.dataRefrigCase->AirChillerSet;
   14105              : 
   14106              :     static constexpr std::string_view Format_104(
   14107              :         "! <Refrigeration Compressor Rack>,Compressor Rack Name, # Refrigerated Cases Connected,# WalkIn Coolers "
   14108              :         "Connected, Heat Rejection Location, Condenser Type, COP");
   14109              :     static constexpr std::string_view Format_105(
   14110              :         "!  <Refrigeration Case>,Refrigeration Case Number, Refrigeration Case Name,Zone Name,Zone Node #,Zone "
   14111              :         "Node Name,Capacity (W/m),LHR,Temperature (C),Length (m),Fan (W/m),Installed Lighting (W/m),Anti-Sweat "
   14112              :         "(W/m),Defrost (W/m)");
   14113              :     static constexpr std::string_view Format_108("!  <Refrigeration Compressor>,Compressor Number,Compressor Name,Nominal Capacity (W)");
   14114              :     static constexpr std::string_view Format_109("! <#Refrigeration Compressor Racks>,Number of Refrigeration Compressor Racks");
   14115              :     static constexpr std::string_view Format_117("! <#Detailed Refrigeration Systems>,Number of Detailed Refrigeration Systems");
   14116              :     static constexpr std::string_view Format_118(
   14117              :         "! <Detailed Refrigeration System>,Refrigeration System Name,Refrigerant Used, # Refrigerated Cases "
   14118              :         "Connected, # WalkInCoolers Connected, #Air Chillers Connected, # Secondary Loops Served, # Cascade Condensers "
   14119              :         "Served, # Mechanical Subcoolers Served, # Compressors Connected, # Compression Stages, Intercooler Type, "
   14120              :         "Intercooler Effectiveness, # Subcoolers Connected, Minimum Condensing Temperature (C)");
   14121              :     static constexpr std::string_view Format_119(
   14122              :         "!  <Refrigeration Walk In Cooler>, Walk In Number, Walk In Name,Capacity (W),Temperature (C),Coil Fan "
   14123              :         "(W), Circulating Fan (W), Lighting (W),Heaters (W),Defrost (W), # Zones");
   14124              :     static constexpr std::string_view Format_120(
   14125              :         "! <#Detailed Transcritical Refrigeration Systems>,Number of Detailed Transcritical Refrigeration Systems");
   14126              :     static constexpr std::string_view Format_121(
   14127              :         "! <Detailed Transcritical Refrigeration System>,Transcritical Refrigeration System Name,Refrigerant Used, # "
   14128              :         "Medium Temperature Refrigerated Cases Connected, # Low Temperature Refrigerated Cases Connected, # Medium "
   14129              :         "Temperature WalkInCoolers Connected, # Low Temperature WalkInCoolers Connected, # High Pressure Compressors "
   14130              :         "Connected, # Low Pressure Compressors Connected, Minimum Condensing Temperature (C)");
   14131              :     static constexpr std::string_view Format_123("!  <Secondary Load>, Secondary System Served Name, Secondary Number");
   14132              :     static constexpr std::string_view Format_126(
   14133              :         "!  <Refrigeration Mechanical Subcooler>, Subcooler Number, Subcooler Name, Name of System Providing "
   14134              :         "Cooling, Design Outlet Temperature (C)");
   14135              :     static constexpr std::string_view Format_127("!  <Refrigeration Liquid Suction Subcooler>, Subcooler Number, Subcooler Name, Design Subcooling "
   14136              :                                                  "(DeltaC),Design liquid inlet temperature (C), Design vapor inlet temperature (C)");
   14137              :     static constexpr std::string_view Format_128("!  <Cascade Load>, System Name Connected, Condenser Number, Condenser Name");
   14138              :     static constexpr std::string_view Format_129(
   14139              :         "!  <Refrigeration Condenser:Air-Cooled>,Condenser Number,Condenser Name,Rated Condensing Temperature "
   14140              :         "(C),Rated Capacity (W), Rated Fan Power (W)");
   14141              :     static constexpr std::string_view Format_130(
   14142              :         "!  <Refrigeration Condenser:Water-Cooled>,Condenser Number,Condenser Name,Rated Condensing Temperature "
   14143              :         "(C),Rated Capacity (W), Rated Water Inlet Temperature (C), Rated Water Flow Rate (m3/s)");
   14144              :     static constexpr std::string_view Format_131(
   14145              :         "!  <Refrigeration Condenser:Evaporative-Cooled>,Condenser Number,Condenser Name,Rated Capacity (W), Rated Fan Power (W)");
   14146              :     static constexpr std::string_view Format_132(
   14147              :         "!  <Refrigeration Condenser:Cascade>, Condenser Number, Condenser Name, Condensing Temperature Control "
   14148              :         "Type, Rated Condensing Temperature (C), Capacity (W), Approach Temperature Difference (DeltaC)");
   14149              :     static constexpr std::string_view Format_133(
   14150              :         "! <Secondary Refrigeration System: Fluid Always Liquid>, Secondary Number, Secondary Name, # Refrigerated "
   14151              :         "Cases Connected, # WalkIn Coolers Connected, Fluid Name, Capacity (W),Evap Temperature in Secondary "
   14152              :         "Evaporator (C), Approach Temperature Difference (DeltaC), Temperature Range (DeltaC), TotalPumpPower (W)");
   14153              :     static constexpr std::string_view Format_134(
   14154              :         "!      <Walk-In Surfaces Facing Zone>, ZoneName, Wall/Ceiling Area (m2), UValue (W/m2-C), AreaStockDoors "
   14155              :         "(m2), HeightStockDoors, UValueStockDoors (W/m2-C), AreaGlassDoors (m2), HeightGlassDoors (m),  "
   14156              :         "UValueGlassDoors (W/m2-C)");
   14157              :     static constexpr std::string_view Format_141("!  <Mechanical Subcooler Load>, Subcooler Number, Subcooler Name");
   14158              :     static constexpr std::string_view Format_142("! <#Secondary Refrigeration Systems>,Number of Secondary Refrigeration Systems");
   14159              :     static constexpr std::string_view Format_146(
   14160              :         "! <Secondary Refrigeration System: Liquid Overfeed>, Secondary Number, Secondary Name, # Refrigerated Cases "
   14161              :         "Connected, # WalkIn Coolers Connected, #Air Coils Connected Fluid Name, Capacity (W),Evap Temperature in "
   14162              :         "Secondary Evaporator (C), Approach Temperature Difference (DeltaC), Circulating Rate, TotalPumpPower (W)");
   14163              :     static constexpr std::string_view Format_148("! <#ZoneHVAC/Refrigeration Air Chiller Sets>,Number of ZoneHVAC/Refrigeration Air Chiller Sets");
   14164              :     static constexpr std::string_view Format_149(
   14165              :         "! <ZoneHVAC/Refrigeration Air Chiller Set>,Chiller Set Name, # Air Chillers Connected, Zone Location");
   14166              :     static constexpr std::string_view Format_151(
   14167              :         "!  <Refrigeration Air Chiller>,Refrigeration Chiller Number, Refrigeration Chiller Name,Zone Name,Zone "
   14168              :         "Node #,Zone Node Name,Sensible Capacity (W/C),Sensible Capacity (W),Evaporating Temperature (C),DT1 (C),Fan "
   14169              :         "Power (W),Heater (W),Defrost (W), Air Flow Rate (m3/s)");
   14170              :     static constexpr std::string_view Format_152("!  <Air Chiller Load>, Air Chiller Name, Air Chiller Number, Zone Name,");
   14171              :     static constexpr std::string_view Format_160(
   14172              :         "!  <Refrigeration GasCooler:Air-Cooled>,Gas Cooler Number, Gas Cooler Name, Rated Outlet Pressure "
   14173              :         "(Pa),Rated Outlet Temperature (C), Rated Approach Temperature (C), Rated Capacity (W), Rated Fan Power (W)");
   14174              : 
   14175              :     // write all headers applicable to this simulation
   14176          801 :     if (state.dataRefrigCase->NumRefrigeratedRacks > 0) {
   14177           31 :         print(state.files.eio, "{}\n", Format_109); // Intro to refrigeration case racks
   14178           31 :         print(state.files.eio, "{}\n", Format_104); // Refrigeration Rack header
   14179              :     } //(NumRefrigeratedRacks > 0)
   14180          801 :     if (state.dataRefrigCase->NumRefrigSystems > 0) {
   14181           15 :         print(state.files.eio, "{}\n", Format_117); // Intro to detailed systems
   14182           15 :         print(state.files.eio, "{}\n", Format_118); // Detailed system header
   14183           15 :         print(state.files.eio, "{}\n", Format_108); // Compressor header (Always have compressor if have detailed system)
   14184              :     } //(NumRefrigSystems > 0)
   14185          801 :     if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
   14186            1 :         print(state.files.eio, "{}\n", Format_142); // Intro to Secondary systems
   14187            1 :         int CountSecPhase = 0;
   14188            1 :         int CountSecBrine = 0;
   14189            3 :         for (int SecondaryID = 1; SecondaryID <= state.dataRefrigCase->NumSimulationSecondarySystems; ++SecondaryID) {
   14190            2 :             if ((Secondary(SecondaryID).FluidType == SecFluidType::AlwaysLiquid) && (CountSecBrine == 0)) {
   14191            1 :                 print(state.files.eio, "{}\n", Format_133); // Secondary system header for brine type systems
   14192            1 :                 ++CountSecBrine;
   14193              :             }
   14194            2 :             if ((Secondary(SecondaryID).FluidType == SecFluidType::PhaseChange) && (CountSecPhase == 0)) {
   14195            1 :                 print(state.files.eio, "{}\n", Format_146); // Secondary system header for liquid overfeed/phase change systems
   14196            1 :                 ++CountSecPhase;
   14197              :             }
   14198              :         }
   14199            1 :         print(state.files.eio, "{}\n", Format_123); //  Secondary system load header
   14200              :     } //(NumSimulationSecondarySystems > 0)
   14201          801 :     if (state.dataRefrigCase->NumRefrigChillerSets > 0) {
   14202            1 :         print(state.files.eio, "{}\n", Format_148); // Intro to Chiller set
   14203            1 :         print(state.files.eio, "{}\n", Format_149); // Chiller set header
   14204            1 :         print(state.files.eio, "{}\n", Format_151); // Intro to Air Chiller
   14205            1 :         print(state.files.eio, "{}\n", Format_152); // Air chiller header
   14206              :     } //(NumRefrigSystems > 0)
   14207          801 :     if (state.dataRefrigCase->NumSimulationCases > 0) {
   14208           37 :         print(state.files.eio, "{}\n", Format_105); //  Case header
   14209              :     } //(NumSimulationCases > 0)
   14210          801 :     if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
   14211           14 :         print(state.files.eio, "{}\n", Format_119); //  Walk-in header
   14212           14 :         print(state.files.eio, "{}\n", Format_134); //  Walk-in zone-specific header
   14213              :     } //(NumSimulationWalkIns > 0)
   14214          801 :     if (state.dataRefrigCase->NumSimulationCondAir > 0) {
   14215           13 :         print(state.files.eio, "{}\n", Format_129); //  Condenser, Air-Cooled header
   14216              :     } //(NumSimulationCondAir > 0)
   14217          801 :     if (state.dataRefrigCase->NumSimulationCondEvap > 0) {
   14218            2 :         print(state.files.eio, "{}\n", Format_131); //  Condenser, Evaporative-Cooled header
   14219              :     } //(NumSimulationCondEvap > 0)
   14220          801 :     if (state.dataRefrigCase->NumSimulationCondWater > 0) {
   14221            1 :         print(state.files.eio, "{}\n", Format_130); //  Condenser, Water-Cooled header
   14222              :     } //(NumSimulationCondWater > 0)
   14223          801 :     if (state.dataRefrigCase->NumSimulationCascadeCondensers > 0) {
   14224            1 :         print(state.files.eio, "{}\n", Format_132); //  Condenser, Cascade header
   14225            1 :         print(state.files.eio, "{}\n", Format_128); //  Cascade Load header
   14226              :     } //(NumSimulationCascadeCondensers > 0)
   14227          801 :     if (state.dataRefrigCase->NumSimulationMechSubcoolers > 0) {
   14228            1 :         print(state.files.eio, "{}\n", Format_141); //  Mech subcooler loads served header
   14229            1 :         print(state.files.eio, "{}\n", Format_126); //  Mechanical Subcooler header
   14230              :     } //(NumSimulationMechSubcoolers > 0)
   14231          801 :     if ((state.dataRefrigCase->NumSimulationSubcoolers - state.dataRefrigCase->NumSimulationMechSubcoolers) > 0) {
   14232            1 :         print(state.files.eio, "{}\n", Format_127); //  LSHX Subcooler header
   14233              :     } //((NumSimulationSubcoolers - NumSimulationMechSubcoolers) > 0)
   14234              : 
   14235          801 :     if (state.dataRefrigCase->NumTransRefrigSystems > 0) {
   14236            1 :         print(state.files.eio, "{}\n", Format_120); // Intro to detailed transcritical refrigeration system
   14237            1 :         print(state.files.eio, "{}\n", Format_121); // Detailed system header
   14238            1 :         if (state.dataRefrigCase->NumSimulationCases > 0) {
   14239            1 :             print(state.files.eio, "{}\n", Format_105); //  Case header
   14240              :         } //(NumSimulationCases > 0)
   14241            1 :         if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
   14242            1 :             print(state.files.eio, "{}\n", Format_119); //  Walk-in header
   14243            1 :             print(state.files.eio, "{}\n", Format_134); //  Walk-in zone-specific header
   14244              :         } //(NumSimulationWalkIns > 0)
   14245            1 :         print(state.files.eio, "{}\n", Format_108); // Compressor header (Always have compressor if have detailed system)
   14246            1 :         if (state.dataRefrigCase->NumSimulationGasCooler > 0) {
   14247            1 :             print(state.files.eio, "{}\n", Format_160); //  Gas Cooler, Air-Cooled header
   14248              :         } //(NumSimulationGasCooler > 0)
   14249              :     } //(NumTransRefrigSystems > 0)
   14250              : 
   14251          801 :     if (state.dataRefrigCase->NumRefrigeratedRacks > 0) {
   14252           31 :         print(state.files.eio, "#Refrigeration Compressor Racks, {}\n", state.dataRefrigCase->NumRefrigeratedRacks);
   14253           92 :         for (int RackNum = 1; RackNum <= state.dataRefrigCase->NumRefrigeratedRacks; ++RackNum) {
   14254           61 :             if (RefrigRack(RackNum).HeatRejectionLocation == HeatRejLocation::Outdoors) {
   14255           34 :                 ChrOut = "Outdoors";
   14256              :             } else {
   14257           27 :                 ChrOut = "Zone";
   14258              :             }
   14259           61 :             switch (RefrigRack(RackNum).CondenserType) {
   14260           58 :             case DataHeatBalance::RefrigCondenserType::Air: {
   14261           58 :                 ChrOut2 = "Air-Cooled";
   14262           58 :             } break;
   14263            2 :             case DataHeatBalance::RefrigCondenserType::Evap: {
   14264            2 :                 ChrOut2 = "Evap-Cooled";
   14265            2 :             } break;
   14266            1 :             case DataHeatBalance::RefrigCondenserType::Water: {
   14267            1 :                 ChrOut2 = "Water-Cooled";
   14268            1 :             } break;
   14269            0 :             default:
   14270            0 :                 break;
   14271              :             }
   14272           61 :             print(state.files.eio,
   14273              :                   " Refrigeration Compressor Rack,{},{},{},{},{},{:.3R}\n",
   14274           61 :                   RefrigRack(RackNum).Name,
   14275           61 :                   RefrigRack(RackNum).NumCases,
   14276           61 :                   RefrigRack(RackNum).NumWalkIns,
   14277              :                   ChrOut,
   14278              :                   ChrOut2,
   14279           61 :                   RefrigRack(RackNum).RatedCOP);
   14280          153 :             for (int CaseNum = 1; CaseNum <= RefrigRack(RackNum).NumCases; ++CaseNum) {
   14281           92 :                 int CaseID = RefrigRack(RackNum).CaseNum(CaseNum);
   14282           92 :                 if (RefrigCase(CaseID).ZoneNodeNum > 0) {
   14283           92 :                     print(state.files.eio,
   14284              :                           "   Refrigeration Case,{},{},{},{},{},{:.1R},{:.2R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R}\n",
   14285              :                           CaseID,
   14286           92 :                           RefrigCase(CaseID).Name,
   14287           92 :                           RefrigCase(CaseID).ZoneName,
   14288           92 :                           RefrigCase(CaseID).ZoneNodeNum,
   14289           92 :                           state.dataLoopNodes->NodeID(RefrigCase(CaseID).ZoneNodeNum),
   14290           92 :                           RefrigCase(CaseID).RateTotCapPerLength,
   14291           92 :                           RefrigCase(CaseID).RatedLHR,
   14292           92 :                           RefrigCase(CaseID).Temperature,
   14293           92 :                           RefrigCase(CaseID).Length,
   14294           92 :                           RefrigCase(CaseID).OperatingFanPower,
   14295           92 :                           RefrigCase(CaseID).LightingPower,
   14296           92 :                           RefrigCase(CaseID).AntiSweatPower,
   14297           92 :                           RefrigCase(CaseID).DefrostPower); // Installed lighting power, may not be rated power
   14298              :                 }
   14299              :             } // numcases
   14300              : 
   14301           61 :             for (int WalkInNum = 1; WalkInNum <= RefrigRack(RackNum).NumWalkIns; ++WalkInNum) {
   14302            0 :                 int WalkInID = RefrigRack(RackNum).WalkInNum(WalkInNum);
   14303            0 :                 print(state.files.eio,
   14304              :                       "   Refrigeration Walk In Cooler,  {},{},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{}\n",
   14305              :                       WalkInID,
   14306            0 :                       WalkIn(WalkInID).Name,
   14307            0 :                       WalkIn(WalkInID).DesignRatedCap,
   14308            0 :                       WalkIn(WalkInID).Temperature,
   14309            0 :                       WalkIn(WalkInID).CoilFanPower,
   14310            0 :                       WalkIn(WalkInID).CircFanPower,
   14311            0 :                       WalkIn(WalkInID).ElecFanPower,
   14312            0 :                       WalkIn(WalkInID).DesignLighting,
   14313            0 :                       WalkIn(WalkInID).HeaterPower,
   14314            0 :                       WalkIn(WalkInID).DefrostCapacity,
   14315            0 :                       WalkIn(WalkInID).NumZones);
   14316            0 :                 for (int ZoneID = 1; ZoneID <= WalkIn(WalkInID).NumZones; ++ZoneID) {
   14317            0 :                     print(state.files.eio,
   14318              :                           "      Walk-In Surfaces Facing Zone, {},{:.1R},{:.4R},{:.2R},{:.2R},{:.4R},{:.2R},{:.2R},{:.4R}\n",
   14319            0 :                           WalkIn(WalkInID).ZoneName(ZoneID),
   14320            0 :                           WalkIn(WalkInID).SurfaceArea(ZoneID),
   14321            0 :                           WalkIn(WalkInID).UValue(ZoneID),
   14322            0 :                           WalkIn(WalkInID).AreaStockDr(ZoneID),
   14323            0 :                           WalkIn(WalkInID).HeightStockDr(ZoneID),
   14324            0 :                           WalkIn(WalkInID).UValueStockDr(ZoneID),
   14325            0 :                           WalkIn(WalkInID).AreaGlassDr(ZoneID),
   14326            0 :                           WalkIn(WalkInID).HeightGlassDr(ZoneID),
   14327            0 :                           WalkIn(WalkInID).UValueGlassDr(ZoneID));
   14328              :                 } // zones for walk ins on rack
   14329              :             } // walk ins on rack
   14330              : 
   14331           61 :             for (int CoilNum = 1; CoilNum <= RefrigRack(RackNum).NumCoils; ++CoilNum) {
   14332            0 :                 int CoilID = RefrigRack(RackNum).CoilNum(CoilNum);
   14333            0 :                 print(state.files.eio, "   Air Chiller Load,{},{},{}\n", WarehouseCoil(CoilID).Name, CoilID, WarehouseCoil(CoilID).ZoneName);
   14334              :             } // numairchillers
   14335              :         } // numracks
   14336              :     } //(NumRefrigeratedRacks > 0)
   14337              : 
   14338          801 :     if (state.dataRefrigCase->NumRefrigSystems > 0) {
   14339           15 :         print(state.files.eio, "#Detailed Refrigeration Systems,{}\n", state.dataRefrigCase->NumRefrigSystems);
   14340           56 :         for (int SystemNum = 1; SystemNum <= state.dataRefrigCase->NumRefrigSystems; ++SystemNum) {
   14341           41 :             print(state.files.eio,
   14342              :                   " Detailed Refrigeration System,{},{},{},{},{},{},{},{},{},{},{},{:.2R},{},{:.1R}\n",
   14343           41 :                   System(SystemNum).Name,
   14344           41 :                   System(SystemNum).RefrigerantName,
   14345           41 :                   System(SystemNum).NumCases,
   14346           41 :                   System(SystemNum).NumWalkIns,
   14347           41 :                   System(SystemNum).NumCoils,
   14348           41 :                   System(SystemNum).NumSecondarys,
   14349           41 :                   System(SystemNum).NumCascadeLoads,
   14350           41 :                   System(SystemNum).NumMechSCServed,
   14351           41 :                   System(SystemNum).NumCompressors + System(SystemNum).NumHiStageCompressors,
   14352           41 :                   System(SystemNum).NumStages,
   14353           41 :                   System(SystemNum).intercoolerType,
   14354           41 :                   System(SystemNum).IntercoolerEffectiveness,
   14355           41 :                   System(SystemNum).NumSubcoolers,
   14356           41 :                   System(SystemNum).TCondenseMin);
   14357              : 
   14358          125 :             for (int CaseNum = 1; CaseNum <= System(SystemNum).NumCases; ++CaseNum) {
   14359           84 :                 int CaseID = System(SystemNum).CaseNum(CaseNum);
   14360           84 :                 if (RefrigCase(CaseID).ZoneNodeNum > 0) {
   14361           84 :                     print(state.files.eio,
   14362              :                           "   Refrigeration Case,{},{},{},{},{},{:.1R},{:.2R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R}\n",
   14363              :                           CaseID,
   14364           84 :                           RefrigCase(CaseID).Name,
   14365           84 :                           RefrigCase(CaseID).ZoneName,
   14366           84 :                           RefrigCase(CaseID).ZoneNodeNum,
   14367           84 :                           state.dataLoopNodes->NodeID(RefrigCase(CaseID).ZoneNodeNum),
   14368           84 :                           RefrigCase(CaseID).RateTotCapPerLength,
   14369           84 :                           RefrigCase(CaseID).RatedLHR,
   14370           84 :                           RefrigCase(CaseID).Temperature,
   14371           84 :                           RefrigCase(CaseID).Length,
   14372           84 :                           RefrigCase(CaseID).OperatingFanPower,
   14373           84 :                           RefrigCase(CaseID).LightingPower,
   14374           84 :                           RefrigCase(CaseID).AntiSweatPower,
   14375           84 :                           RefrigCase(CaseID).DefrostPower);
   14376              :                 }
   14377              :             } // NumCases on system
   14378           56 :             for (int WalkInNum = 1; WalkInNum <= System(SystemNum).NumWalkIns; ++WalkInNum) {
   14379           15 :                 int WalkInID = System(SystemNum).WalkInNum(WalkInNum);
   14380           15 :                 print(state.files.eio,
   14381              :                       "   Refrigeration Walk In Cooler,{},{},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{}\n",
   14382              :                       WalkInID,
   14383           15 :                       WalkIn(WalkInID).Name,
   14384           15 :                       WalkIn(WalkInID).DesignRatedCap,
   14385           15 :                       WalkIn(WalkInID).Temperature,
   14386           15 :                       WalkIn(WalkInID).CoilFanPower,
   14387           15 :                       WalkIn(WalkInID).CircFanPower,
   14388           15 :                       WalkIn(WalkInID).DesignLighting,
   14389           15 :                       WalkIn(WalkInID).HeaterPower,
   14390           15 :                       WalkIn(WalkInID).DefrostCapacity,
   14391           15 :                       WalkIn(WalkInID).NumZones);
   14392           30 :                 for (int ZoneID = 1; ZoneID <= WalkIn(WalkInID).NumZones; ++ZoneID) {
   14393           15 :                     print(state.files.eio,
   14394              :                           "      Walk-In Surfaces Facing Zone, {},{:.1R},{:.4R},{:.2R},{:.2R},{:.4R},{:.2R},{:.2R},{:.4R}\n",
   14395           15 :                           WalkIn(WalkInID).ZoneName(ZoneID),
   14396           15 :                           WalkIn(WalkInID).SurfaceArea(ZoneID),
   14397           15 :                           WalkIn(WalkInID).UValue(ZoneID),
   14398           15 :                           WalkIn(WalkInID).AreaStockDr(ZoneID),
   14399           15 :                           WalkIn(WalkInID).HeightStockDr(ZoneID),
   14400           15 :                           WalkIn(WalkInID).UValueStockDr(ZoneID),
   14401           15 :                           WalkIn(WalkInID).AreaGlassDr(ZoneID),
   14402           15 :                           WalkIn(WalkInID).HeightGlassDr(ZoneID),
   14403           15 :                           WalkIn(WalkInID).UValueGlassDr(ZoneID));
   14404              :                 } // Num zones for each walk in on system
   14405              :             } // NumWalkIns on system
   14406              : 
   14407          124 :             for (int CoilNum = 1; CoilNum <= System(SystemNum).NumCoils; ++CoilNum) {
   14408           83 :                 int CoilID = System(SystemNum).CoilNum(CoilNum);
   14409           83 :                 print(state.files.eio, "   Air Chiller Load,{},{},{}\n", WarehouseCoil(CoilID).Name, CoilID, WarehouseCoil(CoilID).ZoneName);
   14410              :             } // numairchillers
   14411              : 
   14412           42 :             for (int CascadeLoadNum = 1; CascadeLoadNum <= System(SystemNum).NumCascadeLoads; ++CascadeLoadNum) {
   14413            1 :                 int CascadeLoadID = System(SystemNum).CascadeLoadNum(CascadeLoadNum);
   14414            1 :                 print(state.files.eio,
   14415              :                       "   Cascade Load,{},{},{}\n",
   14416            1 :                       System(Condenser(CascadeLoadID).CascadeSysID).Name,
   14417              :                       CascadeLoadID,
   14418            1 :                       Condenser(CascadeLoadID).Name);
   14419              :             } // cascade load on detailed system
   14420              : 
   14421           43 :             for (int SecondaryNum = 1; SecondaryNum <= System(SystemNum).NumSecondarys; ++SecondaryNum) {
   14422            2 :                 int SecondaryID = System(SystemNum).SecondaryNum(SecondaryNum);
   14423            2 :                 print(state.files.eio, "   Secondary Load,{},{}\n", Secondary(SecondaryID).Name, SecondaryID);
   14424              :             } // secondary load on detailed system
   14425              : 
   14426           45 :             for (int SubcoolerNum = 1; SubcoolerNum <= state.dataRefrigCase->NumSimulationSubcoolers; ++SubcoolerNum) {
   14427            4 :                 if (Subcooler(SubcoolerNum).MechSourceSysID != SystemNum) {
   14428            3 :                     continue;
   14429              :                 }
   14430            1 :                 print(state.files.eio, "   Mechanical Subcooler Load, {},{}\n", SubcoolerNum, Subcooler(SubcoolerNum).Name);
   14431              :             } // Num sim subcoolers, looking only for NumSMech Subcoolers served by this system
   14432              : 
   14433           41 :             if (System(SystemNum).NumStages == 1) { // Single-stage compression system
   14434          201 :                 for (int CompressorNum = 1; CompressorNum <= System(SystemNum).NumCompressors; ++CompressorNum) {
   14435          162 :                     int CompID = System(SystemNum).CompressorNum(CompressorNum);
   14436          162 :                     print(state.files.eio, "   Refrigeration Compressor,{},{},{:.0R}\n", CompID, Compressor(CompID).Name, Compressor(CompID).NomCap);
   14437              :                 } // NumCompressors
   14438            2 :             } else if (System(SystemNum).NumStages == 2) { // Two-stage compression system
   14439              :                 // Low-stage compressors
   14440            8 :                 for (int CompressorNum = 1; CompressorNum <= System(SystemNum).NumCompressors; ++CompressorNum) {
   14441            6 :                     int CompID = System(SystemNum).CompressorNum(CompressorNum);
   14442            6 :                     print(state.files.eio,
   14443              :                           "   Refrigeration Low-Stage Compressor,{},{},{:.0R}\n",
   14444              :                           CompID,
   14445            6 :                           Compressor(CompID).Name,
   14446            6 :                           Compressor(CompID).NomCap);
   14447              :                 } // NumCompressors
   14448              :                 // High-stage compressors
   14449           10 :                 for (int CompressorNum = 1; CompressorNum <= System(SystemNum).NumHiStageCompressors; ++CompressorNum) {
   14450            8 :                     int CompID = System(SystemNum).HiStageCompressorNum(CompressorNum);
   14451            8 :                     print(state.files.eio,
   14452              :                           "   Refrigeration High-Stage Compressor,{},{},{:.0R}\n",
   14453              :                           CompID,
   14454            8 :                           Compressor(CompID).Name,
   14455            8 :                           Compressor(CompID).NomCap);
   14456              :                 } // NumHiStageCompressors
   14457              :             } // NumStages
   14458              : 
   14459           41 :             int CondID = System(SystemNum).CondenserNum(1);
   14460           41 :             switch (Condenser(CondID).CondenserType) {
   14461           35 :             case DataHeatBalance::RefrigCondenserType::Air: {
   14462           35 :                 print(state.files.eio,
   14463              :                       "   Refrigeration Condenser:Air-Cooled,{},{},{:.1R},{:.1R},{:.1R}\n",
   14464              :                       CondID,
   14465           35 :                       Condenser(CondID).Name,
   14466           35 :                       Condenser(CondID).RatedTCondense,
   14467           35 :                       Condenser(CondID).RatedCapacity,
   14468           35 :                       Condenser(CondID).RatedFanPower);
   14469           35 :             } break;
   14470            4 :             case DataHeatBalance::RefrigCondenserType::Evap: {
   14471            4 :                 print(state.files.eio,
   14472              :                       "   Refrigeration Condenser:Evaporative-Cooled,{},{},{:.1R},{:.1R}\n",
   14473              :                       CondID,
   14474            4 :                       Condenser(CondID).Name,
   14475            4 :                       Condenser(CondID).RatedCapacity,
   14476            4 :                       Condenser(CondID).RatedFanPower);
   14477            4 :             } break;
   14478            1 :             case DataHeatBalance::RefrigCondenserType::Water: {
   14479            1 :                 print(state.files.eio,
   14480              :                       "   Refrigeration Condenser:Water-Cooled,{},{},{:.1R},{:.1R},{:.1R},{:.1R}\n",
   14481              :                       CondID,
   14482            1 :                       Condenser(CondID).Name,
   14483            1 :                       Condenser(CondID).RatedTCondense,
   14484            1 :                       Condenser(CondID).RatedCapacity,
   14485            1 :                       Condenser(CondID).InletTemp,
   14486            1 :                       Condenser(CondID).DesVolFlowRate);
   14487            1 :             } break;
   14488            1 :             case DataHeatBalance::RefrigCondenserType::Cascade: {
   14489              : 
   14490            1 :                 switch (Condenser(CondID).CascadeTempControl) {
   14491            1 :                 case CascadeCndsrTempCtrlType::TempSet: {
   14492            1 :                     ChrOut = "Fixed";
   14493            1 :                 } break;
   14494            0 :                 case CascadeCndsrTempCtrlType::TempFloat: {
   14495            0 :                     ChrOut = "Floating";
   14496            0 :                 } break;
   14497            0 :                 default:
   14498            0 :                     break;
   14499              :                 } // cascade temperature control
   14500            1 :                 print(state.files.eio,
   14501              :                       "   Refrigeration Condenser:Cascade,{},{},{},{:.1R},{:.1R},{:.1R}\n",
   14502              :                       CondID,
   14503            1 :                       Condenser(CondID).Name,
   14504              :                       ChrOut,
   14505            1 :                       Condenser(CondID).RatedTCondense,
   14506            1 :                       Condenser(CondID).RatedCapacity,
   14507            1 :                       Condenser(CondID).RatedApproachT);
   14508            1 :             } break;
   14509            0 :             default:
   14510            0 :                 break;
   14511              :             } // condenser type
   14512              : 
   14513           43 :             for (int SubcoolerNum = 1; SubcoolerNum <= System(SystemNum).NumSubcoolers; ++SubcoolerNum) {
   14514            2 :                 int SubcoolerID = System(SystemNum).SubcoolerNum(SubcoolerNum);
   14515            2 :                 switch (Subcooler(SubcoolerID).subcoolerType) {
   14516            1 :                 case SubcoolerType::LiquidSuction: {
   14517            1 :                     print(state.files.eio,
   14518              :                           "   Refrigeration Liquid Suction Subcooler,{},{},{:.1R},{:.1R},{:.1R}\n",
   14519              :                           SubcoolerID,
   14520            1 :                           Subcooler(SubcoolerID).Name,
   14521            1 :                           Subcooler(SubcoolerID).LiqSuctDesignDelT,
   14522            1 :                           Subcooler(SubcoolerID).LiqSuctDesignTliqIn,
   14523            1 :                           Subcooler(SubcoolerID).LiqSuctDesignTvapIn);
   14524            1 :                 } break;
   14525            1 :                 case SubcoolerType::Mechanical: {
   14526            1 :                     print(state.files.eio,
   14527              :                           "   Refrigeration Mechanical Subcooler,{},{},{},{:.1R}\n",
   14528              :                           SubcoolerID,
   14529            1 :                           Subcooler(SubcoolerID).Name,
   14530            1 :                           Subcooler(SubcoolerID).MechSourceSys,
   14531            1 :                           Subcooler(SubcoolerID).MechControlTliqOut);
   14532            1 :                 } break;
   14533            0 :                 default:
   14534            0 :                     break;
   14535              :                 }
   14536              :             } // NumSubcoolers
   14537              : 
   14538              :         } // NumRefrigSystems
   14539              :     } //(NumRefrigSystems > 0)
   14540              : 
   14541          801 :     if (state.dataRefrigCase->NumTransRefrigSystems > 0) {
   14542            1 :         print(state.files.eio, "#Detailed Transcritical Refrigeration Systems,{}\n", state.dataRefrigCase->NumTransRefrigSystems);
   14543            2 :         for (int TransSystemNum = 1; TransSystemNum <= state.dataRefrigCase->NumTransRefrigSystems; ++TransSystemNum) {
   14544            1 :             print(state.files.eio,
   14545              :                   " Detailed Transcritical Refrigeration System,{},{},{},{},{},{},{},{},{:.1R}\n",
   14546            1 :                   TransSystem(TransSystemNum).Name,
   14547            1 :                   TransSystem(TransSystemNum).RefrigerantName,
   14548            1 :                   TransSystem(TransSystemNum).NumCasesMT,
   14549            1 :                   TransSystem(TransSystemNum).NumCasesLT,
   14550            1 :                   TransSystem(TransSystemNum).NumWalkInsMT,
   14551            1 :                   TransSystem(TransSystemNum).NumWalkInsLT,
   14552            1 :                   TransSystem(TransSystemNum).NumCompressorsHP,
   14553            1 :                   TransSystem(TransSystemNum).NumCompressorsLP,
   14554            1 :                   GasCooler(TransSystem(TransSystemNum).GasCoolerNum(1)).MinCondTemp);
   14555              : 
   14556            4 :             for (int CaseNum = 1; CaseNum <= TransSystem(TransSystemNum).NumCasesMT; ++CaseNum) {
   14557            3 :                 int CaseID = TransSystem(TransSystemNum).CaseNumMT(CaseNum);
   14558            3 :                 if (RefrigCase(CaseID).ZoneNodeNum > 0) {
   14559            3 :                     print(state.files.eio,
   14560              :                           "   Medium Temperature Refrigeration Case,{},{},{},{},{},{:.1R},{:.2R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R}\n",
   14561              :                           CaseID,
   14562            3 :                           RefrigCase(CaseID).Name,
   14563            3 :                           RefrigCase(CaseID).ZoneName,
   14564            3 :                           RefrigCase(CaseID).ZoneNodeNum,
   14565            3 :                           state.dataLoopNodes->NodeID(RefrigCase(CaseID).ZoneNodeNum),
   14566            3 :                           RefrigCase(CaseID).RateTotCapPerLength,
   14567            3 :                           RefrigCase(CaseID).RatedLHR,
   14568            3 :                           RefrigCase(CaseID).Temperature,
   14569            3 :                           RefrigCase(CaseID).Length,
   14570            3 :                           RefrigCase(CaseID).OperatingFanPower,
   14571            3 :                           RefrigCase(CaseID).LightingPower,
   14572            3 :                           RefrigCase(CaseID).AntiSweatPower,
   14573            3 :                           RefrigCase(CaseID).DefrostPower);
   14574              :                 }
   14575              :             } // NumCasesMT on system
   14576            5 :             for (int CaseNum = 1; CaseNum <= TransSystem(TransSystemNum).NumCasesLT; ++CaseNum) {
   14577            4 :                 int CaseID = TransSystem(TransSystemNum).CaseNumLT(CaseNum);
   14578            4 :                 if (RefrigCase(CaseID).ZoneNodeNum > 0) {
   14579            4 :                     print(state.files.eio,
   14580              :                           "   Low Temperature Refrigeration Case,{},{},{},{},{},{:.1R},{:.2R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R}\n",
   14581              :                           CaseID,
   14582            4 :                           RefrigCase(CaseID).Name,
   14583            4 :                           RefrigCase(CaseID).ZoneName,
   14584            4 :                           RefrigCase(CaseID).ZoneNodeNum,
   14585            4 :                           state.dataLoopNodes->NodeID(RefrigCase(CaseID).ZoneNodeNum),
   14586            4 :                           RefrigCase(CaseID).RateTotCapPerLength,
   14587            4 :                           RefrigCase(CaseID).RatedLHR,
   14588            4 :                           RefrigCase(CaseID).Temperature,
   14589            4 :                           RefrigCase(CaseID).Length,
   14590            4 :                           RefrigCase(CaseID).OperatingFanPower,
   14591            4 :                           RefrigCase(CaseID).LightingPower,
   14592            4 :                           RefrigCase(CaseID).AntiSweatPower,
   14593            4 :                           RefrigCase(CaseID).DefrostPower);
   14594              :                 }
   14595              :             } // NumCasesLT on system
   14596            1 :             for (int WalkInNum = 1; WalkInNum <= TransSystem(TransSystemNum).NumWalkInsMT; ++WalkInNum) {
   14597            0 :                 int WalkInID = TransSystem(TransSystemNum).WalkInNumMT(WalkInNum);
   14598            0 :                 print(state.files.eio,
   14599              :                       "   Medium Temperature Refrigeration Walk In Cooler,{},{},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{}\n",
   14600              :                       WalkInID,
   14601            0 :                       WalkIn(WalkInID).Name,
   14602            0 :                       WalkIn(WalkInID).DesignRatedCap,
   14603            0 :                       WalkIn(WalkInID).Temperature,
   14604            0 :                       WalkIn(WalkInID).CoilFanPower,
   14605            0 :                       WalkIn(WalkInID).CircFanPower,
   14606            0 :                       WalkIn(WalkInID).DesignLighting,
   14607            0 :                       WalkIn(WalkInID).HeaterPower,
   14608            0 :                       WalkIn(WalkInID).DefrostCapacity,
   14609            0 :                       WalkIn(WalkInID).NumZones);
   14610            0 :                 for (int ZoneID = 1; ZoneID <= WalkIn(WalkInID).NumZones; ++ZoneID) {
   14611            0 :                     print(state.files.eio,
   14612              :                           "      Walk-In Surfaces Facing Zone,{},{:.1R},{:.4R},{:.2R},{:.2R},{:.4R},{:.2R},{:.2R},{:.4R}\n",
   14613            0 :                           WalkIn(WalkInID).ZoneName(ZoneID),
   14614            0 :                           WalkIn(WalkInID).SurfaceArea(ZoneID),
   14615            0 :                           WalkIn(WalkInID).UValue(ZoneID),
   14616            0 :                           WalkIn(WalkInID).AreaStockDr(ZoneID),
   14617            0 :                           WalkIn(WalkInID).HeightStockDr(ZoneID),
   14618            0 :                           WalkIn(WalkInID).UValueStockDr(ZoneID),
   14619            0 :                           WalkIn(WalkInID).AreaGlassDr(ZoneID),
   14620            0 :                           WalkIn(WalkInID).HeightGlassDr(ZoneID),
   14621            0 :                           WalkIn(WalkInID).UValueGlassDr(ZoneID));
   14622              :                 } // Num zones for each walk in on system
   14623              :             } // NumWalkInsMT on system
   14624            2 :             for (int WalkInNum = 1; WalkInNum <= TransSystem(TransSystemNum).NumWalkInsLT; ++WalkInNum) {
   14625            1 :                 int WalkInID = TransSystem(TransSystemNum).WalkInNumLT(WalkInNum);
   14626            1 :                 print(state.files.eio,
   14627              :                       "   Low Temperature Refrigeration Walk In Cooler,{},{},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{}\n",
   14628              :                       WalkInID,
   14629            1 :                       WalkIn(WalkInID).Name,
   14630            1 :                       WalkIn(WalkInID).DesignRatedCap,
   14631            1 :                       WalkIn(WalkInID).Temperature,
   14632            1 :                       WalkIn(WalkInID).CoilFanPower,
   14633            1 :                       WalkIn(WalkInID).CircFanPower,
   14634            1 :                       WalkIn(WalkInID).DesignLighting,
   14635            1 :                       WalkIn(WalkInID).HeaterPower,
   14636            1 :                       WalkIn(WalkInID).DefrostCapacity,
   14637            1 :                       WalkIn(WalkInID).NumZones);
   14638            2 :                 for (int ZoneID = 1; ZoneID <= WalkIn(WalkInID).NumZones; ++ZoneID) {
   14639            1 :                     print(state.files.eio,
   14640              :                           "      Walk-In Surfaces Facing Zone,{},{:.1R},{:.4R},{:.2R},{:.2R},{:.4R},{:.2R},{:.2R},{:.4R}\n",
   14641            1 :                           WalkIn(WalkInID).ZoneName(ZoneID),
   14642            1 :                           WalkIn(WalkInID).SurfaceArea(ZoneID),
   14643            1 :                           WalkIn(WalkInID).UValue(ZoneID),
   14644            1 :                           WalkIn(WalkInID).AreaStockDr(ZoneID),
   14645            1 :                           WalkIn(WalkInID).HeightStockDr(ZoneID),
   14646            1 :                           WalkIn(WalkInID).UValueStockDr(ZoneID),
   14647            1 :                           WalkIn(WalkInID).AreaGlassDr(ZoneID),
   14648            1 :                           WalkIn(WalkInID).HeightGlassDr(ZoneID),
   14649            1 :                           WalkIn(WalkInID).UValueGlassDr(ZoneID));
   14650              :                 } // Num zones for each walk in on system
   14651              :             } // NumWalkInsLT on system
   14652              : 
   14653            4 :             for (int CompressorNum = 1; CompressorNum <= TransSystem(TransSystemNum).NumCompressorsHP; ++CompressorNum) {
   14654            3 :                 int CompID = TransSystem(TransSystemNum).CompressorNumHP(CompressorNum);
   14655            3 :                 print(state.files.eio,
   14656              :                       "   High Pressure Refrigeration Compressor,{},{},{:.0R}\n",
   14657              :                       CompID,
   14658            3 :                       Compressor(CompID).Name,
   14659            3 :                       Compressor(CompID).NomCap);
   14660              :             } // NumCompressorsHP
   14661            4 :             for (int CompressorNum = 1; CompressorNum <= TransSystem(TransSystemNum).NumCompressorsLP; ++CompressorNum) {
   14662            3 :                 int CompID = TransSystem(TransSystemNum).CompressorNumLP(CompressorNum);
   14663            3 :                 print(state.files.eio,
   14664              :                       "   Low Pressure Refrigeration Compressor,{},{},{:.0R}\n",
   14665              :                       CompID,
   14666            3 :                       Compressor(CompID).Name,
   14667            3 :                       Compressor(CompID).NomCap);
   14668              :             } // NumCompressorsLP
   14669              : 
   14670            1 :             if (TransSystem(TransSystemNum).NumGasCoolers >= 1) {
   14671            1 :                 int GasCoolerID = TransSystem(TransSystemNum).GasCoolerNum(1);
   14672            1 :                 print(state.files.eio,
   14673              :                       "   Refrigeration GasCooler:Air-Cooled,{},{},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R}\n",
   14674              :                       GasCoolerID,
   14675            1 :                       GasCooler(GasCoolerID).Name,
   14676            1 :                       GasCooler(GasCoolerID).RatedOutletP,
   14677            1 :                       GasCooler(GasCoolerID).RatedOutletT,
   14678            1 :                       GasCooler(GasCoolerID).RatedApproachT,
   14679            1 :                       GasCooler(GasCoolerID).RatedCapacity,
   14680            1 :                       GasCooler(GasCoolerID).RatedFanPower);
   14681              :             } // System(SystemNum)%NumGasCoolers >= 1
   14682              : 
   14683              :         } // NumTransRefrigSystems
   14684              :     } //(NumTransRefrigSystems > 0)
   14685              : 
   14686          801 :     if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
   14687            1 :         print(state.files.eio, "#Secondary Refrigeration Systems,{}\n", state.dataRefrigCase->NumSimulationSecondarySystems);
   14688            3 :         for (int SecondaryID = 1; SecondaryID <= state.dataRefrigCase->NumSimulationSecondarySystems; ++SecondaryID) {
   14689            2 :             switch (Secondary(SecondaryID).FluidType) {
   14690            1 :             case SecFluidType::AlwaysLiquid: {
   14691            1 :                 print(state.files.eio,
   14692              :                       "Secondary Refrigeration System: Fluid Always Liquid,{},{},{},{},{},{:.1R},{:.2R},{:.2R},{:.3R},{:.3R}\n",
   14693              :                       SecondaryID,
   14694            1 :                       Secondary(SecondaryID).Name,
   14695            1 :                       Secondary(SecondaryID).NumCases,
   14696            1 :                       Secondary(SecondaryID).NumWalkIns,
   14697            1 :                       Secondary(SecondaryID).FluidName,
   14698            1 :                       Secondary(SecondaryID).CoolingLoadRated,
   14699            1 :                       Secondary(SecondaryID).TEvapDesign,
   14700            1 :                       Secondary(SecondaryID).TApproachDifRated,
   14701            1 :                       Secondary(SecondaryID).TRangeDifRated,
   14702            1 :                       Secondary(SecondaryID).PumpTotRatedPower);
   14703            1 :             } break;
   14704            1 :             case SecFluidType::PhaseChange: {
   14705            1 :                 print(state.files.eio,
   14706              :                       "Secondary Refrigeration System: Liquid Overfeed,{},{},{},{},{},{:.1R},{:.2R},{:.2R},{:.3R},{:.3R}\n",
   14707              :                       SecondaryID,
   14708            1 :                       Secondary(SecondaryID).Name,
   14709            1 :                       Secondary(SecondaryID).NumCases,
   14710            1 :                       Secondary(SecondaryID).NumWalkIns,
   14711            1 :                       Secondary(SecondaryID).FluidName,
   14712            1 :                       Secondary(SecondaryID).CoolingLoadRated,
   14713            1 :                       Secondary(SecondaryID).TEvapDesign,
   14714            1 :                       Secondary(SecondaryID).TApproachDifRated,
   14715            1 :                       Secondary(SecondaryID).CircRate,
   14716            1 :                       Secondary(SecondaryID).PumpTotRatedPower);
   14717            1 :             } break;
   14718            0 :             default:
   14719            0 :                 break;
   14720              :             }
   14721            9 :             for (int CaseNum = 1; CaseNum <= Secondary(SecondaryID).NumCases; ++CaseNum) {
   14722            7 :                 int CaseID = Secondary(SecondaryID).CaseNum(CaseNum);
   14723            7 :                 if (RefrigCase(CaseID).ZoneNodeNum > 0) {
   14724            7 :                     print(state.files.eio,
   14725              :                           "  Refrigeration Case,{},{},{},{},{},{:.1R},{:.2R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R}\n",
   14726              :                           CaseID,
   14727            7 :                           RefrigCase(CaseID).Name,
   14728            7 :                           RefrigCase(CaseID).ZoneName,
   14729            7 :                           RefrigCase(CaseID).ZoneNodeNum,
   14730            7 :                           state.dataLoopNodes->NodeID(RefrigCase(CaseID).ZoneNodeNum),
   14731            7 :                           RefrigCase(CaseID).RateTotCapPerLength,
   14732            7 :                           RefrigCase(CaseID).RatedLHR,
   14733            7 :                           RefrigCase(CaseID).Temperature,
   14734            7 :                           RefrigCase(CaseID).Length,
   14735            7 :                           RefrigCase(CaseID).OperatingFanPower,
   14736            7 :                           RefrigCase(CaseID).LightingPower,
   14737            7 :                           RefrigCase(CaseID).AntiSweatPower,
   14738            7 :                           RefrigCase(CaseID).DefrostPower);
   14739              :                 }
   14740              :             } // NumCases on secondary on secondary system
   14741              : 
   14742            3 :             for (int WalkInNum = 1; WalkInNum <= Secondary(SecondaryID).NumWalkIns; ++WalkInNum) {
   14743            1 :                 int WalkInID = Secondary(SecondaryID).WalkInNum(WalkInNum);
   14744            1 :                 print(state.files.eio,
   14745              :                       "  Walk In,{},{},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R}\n",
   14746              :                       WalkInID,
   14747            1 :                       WalkIn(WalkInID).Name,
   14748            1 :                       WalkIn(WalkInID).DesignRatedCap,
   14749            1 :                       WalkIn(WalkInID).Temperature,
   14750            1 :                       WalkIn(WalkInID).CoilFanPower,
   14751            1 :                       WalkIn(WalkInID).CircFanPower,
   14752            1 :                       WalkIn(WalkInID).DesignLighting,
   14753            1 :                       WalkIn(WalkInID).HeaterPower,
   14754            1 :                       WalkIn(WalkInID).DefrostCapacity);
   14755            2 :                 for (int ZoneID = 1; ZoneID <= WalkIn(WalkInID).NumZones; ++ZoneID) {
   14756            1 :                     print(state.files.eio,
   14757              :                           "    Walk In Surfaces Facing Zone,{},{:.1R},{:.4R},{:.2R},{:.2R},{:.4R},{:.2R},{:.2R},{:.4R}\n",
   14758            1 :                           WalkIn(WalkInID).ZoneName(ZoneID),
   14759            1 :                           WalkIn(WalkInID).SurfaceArea(ZoneID),
   14760            1 :                           WalkIn(WalkInID).UValue(ZoneID),
   14761            1 :                           WalkIn(WalkInID).AreaStockDr(ZoneID),
   14762            1 :                           WalkIn(WalkInID).HeightStockDr(ZoneID),
   14763            1 :                           WalkIn(WalkInID).UValueStockDr(ZoneID),
   14764            1 :                           WalkIn(WalkInID).AreaGlassDr(ZoneID),
   14765            1 :                           WalkIn(WalkInID).HeightGlassDr(ZoneID),
   14766            1 :                           WalkIn(WalkInID).UValueGlassDr(ZoneID));
   14767              :                 } // zones for walk ins on secondary
   14768              :             } // walk ins on secondary
   14769              : 
   14770            2 :             for (int CoilNum = 1; CoilNum <= Secondary(SecondaryID).NumCoils; ++CoilNum) {
   14771            0 :                 int CoilID = Secondary(SecondaryID).CoilNum(CoilNum);
   14772            0 :                 print(state.files.eio, "   Air Chiller Load,{},{},{}\n", WarehouseCoil(CoilID).Name, CoilID, WarehouseCoil(CoilID).ZoneName);
   14773              :             } // numairchillers
   14774              :         } // secondary
   14775              :     } // numsimulationsecondarys
   14776              : 
   14777          801 :     if (state.dataRefrigCase->NumRefrigChillerSets > 0) {
   14778            1 :         print(state.files.eio, "#ZoneHVAC/Refrigeration Air Chiller Sets,{}\n", state.dataRefrigCase->NumRefrigChillerSets);
   14779           11 :         for (int ChillerSetNum = 1; ChillerSetNum <= state.dataRefrigCase->NumRefrigChillerSets; ++ChillerSetNum) {
   14780           10 :             print(state.files.eio,
   14781              :                   "ZoneHVAC/Refrigeration Air Chiller Set,{},{},{},{}\n",
   14782           10 :                   AirChillerSet(ChillerSetNum).Name,
   14783              :                   ChillerSetNum,
   14784           10 :                   AirChillerSet(ChillerSetNum).NumCoils,
   14785           10 :                   AirChillerSet(ChillerSetNum).ZoneName);
   14786              : 
   14787           93 :             for (int CoilNum = 1; CoilNum <= AirChillerSet(ChillerSetNum).NumCoils; ++CoilNum) {
   14788           83 :                 int CoilID = AirChillerSet(ChillerSetNum).CoilNum(CoilNum);
   14789           83 :                 print(state.files.eio,
   14790              :                       "   Refrigeration Air Chiller,{},{},{},{},{},{:.1R},{:.2R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R},{:.1R}\n",
   14791              :                       CoilID,
   14792           83 :                       WarehouseCoil(CoilID).Name,
   14793           83 :                       WarehouseCoil(CoilID).ZoneName,
   14794           83 :                       WarehouseCoil(CoilID).ZoneNodeNum,
   14795           83 :                       state.dataLoopNodes->NodeID(WarehouseCoil(CoilID).ZoneNodeNum),
   14796           83 :                       WarehouseCoil(CoilID).UnitLoadFactorSens,
   14797           83 :                       WarehouseCoil(CoilID).RatedSensibleCap,
   14798           83 :                       WarehouseCoil(CoilID).TEvapDesign,
   14799           83 :                       WarehouseCoil(CoilID).RatedTemperatureDif,
   14800           83 :                       WarehouseCoil(CoilID).RatedFanPower,
   14801           83 :                       WarehouseCoil(CoilID).HeaterPower,
   14802           83 :                       WarehouseCoil(CoilID).DefrostCapacity,
   14803           83 :                       WarehouseCoil(CoilID).RatedAirVolumeFlow);
   14804              :             } // numairchillers
   14805              :         } // DataHeatBalance::NumRefrigChillerSets
   14806              :     } // DataHeatBalance::NumRefrigChillerSets
   14807          801 : }
   14808              : 
   14809        56850 : void WalkInData::CalculateWalkIn(EnergyPlusData &state) // Absolute pointer to  Walk In
   14810              : {
   14811              : 
   14812              :     // SUBROUTINE INFORMATION:
   14813              :     //       AUTHOR         Therese Stovall, ORNL, May 2009
   14814              :     //       DATE WRITTEN   Oct/Nov 2004
   14815              :     //       MODIFIED       na
   14816              :     //       RE-ENGINEERED  na
   14817              : 
   14818              :     // PURPOSE OF THIS SUBROUTINE:
   14819              :     // To model Walk In Coolers.
   14820              : 
   14821              :     // METHODOLOGY EMPLOYED:
   14822              :     // Walk-in cooler performance is based on the ASHRAE load model, which includes
   14823              :     // infiltration through door openings and sensible loss through walls/ceilings identified
   14824              :     // by the user as sum of UA for each zone. A sub-floor heater is assumed to be sized so that
   14825              :     // the temperature of the slab beneath the floor insulation is the same as the ground
   14826              :     // temperature (to avoid ground freezing and heaving).
   14827              :     // All equipment loads (fan, light, heaters) are modeled as well.  Sensible and latent
   14828              :     // exchange with multiple adjoining zones is included. A master schedule is used for the Walk In operation and
   14829              :     // additional schedules control the lights, defrost, and heater operation.
   14830              : 
   14831              :     // The fan is assumed to be off for Hot-Gas, Hot-Brine, and Electric defrost. The user can choose
   14832              :     // to include the load due to bringing the coil mass up from the evaporating temperature to the melting temperature
   14833              :     //  if they choose.  Otherwise this factor is set to zero.
   14834              : 
   14835              :     // Unmet loads are accumulated to be met the following time step.  This usually occurs during defrost and
   14836              :     // restocking.
   14837              : 
   14838              :     // REFERENCES:
   14839              :     // ASHRAE 2006 Handbook, chapters 13 and 14.
   14840              :     // Gosney, W.B., Olama, G.A.-L., Heat and Enthalpy Gains through Cold Room Doorways,
   14841              :     //     Proceedings of the Institute of Refrigeration, vol. 72, pp 31-41, 1975
   14842              : 
   14843        56850 :     Real64 constexpr DefaultWalkInDoorOpenFactor(0.05); // walk in door open factor (fraction time open)
   14844              : 
   14845              :     static constexpr std::string_view RoutineName("CalculateWalkIn");
   14846        56850 :     Real64 CapApplied(0.0);          // Walk In total capacity at specific operating conditions
   14847        56850 :     Real64 DefrostSchedule(0.0);     // WalkIn defrost schedule, between 0 and 1
   14848        56850 :     Real64 DefrostEnergyNeeded(0.0); // Energy needed to melt all ice, used with temperature termination (J)
   14849        56850 :     Real64 DensityFactorFm(0.0);     // called Fm in ASHRAE 2010 eq 13 page 24.5 for door infiltration
   14850        56850 :     Real64 DensitySqRtFactor(0.0);   // from ASHRAE 2010 eq 12 page 24.4 for door infiltration
   14851              : 
   14852              :     // Current value of WalkIn operating (availability) schedule
   14853        56850 :     Real64 WalkInSchedule = this->availSched->getCurrentVal();
   14854        56850 :     if (WalkInSchedule <= 0) {
   14855            0 :         return;
   14856              :     }
   14857              :     // GET OTHER SCHEDULES
   14858        56850 :     DefrostSchedule = this->defrostSched->getCurrentVal();
   14859        56850 :     Real64 DefrostDripDownSchedule = this->defrostDripDownSched->getCurrentVal();
   14860              :     // next statement In case user doesn't understand concept of drip down schedule
   14861        56850 :     DefrostDripDownSchedule = max(DefrostDripDownSchedule, DefrostSchedule);
   14862              : 
   14863              :     // next four values optional, so set to default before checking for schedule
   14864        56850 :     Real64 StockingLoad = (this->stockingSched != nullptr) ? this->stockingSched->getCurrentVal() : 0.0;
   14865        56850 :     Real64 LightingSchedule = (this->lightingSched != nullptr) ? this->lightingSched->getCurrentVal() : 1.0;
   14866        56850 :     Real64 HeaterSchedule = (this->heaterSched != nullptr) ? this->heaterSched->getCurrentVal() : 1.0;
   14867        56850 :     Real64 CircFanSchedule = (this->circFanAvailSched != nullptr) ? this->circFanAvailSched->getCurrentVal() : 1.0;
   14868              : 
   14869              :     // Set local subroutine variables for convenience
   14870        56850 :     Real64 TWalkIn = this->Temperature; // WalkIn operating temperature (C)
   14871              : 
   14872              :     // Enthalpy of air corresponding to walk in temperature and 90% assumed RH (J/kg)
   14873        56850 :     Real64 EnthalpyAirWalkIn = Psychrometrics::PsyHFnTdbRhPb(state, TWalkIn, 0.9, state.dataEnvrn->OutBaroPress); // assume 90%RH in cooler
   14874              : 
   14875              :     // corresponds to walk in temp and 90% assumed RH(kg water/kg dry air)
   14876        56850 :     Real64 HumRatioAirWalkIn = Psychrometrics::PsyWFnTdbH(state, TWalkIn, EnthalpyAirWalkIn);
   14877        56850 :     Real64 DensityAirWalkIn = Psychrometrics::PsyRhoAirFnPbTdbW(state, state.dataEnvrn->OutBaroPress, TWalkIn, HumRatioAirWalkIn);
   14878        56850 :     Real64 Conv = state.dataEnvrn->Latitude * 2.0 * Constant::Pi / 360.0; // Convert DataEnvironment::Latitude to radians
   14879        56850 :     Real64 Gravity = 9.780373 * (1.0 + 0.0052891 * pow_2(std::sin(Conv)) - 0.0000059 * pow_2(std::sin(2.0 * Conv)));
   14880              : 
   14881              :     // CALCULATE ALL LOADS INFLUENCED BY ZONE TEMPERATURE AND RH
   14882              :     // set to zero before summing over zones
   14883        56850 :     Real64 SensibleLoadTotal(0.0); // Total sensible load on WalkIn over all zones (W)
   14884        56850 :     Real64 LatentLoadTotal(0.0);   // total latent load on WalkIn over all zones (W)
   14885        56850 :     Real64 ZoneLatentLoad(0.0);    // Latent WalkIn credit delivered to zone (W)
   14886              : 
   14887        56850 :     this->SensZoneCreditRate = 0.0;
   14888        56850 :     this->SensZoneCreditCoolRate = 0.0;
   14889        56850 :     this->SensZoneCreditCool = 0.0;
   14890        56850 :     this->SensZoneCreditHeatRate = 0.0;
   14891        56850 :     this->SensZoneCreditHeat = 0.0;
   14892        56850 :     this->LatZoneCreditRate = 0.0;
   14893              : 
   14894              :     // Start zone loop:
   14895       113700 :     for (int ZoneID = 1; ZoneID <= this->NumZones; ++ZoneID) {
   14896        56850 :         int zoneNum = this->ZoneNum(ZoneID);
   14897        56850 :         int zoneNodeNum = this->ZoneNodeNum(ZoneID);
   14898        56850 :         Real64 ZoneDryBulb = state.dataLoopNodes->Node(zoneNodeNum).Temp; // Dry Bulb Temperature of adjacent zone
   14899        56850 :         Real64 WalkInLatLoad = -ZoneLatentLoad;                           // Walk in cooler latent load facing particular zone (W)
   14900        56850 :         Real64 DelTemp = ZoneDryBulb - TWalkIn;                           // Difference between zone and walk in temperatures (C)
   14901        56850 :         Real64 StockDoorArea = this->AreaStockDr(ZoneID);
   14902        56850 :         Real64 GlassDoorArea = this->AreaGlassDr(ZoneID);                          // facing a particular zone (m2)
   14903        56850 :         Real64 UAOtherSurfaces = this->SurfaceArea(ZoneID) * this->UValue(ZoneID); // UA for non-door surfaces facing a certain zone (W/C)
   14904        56850 :         Real64 ZInfilSensLoad(0.0);                                                // Sensible load due to infiltration in one zone
   14905        56850 :         Real64 ZdoorSensLoad(0.0);                                                 // Sensible load due to UA delta T through closed door in one zone
   14906              : 
   14907              :         // Derate compared to fully developed flow through 100% open door
   14908        56850 :         Real64 DoorFlowFactor = 0.8; // see ASHRAE Refrigeration, p13.5, 2006
   14909        56850 :         if (DelTemp <= 11.0) {
   14910            2 :             DoorFlowFactor = 1.1; // from ASHRAE Refrigeration Loads
   14911              :         }
   14912              : 
   14913              :         // Get infiltration loads if either type of door is present in this zone
   14914        56850 :         if (StockDoorArea > 0.0 || GlassDoorArea > 0.0) {
   14915              :             // Zone relative humidity fraction (decimal)
   14916       227400 :             Real64 ZoneRHFrac = Psychrometrics::PsyRhFnTdbWPb(state,
   14917        56850 :                                                               state.dataLoopNodes->Node(zoneNodeNum).Temp,
   14918        56850 :                                                               state.dataLoopNodes->Node(zoneNodeNum).HumRat,
   14919        56850 :                                                               state.dataEnvrn->OutBaroPress,
   14920              :                                                               RoutineName);
   14921              :             // Enthalpy of the air in a particular zone (J/kg)
   14922        56850 :             Real64 EnthalpyZoneAir = Psychrometrics::PsyHFnTdbRhPb(state, ZoneDryBulb, ZoneRHFrac, state.dataEnvrn->OutBaroPress, RoutineName);
   14923        56850 :             Real64 HumRatioZoneAir = Psychrometrics::PsyWFnTdbH(state, ZoneDryBulb, EnthalpyZoneAir, RoutineName);
   14924              :             Real64 DensityZoneAir =
   14925        56850 :                 Psychrometrics::PsyRhoAirFnPbTdbW(state, state.dataEnvrn->OutBaroPress, ZoneDryBulb, HumRatioZoneAir, RoutineName);
   14926        56850 :             if (DensityZoneAir < DensityAirWalkIn) { // usual case when walk in is colder than zone
   14927        56850 :                 DensitySqRtFactor = std::sqrt(1.0 - DensityZoneAir / DensityAirWalkIn);
   14928        56850 :                 DensityFactorFm = std::pow(2.0 / (1.0 + std::pow(DensityAirWalkIn / DensityZoneAir, 0.333)), 1.5);
   14929              :             } else { // temperature inversion with zone colder and/or drier than walk-in, infiltration in reverse direction
   14930              :                 // The enthalpy difference will show whether the energy transport is reversed
   14931              :                 //(same air mass exchange in either direction )
   14932              :                 // That is, these factors establish the magnitude of the exchange air flow, not direction
   14933            0 :                 DensitySqRtFactor = std::sqrt(1.0 - DensityAirWalkIn / DensityZoneAir);
   14934            0 :                 DensityFactorFm = std::pow(2.0 / (1.0 + std::pow(DensityZoneAir / DensityAirWalkIn, 0.333)), 1.5);
   14935              :             } // check for density in zone and in walk-in to avoid taking sqrt of neg number
   14936              : 
   14937        56850 :             Real64 StockDoorInfLoad = 0.0;  // infiltration through stock doors in a particular zone (W)
   14938        56850 :             Real64 StockDoorSensHeat = 0.0; // sensible heat gain through stock doors (UA*delta T) (W)
   14939        56850 :             Real64 DoorProtectEff(0.0);     // Door protection effectiveness
   14940        56850 :             Real64 DrHeight(0.0);           // Door height (m)
   14941        56850 :             Real64 DrArea(0.0);             // Door area (m2)
   14942        56850 :             Real64 FullFlowInfLoad(0.0);    // Total load (lat + sens) due to 100% open doors w/ fully developed flow (W)
   14943              : 
   14944        56850 :             if (StockDoorArea > 0.0) {
   14945        56850 :                 std::array<Real64, (int)WIStockDoor::Num> doorProtectEffs = {0.0, 0.5, 0.9}; // Values from ASHRAE Ref p 13.6
   14946        56850 :                 DoorProtectEff = doorProtectEffs[(int)this->StockDoorProtectType(ZoneID)];
   14947        56850 :                 DrHeight = this->HeightStockDr(ZoneID);
   14948        56850 :                 DrArea = StockDoorArea;
   14949              :                 // if exists, get Stock Door Zone schedule
   14950        56850 :                 Real64 DoorOpenFactor = DefaultWalkInDoorOpenFactor;
   14951        56850 :                 if (this->stockDoorOpenScheds(ZoneID) != nullptr) {
   14952        56850 :                     DoorOpenFactor = this->stockDoorOpenScheds(ZoneID)->getCurrentVal();
   14953              :                 }
   14954              : 
   14955        56850 :                 FullFlowInfLoad = 0.221 * DrArea * (EnthalpyZoneAir - EnthalpyAirWalkIn) * DensityAirWalkIn * DensitySqRtFactor *
   14956        56850 :                                   std::sqrt(Gravity * DrHeight) * DensityFactorFm;
   14957        56850 :                 StockDoorInfLoad = FullFlowInfLoad * DoorOpenFactor * DoorFlowFactor * (1.0 - DoorProtectEff);
   14958        56850 :                 StockDoorSensHeat = DrArea * this->UValueStockDr(ZoneID) * DelTemp;
   14959              :             } // have stock doors
   14960              : 
   14961        56850 :             Real64 GlassDoorSensHeat(0.0); // sensible heat gain through glass reach-in doors (UA*delta T) (W)
   14962        56850 :             Real64 GlassDoorInfLoad = 0.0; // infiltration through glass reach-in doors in a particular zone (W)
   14963              : 
   14964        56850 :             if (GlassDoorArea > 0.0) {
   14965            0 :                 DoorProtectEff = 0.5; // Assume glass doors have air curtain
   14966            0 :                 DrHeight = this->HeightGlassDr(ZoneID);
   14967            0 :                 DrArea = GlassDoorArea;
   14968              :                 // get Glass Door Zone schedule
   14969            0 :                 Real64 DoorOpenFactor = DefaultWalkInDoorOpenFactor; // default value
   14970            0 :                 if (this->glassDoorOpenScheds(ZoneID) != nullptr) {
   14971            0 :                     DoorOpenFactor = this->glassDoorOpenScheds(ZoneID)->getCurrentVal();
   14972              :                 }
   14973              : 
   14974            0 :                 FullFlowInfLoad = 0.221 * DrArea * (EnthalpyZoneAir - EnthalpyAirWalkIn) * DensityAirWalkIn * DensitySqRtFactor *
   14975            0 :                                   std::sqrt(Gravity * DrHeight) * DensityFactorFm;
   14976            0 :                 GlassDoorInfLoad = FullFlowInfLoad * DoorOpenFactor * DoorFlowFactor * (1.0 - DoorProtectEff);
   14977            0 :                 GlassDoorSensHeat = DrArea * this->UValueGlassDr(ZoneID) * DelTemp;
   14978              :             } // have Glass doors
   14979              : 
   14980              :             // assume mass dry air infiltrating into walk-in == mass out into zone,
   14981              :             //                       that is, equal air exchange (ASHRAE 2006 Refrigeration)
   14982        56850 :             Real64 ZoneInfilLoad = -StockDoorInfLoad - GlassDoorInfLoad; // Walk in cooler infiltration load (sens + latent) in certain zone (W)
   14983        56850 :             Real64 MassDryAirRate =
   14984        56850 :                 -ZoneInfilLoad / (EnthalpyZoneAir - EnthalpyAirWalkIn); // Mass dry air infiltrating into/out-of walkin through doors (kg/s)
   14985        56850 :             Real64 WaterRemovRate =
   14986        56850 :                 MassDryAirRate * (HumRatioZoneAir - HumRatioAirWalkIn); // Walk in cooler removes water at this rate in this zone (kg/s)
   14987              :             // Just as with cases,  we assume no latent credit (water removal = 0) to zone or load on cooler during dripdown
   14988              :             // To be consistent with the treatment of refrigerated cases, latent load
   14989              :             //  and latent credit are both based on reducing the infiltrating vapor to ice.  (This is
   14990              :             //  slightly greater than if the latent credit were based upon condensing out the water as liquid.)
   14991              :             //  then it would be: ZoneLatentLoad = -WaterRemovRate * WaterToVaporEnthalpy * (1.0d0-DefrostDripDownSchedule)
   14992        56850 :             ZoneLatentLoad = -WaterRemovRate * IcetoVaporEnthalpy * (1.0 - DefrostDripDownSchedule);
   14993        56850 :             ZInfilSensLoad = ZoneInfilLoad - (-WaterRemovRate * IcetoVaporEnthalpy); // done to avoid moving latent to sens during dripdown
   14994        56850 :             ZdoorSensLoad = -GlassDoorSensHeat - StockDoorSensHeat;
   14995        56850 :             WalkInLatLoad = -ZoneLatentLoad;
   14996        56850 :             if (this->TEvapDesign <= 0.0) { // water turned to ice on coil
   14997        56850 :                 WalkInLatLoad = WaterRemovRate * IcetoVaporEnthalpy * (1.0 - DefrostDripDownSchedule);
   14998              :                 // FROST:  keep track of frost build up on evaporator coil
   14999              :                 //         avoid accumulation during warm-up to avoid reverse dd test problem
   15000        56850 :                 if (!state.dataGlobal->WarmupFlag) {
   15001         7776 :                     Real64 FrostChangekg = (WaterRemovRate * state.dataGlobal->TimeStepZoneSec) * (1.0 - DefrostDripDownSchedule);
   15002         7776 :                     this->KgFrost += FrostChangekg;
   15003              :                 }
   15004              :             } // water to ice
   15005              :         } // No doors
   15006              : 
   15007              :         // Sensible WalkIn credit delivered to a particular zone (W)
   15008        56850 :         Real64 ZoneSensLoad = ZInfilSensLoad + ZdoorSensLoad - UAOtherSurfaces * DelTemp;
   15009        56850 :         Real64 WalkInSensLoad = -ZoneSensLoad; // Walk in cooler sensible load facing particular zone (W)
   15010              : 
   15011              :         // Update globals for use in ZoneTemperaturePredictorCorrector (Air Heat Balance) and
   15012              :         //   Zone Equipment Manager. Sum walk-in credits to zone using existing 'casecredit' variable
   15013              :         //   No return air fractions are applied to walk-ins, and no latent in stocking -
   15014              : 
   15015        56850 :         state.dataHeatBal->RefrigCaseCredit(zoneNum).SenCaseCreditToZone += ZoneSensLoad;
   15016        56850 :         state.dataHeatBal->RefrigCaseCredit(zoneNum).LatCaseCreditToZone += ZoneLatentLoad;
   15017              : 
   15018              :         // Set up report variables for each zone for this walk-in
   15019              :         // Sensible heat exchange can be positive or negative, split into separate output variables and always report positive value
   15020        56850 :         this->SensZoneCreditRate(ZoneID) = ZoneSensLoad;
   15021        56850 :         if (ZoneSensLoad <= 0.0) {
   15022        56850 :             this->SensZoneCreditCoolRate(ZoneID) = -ZoneSensLoad;
   15023        56850 :             this->SensZoneCreditCool(ZoneID) = -ZoneSensLoad * state.dataGlobal->TimeStepZoneSec;
   15024        56850 :             this->SensZoneCreditHeatRate(ZoneID) = 0.0;
   15025        56850 :             this->SensZoneCreditHeat(ZoneID) = 0.0;
   15026              :         } else {
   15027            0 :             this->SensZoneCreditHeatRate(ZoneID) = ZoneSensLoad;
   15028            0 :             this->SensZoneCreditHeat(ZoneID) = ZoneSensLoad * state.dataGlobal->TimeStepZoneSec;
   15029            0 :             this->SensZoneCreditCoolRate(ZoneID) = 0.0;
   15030            0 :             this->SensZoneCreditCool(ZoneID) = 0.0;
   15031              :         }
   15032              :         // This rate should always be negative
   15033        56850 :         this->LatZoneCreditRate(ZoneID) = ZoneLatentLoad;
   15034        56850 :         this->LatZoneCredit(ZoneID) = ZoneLatentLoad * state.dataGlobal->TimeStepZoneSec;
   15035              : 
   15036              :         // Running total over all zones, use later to dispatch capacity
   15037        56850 :         SensibleLoadTotal += WalkInSensLoad;
   15038        56850 :         LatentLoadTotal += WalkInLatLoad;
   15039              : 
   15040              :     } // Do loop over zones for zone-condition-related sensible and latent loads
   15041              : 
   15042              :     // cooling coil fan power default is 375W, = 1/2 HP (Tyler showed 1/3 to 3/4 hp)
   15043              : 
   15044              :     // CALCULATE AUX LOADS DUE TO LIGHTS, FANS AND HEATERS
   15045        56850 :     Real64 LightLoad = this->DesignLighting * LightingSchedule; // Total lighting energy rate (W)
   15046              :     // turn coil fan off during defrost/drip - down period
   15047              : 
   15048              :     // Total fan energy rate (W)
   15049        56850 :     Real64 FanLoad = this->CircFanPower * CircFanSchedule + this->CoilFanPower * (1.0 - DefrostDripDownSchedule);
   15050        56850 :     Real64 HeaterLoad = this->HeaterPower * HeaterSchedule; // Total heater (except defrost) energy rate (W)
   15051              :     // Calculate floor load - using 'DataEnvironment::GroundTemp' assigned in weather manager (can be entered by user if desired)
   15052              :     //    Default value is 18C.
   15053              :     // Total floor energy rate (W)
   15054              :     Real64 FloorLoad =
   15055        56850 :         this->FloorArea * this->FloorUValue * (state.dataEnvrn->GroundTemp[(int)DataEnvironment::GroundTempType::BuildingSurface] - TWalkIn);
   15056              : 
   15057              :     Real64 DefrostLoad;
   15058              : 
   15059              :     // DEFROST CALCULATIONS
   15060        56850 :     if ((DefrostSchedule > 0.0) && (this->defrostType != DefrostType::None) && (this->defrostType != DefrostType::OffCycle)) {
   15061          616 :         DefrostLoad = this->DefrostCapacity * DefrostSchedule;                  // W
   15062          616 :         Real64 StartFrostKg = this->KgFrost;                                    // frost load at start of time step (kg of ice)
   15063          616 :         Real64 DefrostEnergy = DefrostLoad * state.dataGlobal->TimeStepZoneSec; // Joules
   15064          616 :         if (this->DefrostControlType == DefrostCtrlType::TempTerm) {
   15065              :             //  Need to turn defrost system off early if controlled by temperature and all ice melted
   15066              :             //  For temperature termination, need to recognize not all defrost heat goes to melt ice
   15067              :             //  Some goes to misc losses (for fluid defrost, some coil areas bare earlier than
   15068              :             //  others and xfer heat to environment)
   15069              :             //  Assume full ice melting satisfies temperature control.
   15070              :             //      (defaults for DefEnergyFraction are :=0.7 for elec, =0.3 for fluids)
   15071            0 :             Real64 AvailDefrostEnergy = this->DefEnergyFraction * DefrostEnergy; // Joules avail to melt ice
   15072            0 :             Real64 IceSensHeatNeeded = 0.0; // Energy to raise frost temperature to 0C, used w/ temp termination (J)
   15073            0 :             if (StartFrostKg > 0.0) {
   15074            0 :                 if (this->IceTemp < 0.0) {
   15075            0 :                     Real64 StartIceTemp = this->IceTemp;                                       // Frost temperature at start of time step [C]
   15076            0 :                     IceSensHeatNeeded = StartFrostKg * SpecificHeatIce * (0.0 - StartIceTemp); // Joules
   15077            0 :                     if (AvailDefrostEnergy >= IceSensHeatNeeded) {
   15078            0 :                         this->IceTemp = 0.0;
   15079            0 :                         AvailDefrostEnergy -= IceSensHeatNeeded; // Joules
   15080              :                     } else {                                     // DefrostEnergy < IceSensHeatNeeded
   15081            0 :                         this->IceTemp = StartIceTemp + AvailDefrostEnergy / (SpecificHeatIce * StartFrostKg);
   15082            0 :                         AvailDefrostEnergy = 0.0;
   15083              :                     } // AvailDefrostEnergy >= IceSensHeatNeeded
   15084              :                 } // IceTemp < 0,  need to raise temperature of ice
   15085              :                 // Reduce defrost heat load on walkin by amount of ice melted during time step
   15086            0 :                 Real64 FrostChangekg = min(AvailDefrostEnergy / IceMeltEnthalpy, StartFrostKg);
   15087            0 :                 if (FrostChangekg < StartFrostKg) {
   15088            0 :                     DefrostLoad -= FrostChangekg * IceMeltEnthalpy / state.dataGlobal->TimeStepZone / Constant::rSecsInHour;
   15089            0 :                     if (!state.dataGlobal->WarmupFlag) {
   15090            0 :                         this->KgFrost = StartFrostKg - FrostChangekg;
   15091              :                     }
   15092              :                     // DefrostSchedule not changed
   15093              :                 } else { // all frost melted during time step, so need to terminate defrost
   15094              :                     //  see Aug 8 page 3 notes
   15095            0 :                     this->KgFrost = 0.0;
   15096            0 :                     DefrostEnergyNeeded = (IceSensHeatNeeded + (FrostChangekg * IceMeltEnthalpy)) /
   15097            0 :                                           this->DefEnergyFraction; // Joules - energy needed including E unavail to melt ice
   15098            0 :                     DefrostSchedule = min(DefrostSchedule, (DefrostEnergyNeeded / (this->DefrostCapacity * state.dataGlobal->TimeStepZoneSec)));
   15099              :                     // reduce load on walkin by energy put into ice melting
   15100            0 :                     DefrostLoad = max(0.0,
   15101            0 :                                       (DefrostSchedule * this->DefrostCapacity -
   15102            0 :                                        (IceSensHeatNeeded + (FrostChangekg * IceMeltEnthalpy)) / state.dataGlobal->TimeStepZoneSec));
   15103            0 :                     this->IceTemp = this->TEvapDesign;
   15104              : 
   15105              :                 } // frost melted during time step less than amount of ice at start
   15106              :             } else { // no frost present so terminate defrost and reset ice temperature for start of next defrost
   15107            0 :                 DefrostLoad = 0.0;
   15108            0 :                 DefrostSchedule = 0.0;
   15109            0 :                 this->IceTemp = this->TEvapDesign;
   15110              :             } // have frost present
   15111              : 
   15112              :         } else { // Not temperature control type
   15113          616 :             Real64 FrostChangekg = min(DefrostEnergy / IceMeltEnthalpy, StartFrostKg);
   15114              :             // Reduce defrost heat load on walkin by amount of ice melted during time step
   15115          616 :             DefrostLoad -= FrostChangekg * IceMeltEnthalpy / state.dataGlobal->TimeStepZone / Constant::rSecsInHour;
   15116          616 :             if (!state.dataGlobal->WarmupFlag) {
   15117           88 :                 this->KgFrost = StartFrostKg - FrostChangekg;
   15118              :             }
   15119              :             // DefrostSchedule not changed
   15120              :         } // Temperature termination control type
   15121              : 
   15122          616 :     } else { // DefrostSchedule <= 0 or have None or OffCycle
   15123        56234 :         DefrostLoad = 0.0;
   15124              :     } // Defrost calculations
   15125              : 
   15126        56850 :     if (this->defrostType == DefrostType::Elec) {
   15127        39546 :         this->ElecDefrostConsumption = this->DefrostCapacity * DefrostSchedule * state.dataGlobal->TimeStepZoneSec;
   15128        39546 :         this->ElecDefrostPower = this->DefrostCapacity * DefrostSchedule;
   15129              :     } else {
   15130        17304 :         this->ElecDefrostConsumption = 0.0;
   15131        17304 :         this->ElecDefrostPower = 0.0;
   15132              :     }
   15133              : 
   15134              :     // If hot brine or hot gas is used for defrost, need to reduce condenser load by heat reclaimed for defrost
   15135        56850 :     if (this->defrostType == DefrostType::Fluid) {
   15136        17304 :         this->HotDefrostCondCredit = this->DefrostCapacity * DefrostSchedule;
   15137              :     }
   15138              : 
   15139              :     // loads reflects that walk ins continue to accumulate loads, even during defrost
   15140              :     // but cap is used to report portion met by active system while operating
   15141              : 
   15142              :     //*** See if capacity meets load and manage accumulated stored energy ***********************************
   15143        56850 :     SensibleLoadTotal += LightLoad + HeaterLoad + FanLoad + StockingLoad + DefrostLoad + FloorLoad;
   15144        56850 :     Real64 LoadTotal = SensibleLoadTotal + LatentLoadTotal; // total load in time step (W)
   15145              : 
   15146              :     // Account for difference between load and capacity. Assume rack or system able to provide
   15147              :     // rated capacity.  If it can't, that unmet energy will be stored and discharged at the system level.
   15148              :     //  Here we are calculating the load the walk-in cooler places on the refrigeration compressor systems.
   15149              :     //  Meet current load to the extent possible.  If extra capacity available,
   15150              :     //  apply it to previously unmet/stored loads.  If capacity less than current load,
   15151              :     //  (e.g. as it is during defrost cycles) save the unmet/stored load to be met in
   15152              :     //  succeeding time steps. This is an artificial way of recognizing that the internal
   15153              :     //  temperature will increase by a small amount during defrost and the system will have to
   15154              :     //  run full out until the temperature is brought back down.
   15155              : 
   15156              :     // Rate needed to serve all stored energy during single time step (W)
   15157        56850 :     Real64 StoredEnergyRate = this->StoredEnergy / state.dataGlobal->TimeStepZone / Constant::rSecsInHour;
   15158        56850 :     Real64 LoadRequested = LoadTotal + StoredEnergyRate; // Load necessary to meet current and all stored energy needs (W)
   15159              : 
   15160              :     Real64 LatentCapApplied;        // Walk In latent capacity at specific operating conditions
   15161        56850 :     Real64 SensibleCapApplied(0.0); // Walk In sensible capacity at specific operating conditions
   15162              : 
   15163              :     // prorate available cooling capacity for portion of time off due to drip down.
   15164        56850 :     Real64 MaxCap = this->DesignRatedCap * (1.0 - DefrostDripDownSchedule); // Design chilling capacity reduced according to drip-down schedule (W)
   15165              : 
   15166        56850 :     if (MaxCap >= LoadRequested) {
   15167              :         // Have more at least as much capacity available as needed, even counting stored energy
   15168        55816 :         CapApplied = LoadRequested;
   15169        55816 :         SensibleCapApplied = SensibleLoadTotal + StoredEnergyRate;
   15170        55816 :         LatentCapApplied = LatentLoadTotal;
   15171        55816 :         this->StoredEnergy = 0.0;
   15172              :     } else {
   15173              :         // Don't have as much capacity as needed (during dripdown or period following dripdown)
   15174         1034 :         CapApplied = MaxCap;
   15175         1034 :         LatentCapApplied = min(LatentLoadTotal, MaxCap); // Latent load should never be > capavail, but just in case...
   15176         1034 :         SensibleCapApplied = CapApplied - LatentCapApplied;
   15177         1034 :         if (!state.dataGlobal->WarmupFlag) {
   15178          266 :             this->StoredEnergy += (LoadTotal - MaxCap) * state.dataGlobal->TimeStepZoneSec;
   15179              :         }
   15180              :     } // CapAvail vs Load requested
   15181              : 
   15182              :     // ReportWalkIn( WalkInID)
   15183        56850 :     this->TotalCoolingLoad = CapApplied;
   15184        56850 :     this->TotalCoolingEnergy = CapApplied * state.dataGlobal->TimeStepZoneSec;
   15185        56850 :     this->TotSensCoolingEnergyRate = SensibleCapApplied;
   15186        56850 :     this->TotSensCoolingEnergy = SensibleCapApplied * state.dataGlobal->TimeStepZoneSec;
   15187        56850 :     this->TotLatCoolingEnergyRate = LatentCapApplied;
   15188        56850 :     this->TotLatCoolingEnergy = LatentCapApplied * state.dataGlobal->TimeStepZoneSec;
   15189              : 
   15190        56850 :     this->ElecFanPower = FanLoad;
   15191        56850 :     this->ElecFanConsumption = FanLoad * state.dataGlobal->TimeStepZoneSec;
   15192        56850 :     this->ElecHeaterPower = HeaterLoad;
   15193        56850 :     this->ElecHeaterConsumption = HeaterLoad * state.dataGlobal->TimeStepZoneSec;
   15194        56850 :     this->ElecLightingPower = LightLoad;
   15195        56850 :     this->ElecLightingConsumption = LightLoad * state.dataGlobal->TimeStepZoneSec;
   15196        56850 :     this->TotalElecPower = FanLoad + HeaterLoad + LightLoad + this->ElecDefrostPower;
   15197        56850 :     this->TotalElecConsumption = this->TotalElecPower * state.dataGlobal->TimeStepZoneSec;
   15198              : 
   15199              :     //**************************************************************************************************
   15200              :     // Cap Energy and Kg Frost to avoid floating overflow errors
   15201              :     // 1-time warning is issued. It should be rare but could happen with unrealistic inputs.
   15202        56850 :     if (this->StoredEnergy > MyLargeNumber) {
   15203            0 :         this->StoredEnergy = MyLargeNumber;
   15204            0 :         if (this->ShowUnmetWIEnergyWarning) {
   15205            0 :             ShowWarningError(state, format("Refrigeration:WalkIn: {}", this->Name));
   15206            0 :             ShowContinueError(state, " This walk-in cooler has insufficient capacity to meet the loads");
   15207            0 :             ShowContinueError(state,
   15208            0 :                               format("... Occurrence info = {}, {} {}",
   15209            0 :                                      state.dataEnvrn->EnvironmentName,
   15210            0 :                                      state.dataEnvrn->CurMnDy,
   15211            0 :                                      General::CreateSysTimeIntervalString(state)));
   15212            0 :             ShowContinueError(state, " Refer to documentation for further explanation of Total Cooling Capacity.");
   15213            0 :             this->ShowUnmetWIEnergyWarning = false;
   15214              :         } // ShowStoreEnergyWarning
   15215              :     } // stored energy > large number
   15216        56850 :     if (this->KgFrost > MyLargeNumber) {
   15217            0 :         this->KgFrost = MyLargeNumber;
   15218            0 :         if (this->ShowWIFrostWarning) {
   15219            0 :             ShowWarningError(state, format("Refrigeration:WalkIn: {}", this->Name));
   15220            0 :             ShowContinueError(state, " This walkin cooler has insufficient defrost capacity to remove the excess frost accumulation.");
   15221            0 :             ShowContinueError(state, " Check the defrost schedule or defrost capacity. ");
   15222            0 :             ShowContinueError(state,
   15223            0 :                               format("... Occurrence info = {}, {} {}",
   15224            0 :                                      state.dataEnvrn->EnvironmentName,
   15225            0 :                                      state.dataEnvrn->CurMnDy,
   15226            0 :                                      General::CreateSysTimeIntervalString(state)));
   15227            0 :             this->ShowWIFrostWarning = false;
   15228              :         }
   15229              :     }
   15230              : }
   15231              : 
   15232         4044 : void SecondaryLoopData::CalculateSecondary(EnergyPlusData &state, int const SecondaryNum)
   15233              : {
   15234              :     // SUBROUTINE INFORMATION:
   15235              :     //       AUTHOR         Therese Stovall, ORNL
   15236              :     //       DATE WRITTEN   Spring 2009
   15237              :     //       RE-ENGINEERED  na
   15238              : 
   15239              :     // PURPOSE OF THIS SUBROUTINE:
   15240              :     // Find the total cooling load, pump power, and needed primary refrigerant supply temperature
   15241              :     // for a secondary system.
   15242              : 
   15243              :     // METHODOLOGY EMPLOYED:
   15244              :     // Sum the loads for the cases and walk-ins supplied by a secondary loop.
   15245              :     // Calculate the pumping power.
   15246              :     // Assume that the fluid supply and return temperatures are fixed and the
   15247              :     // fluid flow rate is varied to meed the variable load.
   15248              :     // User has been told in IO and Eng ref: for secondary systems/pumps: pump energy is f(viscosity),
   15249              :     //        but since specifying Tcircfluid as steady
   15250              :     //        state in loop, specify power for fluid and system head/resistance at that temp
   15251              :     // ashrae 2006 p4.1 supports 78% eff for pump impellers
   15252              :     //  all power into heat because it would otherwise not be counted in zone
   15253              :     //  if use semihermetic motor, also need to add motor ineff as heat
   15254              : 
   15255              :     // REFERENCES:
   15256              :     // SCE report
   15257              :     //  others
   15258              : 
   15259         4044 :     Real64 constexpr ErrorTol(0.001); // Iterative solution tolerance
   15260              : 
   15261              :     bool AtPartLoad;          // Whether or not need to iterate on pump power
   15262              :     bool DeRate;              // If true, need to derate aircoils because don't carry over unmet energy
   15263              :     int Iter;                 // loop counter
   15264              :     Real64 CpBrine;           // Specific heat (W/kg)
   15265              :     Real64 DensityBrine;      // Density (kg/m3)
   15266              :     Real64 DiffTemp;          // (C)
   15267              :     Real64 distPipeHeatGain;  // Optional (W)
   15268              :     Real64 Error;             // Used in iterative soln for pumps needed to meet load (that has to include pump energy)
   15269              :     Real64 FlowVolNeeded;     // Flow rate needed to meet load (m3/s)
   15270              :     Real64 PartLdFrac;        // Used to ratio pump power
   15271              :     Real64 PartPumpFrac;      // Used to see if part pumps dispatched meets part pump load
   15272              :     Real64 PrevTotalLoad;     // Used in pump energy convergence test
   15273              :     Real64 RefrigerationLoad; // Load for cases and walk-ins served by loop, does not include pump energy (W)
   15274              :     Real64 StoredEnergyRate;  // Used to meet loads unmet in previous time step (related to defrost cycles
   15275              :     //     on cases/walk-ins served)(W)
   15276              :     Real64 TBrineIn;                  // Brine temperature going to heat exchanger, C
   15277              :     Real64 TotalHotDefrostCondCredit; // Used to credit condenser when heat reclaim used for hot gas/brine defrost (W)
   15278              :     Real64 TotalPumpPower;            // Total Pumping power for loop, W
   15279              :     Real64 TotalLoad;                 // Total Cooling Load on secondary loop, W
   15280         4044 :     Real64 TPipesReceiver(0.0);       // Temperature used for contents of pipes and/or receiver in calculating shell losses (C)
   15281              :     Real64 VarFrac;                   // Pump power fraction for variable speed pump, dimensionless
   15282              :     Real64 VolFlowRate;               // Used in dispatching pumps to meet load (m3/s)
   15283              : 
   15284         4044 :     auto &RefrigCase = state.dataRefrigCase->RefrigCase;
   15285         4044 :     auto &WalkIn = state.dataRefrigCase->WalkIn;
   15286         4044 :     auto &WarehouseCoil = state.dataRefrigCase->WarehouseCoil;
   15287              : 
   15288         4044 :     Real64 localTimeStep = (state.dataRefrigCase->UseSysTimeStep) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone;
   15289         4044 :     Real64 localTimeStepSec = localTimeStep * Constant::rSecsInHour;
   15290              : 
   15291         4044 :     switch (this->FluidType) {
   15292         2022 :     case SecFluidType::AlwaysLiquid: {
   15293         2022 :         CpBrine = this->CpBrineRated;
   15294         2022 :         DensityBrine = this->DensityBrineRated;
   15295         2022 :         TBrineIn = this->TBrineInRated;
   15296         2022 :         TPipesReceiver = this->TBrineAverage;
   15297         2022 :     } break;
   15298         2022 :     case SecFluidType::PhaseChange: {
   15299         2022 :         TPipesReceiver = this->TCondense;
   15300         2022 :     } break;
   15301            0 :     default:
   15302            0 :         break;
   15303              :     } // Fluid type
   15304              : 
   15305              :     // Initialize this secondary for this time step
   15306         4044 :     TotalPumpPower = 0.0;
   15307         4044 :     RefrigerationLoad = 0.0;
   15308         4044 :     TotalHotDefrostCondCredit = 0.0;
   15309         4044 :     FlowVolNeeded = 0.0;
   15310         4044 :     DeRate = false;
   15311              : 
   15312              :     // SCE page 28 gives a delta T for pipe heat gains
   15313              :     //         (.25F each for supply and discharge) for use with mdot*cp.
   15314              :     //          However, another author shows this as a major diff between dx and secondary
   15315              :     //          So - allow the user to include this in his total load, even though he has to do
   15316              :     //          most of the calculations before the input (to get to SumUADistPiping)).
   15317         4044 :     distPipeHeatGain = 0.0;
   15318         4044 :     if (this->SumUADistPiping > MySmallNumber) {
   15319         4044 :         int ZoneNodeNum = this->DistPipeZoneNodeNum;
   15320         4044 :         DiffTemp = state.dataLoopNodes->Node(ZoneNodeNum).Temp - TPipesReceiver;
   15321         4044 :         distPipeHeatGain = DiffTemp * this->SumUADistPiping;
   15322              :         // pipe heat load is a positive number (ie. heat absorbed by pipe, so needs to be subtracted
   15323              :         //     from refrigcasecredit (- for cooling zone, + for heating zone)
   15324         4044 :         this->DistPipeZoneHeatGain = -distPipeHeatGain;
   15325         4044 :         state.dataHeatBal->RefrigCaseCredit(this->DistPipeZoneNum).SenCaseCreditToZone -= distPipeHeatGain;
   15326              :     } // calc distribution piping heat gains
   15327              : 
   15328         4044 :     Real64 receiverHeatGain = 0.0;
   15329         4044 :     if (this->SumUAReceiver > MySmallNumber) {
   15330         2022 :         int ZoneNodeNum = this->ReceiverZoneNodeNum;
   15331         2022 :         DiffTemp = state.dataLoopNodes->Node(ZoneNodeNum).Temp - TPipesReceiver;
   15332         2022 :         receiverHeatGain = DiffTemp * this->SumUAReceiver;
   15333              :         // receiver heat load is a positive number (ie. heat absorbed by receiver, so needs to be subtracted
   15334              :         //     from refrigcasecredit (- for cooling zone, + for heating zone)
   15335         2022 :         this->ReceiverZoneHeatGain = -receiverHeatGain;
   15336         2022 :         state.dataHeatBal->RefrigCaseCredit(this->ReceiverZoneNum).SenCaseCreditToZone -= receiverHeatGain;
   15337              :     } // calc receiver heat gains
   15338              : 
   15339              :     // Sum up all the case and walk-in loads served by the secondary loop
   15340         4044 :     if (this->NumCases > 0) {
   15341        18198 :         for (int caseNum = 1; caseNum <= this->NumCases; ++caseNum) {
   15342        14154 :             int CaseID = this->CaseNum(caseNum);
   15343        14154 :             RefrigCase(CaseID).CalculateCase(state);
   15344              :             // increment TotalCoolingLoad Hot gas/brine defrost credits for each secondary loop
   15345        14154 :             RefrigerationLoad += RefrigCase(CaseID).TotalCoolingLoad;
   15346        14154 :             TotalHotDefrostCondCredit += RefrigCase(CaseID).HotDefrostCondCredit;
   15347              :         } // CaseNum
   15348              :     } // NumCases > 0
   15349         4044 :     if (this->NumWalkIns > 0) {
   15350         4044 :         for (int WalkInIndex = 1; WalkInIndex <= this->NumWalkIns; ++WalkInIndex) {
   15351         2022 :             int WalkInID = this->WalkInNum(WalkInIndex);
   15352         2022 :             WalkIn(WalkInID).CalculateWalkIn(state);
   15353              :             // increment TotalCoolingLoad for  each system
   15354         2022 :             RefrigerationLoad += WalkIn(WalkInID).TotalCoolingLoad;
   15355         2022 :             TotalHotDefrostCondCredit += WalkIn(WalkInID).HotDefrostCondCredit;
   15356              :         } // NumWalkIns systems
   15357              :     } // Secondary(SecondaryNum)%NumWalkIns > 0
   15358              : 
   15359         4044 :     if (this->NumCoils > 0) {
   15360            0 :         for (int CoilIndex = 1; CoilIndex <= this->NumCoils; ++CoilIndex) {
   15361            0 :             int CoilID = this->CoilNum(CoilIndex);
   15362              :             // already CALL CalculateCoil(CoilID) for each coil, dispatched in coilset order for each zone
   15363              :             // increment TotalCoolingLoad for each system
   15364              :             //  here will find out if secondary can serve total load, if not will derate coil output/case credits
   15365            0 :             RefrigerationLoad += WarehouseCoil(CoilID).TotalCoolingLoad;
   15366            0 :             TotalHotDefrostCondCredit += WarehouseCoil(CoilID).HotDefrostCondCredit;
   15367              :         } // NumCoils on secondary system
   15368              :     } // Secondary(SecondaryNum)%NumCoils > 0
   15369              : 
   15370         4044 :     TotalLoad = RefrigerationLoad + distPipeHeatGain + receiverHeatGain;
   15371         4044 :     AtPartLoad = true;
   15372              :     // Check to see if load is already >+ maxload without pump heat
   15373         4044 :     if (this->FluidType == SecFluidType::AlwaysLiquid) { //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
   15374         2022 :         FlowVolNeeded = TotalLoad / this->HeatExchangeEta / (CpBrine * DensityBrine * (TBrineIn - this->TEvapDesign));
   15375              :         // For brine/glycol systems, find flow volume needed to meet load
   15376              :         // Per ashrae 2006, p4.1, eval mass flow rate to pump at brine return (to chiller) temp
   15377              :         //   because pumps located in return piping
   15378         2022 :         if (FlowVolNeeded >= this->MaxVolFlow) {
   15379              :             // Don't need to iterate on pumps, just set to max.  Will have unmet load this time step (unless coils present)
   15380            4 :             VolFlowRate = this->MaxVolFlow;
   15381            4 :             TotalPumpPower = this->PumpTotRatedPower;
   15382            4 :             TotalLoad += TotalPumpPower * this->PumpPowerToHeat;
   15383            4 :             AtPartLoad = false;
   15384            4 :             if (this->NumCoils > 0) {
   15385            0 :                 DeRate = true;
   15386              :             }
   15387              :         } // flowvolneeded >= maxvolflow
   15388              :     } else { // have SecFluidTypePhaseChange !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
   15389         2022 :         if (TotalLoad >= this->MaxLoad) {
   15390            5 :             TotalPumpPower = this->PumpTotRatedPower;
   15391            5 :             TotalLoad += TotalPumpPower * this->PumpPowerToHeat;
   15392            5 :             VolFlowRate = this->MaxVolFlow;
   15393            5 :             AtPartLoad = false;
   15394            5 :             if (this->NumCoils > 0) {
   15395            0 :                 DeRate = true;
   15396              :             }
   15397              :         }
   15398              :     } // fluid type check for max load or max flow       >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
   15399              : 
   15400              :     // If totalLoad < maxload, then need to calculate partial pump load
   15401              :     // Need an iterative soln for pump energy needed to meet total load
   15402              :     //  because that total load has to include pump energy
   15403         4044 :     if (AtPartLoad) {
   15404         7287 :         for (Iter = 1; Iter <= 10; ++Iter) {
   15405         7287 :             if (TotalLoad <= 0.0) {
   15406              :                 // Load on secondary loop is zero (or negative).
   15407              :                 // Set volumetric flow rate and pump power to be zero.
   15408            0 :                 VolFlowRate = 0.0;
   15409            0 :                 TotalPumpPower = 0.0;
   15410            0 :                 break;
   15411              :             }
   15412         7287 :             PrevTotalLoad = TotalLoad;
   15413         7287 :             if (this->FluidType == SecFluidType::AlwaysLiquid) {
   15414         4113 :                 FlowVolNeeded = TotalLoad / this->HeatExchangeEta / (CpBrine * DensityBrine * (TBrineIn - this->TEvapDesign));
   15415         4113 :                 PartLdFrac = FlowVolNeeded / this->MaxVolFlow;
   15416              :             } else {
   15417         3174 :                 PartLdFrac = TotalLoad / this->MaxLoad;
   15418              :             }
   15419         7287 :             if (this->PumpControlType == SecPumpCtrl::Constant) {
   15420         4113 :                 VolFlowRate = 0.0;
   15421         4113 :                 TotalPumpPower = 0.0;
   15422        10022 :                 for (int PumpID = 1; PumpID <= this->NumPumps; ++PumpID) { // dispatch pumps to meet needed flow rate
   15423        10022 :                     if (this->FluidType == SecFluidType::AlwaysLiquid) {   //>>>>>>>>>>>>>>>>>>>>>
   15424        10022 :                         VolFlowRate += this->PumpIncrementFlowVol;
   15425        10022 :                         TotalPumpPower += this->PumpIncrementPower;
   15426        10022 :                         if (VolFlowRate >= FlowVolNeeded) {
   15427         4113 :                             break;
   15428              :                         }
   15429              :                     } else { // fluid type phase change >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
   15430            0 :                         VolFlowRate += this->PumpIncrementFlowVol;
   15431            0 :                         TotalPumpPower += this->PumpIncrementPower;
   15432            0 :                         PartPumpFrac = TotalPumpPower / this->PumpTotRatedPower;
   15433            0 :                         if (PartPumpFrac >= PartLdFrac) {
   15434            0 :                             break;
   15435              :                         }
   15436              :                     } // fluid type              >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
   15437              :                 } // Dispatching pumps until fluid flow need is met
   15438              :             } else { // pump type variable
   15439         3174 :                 VarFrac = max(0.1, Curve::CurveValue(state, this->VarSpeedCurvePtr, PartLdFrac));
   15440         3174 :                 TotalPumpPower = this->PumpTotRatedPower * VarFrac;
   15441         3174 :                 VolFlowRate = this->MaxVolFlow * PartLdFrac;
   15442              :             } // pump type
   15443              : 
   15444         7287 :             TotalLoad = RefrigerationLoad + distPipeHeatGain + receiverHeatGain + TotalPumpPower * this->PumpPowerToHeat;
   15445         7287 :             Error = std::abs((TotalLoad - PrevTotalLoad) / PrevTotalLoad);
   15446         7287 :             if (Error < ErrorTol) {
   15447         4035 :                 break;
   15448              :             }
   15449              :         } // end iteration on pump energy convergence
   15450              : 
   15451              :         //   IF (Iter >=10 .AND. .NOT. WarmupFlag)THEN
   15452              :         //     If( .not. WarmupFlag) Then
   15453              :         //      Write(OutputFileDebug,707)Month, DataGlobals::CurrentTime, Iter, TotalLoad, TotalPumpPower
   15454              :         //     End If
   15455              :         // 707 format(' in iter loop at 707: ',1x,I2,1x,F5.2,1x,I5,7(F10.5,1x))
   15456              :         //    END IF  !didn't converge
   15457              :     } //(AtPartLoad)
   15458              : 
   15459              :     // If only loads are cases and walk-ins, that is, no air coils:
   15460              :     //  Account for difference between load and capacity on secondary loop. Assume system able to provide
   15461              :     //  rated capacity.  If it can't, that unmet energy will be stored and discharged at the system level.
   15462              :     //  Meet current load to the extent possible.  If extra capacity available,
   15463              :     //  apply it to previously unmet/stored loads.  If capacity less than current load,
   15464              :     //  (e.g. as it may be following defrost cycles on cases or walk-ins served by secondary loop)
   15465              :     //  save the unmet/stored load to be met in succeeding time steps.
   15466         4044 :     if (this->NumCoils == 0) {
   15467         4044 :         StoredEnergyRate = max(0.0, (this->UnmetEnergy / state.dataGlobal->TimeStepZone / Constant::rSecsInHour));
   15468              :         // Load necessary to meet current and all stored energy needs (W)
   15469         4044 :         Real64 LoadRequested = TotalLoad + StoredEnergyRate;
   15470         4044 :         if (this->MaxLoad > LoadRequested) {
   15471              :             // Have at least as much capacity avail as needed, even counting stored energy
   15472         4030 :             this->TotalCoolingLoad = LoadRequested;
   15473         4030 :             RefrigerationLoad += StoredEnergyRate;
   15474         4030 :             this->UnmetEnergy = 0.0;
   15475              :         } else {
   15476              :             // Don't have as much capacity as needed (likely following defrost periods)
   15477           14 :             this->TotalCoolingLoad = this->MaxLoad;
   15478           14 :             RefrigerationLoad -= (TotalLoad - this->MaxLoad);
   15479           14 :             if (!state.dataGlobal->WarmupFlag) {
   15480           14 :                 this->UnmetEnergy += ((TotalLoad - this->MaxLoad) * state.dataGlobal->TimeStepZoneSec);
   15481              :             }
   15482              :         } // load requested greater than MaxLoad
   15483         4044 :         if (this->UnmetEnergy > MyLargeNumber) {
   15484            0 :             this->UnmetEnergy = MyLargeNumber;
   15485            0 :             if (state.dataRefrigCase->ShowUnmetSecondEnergyWarning(SecondaryNum)) {
   15486            0 :                 ShowWarningError(state, format("Secondary Refrigeration Loop: {}", this->Name));
   15487            0 :                 ShowContinueError(state, " This secondary system has insufficient capacity to meet the refrigeration loads.");
   15488            0 :                 state.dataRefrigCase->ShowUnmetSecondEnergyWarning(SecondaryNum) = false;
   15489              :             }
   15490              :         } //>my large number
   15491              : 
   15492              :     } else { // air coils on secondary loop, no "unmet" energy accounting, just reduce amount of cooling provided to zone by coils
   15493            0 :         DeRate = false;
   15494            0 :         if (TotalLoad > this->MaxLoad) {
   15495            0 :             DeRate = true;
   15496              :         }
   15497            0 :         FinalRateCoils(
   15498              :             state, DeRate, SourceType::SecondarySystem, SecondaryNum, TotalLoad, this->MaxLoad); // assign case credits for coils on this loop
   15499              :         // Bug TotalCoolingLoad not set but used below
   15500              :     } // no air coils on secondary loop
   15501         4044 :     this->PumpPowerTotal = TotalPumpPower;
   15502         4044 :     this->PumpElecEnergyTotal = TotalPumpPower * localTimeStepSec;
   15503         4044 :     this->TotalRefrigLoad = RefrigerationLoad;
   15504         4044 :     this->TotalRefrigEnergy = RefrigerationLoad * localTimeStepSec;
   15505         4044 :     this->TotalCoolingEnergy = TotalCoolingLoad * localTimeStepSec;
   15506         4044 :     this->FlowVolActual = VolFlowRate;
   15507         4044 :     this->HotDefrostCondCredit = TotalHotDefrostCondCredit;
   15508         4044 :     this->DistPipeHeatGain = distPipeHeatGain;
   15509         4044 :     this->DistPipeHeatGainEnergy = distPipeHeatGain * localTimeStepSec;
   15510         4044 :     this->ReceiverHeatGain = receiverHeatGain;
   15511         4044 :     this->ReceiverHeatGainEnergy = receiverHeatGain * localTimeStepSec;
   15512         4044 : }
   15513              : 
   15514       568465 : void SumZoneImpacts(EnergyPlusData &state)
   15515              : {
   15516              : 
   15517              :     // SUBROUTINE INFORMATION:
   15518              :     //       AUTHOR         Therese Stovall, ORNL
   15519              :     //       DATE WRITTEN   Spring 2010
   15520              :     //       RE-ENGINEERED  na
   15521              : 
   15522              :     // PURPOSE OF THIS SUBROUTINE:
   15523              :     // Find the total impact of all refrigeration systems on each zone.
   15524              : 
   15525              :     // METHODOLOGY EMPLOYED:
   15526              :     // Calculate the energy from refrigerated case credits arising from interaction between the zone and:
   15527              :     //   refrigerated cases and walk-ins
   15528              :     //   heat rejection from zone-located compressor-racks and zone-located air-cooled condensers
   15529              :     //   heat absorbed by suction piping, secondary loop distribution piping, and
   15530              :     //   secondary receiver shells
   15531              : 
   15532       568465 :     auto &CoilSysCredit = state.dataRefrigCase->CoilSysCredit;
   15533       568465 :     auto &CaseWIZoneReport = state.dataRefrigCase->CaseWIZoneReport;
   15534              : 
   15535       568465 :     if (state.dataRefrigCase->UseSysTimeStep) { // air chillers
   15536      5343825 :         for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) {
   15537      4987570 :             auto &credit = CoilSysCredit(ZoneNum);
   15538      4987570 :             credit.ReportH2ORemovedKgPerS_FromZoneRate = -credit.LatKgPerS_ToZoneRate;
   15539      4987570 :             credit.ReportLatCreditToZoneRate = -credit.LatCreditToZoneRate;
   15540      4987570 :             credit.ReportLatCreditToZoneEnergy = -credit.LatCreditToZoneEnergy;
   15541              :             // Sensible rate can be positive or negative, split into separate output variables and
   15542              :             //   always report positive value
   15543      4987570 :             if (credit.SenCreditToZoneRate <= 0.0) {
   15544      4588702 :                 credit.ReportSenCoolingToZoneRate = -credit.SenCreditToZoneRate;
   15545      4588702 :                 credit.ReportSenCoolingToZoneEnergy = -credit.SenCreditToZoneEnergy;
   15546      4588702 :                 credit.ReportHeatingToZoneRate = 0.0;
   15547      4588702 :                 credit.ReportHeatingToZoneEnergy = 0.0;
   15548              :             } else {
   15549       398868 :                 credit.ReportSenCoolingToZoneRate = 0.0;
   15550       398868 :                 credit.ReportSenCoolingToZoneEnergy = 0.0;
   15551       398868 :                 credit.ReportHeatingToZoneRate = credit.SenCreditToZoneRate;
   15552       398868 :                 credit.ReportHeatingToZoneEnergy = -credit.SenCreditToZoneEnergy;
   15553              :             }
   15554      4987570 :             credit.ReportTotCoolingToZoneRate = credit.ReportLatCreditToZoneRate + credit.ReportSenCoolingToZoneRate;
   15555      4987570 :             credit.ReportTotCoolingToZoneEnergy = credit.ReportLatCreditToZoneEnergy + credit.ReportSenCoolingToZoneEnergy;
   15556              :         }
   15557              :     } // UseSysTimeStep signals run for air chillers
   15558              : 
   15559              :     // Can arrive here when load call to refrigeration looks for cases/walkin systems and usetimestep is .FALSE.
   15560       780675 :     if ((!state.dataRefrigCase->UseSysTimeStep) &&
   15561       212210 :         ((state.dataRefrigCase->NumSimulationCases > 0) || (state.dataRefrigCase->NumSimulationWalkIns > 0))) {
   15562      5696574 :         for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) {
   15563      5484364 :             auto &report = CaseWIZoneReport(ZoneNum);
   15564      5484364 :             report.SenCaseCreditToZoneEnergy = state.dataHeatBal->RefrigCaseCredit(ZoneNum).SenCaseCreditToZone * state.dataGlobal->TimeStepZoneSec;
   15565              :             // Latent always negative
   15566      5484364 :             report.LatCoolingToZoneRate = -state.dataHeatBal->RefrigCaseCredit(ZoneNum).LatCaseCreditToZone;
   15567      5484364 :             report.LatCoolingToZoneEnergy = report.LatCoolingToZoneRate * state.dataGlobal->TimeStepZoneSec;
   15568              :             // Sensible rate can be positive or negative, split into separate output variables and
   15569              :             //   always report positive value
   15570      5484364 :             if (state.dataHeatBal->RefrigCaseCredit(ZoneNum).SenCaseCreditToZone <= 0.0) {
   15571      5422690 :                 report.SenCoolingToZoneRate = -state.dataHeatBal->RefrigCaseCredit(ZoneNum).SenCaseCreditToZone;
   15572      5422690 :                 report.SenCoolingToZoneEnergy = -state.dataHeatBal->RefrigCaseCredit(ZoneNum).SenCaseCreditToZone * state.dataGlobal->TimeStepZoneSec;
   15573      5422690 :                 report.HeatingToZoneRate = 0.0;
   15574      5422690 :                 report.HeatingToZoneEnergy = 0.0;
   15575              :             } else {
   15576        61674 :                 report.SenCoolingToZoneRate = 0.0;
   15577        61674 :                 report.SenCoolingToZoneEnergy = 0.0;
   15578        61674 :                 report.HeatingToZoneRate = state.dataHeatBal->RefrigCaseCredit(ZoneNum).SenCaseCreditToZone;
   15579        61674 :                 report.HeatingToZoneEnergy = state.dataHeatBal->RefrigCaseCredit(ZoneNum).SenCaseCreditToZone * state.dataGlobal->TimeStepZoneSec;
   15580              :             }
   15581      5484364 :             report.TotCoolingToZoneRate = report.SenCoolingToZoneRate + report.LatCoolingToZoneRate;
   15582      5484364 :             report.TotCoolingToZoneEnergy = report.SenCoolingToZoneEnergy + report.LatCoolingToZoneEnergy;
   15583      5484364 :             report.TotHtXferToZoneRate =
   15584      5484364 :                 state.dataHeatBal->RefrigCaseCredit(ZoneNum).SenCaseCreditToZone + state.dataHeatBal->RefrigCaseCredit(ZoneNum).LatCaseCreditToZone;
   15585      5484364 :             report.TotHtXferToZoneEnergy = report.TotHtXferToZoneRate * state.dataGlobal->TimeStepZoneSec;
   15586              :         } // over zones for cases and walkins
   15587              :     }
   15588       568465 : }
   15589              : 
   15590      3653619 : void CheckRefrigerationInput(EnergyPlusData &state)
   15591              : {
   15592              : 
   15593              :     // SUBROUTINE INFORMATION:
   15594              :     //       AUTHOR         Linda Lawrie
   15595              :     //       DATE WRITTEN   Sep 2010 - mining function
   15596              :     //       MODIFIED       na
   15597              :     //       RE-ENGINEERED  na
   15598              : 
   15599              :     // PURPOSE OF THIS SUBROUTINE:
   15600              :     // Provides the structure to get Refrigeration input so that
   15601              :     // it can be called from internally or outside the module.
   15602              : 
   15603      3653619 :     if (state.dataRefrigCase->GetRefrigerationInputFlag) {
   15604              : 
   15605          801 :         GetRefrigerationInput(state);
   15606          801 :         SetupReportInput(state);
   15607          801 :         state.dataRefrigCase->GetRefrigerationInputFlag = false;
   15608              : 
   15609          801 :         if ((!state.dataRefrigCase->HaveCasesOrWalkins) && (!state.dataRefrigCase->HaveChillers)) {
   15610          763 :             state.dataRefrigCase->ManageRefrigeration = false;
   15611          763 :             return;
   15612              :         }
   15613           38 :         if ((!state.dataRefrigCase->HaveDetailedRefrig) && (!state.dataRefrigCase->HaveRefrigRacks) &&
   15614            0 :             (!state.dataRefrigCase->HaveDetailedTransRefrig)) {
   15615            0 :             state.dataRefrigCase->ManageRefrigeration = false;
   15616            0 :             return;
   15617              :         }
   15618              :     } // GetRefrigerationInputFlag
   15619              : }
   15620              : 
   15621       356260 : void SimAirChillerSet(EnergyPlusData &state,
   15622              :                       std::string const &AirChillerSetName,
   15623              :                       int const ZoneNum,
   15624              :                       bool const FirstHVACIteration,
   15625              :                       Real64 &SysOutputProvided,
   15626              :                       Real64 &LatOutputProvided,
   15627              :                       int &AirChillerSetPtr // from ZoneEquipList(CurZoneEqNum)%EquipIndex(EquipPtr)
   15628              : )
   15629              : {
   15630              : 
   15631              :     // SUBROUTINE INFORMATION:
   15632              :     //       AUTHOR         Therese Stovall, ORNL
   15633              :     //       DATE WRITTEN   January 2011
   15634              :     //       MODIFIED       na
   15635              :     //       RE-ENGINEERED  na
   15636              : 
   15637              :     // PURPOSE OF THIS SUBROUTINE:
   15638              :     // Transfers the load requested from the zone to the refrigeration module.
   15639              :     // The load is met, partially met, or not met in the call to the detailed system solution
   15640              :     // METHODOLOGY EMPLOYED:
   15641              :     // Called from Zone Equipment Manager.
   15642              : 
   15643       356260 :     auto &AirChillerSet = state.dataRefrigCase->AirChillerSet;
   15644       356260 :     auto &CoilSysCredit = state.dataRefrigCase->CoilSysCredit;
   15645              : 
   15646              :     int ChillerSetID;
   15647              :     Real64 RemainingOutputToCoolingSP; // Remaining requested load in zone
   15648              : 
   15649       356260 :     CheckRefrigerationInput(state);
   15650              : 
   15651              :     // Find the correct Chiller set
   15652       356260 :     if (AirChillerSetPtr == 0) {
   15653           10 :         ChillerSetID = Util::FindItemInList(AirChillerSetName, AirChillerSet);
   15654           10 :         if (ChillerSetID == 0) {
   15655            0 :             ShowFatalError(state, format("SimAirChillerSet: Unit not found={}", AirChillerSetName));
   15656              :         } // chillersetid ==0 because not in list
   15657           10 :         AirChillerSetPtr = ChillerSetID;
   15658              :     } else { // airchllersetpointer passed in call to subroutine not ==0
   15659       356250 :         ChillerSetID = AirChillerSetPtr;
   15660       356250 :         if (ChillerSetID > state.dataRefrigCase->NumRefrigChillerSets || ChillerSetID < 1) {
   15661            0 :             ShowFatalError(state,
   15662            0 :                            format("SimAirChillerSet:  Invalid AirChillerSetPtr passed={}, Number of Units={}, Entered Unit name={}",
   15663              :                                   ChillerSetID,
   15664            0 :                                   state.dataRefrigCase->NumRefrigChillerSets,
   15665              :                                   AirChillerSetName));
   15666              :         } // ChillerSetID makes no sense
   15667       356250 :         if (state.dataRefrigCase->CheckChillerSetName(ChillerSetID)) {
   15668           10 :             if (AirChillerSetName != AirChillerSet(ChillerSetID).Name) {
   15669            0 :                 ShowFatalError(state,
   15670            0 :                                format("SimAirChillerSet:  Invalid AirChillerSetPtr passed={}, Unit name={}, stored Unit Name for that index={}",
   15671              :                                       ChillerSetID,
   15672              :                                       AirChillerSetName,
   15673            0 :                                       AirChillerSet(ChillerSetID).Name));
   15674              :             } // name not equal correct name
   15675           10 :             state.dataRefrigCase->CheckChillerSetName(ChillerSetID) = false;
   15676              :         } // CheckChillerSetName logical test
   15677              :     } //(AirChillerSetPtr == 0 or else not == 0
   15678              : 
   15679       356260 :     if (FirstHVACIteration) {
   15680      1959760 :         for (ChillerSetID = 1; ChillerSetID <= state.dataRefrigCase->NumRefrigChillerSets;
   15681              :              ++ChillerSetID) { // bbb what point of do loop, only set one (airchillersetptr) to zero
   15682      1781600 :             AirChillerSet(AirChillerSetPtr).QZnReqSens = 0.0;
   15683              :         }
   15684              :     } // FirstHVACIteration
   15685              : 
   15686       356260 :     RemainingOutputToCoolingSP = state.dataZoneEnergyDemand->ZoneSysEnergyDemand(ZoneNum).RemainingOutputReqToCoolSP;
   15687              :     // RemainingOutputToCoolingSP in Watts, < 0 for cooling demand
   15688              : 
   15689       356260 :     if (RemainingOutputToCoolingSP < 0.0 && state.dataHeatBalFanSys->TempControlType(ZoneNum) != HVAC::SetptType::SingleHeat) {
   15690       291453 :         AirChillerSet(AirChillerSetPtr).QZnReqSens = RemainingOutputToCoolingSP;
   15691              :     } else {
   15692        64807 :         AirChillerSet(AirChillerSetPtr).QZnReqSens = 0.0;
   15693              :     }
   15694              : 
   15695       356260 :     state.dataRefrigCase->UseSysTimeStep = true;
   15696              : 
   15697       356260 :     ManageRefrigeratedCaseRacks(state);
   15698              : 
   15699       356260 :     state.dataRefrigCase->UseSysTimeStep = false;
   15700              : 
   15701              :     // Return values to Zone Equipment Manager.
   15702       356260 :     LatOutputProvided = CoilSysCredit(ZoneNum).LatKgPerS_ToZoneRate;
   15703       356260 :     SysOutputProvided = CoilSysCredit(ZoneNum).SenCreditToZoneRate;
   15704       356260 : }
   15705              : 
   15706      3562550 : void AirChillerSetData::CalculateAirChillerSets(EnergyPlusData &state)
   15707              : {
   15708              : 
   15709              :     // SUBROUTINE INFORMATION:
   15710              :     //       AUTHOR         Therese Stovall, ORNL
   15711              :     //       DATE WRITTEN   January 2011
   15712              :     //       MODIFIED       na
   15713              :     //       RE-ENGINEERED  na
   15714              : 
   15715              :     // PURPOSE OF THIS SUBROUTINE:
   15716              :     // Transfers the load requested from the zone to the refrigeration module.
   15717              :     // The load is met, partially met, or not met in the next time step when the refrigerated case
   15718              :     // module is called via case credits. Therefore, by definition, the sensible and latent
   15719              :     // output provided are zero.
   15720              :     // METHODOLOGY EMPLOYED:
   15721              :     // Called from Zone Equipment Manager.
   15722              :     //       have however done the variable definitions for in and out.
   15723              : 
   15724      3562550 :     Real64 AirChillerSetSchedule = 0.0; // Schedule value for air chiller SET
   15725      3562550 :     Real64 QZNReqSens = 0.0;            // Amount of sensible heat needed by the zone, NEGATIVE when cooling needed [W]
   15726      3562550 :     Real64 RemainQZNReqSens = 0.0;      // Remaining amount of sensible heat needed by the zone [W]
   15727              : 
   15728      3562550 :     auto &WarehouseCoil = state.dataRefrigCase->WarehouseCoil;
   15729              : 
   15730              :     // Note, all coils in a coil set are in the same zone
   15731              :     // the coils may be served by different detailed systems
   15732              :     // The coils are dispatched to meet the load specified in the previous time step in order listed in coilset object
   15733      3562550 :     AirChillerSetSchedule = this->availSched->getCurrentVal();
   15734              : 
   15735      3562550 :     if (AirChillerSetSchedule <= 0.0) {
   15736            0 :         return;
   15737              :     }
   15738      3562550 :     QZNReqSens = this->QZnReqSens;
   15739      3562550 :     RemainQZNReqSens = QZNReqSens;
   15740              : 
   15741     33131715 :     for (int CoilIndex = 1; CoilIndex <= this->NumCoils; ++CoilIndex) {
   15742     29569165 :         int CoilID = this->CoilNum(CoilIndex);
   15743              : 
   15744     29569165 :         WarehouseCoil(CoilID).CalculateCoil(state, RemainQZNReqSens);
   15745     29569165 :         RemainQZNReqSens += WarehouseCoil(CoilID).SensCreditRate;
   15746              :         // should be a negative minus a negative, so a smaller negative, that is, going toward zero, but senscoolingenergyrate expressed as
   15747              :         // positive  Need to go over all the coils so that the defrosts occur on schedule, even when the chiller isn't called for at that
   15748              :         // particular time step  IF(RemainQZNReqSens >=0.0d0)EXIT  !shouldn't be > 0 because limited by request in calculatecoil
   15749     29569165 :         if (RemainQZNReqSens > 0.0) {
   15750      3690542 :             RemainQZNReqSens = 0.0;
   15751              :         }
   15752              :     } // CoilIndex
   15753              : }
   15754              : 
   15755        90934 : void FinalRateCoils(EnergyPlusData &state,
   15756              :                     bool const DeRate,                 // True if compressor rack or secondary ht exchanger unable to provide capacity
   15757              :                     SourceType const SystemSourceType, // Secondarysystem or DetailedSystem
   15758              :                     int const SystemID,                // ID for Secondary loop or detailed system calling for derate
   15759              :                     Real64 const InitialTotalLoad,     // Load on system or secondary loop as initially calculated [W]
   15760              :                     Real64 const AvailableTotalLoad    // Load that system or secondary loop is able to serve [W]
   15761              : )
   15762              : {
   15763              : 
   15764              :     // SUBROUTINE INFORMATION:
   15765              :     //       AUTHOR         Therese Stovall, ORNL
   15766              :     //       DATE WRITTEN   January 2011
   15767              :     //       MODIFIED       na
   15768              :     //       RE-ENGINEERED  na
   15769              : 
   15770              :     // PURPOSE OF THIS SUBROUTINE:
   15771              :     // When compressor system, or secondary loop capacity is insufficient to meet coil loads
   15772              :     //   Come back here and derate the coil case credits to show unmet load impact
   15773              :     //   Note that the coil fan, heater, and defrost would be unaffected because they
   15774              :     //   would still be running at level calculated previously
   15775              : 
   15776        90934 :     auto &System = state.dataRefrigCase->System;
   15777        90934 :     auto &WarehouseCoil = state.dataRefrigCase->WarehouseCoil;
   15778              : 
   15779        90934 :     int NumCoils = 0;
   15780        90934 :     Real64 DeRateFactor = 0.0;        // Ratio of energy available from system or secondary loop
   15781        90934 :     Real64 InitLatCreditEnergy = 0.0; // Latent credit energy before derate [W]
   15782        90934 :     Real64 FrostReduction = 0.0;      // Change in frost on coils based on derated latent load [kg]
   15783              : 
   15784              :     {
   15785        90934 :         switch (SystemSourceType) {
   15786        90934 :         case SourceType::DetailedSystem:
   15787        90934 :             NumCoils = System(SystemID).NumCoils;
   15788        90934 :             break;
   15789            0 :         case SourceType::SecondarySystem:
   15790            0 :             NumCoils = state.dataRefrigCase->Secondary(SystemID).NumCoils;
   15791            0 :             break;
   15792            0 :         default:
   15793            0 :             assert(false);
   15794              :         }
   15795              :     } // DeRateCoils
   15796              : 
   15797        90934 :     if (DeRate) {
   15798       636538 :         ShowRecurringWarningErrorAtEnd(
   15799              :             state,
   15800       181868 :             "Refrigeration:System chilling WarehouseCoils " + System(SystemID).Name +
   15801              :                 " - Refrigeration system unable to meet load of warehouse coils chilled by system ... continues by derating coil load",
   15802        90934 :             System(SystemID).InsuffCapWarn);
   15803              : 
   15804        90934 :         DeRateFactor = AvailableTotalLoad / InitialTotalLoad;
   15805        90934 :         Real64 const time_step_sec(state.dataHVACGlobal->TimeStepSysSec);
   15806      1127963 :         for (int CoilIndex = 1; CoilIndex <= NumCoils; ++CoilIndex) {
   15807      1037029 :             int CoilID = System(SystemID).CoilNum(CoilIndex);
   15808      1037029 :             auto &warehouse_coil = WarehouseCoil(CoilID);
   15809              : 
   15810              :             // need to adjust ice on coil due to reduction in latent load met by coil
   15811      1037029 :             InitLatCreditEnergy = warehouse_coil.LatCreditEnergy;
   15812              : 
   15813      1037029 :             warehouse_coil.TotalCoolingLoad *= DeRateFactor;
   15814      1037029 :             warehouse_coil.TotalCoolingEnergy *= DeRateFactor;
   15815      1037029 :             warehouse_coil.SensCoolingEnergyRate *= DeRateFactor;
   15816      1037029 :             warehouse_coil.SensCoolingEnergy *= DeRateFactor;
   15817      1037029 :             warehouse_coil.LatCreditRate *= DeRateFactor;
   15818      1037029 :             warehouse_coil.LatCreditEnergy *= DeRateFactor;
   15819      1037029 :             warehouse_coil.LatKgPerS_ToZone *= DeRateFactor;
   15820      1037029 :             warehouse_coil.SensCreditRate = warehouse_coil.SensCoolingEnergyRate - warehouse_coil.ElecFanPower - warehouse_coil.ElecHeaterPower -
   15821      1037029 :                                             warehouse_coil.ThermalDefrostPower;
   15822      1037029 :             warehouse_coil.SensCreditEnergy = warehouse_coil.SensCreditRate * time_step_sec;
   15823              : 
   15824      1037029 :             FrostReduction = (InitLatCreditEnergy - warehouse_coil.LatCreditEnergy) / IcetoVaporEnthalpy;
   15825      1037029 :             warehouse_coil.KgFrost = max(0.0, warehouse_coil.KgFrost - FrostReduction);
   15826              : 
   15827      1037029 :             if (warehouse_coil.SensCreditRate >= 0.0) {
   15828       825527 :                 warehouse_coil.ReportSensCoolCreditRate = warehouse_coil.SensCreditRate;
   15829       825527 :                 warehouse_coil.ReportHeatingCreditRate = 0.0;
   15830              :             } else {
   15831       211502 :                 warehouse_coil.ReportSensCoolCreditRate = 0.0;
   15832       211502 :                 warehouse_coil.ReportHeatingCreditRate = -warehouse_coil.SensCreditRate;
   15833              :             }
   15834      1037029 :             warehouse_coil.ReportSensCoolCreditEnergy = warehouse_coil.ReportSensCoolCreditRate * time_step_sec;
   15835      1037029 :             warehouse_coil.ReportHeatingCreditEnergy = warehouse_coil.ReportHeatingCreditRate * time_step_sec;
   15836      1037029 :             warehouse_coil.ReportTotalCoolCreditRate = warehouse_coil.ReportSensCoolCreditRate + warehouse_coil.LatCreditRate;
   15837      1037029 :             warehouse_coil.ReportTotalCoolCreditEnergy = warehouse_coil.ReportSensCoolCreditEnergy + warehouse_coil.LatCreditEnergy;
   15838              :         }
   15839              :     } // DeRate == true
   15840        90934 : }
   15841              : 
   15842     29569165 : void WarehouseCoilData::CalculateCoil(EnergyPlusData &state, Real64 const QZnReq)
   15843              : {
   15844              : 
   15845              :     // SUBROUTINE INFORMATION:
   15846              :     //       AUTHOR         Therese Stovall, ORNL
   15847              :     //       DATE WRITTEN   January 2011
   15848              :     //       MODIFIED       na
   15849              :     //       RE-ENGINEERED  na
   15850              : 
   15851              :     // PURPOSE OF THIS SUBROUTINE:
   15852              :     // Simulates the refrigerated warehouse coil object.
   15853              :     // Note QZnReq < 0 corresponds to cooling needed
   15854              : 
   15855              :     // METHODOLOGY EMPLOYED:
   15856              :     // Called from Calculate Air Chiller Set.
   15857              :     // Air chillers are used to model the type of equipment typically used in
   15858              :     // refrigerated warehouses. For that reason, there is a major difference
   15859              :     // between the air chiller model and those for refrigerated cases or walk-ins.
   15860              :     // For cases and walk-ins, a portion of the model is directed toward
   15861              :     // calculating the amount of refrigeration needed to maintain the refrigerated
   15862              :     // volume at the desired temperature due to heat exchange with the surrounding
   15863              :     // zone, and that zone is conditioned to a nearly constant temperature.
   15864              :     // In a refrigerated warehouse, the refrigeration load is caused by heat exchange
   15865              :     // with a variable external environment.  For that reason, the loads for these
   15866              :     // zones are calculated by the usual EnergyPlus zone heat balance.
   15867              :     // The amount of refrigeration needed to maintain the specified temperature
   15868              :     // setpoints is then passed to the air chiller model, in a similar fashion
   15869              :     // to the load passed to a window air conditioner model. The air chillers
   15870              :     // are therefore solved using the system time step, not the zone time step
   15871              :     // used for cases and walk-ins.
   15872              :     // The air chiller performance is based on three types of manufacturers ratings,
   15873              :     // Unit Load Factor, Total Capacity Map, or a set of European standards.
   15874              :     // Correction factors for material and refrigerant are applied to all of these ratings.
   15875              : 
   15876              :     static constexpr std::string_view TrackMessage("from RefrigeratedCase:CalculateCoil");
   15877              : 
   15878     29569165 :     Real64 CoilSchedule = this->availSched->getCurrentVal(); // Current value of Coil operating (availability) schedule
   15879     29569165 :     if (CoilSchedule <= 0.0) {
   15880      7891456 :         return;
   15881              :     }
   15882              : 
   15883     21677709 :     Real64 DefrostSchedule = this->defrostSched->getCurrentVal();                 // Coil defrost schedule, between 0 and 1
   15884     21677709 :     Real64 DefrostDripDownSchedule = this->defrostDripDownSched->getCurrentVal(); // Coil drip-down schedule (allows coil to drain after defrost)
   15885              :     // next statement In case user doesn't understand concept of drip down schedule
   15886     21677709 :     DefrostDripDownSchedule = max(DefrostDripDownSchedule, DefrostSchedule);
   15887              :     // next value optional, so set to default before checking for schedule
   15888     21677709 :     Real64 HeaterSchedule = 1.0; // zero to one
   15889     21677709 :     if (this->heaterAvailSched != nullptr) {
   15890     21677709 :         HeaterSchedule = this->heaterAvailSched->getCurrentVal();
   15891              :     }
   15892              : 
   15893              :     // Set local subroutine variables for convenience
   15894     21677709 :     FanSpeedCtrlType FanSpeedControlType = this->FanType;
   15895     21677709 :     Real64 AirVolumeFlowRated = this->RatedAirVolumeFlow;   // Coil rated air flow (m3/s)
   15896     21677709 :     Real64 FanPowerRated = this->RatedFanPower;             // (W)
   15897     21677709 :     Real64 HeaterLoad = this->HeaterPower * HeaterSchedule; // Total heater (except defrost) energy rate (W)
   15898     21677709 :     Real64 DefrostCap = this->DefrostCapacity;              // Design defrost capacity of Coil (W)
   15899     21677709 :     Real64 TEvap = this->TEvapDesign;                       // Evaporating temperature in the coil (C)
   15900              : 
   15901     21677709 :     Real64 CoilCapTotEstimate(0.0); // Part of loop to solve for total coil capacity as a function of inlet air conditions (W)
   15902     21677709 :     Real64 AirVolumeFlowMax(0.0);   // Coil air flow limited by drip down schedule (m3/s)
   15903     21677709 :     Real64 CoilCapTotal(0.0);       // Sensible plus latent load (W)
   15904     21677709 :     Real64 CoilInletDensity(0.0);   // Coil air inlet density (kg/m3)
   15905     21677709 :     Real64 CoilInletDryAirCp(0.0);  // Dry air specific heat at coil inlet temperature (J/kg-C)
   15906     21677709 :     Real64 CoilInletHumRatio(0.0);  // Coil air inlet humidity ratio (kg water/kg air)
   15907     21677709 :     Real64 CoilInletTemp(0.0);      // Inlet temperature of air to coil, not mixed zone temperature unless "middle" location selected (C)
   15908     21677709 :     Real64 CoilInletEnthalpy(0.0);  // Coil inlet air enthalpy (J/kg)
   15909     21677709 :     Real64 CoilInletRHFrac(0.0);    // Coil inlet air relative humidity expressed as a fraction (0 to 1)
   15910     21677709 :     Real64 DefrostLoad(0.0);
   15911     21677709 :     Real64 DryAirMassFlowMax(0.0);      // Rated volume flow rate times dry air density adjusted for schedules (kg/s)
   15912     21677709 :     Real64 FanPowerActual(0.0);         // (W)
   15913     21677709 :     Real64 FrostChangekg(0.0);          // Amount of frost added or melted  (kg)
   15914     21677709 :     Real64 latLoadServed(0.0);          // Energy rate used to remove water from zone air (W)
   15915     21677709 :     Real64 SensLoadRequestedGross(0.0); // Gross sensible load removed by coil
   15916     21677709 :     Real64 SensLoadGross(0.0);          // Sensible load met by coil (W)
   15917     21677709 :     Real64 SHR(0.0);                    // Sensible heat ratio, sensible load/total load
   15918     21677709 :     Real64 SHRCorrection(0.0);          // Actual total/sensible load, NOT = Inverse SHR (unless coil efficiency = 1.0)
   15919     21677709 :     Real64 WaterRemovRate(0.0);         // Walk in cooler removes water at this rate in this zone (kg/s)
   15920              : 
   15921     21677709 :     if (DefrostDripDownSchedule == 1.0) {
   15922      2261960 :         AirVolumeFlowMax = 0.0;
   15923      2261960 :         DryAirMassFlowMax = 0.0;
   15924              :     } else { // DefrostDripDownSchedule < 1.0d0, cooling will occur at least part of the time step
   15925              :         // Sensible load requested by zone balance (W)
   15926     19415749 :         Real64 SensLoadRequested = -QZnReq; // here let cooling demand be positive within subroutine
   15927     19415749 :         if (SensLoadRequested <= 0.0) {     // No load so assume control keeps off, except that scheduled defrost still occurs
   15928      9889889 :             AirVolumeFlowMax = 0.0;
   15929      9889889 :             DryAirMassFlowMax = 0.0;
   15930              :         } else {
   15931      9525860 :             SensLoadRequestedGross = SensLoadRequested + HeaterLoad + FanPowerRated;
   15932      9525860 :             Real64 ZoneMixedAirDryBulb = state.dataLoopNodes->Node(this->ZoneNodeNum).Temp;    // (C)
   15933      9525860 :             Real64 ZoneMixedAirHumRatio = state.dataLoopNodes->Node(this->ZoneNodeNum).HumRat; // kg water/kg air in the zone mixed air
   15934              :             Real64 ZoneMixedAirRHFrac =
   15935      9525860 :                 Psychrometrics::PsyRhFnTdbWPb(state, ZoneMixedAirDryBulb, ZoneMixedAirHumRatio, state.dataEnvrn->OutBaroPress, TrackMessage);
   15936              :             Real64 ZoneMixedAirEnthalpy =
   15937      9525860 :                 Psychrometrics::PsyHFnTdbRhPb(state, ZoneMixedAirDryBulb, ZoneMixedAirRHFrac, state.dataEnvrn->OutBaroPress, TrackMessage);
   15938              :             Real64 ZoneMixedAirDensity =
   15939      9525860 :                 Psychrometrics::PsyRhoAirFnPbTdbW(state, state.dataEnvrn->OutBaroPress, ZoneMixedAirDryBulb, ZoneMixedAirHumRatio, TrackMessage);
   15940              :             Real64 ZoneDryAirDensity =
   15941      9525860 :                 Psychrometrics::PsyRhoAirFnPbTdbW(state, state.dataEnvrn->OutBaroPress, ZoneMixedAirDryBulb, 0.0, TrackMessage);
   15942      9525860 :             Real64 DryAirMassFlowRated = AirVolumeFlowRated * ZoneDryAirDensity;
   15943              :             // calc t inlet to coil assuming at middle/mixed point in room  bbb -
   15944              :             //    later need to do for hottest/coolest in room where Tin /= Tzonemixed
   15945              :             // calc RH inlet to coil assuming at middle/mixed point in room
   15946              :             // calc coilcap, sens and latent, available as f(inlet T,RH)
   15947      9525860 :             switch (this->VerticalLocation) {
   15948      9525860 :             case VerticalLoc::Floor:
   15949              :                 // purposely fall through
   15950              :             case VerticalLoc::Ceiling:
   15951              :                 // purposely fall through
   15952              :             case VerticalLoc::Middle:
   15953      9525860 :                 CoilInletTemp = ZoneMixedAirDryBulb;
   15954      9525860 :                 CoilInletEnthalpy = ZoneMixedAirEnthalpy;
   15955      9525860 :                 CoilInletRHFrac = ZoneMixedAirRHFrac;
   15956      9525860 :                 CoilInletDensity = ZoneMixedAirDensity;
   15957      9525860 :                 CoilInletHumRatio = ZoneMixedAirHumRatio;
   15958      9525860 :                 CoilInletDryAirCp = Psychrometrics::PsyCpAirFnW(0.0);
   15959      9525860 :                 break;
   15960            0 :             default:
   15961            0 :                 assert(false);
   15962              :             }
   15963      9525860 :             AirVolumeFlowMax = AirVolumeFlowRated * (1.0 - DefrostDripDownSchedule) * CoilSchedule;
   15964      9525860 :             DryAirMassFlowMax = DryAirMassFlowRated * (1.0 - DefrostDripDownSchedule) * CoilSchedule;
   15965              : 
   15966              :         } // Sens load requested is non-zero
   15967              :     } // DefrostDripDownSchedule == 1.0d0
   15968              : 
   15969     21677709 :     if (AirVolumeFlowMax > 0.0) {
   15970              : 
   15971              :         Real64 TemperatureDif =
   15972      9525860 :             min(this->MaxTemperatureDif, (CoilInletTemp - TEvap)); // difference between inlet air and evaporating temperature (deltaC)
   15973              : 
   15974      9525860 :         if (this->ratingType == RatingType::RatedCapacityTotal) {
   15975              :             // RatingType = CapacityTotalSpecificConditions, will be doing a table lookup
   15976              :             //    based upon RHInlet, DT1, CoilInletTemperature - see excel files from B. Nelson, CoilCom
   15977              :             //    In the table, X1== inlet air dry bulb temperature
   15978              :             //                  X2== Difference between inlet T and evap T
   15979              :             //                  X3== RH expressed as decimal
   15980       344255 :             CoilCapTotEstimate = Curve::CurveValue(state, this->SHRCorrectionCurvePtr, CoilInletTemp, TemperatureDif, CoilInletRHFrac) *
   15981       344255 :                                  this->RatedCapTotal * (1.0 - DefrostDripDownSchedule) * CoilSchedule;
   15982              : 
   15983              :         } else { // work with unit load factor (sensible only), function of DT1 (Tair in drybulb-Tevap)
   15984      9181605 :             Real64 SensibleCapacityMax = this->UnitLoadFactorSens * TemperatureDif * (1.0 - DefrostDripDownSchedule) *
   15985              :                                          CoilSchedule; // Sensible capacity adjusted for any time in dripdown state (W)
   15986              : 
   15987      9181605 :             if (SensibleCapacityMax > 0.0) {
   15988      9155685 :                 Real64 ExitTemperatureEstimate =
   15989      9155685 :                     CoilInletTemp - (SensibleCapacityMax / (DryAirMassFlowMax * CoilInletDryAirCp)); // Estimated Air temperature leaving the coil (C)
   15990      9155685 :                 if (ExitTemperatureEstimate <= TEvap) {
   15991            0 :                     ShowWarningError(state, format("{}Refrigeration:AirCoil: {}", TrackMessage, this->Name));
   15992            0 :                     ShowContinueError(state, " The estimated air outlet temperature is less than the evaporating temperature.");
   15993              :                 }
   15994      9155685 :                 Real64 ExitEnthalpyEstimate = Psychrometrics::PsyHFnTdbRhPb(state,
   15995              :                                                                             ExitTemperatureEstimate,
   15996              :                                                                             1.0,
   15997      9155685 :                                                                             state.dataEnvrn->OutBaroPress,
   15998              :                                                                             TrackMessage); // Estimated Air enthalpy leaving the coil (J/kg)
   15999      9155685 :                 if (ExitEnthalpyEstimate <= CoilInletEnthalpy) {
   16000      6290134 :                     CoilCapTotEstimate = (CoilInletEnthalpy - ExitEnthalpyEstimate) * AirVolumeFlowMax * CoilInletDensity;
   16001              :                 } else {
   16002              :                     // Assume no water is extracted from flow
   16003      2865551 :                     ExitEnthalpyEstimate = Psychrometrics::PsyHFnTdbW(ExitTemperatureEstimate, CoilInletHumRatio);
   16004      2865551 :                     CoilCapTotEstimate = (CoilInletEnthalpy - ExitEnthalpyEstimate) * AirVolumeFlowMax * CoilInletDensity;
   16005              :                 }
   16006      9155685 :                 if (SensibleCapacityMax > CoilCapTotEstimate) {
   16007       889620 :                     SensibleCapacityMax = CoilCapTotEstimate;
   16008              :                 }
   16009      9155685 :                 if (std::abs(CoilCapTotEstimate) > 0.0) {
   16010      9155445 :                     SHR = SensibleCapacityMax / (CoilCapTotEstimate);
   16011              :                 } else {
   16012              :                     // will occur whenever defrost or dripdown
   16013          240 :                     SHR = 0.0;
   16014              :                 }
   16015              : 
   16016      9155685 :                 switch (this->SHRCorrType) {
   16017      8978370 :                 case SHRCorrectionType::SHR60: {
   16018              :                     // line from y = SHRCorrection60 value to 1. as x(SHR) goes from .6 to 1, from B. Nelson, ASHRAE August 2010
   16019      8978370 :                     Real64 Slope = (this->SHRCorrection60 - 1.0) / (0.6 - 1.0); // Part of linear SHR60 correction factor, dimensionless
   16020      8978370 :                     Real64 Yint = this->SHRCorrection60 - (Slope * 0.6);        // Part of linear SHR60 correction factor, dimensionless
   16021      8978370 :                     SHRCorrection = Slope * SHR + Yint;
   16022      8978370 :                 } break;
   16023            0 :                 case SHRCorrectionType::QuadraticSHR: {
   16024            0 :                     SHRCorrection = Curve::CurveValue(state, this->SHRCorrectionCurvePtr, SHR);
   16025            0 :                 } break;
   16026       177315 :                 case SHRCorrectionType::European: {
   16027              :                     // With European ratings, either start with rated total sensible capacity or rated total capacity
   16028              :                     //    If rated total capacity is used, 'get input'
   16029              :                     //    translated it to rated total sensible capacity using
   16030              :                     //    PARAMETER ::EuropeanWetCoilFactor = (/1.35D0, 1.15D0,  1.05D0,  1.01D0,   1.0D0/)
   16031              :                     //    That sensible capacity rating was then turned to a rated UnitLoadFactor using
   16032              :                     //    the rated temperature difference. That sensible rating was also corrected
   16033              :                     //    for refrigerant and fin material in 'get input' and is given as UnitLoadFactor
   16034              :                     //  The total (sens + latent) capacity is equal to that * DT1 * WetCoilFactor(TcoilIn)
   16035              :                     //    Sensible capacity max already has DT1, just need WetCoilFactor(TcoilIn)
   16036              :                     // PARAMETER ::EuropeanWetCoilFactor = (/1.35D0, 1.15D0,  1.05D0,  1.01D0,   1.0D0/)
   16037              :                     // PARAMETER ::EuropeanAirInletTemp  = (/10.0D0,  0.0D0, -18.0D0, -25.0D0, -34.0D0/)
   16038              :                     // PARAMETER ::EuropeanEvapTemp      = (/ 0.0D0, -8.0D0, -25.0D0, -31.0D0, -40.0D0/)
   16039              :                     // PARAMETER ::EuropeanDT1           = (/10.0D0,  8.0D0,   7.0D0,   7.0D0,   6.0D0/)
   16040       177315 :                     if (CoilInletTemp <= -25.0) {
   16041            0 :                         SHRCorrection = 1.0;
   16042       177315 :                     } else if (CoilInletTemp > -25.0 && CoilInletTemp <= 0.0) {
   16043       133720 :                         SHRCorrection = (EuropeanWetCoilFactor[1] - EuropeanWetCoilFactor[3]) / (EuropeanAirInletTemp[1] - EuropeanAirInletTemp[3]) *
   16044       267440 :                                             (EuropeanAirInletTemp[1] - CoilInletTemp) +
   16045       133720 :                                         EuropeanWetCoilFactor[3];
   16046        43595 :                     } else if (CoilInletTemp > 0.0 && CoilInletTemp <= 5.0) {
   16047        10040 :                         SHRCorrection = (EuropeanWetCoilFactor[0] - EuropeanWetCoilFactor[1]) / (EuropeanAirInletTemp[0] - EuropeanAirInletTemp[1]) *
   16048        20080 :                                             (EuropeanAirInletTemp[0] - CoilInletTemp) +
   16049        10040 :                                         EuropeanWetCoilFactor[1];
   16050        33555 :                     } else if (CoilInletTemp > 5.0) {
   16051        33555 :                         SHRCorrection = EuropeanWetCoilFactor[0];
   16052              :                     } // calc correction as a function of coil inlet temperature
   16053       177315 :                 } break;
   16054            0 :                 default:
   16055            0 :                     break;
   16056              :                 }
   16057      9155685 :                 CoilCapTotEstimate = SHRCorrection * SensibleCapacityMax;
   16058              :             } else { // NOT (SensibleCapacityMax > 0.0d0)
   16059        25920 :                 CoilCapTotEstimate = 0.0;
   16060              :             } //  (SensibleCapacityMax > 0.0d0)
   16061              :         } // Rating type : CapacityTotalSpecificConditions or Sensible Unit Load Factor
   16062              : 
   16063      9525860 :         if (CoilCapTotEstimate > 0.0) {
   16064      9499460 :             Real64 ExitEnthalpy =
   16065      9499460 :                 CoilInletEnthalpy - (CoilCapTotEstimate / (AirVolumeFlowMax * CoilInletDensity)); // Air enthalpy leaving the coil (J/kg)
   16066      9499460 :             Real64 ExitTemperature = Psychrometrics::PsyTsatFnHPb(
   16067      9499460 :                 state, ExitEnthalpy, state.dataEnvrn->OutBaroPress, TrackMessage); // RH =1.0 at Tsat // Air temperature leaving the coil (C)
   16068      9499460 :             Real64 ExitHumRatio = Psychrometrics::PsyWFnTdbH(state, ExitTemperature, ExitEnthalpy, TrackMessage); // kg water/kg air
   16069      9499460 :             if (ExitHumRatio > CoilInletHumRatio) {
   16070      3801648 :                 ExitHumRatio = CoilInletHumRatio;
   16071              :             }
   16072      9499460 :             WaterRemovRate = DryAirMassFlowMax * (CoilInletHumRatio - ExitHumRatio);
   16073      9499460 :             latLoadServed = WaterRemovRate * IcetoVaporEnthalpy;
   16074      9499460 :             SensLoadGross = CoilCapTotEstimate - latLoadServed;
   16075      9499460 :             FanPowerActual = FanPowerRated;
   16076      9499460 :             if (SensLoadGross < 0.0) {
   16077              :                 // Could rarely happen during initial cooldown of a warm environment
   16078           58 :                 SensLoadGross = 0.0;
   16079           58 :                 latLoadServed = CoilCapTotEstimate;
   16080           58 :                 WaterRemovRate = latLoadServed / IcetoVaporEnthalpy;
   16081              :             } // SensLoadGross < 0
   16082              :         } else { // NOT (SensibleCapacityMax > 0.0d0)
   16083        26400 :             WaterRemovRate = 0.0;
   16084        26400 :             latLoadServed = 0.0;
   16085        26400 :             SensLoadGross = 0.0;
   16086        26400 :             FanPowerActual = 0.0;
   16087              :         } //(CoilCapTotEstimate > 0.0d0)
   16088              : 
   16089      9525860 :         Real64 FanPowerMax = FanPowerRated * (1.0 - DefrostDripDownSchedule); // Total fan energy rate, limited by dripdown period (W)
   16090      9525860 :         if (SensLoadGross > SensLoadRequestedGross) {                         // part load operation
   16091              :             // don't need full chiller power, reduce fan speed to reduce air flow
   16092              :             // move fan to part power if need to
   16093      3709785 :             Real64 CapFac = SensLoadRequestedGross / SensLoadGross; // used to reduce fan power when don't need full coil capacity
   16094      3709785 :             Real64 AirVolRatio = max(this->FanMinAirFlowRatio, std::pow(CapFac, EvaporatorAirVolExponent)); // used when operating at part load
   16095              :             // Fans limited by minimum air flow ratio
   16096              : 
   16097      3709785 :             switch (FanSpeedControlType) {
   16098            0 :             case FanSpeedCtrlType::VariableSpeed: {                // fan power law, adjusted for reality, applies
   16099            0 :                 Real64 FanPowerRatio = std::pow(AirVolRatio, 2.5); // Used for variable speed fans, dimensionless
   16100            0 :                 FanPowerActual = FanPowerRatio * FanPowerMax;
   16101            0 :             } break;
   16102      3709785 :             case FanSpeedCtrlType::ConstantSpeed: {
   16103      3709785 :                 FanPowerActual = AirVolRatio * std::exp(1.0 - AirVolRatio) * FanPowerMax;
   16104      3709785 :             } break;
   16105            0 :             case FanSpeedCtrlType::ConstantSpeedLinear: { // e.g., on-off control
   16106            0 :                 FanPowerActual = AirVolRatio * FanPowerMax;
   16107            0 :             } break;
   16108            0 :             case FanSpeedCtrlType::TwoSpeed: {
   16109              :                 // low speed setting of 1/2 fan speed can give up to 60% of capacity.
   16110              :                 // 1/2 speed corresponds to ~1/8 power consumption (FanHalfSpeedRatio = 1/(2**2.5) = 0.1768)
   16111              :                 // dampers are used to control flow within those two ranges as in FanConstantSpeed
   16112            0 :                 if (CapFac < CapFac60Percent) {
   16113            0 :                     FanPowerActual = ((AirVolRatio + 0.4) * (FanHalfSpeedRatio)) * std::exp(1.0 - AirVolRatio) * FanPowerMax;
   16114              :                 } else {
   16115            0 :                     FanPowerActual = AirVolRatio * std::exp(1.0 - AirVolRatio) * FanPowerMax;
   16116              :                 } // capfac60percent
   16117            0 :             } break;
   16118            0 :             default:
   16119            0 :                 break;
   16120              :             } // fan speed control type
   16121              : 
   16122              :             // reduce latent capacity according to value called for for sensible  - recalc latent.
   16123              :             //   recalc coilcaptotal
   16124      3709785 :             WaterRemovRate *= AirVolRatio;
   16125      3709785 :             latLoadServed = WaterRemovRate * IcetoVaporEnthalpy;
   16126      3709785 :             SensLoadGross = SensLoadRequestedGross;
   16127              :         } else { // at full load
   16128      5816075 :             FanPowerActual = FanPowerMax;
   16129              :         } // part load and sensload served > 0.
   16130              : 
   16131      9525860 :         CoilCapTotal = SensLoadGross + latLoadServed;
   16132      9525860 :         if (CoilCapTotal > 0.0) {
   16133      9499460 :             SHR = SensLoadGross / CoilCapTotal;
   16134              :         } else {
   16135        26400 :             SHR = 0.0;
   16136              :         } //(CoilCapTotal > 0.0d0)
   16137              : 
   16138              :         // now handle ice on coil and defrost because defrost energy not into melting ice goes into sensible load
   16139              :         // FROST:  keep track of frost build up on evaporator coil
   16140              :         //         avoid accumulation during warm-up to avoid reverse dd test problem
   16141      9525860 :         if (!state.dataGlobal->WarmupFlag) {
   16142       466527 :             FrostChangekg = (WaterRemovRate * state.dataHVACGlobal->TimeStepSysSec);
   16143       466527 :             this->KgFrost += FrostChangekg;
   16144              :         }
   16145              : 
   16146              :     } else { // NOT (AirVolumeFlowMax > 0.0d0)
   16147     12151849 :         WaterRemovRate = 0.0;
   16148     12151849 :         latLoadServed = 0.0;
   16149     12151849 :         SensLoadGross = 0.0;
   16150     12151849 :         FanPowerActual = 0.0;
   16151              :     } //(AirVolumeFlowMax > 0.0d0)
   16152              : 
   16153              :     // DEFROST CALCULATIONS   ***** need to reduce sensible heat to zone from
   16154              :     //                     defrost by amount used to melt ice. Last two elements
   16155              :     //                     in starting IF are there to mimic temperature override
   16156              :     //                     on the coils that stops defrost if the coils get above
   16157              :     //                     a certain temperature (such as when there's no load and no ice)
   16158     21677709 :     if ((DefrostSchedule > 0.0) && (this->defrostType != DefrostType::None) && (this->defrostType != DefrostType::OffCycle)) {
   16159      2694120 :         DefrostLoad = DefrostCap * DefrostSchedule;                                // Part of the defrost that is a heat load on the zone (W)
   16160      2694120 :         Real64 DefrostEnergy = DefrostLoad * state.dataHVACGlobal->TimeStepSysSec; // Joules
   16161      2694120 :         Real64 StartFrostKg = this->KgFrost;                                       // frost load at start of time step (kg of ice)
   16162              : 
   16163      2694120 :         if (this->DefrostControlType == DefrostCtrlType::TempTerm) {
   16164              :             //  Need to turn defrost system off early if controlled by temperature and all ice melted
   16165              :             //  For temperature termination, need to recognize not all defrost heat goes to melt ice
   16166              :             //  Some goes to misc losses (for fluid defrost, some coil areas bare earlier than
   16167              :             //  others and xfer heat to environment)
   16168              :             //  Assume full ice melting satisfies temperature control.
   16169              :             //      (defaults for DefEnergyFraction are :=0.7 for elec, =0.3 for fluids)
   16170        19940 :             Real64 AvailDefrostEnergy = this->DefEnergyFraction * DefrostEnergy; // available to melt ice with temp term control (J)
   16171        19940 :             Real64 IceSensHeatNeeded = 0.0; // Energy to raise frost temperature to 0C, used w/ temp termination (J)
   16172        19940 :             if (StartFrostKg > 0.0) {
   16173          180 :                 if (this->IceTemp < 0.0) {
   16174          160 :                     Real64 StartIceTemp = this->IceTemp;                                       // Frost temperature at start of time step [C]
   16175          160 :                     IceSensHeatNeeded = StartFrostKg * SpecificHeatIce * (0.0 - StartIceTemp); // Joules
   16176          160 :                     if (AvailDefrostEnergy >= IceSensHeatNeeded) {
   16177          160 :                         this->IceTemp = 0.0;
   16178          160 :                         AvailDefrostEnergy -= IceSensHeatNeeded; // Joules
   16179              :                     } else {                                     // DefrostEnergy < IceSensHeatNeeded
   16180            0 :                         this->IceTemp = StartIceTemp + AvailDefrostEnergy / (SpecificHeatIce * StartFrostKg);
   16181            0 :                         AvailDefrostEnergy = 0.0;
   16182              :                     } // AvailDefrostEnergy >= IceSensHeatNeeded
   16183              :                 } // IceTemp < 0,  need to raise temperature of ice
   16184              :                 // Reduce defrost heat load on walkin by amount of ice melted during time step
   16185          180 :                 FrostChangekg = min(AvailDefrostEnergy / IceMeltEnthalpy, StartFrostKg);
   16186          180 :                 if (FrostChangekg < StartFrostKg) {
   16187           20 :                     DefrostLoad -= FrostChangekg * IceMeltEnthalpy / state.dataHVACGlobal->TimeStepSys / Constant::rSecsInHour;
   16188           20 :                     if (!state.dataGlobal->WarmupFlag) {
   16189           20 :                         this->KgFrost = StartFrostKg - FrostChangekg;
   16190              :                     }
   16191              :                     // DefrostSchedule not changed because ice not all melted, temp term not triggered
   16192              :                 } else { // all frost melted during time step, so need to terminate defrost
   16193              :                     //  see Aug 8 2010 page 3 notes
   16194          160 :                     this->KgFrost = 0.0;
   16195          160 :                     Real64 DefrostEnergyNeeded = (IceSensHeatNeeded + (FrostChangekg * IceMeltEnthalpy)) /
   16196          160 :                                                  this->DefEnergyFraction; // Joules - energy needed including E unavail to melt ice
   16197          160 :                     DefrostSchedule = min(DefrostSchedule, (DefrostEnergyNeeded / (DefrostCap * state.dataHVACGlobal->TimeStepSysSec)));
   16198              :                     // reduce heat load on warehouse by energy put into ice melting
   16199              :                     // Defrost load that actually goes to melting ice (W)
   16200          160 :                     Real64 DefrostRateNeeded = (IceSensHeatNeeded + (FrostChangekg * IceMeltEnthalpy)) / (state.dataHVACGlobal->TimeStepSysSec);
   16201          160 :                     DefrostLoad = max(0.0, (DefrostSchedule * DefrostCap - DefrostRateNeeded));
   16202          160 :                     this->IceTemp = this->TEvapDesign;
   16203              :                 } // frost melted during time step less than amount of ice at start
   16204              :             } else {
   16205              :                 // no frost present so terminate defrost and reset ice temperature for start of next defrost
   16206              :                 // However, dripdown schedule still prevents/limits cooling capacity during time step
   16207        19760 :                 DefrostLoad = 0.0;
   16208        19760 :                 DefrostSchedule = 0.0;
   16209        19760 :                 this->IceTemp = this->TEvapDesign;
   16210              :             } // have frost present
   16211              : 
   16212              :         } else {
   16213              :             // Not temperature control type, controlled only by schedule
   16214              :             // Reduce defrost heat load on the zone by amount of ice melted during time step
   16215              :             // But DefrostSchedule not changed
   16216      2674180 :             FrostChangekg = max(0.0, min((DefrostEnergy / IceMeltEnthalpy), StartFrostKg));
   16217      2674180 :             DefrostLoad -= FrostChangekg * IceMeltEnthalpy / state.dataHVACGlobal->TimeStepSys / Constant::rSecsInHour;
   16218      2674180 :             if (!state.dataGlobal->WarmupFlag) {
   16219       157600 :                 this->KgFrost = StartFrostKg - FrostChangekg;
   16220              :             }
   16221              :         } // Temperature termination vs. time-clock control type
   16222              : 
   16223      2694120 :     } else { // DefrostSchedule <= 0 or have None or OffCycle
   16224     18983589 :         DefrostLoad = 0.0;
   16225              :     } // Defrost calculations
   16226              : 
   16227     21677709 :     Real64 SensLoadFromZone = SensLoadGross - HeaterLoad - DefrostLoad -
   16228              :                               FanPowerActual; // Net sensible load removed from zone after accounting for heaters, fans, defrost [W]
   16229              : 
   16230              :     // ReportWarehouseCoil(CoilID)
   16231     21677709 :     this->ThermalDefrostPower = DefrostLoad;
   16232     21677709 :     if (this->defrostType == DefrostType::Elec) {
   16233     21321454 :         this->ElecDefrostConsumption = DefrostCap * DefrostSchedule * state.dataHVACGlobal->TimeStepSysSec;
   16234     21321454 :         this->ElecDefrostPower = DefrostCap * DefrostSchedule;
   16235              :     } else {
   16236       356255 :         this->ElecDefrostConsumption = 0.0;
   16237       356255 :         this->ElecDefrostPower = 0.0;
   16238              :     }
   16239              : 
   16240              :     // If hot brine or hot gas is used for defrost, need to reduce condenser load by heat reclaimed for defrost
   16241     21677709 :     if (this->defrostType == DefrostType::Fluid) {
   16242       356255 :         this->HotDefrostCondCredit = DefrostCap * DefrostSchedule;
   16243              :     }
   16244              :     // LatentLoadServed is positive for latent heat removed from zone
   16245              :     // SensLoadFromZone positive for heat REMOVED from zone, switch when do credit to zone
   16246     21677709 :     this->SensCreditRate = SensLoadFromZone;
   16247     21677709 :     this->SensCreditEnergy = SensLoadFromZone * state.dataHVACGlobal->TimeStepSysSec;
   16248     21677709 :     this->LatCreditRate = latLoadServed;
   16249     21677709 :     this->LatCreditEnergy = latLoadServed * state.dataHVACGlobal->TimeStepSysSec;
   16250     21677709 :     this->LatKgPerS_ToZone = WaterRemovRate;
   16251     21677709 :     this->TotalCoolingLoad = CoilCapTotal;
   16252     21677709 :     this->TotalCoolingEnergy = CoilCapTotal * state.dataHVACGlobal->TimeStepSysSec;
   16253     21677709 :     this->SensCoolingEnergyRate = SensLoadGross;
   16254     21677709 :     this->SensCoolingEnergy = SensLoadGross * state.dataHVACGlobal->TimeStepSysSec;
   16255     21677709 :     this->SensHeatRatio = SHR;
   16256     21677709 :     this->ElecFanPower = FanPowerActual;
   16257     21677709 :     this->ElecFanConsumption = FanPowerActual * state.dataHVACGlobal->TimeStepSysSec;
   16258     21677709 :     this->ElecHeaterPower = HeaterLoad;
   16259     21677709 :     this->ElecHeaterConsumption = HeaterLoad * state.dataHVACGlobal->TimeStepSysSec;
   16260              : 
   16261     21677709 :     this->TotalElecPower = FanPowerActual + HeaterLoad + this->ElecDefrostPower;
   16262     21677709 :     this->TotalElecConsumption = this->TotalElecPower * state.dataHVACGlobal->TimeStepSysSec;
   16263              : 
   16264     21677709 :     if (this->SensCreditRate >= 0.0) {
   16265     18016343 :         this->ReportSensCoolCreditRate = this->SensCreditRate;
   16266     18016343 :         this->ReportHeatingCreditRate = 0.0;
   16267              :     } else {
   16268      3661366 :         this->ReportSensCoolCreditRate = 0.0;
   16269      3661366 :         this->ReportHeatingCreditRate = -this->SensCreditRate;
   16270              :     }
   16271     21677709 :     this->ReportSensCoolCreditEnergy = this->ReportSensCoolCreditRate * state.dataHVACGlobal->TimeStepSysSec;
   16272     21677709 :     this->ReportHeatingCreditEnergy = this->ReportHeatingCreditRate * state.dataHVACGlobal->TimeStepSysSec;
   16273     21677709 :     this->ReportTotalCoolCreditRate = this->ReportSensCoolCreditRate + this->LatCreditRate;
   16274     21677709 :     this->ReportTotalCoolCreditEnergy = this->ReportSensCoolCreditEnergy + this->LatCreditEnergy;
   16275              : 
   16276              :     //**************************************************************************************************
   16277              :     // Cap Kg Frost to avoid floating overflow errors
   16278              :     // 1-time warning is issued. It should be rare but could happen with unrealistic inputs.
   16279              : 
   16280     21677709 :     if (this->KgFrost > MyLargeNumber) {
   16281            0 :         this->KgFrost = MyLargeNumber;
   16282            0 :         if (this->ShowCoilFrostWarning) {
   16283            0 :             ShowWarningError(state, format("Refrigeration:AirCoil: {}", this->Name));
   16284            0 :             ShowContinueError(state, " This refrigerated air coil has insufficient defrost capacity to remove the excess frost accumulation.");
   16285            0 :             ShowContinueError(state, " Check the defrost schedule or defrost capacity. ");
   16286            0 :             ShowContinueErrorTimeStamp(state, "... Occurrence info");
   16287            0 :             this->ShowCoilFrostWarning = false;
   16288              :         }
   16289              :     }
   16290              : }
   16291              : 
   16292      2828408 : void FigureRefrigerationZoneGains(EnergyPlusData &state)
   16293              : {
   16294              : 
   16295              :     // SUBROUTINE INFORMATION:
   16296              :     //       AUTHOR         B. Griffith
   16297              :     //       DATE WRITTEN   Dec 2011
   16298              :     //       MODIFIED       na
   16299              :     //       RE-ENGINEERED  na
   16300              : 
   16301              :     // PURPOSE OF THIS SUBROUTINE:
   16302              :     // initialize zone gain terms at begin environment
   16303              : 
   16304      2828408 :     auto &System = state.dataRefrigCase->System;
   16305      2828408 :     auto &TransSystem = state.dataRefrigCase->TransSystem;
   16306      2828408 :     auto &RefrigRack = state.dataRefrigCase->RefrigRack;
   16307      2828408 :     auto &Secondary = state.dataRefrigCase->Secondary;
   16308      2828408 :     auto &WalkIn = state.dataRefrigCase->WalkIn;
   16309      2828408 :     auto &RefrigCase = state.dataRefrigCase->RefrigCase;
   16310              : 
   16311      2828408 :     CheckRefrigerationInput(state);
   16312              : 
   16313      2828408 :     if (state.dataGlobal->BeginEnvrnFlag && state.dataRefrigCase->FigureRefrigerationZoneGainsMyEnvrnFlag) {
   16314              : 
   16315         6496 :         if (state.dataRefrigCase->NumRefrigSystems > 0) {
   16316          399 :             for (auto &e : System) {
   16317          288 :                 e.PipeHeatLoad = 0.0;
   16318          288 :                 e.NetHeatRejectLoad = 0.0;
   16319              :             }
   16320              :         }
   16321              : 
   16322         6496 :         if (state.dataRefrigCase->NumTransRefrigSystems > 0) {
   16323           12 :             for (auto &e : TransSystem) {
   16324            6 :                 e.PipeHeatLoadMT = 0.0;
   16325            6 :                 e.PipeHeatLoadLT = 0.0;
   16326            6 :                 e.NetHeatRejectLoad = 0.0;
   16327              :             }
   16328              :         }
   16329              : 
   16330         6496 :         if (state.dataRefrigCase->NumRefrigeratedRacks > 0) {
   16331          772 :             for (auto &e : RefrigRack) {
   16332          514 :                 e.SensZoneCreditHeatRate = 0.0;
   16333          514 :                 e.SensHVACCreditHeatRate = 0.0;
   16334              :             }
   16335              :         }
   16336              : 
   16337         6496 :         if (state.dataRefrigCase->NumSimulationSecondarySystems > 0) {
   16338           18 :             for (auto &e : Secondary) {
   16339           12 :                 e.DistPipeZoneHeatGain = 0.0;
   16340           12 :                 e.ReceiverZoneHeatGain = 0.0;
   16341              :             }
   16342              :         }
   16343              : 
   16344         6496 :         if (state.dataRefrigCase->NumSimulationWalkIns > 0) {
   16345          249 :             for (int loop = 1; loop <= state.dataRefrigCase->NumSimulationWalkIns; ++loop) {
   16346          144 :                 WalkIn(loop).SensZoneCreditRate = 0.0;
   16347          144 :                 WalkIn(loop).LatZoneCreditRate = 0.0;
   16348              :             }
   16349              :         }
   16350         6496 :         if (state.dataRefrigCase->NumSimulationCases > 0) {
   16351         1700 :             for (auto &e : RefrigCase) {
   16352         1385 :                 e.SensZoneCreditRate = 0.0;
   16353         1385 :                 e.SensHVACCreditRate = 0.0;
   16354         1385 :                 e.LatZoneCreditRate = 0.0;
   16355         1385 :                 e.LatHVACCreditRate = 0.0;
   16356              :             }
   16357              :         }
   16358         6496 :         state.dataRefrigCase->FigureRefrigerationZoneGainsMyEnvrnFlag = false;
   16359              :     }
   16360      2828408 :     if (!state.dataGlobal->BeginEnvrnFlag) {
   16361      2821912 :         state.dataRefrigCase->FigureRefrigerationZoneGainsMyEnvrnFlag = true;
   16362              :     }
   16363      2828408 : }
   16364              : 
   16365         2891 : void ZeroHVACValues(EnergyPlusData &state)
   16366              : {
   16367              : 
   16368              :     // SUBROUTINE INFORMATION:
   16369              :     //       AUTHOR         T. Stovall
   16370              :     //       DATE WRITTEN   Aug 2012
   16371              :     //       MODIFIED       na
   16372              :     //       RE-ENGINEERED  na
   16373              : 
   16374              :     // PURPOSE OF THIS SUBROUTINE:
   16375              :     // Reset all values that communicate outside module for HVAC steps
   16376              :     // to zero when called on zone timestep. Otherwise, values may be held over when
   16377              :     // no HVAC load calls module during that zone time step.
   16378              : 
   16379         2891 :     auto &RefrigRack = state.dataRefrigCase->RefrigRack;
   16380         2891 :     auto &Condenser = state.dataRefrigCase->Condenser;
   16381              : 
   16382         2891 :     int DemandARRID = 0; // Index to water tank Demand used for evap condenser
   16383              : 
   16384         2891 :     if (state.dataRefrigCase->HaveRefrigRacks) {
   16385              :         // HaveRefrigRacks is TRUE when NumRefrigeratedRAcks > 0
   16386              :         // RefrigRack ALLOCATED to NumRefrigeratedRacks
   16387            0 :         for (int RackNum = 1; RackNum <= state.dataRefrigCase->NumRefrigeratedRacks; ++RackNum) {
   16388            0 :             if (RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
   16389            0 :                 Real64 MassFlowRate = 0.0;
   16390            0 :                 PlantUtilities::SetComponentFlowRate(
   16391            0 :                     state, MassFlowRate, RefrigRack(RackNum).InletNode, RefrigRack(RackNum).OutletNode, RefrigRack(RackNum).plantLoc);
   16392              :             }
   16393            0 :             if (RefrigRack(RackNum).CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
   16394            0 :                 if (RefrigRack(RackNum).EvapWaterSupplyMode == WaterSupply::FromTank) {
   16395            0 :                     DemandARRID = RefrigRack(RackNum).EvapWaterTankDemandARRID;
   16396            0 :                     int TankID = RefrigRack(RackNum).EvapWaterSupTankID;
   16397            0 :                     state.dataWaterData->WaterStorage(TankID).VdotRequestDemand(DemandARRID) = 0.0;
   16398              :                 }
   16399              :             }
   16400              :         } // RackNum
   16401              :     } // HaveRefrigRacks
   16402              : 
   16403         2891 :     if (state.dataRefrigCase->NumRefrigCondensers > 0) {
   16404              :         // Condenser ALLOCATED to DataHeatBalance::NumRefrigCondensers
   16405        28910 :         for (int CondID = 1; CondID <= state.dataRefrigCase->NumRefrigCondensers; ++CondID) {
   16406        26019 :             if (Condenser(CondID).CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
   16407            0 :                 Real64 MassFlowRate = 0.0;
   16408            0 :                 PlantUtilities::SetComponentFlowRate(
   16409            0 :                     state, MassFlowRate, Condenser(CondID).InletNode, Condenser(CondID).OutletNode, Condenser(CondID).plantLoc);
   16410              :             }
   16411        26019 :             if (Condenser(CondID).CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
   16412            0 :                 if (Condenser(CondID).EvapWaterSupplyMode == WaterSupply::FromTank) {
   16413            0 :                     DemandARRID = Condenser(CondID).EvapWaterTankDemandARRID;
   16414            0 :                     int TankID = Condenser(CondID).EvapWaterSupTankID;
   16415            0 :                     state.dataWaterData->WaterStorage(TankID).VdotRequestDemand(DemandARRID) = 0.0;
   16416              :                 }
   16417              :             }
   16418              :         } // ICond
   16419              :     } // DataHeatBalance::NumRefrigCondensers>0
   16420         2891 : }
   16421              : 
   16422              : } // namespace EnergyPlus::RefrigeratedCase
        

Generated by: LCOV version 2.0-1